__traits getMember is context sensetive?

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 14 03:04:30 PDT 2015


On Sunday, 14 June 2015 at 09:46:56 UTC, JDemler wrote:
> On Sunday, 14 June 2015 at 05:52:00 UTC, ketmar wrote:
>> oh, seems that i managed to make everything even less 
>> understandable...
>
> Your code works perfectly and makes at least some sense to me. 
> Thank you.
>
> If i understand it correctly: __traits-time = 
> templateinstatiation-time = pragma-time before ctfe-time?

Not really. These things are just (conceptually) done as/when 
they are required. If a template instantiation needs to do ctfe 
to calculate it's result, it does it. If some code running in 
ctfe needs the result of a template, it instantiates it.

The only distinction you have to think about is compile-time vs 
run-time, with the caveat that ctfe code is run as if it were 
run-time, but the result can be used at compile-time. If you 
imagine ctfe as being "compiling the function, running it, 
getting the answer and copying it in to your code" then even that 
distinction goes away and you just have ct vs rt.


More information about the Digitalmars-d-learn mailing list