"Value class instance" pattern?

Artur Skawina art.08.09 at gmail.com
Sun Jul 14 09:48:56 PDT 2013


On 07/14/13 18:24, Dicebot wrote:
> class A
> {
>     // immutable int x = void; // works not

`void` is special - yes. But keep in mind that this currently does
not actually do what it intuitively appears to, and what the code
posted in this thread apparently expects. IOW void-initialization
of aggregate fields does *not* actually disable initialization;
the result can be /worse/ codegen (blitting of `.init` instead of
bzero'ing). At least this was how it worked last time i tried this,
months ago; had to use ugly template mixins to avoid the expensive
useless copy (`x` was a static array). Handling it properly requires
supporting holes in .init.

artur


More information about the Digitalmars-d mailing list