#include <iostream>
template<typename T>
struct Bar
{
typedef void (T::*F)();
Bar( T& t_ , F f ) : t( t_ ) , func( f )
{
}
void operator()()
{
(t.*func)();
}
F func;
T& t;
};
template<typename T>
class Foo
{
private:
void foo()
{
std::cout << "Foo<T>::foo()" << std::endl;
}
public:
Foo() : bar( *this , &Foo::foo )
{
bar();
}
Bar<Foo<T> > bar;
};
int main()
{
Foo<int> foo;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGU8dHlwZW5hbWUgVD4Kc3RydWN0IEJhcgp7CiAgICB0eXBlZGVmIHZvaWQgKFQ6OipGKSgpOwogICAgCiAgICBCYXIoIFQmIHRfICwgRiBmICkgOiB0KCB0XyApICwgZnVuYyggZiApCiAgICB7CiAgICB9CiAgICAKICAgIHZvaWQgb3BlcmF0b3IoKSgpCiAgICB7CiAgICAgICAgKHQuKmZ1bmMpKCk7CiAgICB9CiAgICAgICAgICAgIAogICAgRiBmdW5jOwogICAgVCYgdDsKfTsKCnRlbXBsYXRlPHR5cGVuYW1lIFQ+CmNsYXNzIEZvbwp7CnByaXZhdGU6Cgl2b2lkIGZvbygpCgl7CiAgICAgICAgc3RkOjpjb3V0IDw8ICJGb288VD46OmZvbygpIiA8PCBzdGQ6OmVuZGw7Cgl9CiAgICAKcHVibGljOiAgICAKCUZvbygpIDogYmFyKCAqdGhpcyAsICZGb286OmZvbyApIAoJewogICAgICAgIGJhcigpOwoJfQogICAgCiAgICBCYXI8Rm9vPFQ+ID4gYmFyOwp9OwoKaW50IG1haW4oKQp7CglGb288aW50PiBmb287Cn0=