Even if Singleton.instance returns by ref, s object is still
stack-allocated struct, which is not affected by further
modification of private pointer.
But where and when is ( a second ? ) Singleton created or
duplicated ? The only ctor is in the static instance ( it is
called only once according to my debugger ) and allocates a
Singleton instance on the Heap ( as far as I understand "new
Struct" ). The return statement does return a reference ( to a
pointer, even that shouldn't be necessary ) so I would expect ...
well a reference and not a copy. So where does the second object
come from ?
- Re: Singleton Pattern with struct ParticlePeter