On 01/24/13 18:14, Artur Skawina wrote: > struct Singleton { > private: > this( int a = 0 ) {} ; > static Singleton* s ; > > public: > @disable this(); > @disable this(this); > static instance() @property { > static struct Ref(T) { T* obj; ref g() @property { return *obj; } > alias obj this; @disable this(this); } > if ( s is null ) > s = new Singleton( 0 ) ; > return Ref!(typeof(this))(s) ; > } > > int val = 0 ; > }
Grr. What I meant to write was of course: static struct Ref(T) { T* obj; ref g() @property { return *obj; } alias g this; @disable this(this); } Sorry, artur