Document number: P1424R1
Project: Programming Language C++
Audience: SG10, Library Working group
 
Antony Polukhin <antoshkka@gmail.com>, <antoshkka@yandex-team.ru>
 
Date: 2019-04-25

'constexpr' feature macro concerns

I. Quick Introduction

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.

II. Approaches

A. Single constexpr feature testing macro

Make a __cpp_lib_constexpr macro and increment its version on each new constexpr addition to the library.

Pros:

Cons:

B. Fuse constexpr feature testing into the feature testing macro of a component

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:

C. Have a feature testing macro per paper/proposal

This approach was taken by the P1032R1 with its __cpp_lib_constexpr_misc macro.

Pros:

Cons:

III. Conclusions

Each approach has its own advantages and disadvantages. I'd like recommend the following generic approach:

IV. LWG discussion

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.

V. Wording (relative to N4800)

Apply the following changes to the Table 36 "Standard library feature-test macros" in [support.limits.general]:

__cpp_lib_constexpr_misc201811L<array> <functional> <iterator> <string_view> <tuple> <utility>Any C++ library header from Table 19 or any C++ header for C library facilities from Table 20