#include <iostream>
#include <string>
auto myLambda = [](auto x, auto y) {return x + y;};
int main()
{
std::cout << myLambda(3, 4) << " ";
std::cout << myLambda(std::string("Hello"), std:: string("World")) << " ";
std::cout << myLambda(3.3, 4.4) << " ";
std::cout << std::endl;
return 0;
}
// Output: 7 HelloWorld 7.7
Reference: https://en.wikipedia.org/wiki/C%2B%2B14#Generic_lambdas
Monday, September 25, 2017
C++14: Generic lambdas
C++14 added generic lambdas. Here is an example:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment