diff --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst --- a/libcxx/docs/UsingLibcxx.rst +++ b/libcxx/docs/UsingLibcxx.rst @@ -196,6 +196,32 @@ warning saying that `std::auto_ptr` is deprecated. If the macro is defined, no warning will be emitted. By default, this macro is not defined. +**_LIBCPP_ENABLE_INCOMPLETE_FEATURES**: + Some library features in libc++ are marked as incomplete. Including + incomplete headers will result in a compilation failure, unless the + appropriate macro is defined. This is used for features that: + + * Are large and partial implementations aren't easily detected during + compilation. For example: + + * Calling a missing ranges algorithm leads to a compilation failure and + is easily detected. + * Calling an incomplete ``std::format`` function may compile, but at + run-time its behavior may not match the required behavior. + + * Aren't guaranteed ABI stable yet, due to: + + * The feature is still being developed. + * The C++ committee considers backporting ABI breaking changes to an + older version of the Standard. During the June 2021 plenary several ABI + breaking changes were retroactively applied to the C++20 Standard. + + This macro is only used for features that are in a ratified version of the + C++ Standard. It's possible to determine the implementation status by testing + the appropriate feature test macro. Once a feature is complete it will be + available without defining a macro. By default, this macro is not defined. + + C++17 Specific Configuration Macros ----------------------------------- **_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**: @@ -227,6 +253,20 @@ ``[[nodiscard]]`` in dialects after C++17. See :ref:`Extended Applications of [[nodiscard]] ` for more information. +**_LIBCPP_ENABLE_CXX20_INCOMPLETE_FORMAT**: + This macros is used to enable the incomplete C++20 ```` header. This + macro automatically defined when defining + ``_LIBCPP_ENABLE_INCOMPLETE_FEATURES``. The implementation status of the + ```` header can be tested with the ``__cpp_lib_format`` feature + test macro. + +**_LIBCPP_ENABLE_CXX20_INCOMPLETE_RANGES**: + This macros is used to enable the incomplete C++20 ```` header. This + macro automatically defined when defining + ``_LIBCPP_ENABLE_INCOMPLETE_FEATURES``. The implementation status of the + ```` header can be tested with the ``__cpp_lib_ranges`` feature + test macro. + **_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES**: This macro is used to re-enable all the features removed in C++20. The effect is equivalent to manually defining each macro listed below. diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1362,6 +1362,11 @@ #define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS #endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES +#if defined(_LIBCPP_ENABLE_INCOMPLETE_FEATURES) +#define _LIBCPP_ENABLE_CXX20_INCOMPLETE_FORMAT +#define _LIBCPP_ENABLE_CXX20_INCOMPLETE_RANGES +#endif // _LIBCPP_ENABLE_INCOMPLETE_FEATURES + #if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611 #define _LIBCPP_HAS_NO_DEDUCTION_GUIDES #endif diff --git a/libcxx/include/format b/libcxx/include/format --- a/libcxx/include/format +++ b/libcxx/include/format @@ -60,6 +60,10 @@ #include <__format/format_parse_context.h> #include +#ifndef _LIBCPP_ENABLE_CXX20_INCOMPLETE_FORMAT +#error The implementation of the format library is incomplete define _LIBCPP_ENABLE_CXX20_INCOMPLETE_FORMAT to use it. +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/libcxx/include/ranges b/libcxx/include/ranges --- a/libcxx/include/ranges +++ b/libcxx/include/ranges @@ -180,6 +180,10 @@ #include #include +#ifndef _LIBCPP_ENABLE_CXX20_INCOMPLETE_RANGES +#error The implementation of the ranges library is incomplete define _LIBCPP_ENABLE_CXX20_INCOMPLETE_RANGES to use it. +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif diff --git a/libcxx/test/std/utilities/format/format.error/format.error.pass.cpp b/libcxx/test/std/utilities/format/format.error/format.error.pass.cpp --- a/libcxx/test/std/utilities/format/format.error/format.error.pass.cpp +++ b/libcxx/test/std/utilities/format/format.error/format.error.pass.cpp @@ -15,6 +15,9 @@ // class format_error; +// This define should be automatically defined by the test runner. +// And there should be additional tests to see that the compilation fails when the proper defines aren't set. +#define _LIBCPP_ENABLE_INCOMPLETE_FEATURES #include #include #include