123456
#include <iostream> int main() { [](){std::cout << "hello world" << std::endl;} return 0; }
123456789101112131415
#include <iostream> int main() { // anonymous lambda taking no arguments; function object called with () [] { std::cout << "1. hello world!\n" ; } () ; // a generic lambda taking one argument (of any printable type) const auto say = [] ( auto&& msg ) { std::cout << msg ; } ; // pass one argument while calling the closure object say(2) ; say( ". hello again!" ) ; say( '\n' ) ; }