c++11 - std::bind no viable conversion -
i created pathfind algorithm can set heuristic method. using a
function<int (point2i origin, point2i destiny)> heuristicfunc;
as function pointer , want initialize default heristic.
so:
pathfind.h
class pathfind{ private: function<int (point2i origin, point2i destiny)> heuristicfunc; int hmethod(point2i origin, point2i destiny); public: pathfind(); }
pathfind.cpp
pathfind::pathfind(){ //1st seek this->heuristicfunc=&pathfind::hmethod; //2nd seek this->heuristicfunc=std::bind(&pathfind::hmethod, this); }
but returns same error:
/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/include/c++/v1/functional:1472:15: candidate function not viable: no known conversion 'int (core::pathfind::*)(point2i, point2i)' 'const std::__1::function, sf::point2)>' 1st argument
why tries convert int(core::pathfind::*) ?
thanks.
using namespace std::placeholders; heuristicfunc = std::bind(&pathfind::hmethod, this, _1, _2);
every argument don't supply has indicated via placeholder.
c++11 functor
No comments:
Post a Comment