Skip to content

Instantly share code, notes, and snippets.

@ssboisen
Created March 12, 2014 15:25
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 ssboisen/9509165 to your computer and use it in GitHub Desktop.
Save ssboisen/9509165 to your computer and use it in GitHub Desktop.
#include "stdafx.h"
#include <iostream>
#include <functional>
class FunctionTester
{
public:
FunctionTester();
std::function<int(bool)> DoStuff();
};
FunctionTester::FunctionTester()
{
}
std::function<int(bool)> FunctionTester::DoStuff()
{
return [](bool a) { if (a) { return 1; } else { return 0; } };
}
int _tmain(int argc, _TCHAR* argv[])
{
auto tester = FunctionTester();
auto thingy = tester.DoStuff();
auto lol = thingy(true);
std::cout << lol << std::endl;
lol = thingy(false);
std::cout << lol << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment