In P1032R1 "Misc constexpr bits" a feature testing macro __cpp_lib_constexpr_misc
was proposed.
That's not the best name for the macro. The name is not very informative. __cpp_lib_constexpr_misc
also does not suite the needs of future constexprifications.
This paper discuss different approaches for constexpr feature testing macro.
Make a __cpp_lib_constexpr
macro and increment its version on each new constexpr addition to the library.
Pros:
Cons:
Update the value of feature testing macro of a particular component. For example, update __cpp_lib_string_view
with value 201811L
because P1032R1 "Misc constexpr bits" touched the string_view
.
Pros:
Cons:
This approach was taken by the P1032R1 with its __cpp_lib_constexpr_misc
macro.
Pros:
Cons:
Each approach has its own advantages and disadvantages. I'd like recommend the following generic approach:
__cpp_lib_constexpr
macro and increase it on each LWG constexpr paper adoption.Discussion of the paper in Kona lead to the following conclusion: rename __cpp_lib_constexpr_misc
to __cpp_lib_constexpr
and bump the value on every change.
Note that for a more generic feature testing macro we should include it in every header or just not include it in some subset of headers. Otherwise it would be surprising for users. For example if we increment the macro value for some constexpr additions in <vector> the macro will not be available via <vector> inclusion.
Apply the following changes to the Table 36 "Standard library feature-test macros" in [support.limits.general]:
__cpp_lib_constexpr | 201811L | <array> <functional>
<iterator> <string_view>
<tuple> <utility> |