Is there a way to see if .init has been set by the user?

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Sep 21 05:50:11 PDT 2013


On 9/21/13, bearophile <bearophileHUGS at lycos.com> wrote:
> I think there is no simple
> way to know if a variable has being default-initialized or not.
> Why do you want to know it?

There is however a way to extract it if it's a part of an aggregate:

-----
struct S
{
    int x = 1;
}

void main()
{
    static assert(S.x.init == 0);
    static assert(S.init.x == 1);
}
-----


More information about the Digitalmars-d-learn mailing list