0
目前自動型我有這樣的代碼:在Boost的屬性樹
if(!variables["width"].defaulted())
{
configTree.put(treeNames["width"], variables["width"].as<int>());
}
if(!variables["height"].defaulted())
{
configTree.put(treeNames["height"], variables["height"].as<int>());
}
if(!variables["fullscreen"].defaulted())
{
configTree.put(treeNames["fullscreen"], variables["height"].as<int>());
}
我想簡單地這一點。唯一阻止我的是我將來也會有std :: string變量,這意味着只需遍歷所有的值並使用as()不會起作用。
我考慮嘗試使用boost :: any作爲<>(),但這不起作用(加載模板錯誤)。我也考慮過使用一個具有指定它的類型的值的元組,然後切換並調用適當的<>(),但這似乎有點矯枉過正。
有沒有簡單的方法呢?
你想實現什麼? (如果你不想實現任何東西,很容易簡化,只需全部刪除即可) – Florian
我想通過每個變量值並將其插入到配置樹,字符串或int中。 – Jookia