Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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
You can’t perform that action at this time.