Home > Fresh News > Complex initialization for a const variable

Complex initialization for a const variable

April 13th, 2013
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

Comments are closed.