Metaprogramming in C++ and in D

后端 未结 10 1910
生来不讨喜
生来不讨喜 2021-01-30 04:46

The template mechanism in C++ only accidentally became useful for template metaprogramming. On the other hand, D\'s was designed specifically to facilitate this. And apparently

10条回答
  •  伪装坚强ぢ
    2021-01-30 05:36

    I wrote up my experiences with D's templates, string mixins, and template mixins: http://david.rothlis.net/d/templates/

    It should give you a flavour of what is possible in D -- I don't think that in C++ you can access an identifier as a string, transform that string at compile time, and generate code from the manipulated string.

    My conclusion: Extremely flexible, extremely powerful, and usable by mere mortals, but the reference compiler is still somewhat buggy when it comes to the more advanced compile-time metaprogramming stuff.

提交回复
热议问题