#include #include #include template class fwd { public: template fwd( U&& u ) { static_assert( sizeof(_store) >= sizeof(T), "Failed to reserve enough space" ); new ((char*)&_store[0]) T( std::forward(u) ); } fwd() { new ((char*)&_store[0]) T(); } T& operator*() { void* v = &_store[0]; return *((T*)v); } const T& operator*()const { const void* v = &_store[0]; return *((const T*)v); } const T* operator->()const { const void* v = &_store[0]; return ((const T*)v); } T* operator->(){ void* v = &_store[0]; return (( T*)v); } ~fwd() { void* v = &_store[0]; ((T*)v)->~T(); } private: char _store[S]; }; struct test; class A { public: A(); private: fwd x; }; struct test { test( int _a ):a(_a){} int a; int b; }; A::A():x(5){ std::cerr<a<