Skip to content

Instantly share code, notes, and snippets.

@cbsmith
Last active December 23, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbsmith/6689684 to your computer and use it in GitHub Desktop.
Save cbsmith/6689684 to your computer and use it in GitHub Desktop.
C++11 lambda sorcery
// -*- 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