Content deleted Content added
No edit summary |
|||
Line 27:
Using compile time function evaluation, code used to compute the factorial would be exactly the same as what one would write for run time evaluation.
Here's an example of CTFE in the [[D programming language]]<ref>[http:/
<source lang="D">
Line 41:
</source>
This example specifies a valid D function called "factorial" which would typically be evaluated at run time. The use of <code>const</code> tells the compiler that the initializer for the variables must be computed at compile time. Note that the arguments to the function must be able to be resolved at compile time as well.<ref>[http:/
CTFE can be used to populate data structures at compile-time in a simple way (D version 2):
|