On Thursday, 24 January 2013 at 15:05:15 UTC, Jacob Carlborg
wrote:
On 2013-01-24 15:43, Maxim Fomin wrote:
Even if Singleton.instance returns by ref, s object is still
stack-allocated struct, which is not affected by further
modification of
private pointer.
The struct is allocated using "new".
This is about "auto s = " in main, not about "new" in method.
Type of s is Singleton, not Singleton* or "ref Singleton".
Singleton s = Singleton.instance; // is compiled when
Singleton* s = Singleton.instance; // is not - Error: cannot
implicitly convert // expression (instance()) of type Singleton
to Singleton*