#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
class Foo {
public:
int i;
void test() {
std::cout << i << std::endl;
}
};
int main()
{
Foo f;
f.i = 100;
auto func = std::bind(&Foo::test, std::ref(f));
f.i = 1000;
func();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KI2luY2x1ZGUgPHV0aWxpdHk+CgpjbGFzcyBGb28gewogICAgcHVibGljOgogICAgaW50IGk7CiAgICB2b2lkIHRlc3QoKSB7CiAgICAgICAgc3RkOjpjb3V0IDw8IGkgPDwgc3RkOjplbmRsOwogICAgfQp9OwoKCmludCBtYWluKCkKewogICAgRm9vIGY7CiAgICBmLmkgPSAxMDA7CiAgICBhdXRvIGZ1bmMgPSBzdGQ6OmJpbmQoJkZvbzo6dGVzdCwgc3RkOjpyZWYoZikpOwogICAgZi5pID0gMTAwMDsKICAgIGZ1bmMoKTsKCn0=