[libc++] Require concepts support for <numbers>

Similar to <concepts>, we need to protect the header and test against
inclusion and being run if concepts aren't supported by the compiler.

Differential Revision: https://reviews.llvm.org/D82171
This commit is contained in:
Raul Tambre 2020-06-19 10:36:44 -04:00 committed by Louis Dionne
parent 6d9565d6d5
commit 98eb1457ff
10 changed files with 34 additions and 13 deletions

View File

@ -60,7 +60,7 @@ namespace std::numbers {
#include <__config>
#if _LIBCPP_STD_VER > 17
#if _LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
#include <type_traits>
#include <version>
@ -136,6 +136,6 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
#endif //_LIBCPP_STD_VER > 17
#endif //_LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
#endif // _LIBCPP_NUMBERS

View File

@ -238,7 +238,9 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_is_constant_evaluated 201811L
# endif
# define __cpp_lib_list_remove_return_type 201806L
# define __cpp_lib_math_constants 201907L
# if defined(__cpp_concepts) && __cpp_concepts >= 201811L
# define __cpp_lib_math_constants 201907L
# endif
// # define __cpp_lib_ranges 201811L
# define __cpp_lib_span 202002L
// # define __cpp_lib_three_way_comparison 201711L

View File

@ -40,11 +40,17 @@
#elif TEST_STD_VER > 17
# ifndef __cpp_lib_math_constants
# error "__cpp_lib_math_constants should be defined in c++2a"
# endif
# if __cpp_lib_math_constants != 201907L
# error "__cpp_lib_math_constants should have the value 201907L in c++2a"
# if defined(__cpp_concepts) && __cpp_concepts >= 201811L
# ifndef __cpp_lib_math_constants
# error "__cpp_lib_math_constants should be defined in c++2a"
# endif
# if __cpp_lib_math_constants != 201907L
# error "__cpp_lib_math_constants should have the value 201907L in c++2a"
# endif
# else
# ifdef __cpp_lib_math_constants
# error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201811L is not defined!"
# endif
# endif
#endif // TEST_STD_VER > 17

View File

@ -1980,11 +1980,17 @@
# error "__cpp_lib_map_try_emplace should have the value 201411L in c++2a"
# endif
# ifndef __cpp_lib_math_constants
# error "__cpp_lib_math_constants should be defined in c++2a"
# endif
# if __cpp_lib_math_constants != 201907L
# error "__cpp_lib_math_constants should have the value 201907L in c++2a"
# if defined(__cpp_concepts) && __cpp_concepts >= 201811L
# ifndef __cpp_lib_math_constants
# error "__cpp_lib_math_constants should be defined in c++2a"
# endif
# if __cpp_lib_math_constants != 201907L
# error "__cpp_lib_math_constants should have the value 201907L in c++2a"
# endif
# else
# ifdef __cpp_lib_math_constants
# error "__cpp_lib_math_constants should not be defined when defined(__cpp_concepts) && __cpp_concepts >= 201811L is not defined!"
# endif
# endif
# if !defined(_LIBCPP_VERSION)

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// UNSUPPORTED: libcpp-no-concepts
#include <numbers>

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// UNSUPPORTED: libcpp-no-concepts
#include <numbers>

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// UNSUPPORTED: libcpp-no-concepts
#include <cassert>
#include <numbers>

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// UNSUPPORTED: libcpp-no-concepts
#include <numbers>

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// UNSUPPORTED: libcpp-no-concepts
#include <cassert>
#include <numbers>

View File

@ -604,6 +604,8 @@ feature_test_macros = sorted([ add_version_header(x) for x in [
"c++2a": int(201907),
},
"headers": ["numbers"],
"depends": "defined(__cpp_concepts) && __cpp_concepts >= 201811L",
"internal_depends": "defined(__cpp_concepts) && __cpp_concepts >= 201811L",
},
]], key=lambda tc: tc["name"])