Home > Fresh News > Complex initialization for a const variable

Complex initialization for a const variable

April 13th, 2013 Leave a comment Go to comments
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

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.