#include #include #include #include class Vertex {}; class Edge { public: const Vertex& otherSide(const Edge&) const { return otherSide_; }; private: Vertex otherSide_; }; class Graph; // Returns the cost between start and finish, given a graph int costEstimate(const Graph& aGraph, const Vertex& start, const Vertex& finish) { return 0; } bool edgeCompare(const Graph& graph, const Edge& start, const Vertex& finish, const Edge& lhs, const Edge& rhs) { return costEstimate(graph, start.otherSide(lhs), finish) < costEstimate(graph, start.otherSide(rhs), finish); } class Graph{ public: void doSomething() { Edge start; Vertex finish; // Member function of a graph std::vector< Edge > v; // Sort them according to the cost std::sort( v.begin(), v.end(), boost::lambda::bind(edgeCompare, *this, start, finish, boost::lambda::_1, boost::lambda::_2)); } }; int main() { Graph graph; graph.doSomething(); }