preprocessor-meta-program

Is C++ preprocessor metaprogramming Turing-complete?

我只是一个虾纸丫 提交于 2019-11-30 21:38:11
I know C++ template metaprogramming is Turing-complete. Does the same thing hold for preprocessor metaprogramming? No. The C++ preprocessor does not allow for unlimited state. You only have a finite number of on/off states, plus a include stack. This makes it a push-down automaton, not a turing machine (this ignores also the fact that preprocessor recursion is limited - but so is template recursion). However, if you bend your definitions a bit, this is possible by invoking the preprocessor multiple times - by allowing the preprocessor to generate a program which re-invokes the preprocessor,

Is C++ preprocessor metaprogramming Turing-complete?

情到浓时终转凉″ 提交于 2019-11-30 05:44:59
问题 I know C++ template metaprogramming is Turing-complete. Does the same thing hold for preprocessor metaprogramming? 回答1: No. The C++ preprocessor does not allow for unlimited state. You only have a finite number of on/off states, plus a include stack. This makes it a push-down automaton, not a turing machine (this ignores also the fact that preprocessor recursion is limited - but so is template recursion). However, if you bend your definitions a bit, this is possible by invoking the