Home > Backend Development > C++ > body text

Is Stateful Metaprogramming Still Legal in C 17?

DDD
Release: 2024-11-20 22:14:13
Original
161 people have browsed it

Is Stateful Metaprogramming Still Legal in C  17?

Legality of Stateful Metaprogramming in C 14 vs. C 17

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template