Storing States in C++ Metaprogramming?

℡╲_俬逩灬. 提交于 2019-12-11 07:44:18

问题


Is it possible to store states in C++ metaprograms? I'm not entirely sure what I mean, but I want a template class that can be "assigned" to, e.g. state::value can be changed via the use of C++ templates.

I know I probably sound very vague, but I hope someone understands what I'm talking about (also please no Boost.MPL).


回答1:


It's not possible, the TMP part of C++ is a purely functional language without the concept of side effects.




回答2:


That would be a heaven for bugs.

It would also violate the template single-instantiation rule, and it will blow up the size of your program (not to mention confusing the heck out of you).



来源:https://stackoverflow.com/questions/6105994/storing-states-in-c-metaprogramming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!