If you want to compare the two vectors by cost, try this:
bool predicate(const std::vector& a, const std::vector& b)
{
return COST(a) < COST(b);
}
Notes:
- The above works with C++98, too, I'm not sure about how widespread the use of C++11 is and whether you have a compliant compiler. Otherwise, you can of course use a lambda expression, too, as sftrabbit suggested.
- You don't say what COST returns, I simply assumed some sortable value like float or long.
- I hope you don't copy the vector when passing it to COST(), that would be horribly inefficient.
- COST suggests a macro, like all UPPERCASE_NAMES. Don't use macros. Don't use macro names for functions.