mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-19 00:55:13 +08:00
74d14778e7
This adds std::__is_constant_evaluated() as a C++11 wrapper for __builtin_is_constant_evaluated, but just returning false if the built-in isn't supported by the compiler. This allows us to use it throughout the library without checking __has_builtin every time. Some uses in std::vector and std::string can only be constexpr when the std::is_constant_evaluated() function actually works, so we might as well guard them with a relevant macro and call that function directly, rather than the built-in or std::__is_constant_evaluated(). The remaining checks of the __cpp_lib_is_constant_evaluated macro could now be replaced by checking __cplusplus >= 202002 instead, but there's no practical difference. We still need some kind of preprocessor check there anyway. libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in (PREDEFINED): Change macro name. * include/bits/allocator.h (allocate, deallocate): Use std::__is_constant_evaluated() unconditionally, instead of checking whether std::is_constant_evaluated() (or the built-in) can be used. * include/bits/basic_string.h: Check new macro. call std::is_constant_evaluated() directly in C++20-only code that is guarded by a suitable macro. * include/bits/basic_string.tcc: Likewise. * include/bits/c++config (__is_constant_evaluated): Define. (_GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED): Replace with ... (_GLIBCXX_HAVE_IS_CONSTANT_EVALUATED): New macro. * include/bits/char_traits.h (char_traits): Replace conditional calls to std::is_constant_evaluated with unconditional calls to std::__is_constant_evaluated. * include/bits/cow_string.h: Use new macro. * include/bits/ranges_algobase.h (__copy_or_move): Replace conditional calls to std::is_constant_evaluated with unconditional calls to std::__is_constant_evaluated. (__copy_or_move_backward, __fill_n_fn): Likewise. * include/bits/ranges_cmp.h (ranges::less): Likewise. * include/bits/stl_algobase.h (lexicographical_compare_three_way): Likewise. * include/bits/stl_bvector.h: Call std::is_constant_evaluated directly in C++20-only code that is guarded by a suitable macro. * include/bits/stl_construct.h (_Construct, _Destroy, _Destroy_n): Replace is_constant_evaluated with __is_constant_evaluated. * include/bits/stl_function.h (greater, less, greater_equal) (less_equal): Replace __builtin_is_constant_evaluated and __builtin_constant_p with __is_constant_evaluated. * include/bits/stl_vector.h: Call std::is_constant_evaluated() in C++20-only code. * include/debug/helper_functions.h (__check_singular): Use __is_constant_evaluated instead of built-in, or remove check entirely. * include/std/array (operator<=>): Use __is_constant_evaluated unconditionally. * include/std/bit (__bit_ceil): Likewise. * include/std/type_traits (is_constant_evaluated): Define using 'if consteval' if possible. * include/std/version: Use new macro. * libsupc++/compare: Use __is_constant_evaluated instead of __builtin_is_constant_evaluated. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust dg-error lines. |
||
---|---|---|
.. | ||
array_type_info.cc | ||
atexit_arm.cc | ||
atexit_thread.cc | ||
atomic_lockfree_defines.h | ||
bad_alloc.cc | ||
bad_array_length.cc | ||
bad_array_new.cc | ||
bad_cast.cc | ||
bad_typeid.cc | ||
class_type_info.cc | ||
compare | ||
cxxabi_forced.h | ||
cxxabi_init_exception.h | ||
cxxabi.h | ||
del_op.cc | ||
del_opa.cc | ||
del_opant.cc | ||
del_opnt.cc | ||
del_ops.cc | ||
del_opsa.cc | ||
del_opv.cc | ||
del_opva.cc | ||
del_opvant.cc | ||
del_opvnt.cc | ||
del_opvs.cc | ||
del_opvsa.cc | ||
dyncast.cc | ||
eh_alloc.cc | ||
eh_arm.cc | ||
eh_atomics.h | ||
eh_aux_runtime.cc | ||
eh_call.cc | ||
eh_catch.cc | ||
eh_exception.cc | ||
eh_globals.cc | ||
eh_personality.cc | ||
eh_ptr.cc | ||
eh_term_handler.cc | ||
eh_term_handler.h | ||
eh_terminate.cc | ||
eh_throw.cc | ||
eh_tm.cc | ||
eh_type.cc | ||
eh_unex_handler.cc | ||
enum_type_info.cc | ||
exception | ||
exception_defines.h | ||
exception_ptr.h | ||
exception.h | ||
function_type_info.cc | ||
fundamental_type_info.cc | ||
guard_error.cc | ||
guard.cc | ||
hash_bytes.cc | ||
hash_bytes.h | ||
initializer_list | ||
Makefile.am | ||
Makefile.in | ||
nested_exception.cc | ||
nested_exception.h | ||
new | ||
new_handler.cc | ||
new_op.cc | ||
new_opa.cc | ||
new_opant.cc | ||
new_opnt.cc | ||
new_opv.cc | ||
new_opva.cc | ||
new_opvant.cc | ||
new_opvnt.cc | ||
pbase_type_info.cc | ||
pmem_type_info.cc | ||
pointer_type_info.cc | ||
pure.cc | ||
si_class_type_info.cc | ||
tinfo2.cc | ||
tinfo.cc | ||
tinfo.h | ||
typeinfo | ||
unwind-cxx.h | ||
vec.cc | ||
vmi_class_type_info.cc | ||
vterminate.cc | ||
vtv_stubs.cc |