Skip to content

Instantly share code, notes, and snippets.

@Cryolite
Created March 2, 2012 02:13
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 Cryolite/1954960 to your computer and use it in GitHub Desktop.
Save Cryolite/1954960 to your computer and use it in GitHub Desktop.
#include <functional>
#include <iostream>
class C
{
public:
C() : i_() {}
std::function<void(int)> set = [this](int i) mutable { this->i_ = i; };
std::function<int()> get = [this]() { return this->i_; };
int i_;
};
int main()
{
C c;
c.set(42);
std::cout << c.get() << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment