Original Issue:
Stateful metaprogramming, using techniques like constexpr counters, allows for state manipulation in metaprogramming. While legal under C 14, concerns were raised regarding its conformity with the language's semantics.
Question:
Has the status of stateful metaprogramming changed in C 17?
CWG Active Issue 2118:
The C Standards Committee has recognized this as a potential issue and assigned it as CWG active issue 2118. The concern is that utilizing friend functions in templates to capture and retrieve metaprogramming state is arcane and should be declared ill-formed.
Resolution in C 17:
As of the May 2015 CWG meeting, the issue remains unresolved. While the committee agreed that such techniques should be ill-formed, the mechanism for prohibiting them is yet to be determined.
Current Implication:
Stateful metaprogramming techniques remain technically legal in C 17. However, when a prohibition mechanism is eventually implemented, it may retroactively make these techniques non-conforming code.
The above is the detailed content of Is Stateful Metaprogramming Still Legal in C 17?. For more information, please follow other related articles on the PHP Chinese website!