, . std::sort - , , , .
, , - :
struct __unique_lambda_defined_by_compiler //arbitrary ugly name!
{
bool operator()(float a, float b) const {
return std::abs(a) < std::abs(b);
}
};
, :
std::sort(x, x + N, __unique_lambda_defined_by_compiler());
, ( !), std::function ( ), :
std::vector<std::function<bool(int,int)>> callbacks;
callbacks.push_back([](int, int) { ... });
callbacks.push_back([](int, int) { ... });
callbacks.push_back([](int, int) { ... });
bool compare(int,int) { ... }
callbacks.push_back(compare);