Created
August 12, 2016 01:40
-
-
Save yura/01d46c03d58b1134564c14bbe1521861 to your computer and use it in GitHub Desktop.
Initializing constexpr variable by a lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
constexpr auto fx = [] (std::string msg) { | |
return msg + "!\n"; }; | |
int main(int argc, char* argv[]) { | |
if (argc == 2) | |
std::cout << "hello " << fx(argv[1]); | |
else | |
std::cout << "hello world!" << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment