我想使用这个函数并制作一个自定义排序函数,但我不知道比较函数是如何工作的或使用 lambda。
有人可以给我一个使用它的工作示例吗?
/* Sorts the direct children of this node according to the predicate.
The predicate is passed the whole pair of key and child. */
template <class Compare> void sort (Compare comp);
谓词传递整对键和子项。
这是一对key/ptree吗?我不知道数据类型是什么。
我正在搜索类似于列表的 lambda 函数
unorderedGenList.sort([](const boost::property_tree::ptree & treeA, const boost::property_tree::ptree & treeB)
{
if(std::stod(treeA.get<std::string>("sortA","0")) < std::stod(treeB.get<std::string>("sortA","0"))
|| (std::stod(treeA.get<std::string>("sortA","0")) == std::stod(treeB.get<std::string>("sortA","0")) && std::stod(treeA.get<std::string>("sortB","0")) < std::stod(treeB.get<std::string>("sortB","0")))
)
return true;
return false;
});