P1353R0
John Spicer <jhs@edg.com>
Audience: CWG, LWG
2017-11-09

P1353R0: Missing Feature Test Macros

Introduction

This paper adds some feature test macros for recent working paper changes for which feature test macros were not included.

SG10 believes there are other missing macros and we will be doing a review of the C++20 papers to check for other cases, but there is interest in defining these now for implementors and users that need them.

In some cases a feature requires two macros, one for the language and one for the library. For example, the library does not want to define its three-way comparison operations unless the compiler supports the feature.

For end-users, it is suggested that they test only the library macro, as that will only be true if the language macro is also true. As a result, the language macros contain "impl" to distinguish them from the more general version that is expected to be set by the library.

Note that originally SG10 suggested that the library version of the macro not include the usual _lib part, but LWG was not comfortable with the inconsistency of having a library macro (which requires a header before it can be used) that does not contain _lib.

Also note that SG10 originally proposed that the core feature tests include _lang, but LWG wanted something that more clearly implied that the the macro was for a core feature and not intended to be used by end-users. They sugggested that _impl be used instead.

Contracts

SG10 discussed whether to provide a feature test macro for contracts. The recommendation is that __has_cpp_attribute should be used instead.

Wording changes

Modify table 16 in [cpp.predefined] with the macro names and values from the table below. The "Paper" and "Notes" columns are only for explanatory purposes as part of this document.

Macro Name Value Paper Notes
__cpp_impl_destroying_delete 201806L P0722R3 This macro is intended to be set by the compiler and used by the library to determine whether the library feature can be provided.
__cpp_impl_three_way_comparison 201711L P0515R3 This macro is intended to be set by the compiler and used by the library to determine whether the library feature can be provided.
__cpp_explicit_bool__cpp_conditional_explicit 201806L P0892R2 Rename the previously added macro

Modify table 35 in [support.limits.general] with the macro names, values, and header(s) from the table below. The "Paper" and "Notes" columns are only for explanatory purposes as part of this document.

Macro Name Value Header(s) Paper Notes
__cpp_lib_destroying_delete 201806L <new> P0722R3 This macro is intended to be checked by end-users
__cpp_lib_three_way_comparison 201711L <compare> P0768R1 This macro is intended to be checked by end-users