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

bearophile bearophileHUGS at lycos.com
Sat Sep 21 04:35:10 PDT 2013


simendsjo:

> I want to know if a variable has changed .init, but I don't 
> know if it's possible if the .init value is the same. Does 
> anyone have a solution for this?
>
>     int a;
>     int b = 0;
>     pragma(msg, a.init); // 0
>     pragma(msg, b.init); // 0
>     // how can I see that b has "= 0"?

init is part of a type and you can't change it. a and by are both 
ints, and in both cases int.init is 0. 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?

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list