C++ 设置boost配对堆的比较函数
我有一个结构,它的成员类型为boost::heap:。pairing\u heap。 我的目的是为配对堆传递一个比较函数(可以是成员,但不是必需的)。我怎样才能做到这一点。我试过这个 我不明白错误信息。我觉得一切都很好C++ 设置boost配对堆的比较函数,c++,boost,stl,C++,Boost,Stl,我有一个结构,它的成员类型为boost::heap:。pairing\u heap。 我的目的是为配对堆传递一个比较函数(可以是成员,但不是必需的)。我怎样才能做到这一点。我试过这个 我不明白错误信息。我觉得一切都很好 struct B{ //some more fields: irrelevant here bool compare_(std::pair<int,int>&, std::pair<int,int>&); boost::heap
struct B{
//some more fields: irrelevant here
bool compare_(std::pair<int,int>&, std::pair<int,int>&);
boost::heap::pairing_heap<std::pair<int,int>, boost::heap::compare<compare_> > in;
};
bool Block::compare_(std::pair<int,int>& c, std::pair<int,int>& d)
{
//returns true or false based on some criteria
}
error: type/value mismatch at argument 1 in template parameter list for ‘template<class T> struct boost::heap::compare’
结构B{
//还有一些字段:这里不相关
bool比较(std::pair&,std::pair&);
boost::heap::将堆配对;
};
布尔块::比较(标准::成对&c,标准::成对&d)
{
//根据某些条件返回true或false
}
错误:“模板结构boost::heap::compare”的模板参数列表中参数1的类型/值不匹配
您正在使用一个(假设它是您的)。如果您将此的inmplicit第一个参数计算在内,则可能是因为您正在传递一个成员函数,而该函数实际上有三个参数。