Can I define a C++ lambda function without auto? -
Can I define a C++ lambda function without auto? -
i have plenty of c# experience before new c++. have seen problem when trying utilize lambda used do.
for example:
auto compare = [] (int i1, int i2) { homecoming i1*2 > i2; }
is there way define lambda specific type, rather auto deduction?
i asking because want define mutual lambda class. lambada used in multiple places don't want define them multiple times. however, 'auto' can used on static members, while on other hand, want access non-static fields in lambda.
you utilize std::function. std::function can glob lambda or function pointer. http://en.cppreference.com/w/cpp/utility/functional/function
std::function< bool(int, int) > myfunc = []( int x, int y ){ homecoming x > y; };
c++ lambda
Comments
Post a Comment