Generic lambda (C++ 14)

suggest change

C++14 allows to use auto in lambda argument

auto print = [](const auto& arg) { std::cout << arg << std::endl; };

print(42);
print("hello world");

That lambda is mostly equivalent to

struct lambda {
    template <typename T>
    auto operator ()(const T& arg) const {
        std::cout << arg << std::endl;
    }
};

and then

lambda print;

print(42);
print("hello world");

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


auto keyword:
* auto
* Generic lambda (C++ 14)

Table Of Contents
8 Arrays
11 Loops
16 auto keyword
39 Streams
51 Unions
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
84 RTTI
87 Scopes
104 Profiling
107 Recursion
117 Iteration
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype