constexpr and CTFE

Lutger Blijdestijn lutger.blijdestijn at gmail.com
Sun Mar 27 08:48:20 PDT 2011


bearophile wrote:

> This first question is mostly for D.learn, but below I show a partially
> related link too, so I put both of them here.
> 
> If you have library code, and the users of your library run one of your
> functions at compile time, later if you change your function it may not
> run at compile time any more. So isn't the quality of being able to run at
> compile time part of the signature of the function?

An attribute similar to pure that can be checked by the compiler might be 
useful. However, the signature affects the type right? I'm not sure that is 
the intent of ctfe. A simple ddoc annotation and a unittest is probably  
enough to both ensure and convey the ctfe-ability.
 
> ---------------
> 
> GCC 4.6 implements the C++0x constexpr. I've found a note about constexpr,
> that touches the topic of logic const too, purity, memoization:
> 
> http://stackoverflow.com/questions/4748083/when-should-you-use-constexpr-
capability-in-c0x/4750253#4750253
> 
> Bye,
> bearophile



More information about the Digitalmars-d mailing list