Lamda

How do I make a lamda program print just the output?

1
2
3
4
5
6
#include <iostream>
int main()
{
[](){std::cout << "hello world" << std::endl;}
return 0;
}
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#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' ) ;
}

http://coliru.stacked-crooked.com/a/a1961504fa34d3fc
Topic archived. No new replies allowed.