At compile time
Jarrett Billingsley
jarrett.billingsley at gmail.com
Tue Aug 4 19:58:18 PDT 2009
On Tue, Aug 4, 2009 at 10:13 PM, bearophile<bearophileHUGS at lycos.com> wrote:
> Jarrett Billingsley:
>> I don't think you can call struct methods at compile-time. Kind of
>> lame, I know. Try making norm a free function.
>
> I see. It's a significant limitation, that curiously G++ doesn't share.
I don't think your C++ code is doing what you think it's doing. I'm
pretty sure the C++ code:
const V3 v(V3(-0.5, -0.65, 0.9).norm());
is equivalent to the following D code:
const V3 v;
static this() { v = V3(-0.5, -0.65, 0.9).norm(); }
C++ has static initialization that occurs before main() too. It's
just.. hidden.
More information about the Digitalmars-d-learn
mailing list