Archive

Posts Tagged ‘C++0x’

Complex initialization for a const variable

April 13th, 2013 No comments
1
2
3
4
5
6
7
8
9
10
11
12
13
int main()
{
    bool someFlag = false;
    const auto value = [&]{
                               if(someFlag)
                                   return -1;
                               else
                                   return 1;
                              } ();
 
    std::cout << "value == " << value << std::endl;
    return 0;
}

Complex initialization for a const variable