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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -