#include "alfe/main.h" #ifndef INCLUDED_REFERENCE_H #define INCLUDED_REFERENCE_H template class Reference : private Handle { public: Reference() { } template static Reference create(Args&&... args) { Reference r(Handle::create>(std::forward(args)...)); return r; } T* operator->() { return body()->t(); } T& operator*() { return *body()->t(); } private: class BaseBody : public Handle::Body { public: virtual T* t() = 0; }; template class Body : public BaseBody { public: template Body(Args&&... args) : _c(std::forward(args)...) { } T* t() { return &_c; } C _c; }; BaseBody* body() { return as(); } Reference(const Handle& other) : Handle(other) { } }; #endif // INCLUDED_REFERENCE_H