Bypassing the postblit?
Maxim Fomin
maxim at maxim-fomin.ru
Sun Dec 29 10:40:06 PST 2013
On Sunday, 29 December 2013 at 16:22:04 UTC, Ritu wrote:
> I have a struct that wraps a class object and lazily
> initializes it. Now in case the struct instance is passed as an
> argument to a function and it has not been initialized yet, the
> default copy constructor and the postblit do not offer a
> possibility to initialize the class object before copying.
Why this is a problem? You can create function which return class
field from struct wrapper and make such function alias this, in
addition postblit should allocate new class. The fact that
original struct may have null value is irrelevant if copying is
made correctly.
More information about the Digitalmars-d
mailing list