Skip to content

Instantly share code, notes, and snippets.

@yura
Created August 12, 2016 01:40
Show Gist options
  • Save yura/01d46c03d58b1134564c14bbe1521861 to your computer and use it in GitHub Desktop.
Save yura/01d46c03d58b1134564c14bbe1521861 to your computer and use it in GitHub Desktop.
Initializing constexpr variable by a lambda
#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