C ++ 0x refused to use old ties, such as bind1st, and bind2ndin favor of the total std::bind. C ++ 0x lambdas are perfectly combined with std::bind, but they do not bind to classical bind1st and bind2nd, because the default lambdas are not nested typedefs, such as argument_type, first_argument_type, second_argument_typeand result_type, so I think that std::functioncan serve as a standard method to bind lambdas old ties, since it provides the necessary typedefs.
However, use is std::functiondifficult to use in this context, as it forces you to specify the type of function when creating it.
auto bound =
std::bind1st(std::function<int (int, int)>([](int i, int j){ return i < j; }), 10);
auto bound =
std::bind1st(std::make_function([](int i, int j){ return i < j; }), 10);
I could not find a convenient object generator for std::function. Something like std::make_fuctionit would be nice to have. Is there such a thing? If not, is there another better way to bind lamd to classic binders?
source
share