Last active
December 23, 2015 20:29
-
-
Save cbsmith/6689684 to your computer and use it in GitHub Desktop.
C++11 lambda sorcery
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
// -*- compile-command: "clang++ -ggdb -o test -std=c++11 -stdlib=libc++ test.cpp" -*- | |
#include <iostream> | |
float add(float x, float y) { | |
return x+y; | |
} | |
auto add_fourty_two = +[](float x) { return add(x, 42); }; | |
auto add_pie_and_fourty_two = +[]() { return add_fourty_two(3.1415926); }; | |
int main() | |
{ | |
std::cout << "Output: " << add_pie_and_fourty_two() << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment