Thursday, June 11, 2015

Fizz buzz with template meta programming: C++ vs D




C++ compile time:






D run time:



D compile time:




The D compile time version is almost identical to the run time version, except replacing 'if' with 'static if' and replacing function call with template instantiation.  And it is so much more readable than the C++ counterpart.

No comments: