On Saturday, 21 September 2013 at 12:50:20 UTC, Andrej Mitrovic wrote:
On 9/21/13, bearophile <bearophileh...@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);
}
-----

I'm though of using if for aggregates, yes. But this doesn't handle the case where you set the same value is T.init.

Reply via email to