From 919fa850fe280618b66d24e1f3604b66fa5adbdd Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Mon, 3 Mar 2025 11:34:59 +0800 Subject: [PATCH 1/4] [libc++] Deprecate `is_pod(_v)` since C++20 Previously, commit 042f07eed8c1acba19ea04310137bee12b18045a claimed that P0767R1 was implemented in LLVM 7.0, but no deprecation warning was implemented. This patch adds the missing warnings. --- libcxx/docs/ReleaseNotes/21.rst | 2 ++ libcxx/include/__type_traits/is_pod.h | 5 +++-- libcxx/include/type_traits | 4 ++-- .../is_pod.deprecated.verify.cpp | 18 ++++++++++++++++++ .../meta.unary/meta.unary.prop/is_pod.pass.cpp | 2 ++ 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.deprecated.verify.cpp diff --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst index e7cfa625a132c..a8d15a0f2f898 100644 --- a/libcxx/docs/ReleaseNotes/21.rst +++ b/libcxx/docs/ReleaseNotes/21.rst @@ -55,6 +55,8 @@ Improvements and New Features Deprecations and Removals ------------------------- +- ``std::is_pod`` and ``std::is_pod_v`` are deprecated since C++20 according to the standard. + Upcoming Deprecations and Removals ---------------------------------- diff --git a/libcxx/include/__type_traits/is_pod.h b/libcxx/include/__type_traits/is_pod.h index a57662400394a..b6aacf3b2b202 100644 --- a/libcxx/include/__type_traits/is_pod.h +++ b/libcxx/include/__type_traits/is_pod.h @@ -19,11 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD template -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant {}; +struct _LIBCPP_TEMPLATE_VIS +_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant {}; #if _LIBCPP_STD_VER >= 17 template -_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp); +_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index ffcddb0176615..772e4cb876469 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -95,8 +95,8 @@ namespace std template struct is_unbounded_array; // C++20 // Member introspection: - template struct is_pod; template struct is_trivial; + template struct is_pod; // Deprecated in C++20 template struct is_trivially_copyable; template struct is_standard_layout; template struct is_literal_type; // Deprecated in C++17; removed in C++20 @@ -303,7 +303,7 @@ namespace std template inline constexpr bool is_standard_layout_v = is_standard_layout::value; // C++17 template inline constexpr bool is_pod_v - = is_pod::value; // C++17 + = is_pod::value; // C++17; deprecated in C++20 template inline constexpr bool is_literal_type_v = is_literal_type::value; // C++17; deprecated in C++17; removed in C++20 template inline constexpr bool is_empty_v diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.deprecated.verify.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.deprecated.verify.cpp new file mode 100644 index 0000000000000..0f9b1856591d8 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.deprecated.verify.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// REQUIRES: std-at-least-c++20 + +// + +// is_pod and is_pod_v are deprecated in C++20 by P0767R1 + +#include + +static_assert(std::is_pod::value); // expected-warning {{'is_pod' is deprecated}} +static_assert(std::is_pod_v); // expected-warning {{'is_pod_v' is deprecated}} diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp index 87fe6ebbee883..887033fc72d86 100644 --- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp @@ -10,6 +10,8 @@ // is_pod +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS + #include #include "test_macros.h" From 62485b536b326b6df2e5069227954e7d0d2587f8 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Tue, 4 Mar 2025 17:09:29 +0800 Subject: [PATCH 2/4] Modify release notes and the status page per review comments. --- libcxx/docs/ReleaseNotes/21.rst | 3 ++- libcxx/docs/Status/Cxx20Papers.csv | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst index a8d15a0f2f898..dd9b683af0901 100644 --- a/libcxx/docs/ReleaseNotes/21.rst +++ b/libcxx/docs/ReleaseNotes/21.rst @@ -39,6 +39,7 @@ Implemented Papers ------------------ - N4258: Cleaning-up noexcept in the Library (`Github `__) +- P0767R1: Deprecate POD (`Github `__) - P1361R2: Integration of chrono with text formatting (`Github `__) Improvements and New Features @@ -55,7 +56,7 @@ Improvements and New Features Deprecations and Removals ------------------------- -- ``std::is_pod`` and ``std::is_pod_v`` are deprecated since C++20 according to the standard. +- ``std::is_pod`` and ``std::is_pod_v`` are deprecated in C++20 and later. Upcoming Deprecations and Removals ---------------------------------- diff --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv index cb25006797055..4430b785334c1 100644 --- a/libcxx/docs/Status/Cxx20Papers.csv +++ b/libcxx/docs/Status/Cxx20Papers.csv @@ -13,7 +13,7 @@ "`P0616R0 `__","de-pessimize legacy algorithms with std::move","2017-11 (Albuquerque)","|Complete|","12","" "`P0653R2 `__","Utility to convert a pointer to a raw pointer","2017-11 (Albuquerque)","|Complete|","6","" "`P0718R2 `__","Atomic shared_ptr","2017-11 (Albuquerque)","","","" -"`P0767R1 `__","Deprecate POD","2017-11 (Albuquerque)","|Complete|","7","" +"`P0767R1 `__","Deprecate POD","2017-11 (Albuquerque)","|Complete|","21","It was previously erroneously marked as complete in LLVM 7." "`P0768R1 `__","Library Support for the Spaceship (Comparison) Operator","2017-11 (Albuquerque)","|Complete|","","" "`P0777R1 `__","Treating Unnecessary ``decay``\ ","2017-11 (Albuquerque)","|Complete|","7","" "","","","","","" From 372e8a98990879ceb85e72c9972434ffa83a4a24 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Thu, 6 Mar 2025 10:51:13 +0800 Subject: [PATCH 3/4] Drive-by changes in `` - aligning all version comments to line 65, - using `// since C++` instead of `// C++`, in lowercase as used in most version comments, - changing the comments for `bool_constant` to `// since C++17` as it's a C++17 feature, - changing the class-key of `result_of` to `struct`, which follows N4659 [depr.meta.types] and the actual usage in libc++, - consistently using `class` to introduce type template parameters, - consistently using `inline constexpr` for variable templates, - moving the comments for `is_nothrow_convertible_v` to the part for variable templates, and - removing duplicated comments for `true_type` and `false_type`. --- libcxx/include/type_traits | 313 ++++++++++++++++++++----------------- 1 file changed, 166 insertions(+), 147 deletions(-) diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 772e4cb876469..88ebdc3e1a784 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -18,13 +18,11 @@ namespace std // helper class: template struct integral_constant; - typedef integral_constant true_type; // C++11 - typedef integral_constant false_type; // C++11 + typedef integral_constant true_type; // since C++11 + typedef integral_constant false_type; // since C++11 - template // C++14 - using bool_constant = integral_constant; // C++14 - typedef bool_constant true_type; // C++14 - typedef bool_constant false_type; // C++14 + template + using bool_constant = integral_constant; // since C++17 // helper traits template struct enable_if; @@ -32,7 +30,7 @@ namespace std // Primary classification traits: template struct is_void; - template struct is_null_pointer; // C++14 + template struct is_null_pointer; // since C++14 template struct is_integral; template struct is_floating_point; template struct is_array; @@ -51,7 +49,7 @@ namespace std template struct is_arithmetic; template struct is_fundamental; template struct is_member_pointer; - template struct is_scoped_enum; // C++23 + template struct is_scoped_enum; // since C++23 template struct is_scalar; template struct is_object; template struct is_compound; @@ -75,9 +73,9 @@ namespace std template struct remove_pointer; template struct add_pointer; - template struct type_identity; // C++20 + template struct type_identity; // since C++20 template - using type_identity_t = typename type_identity::type; // C++20 + using type_identity_t = typename type_identity::type; // since C++20 // Integral properties: template struct is_signed; @@ -91,20 +89,20 @@ namespace std template struct remove_extent; template struct remove_all_extents; - template struct is_bounded_array; // C++20 - template struct is_unbounded_array; // C++20 + template struct is_bounded_array; // since C++20 + template struct is_unbounded_array; // since C++20 // Member introspection: template struct is_trivial; - template struct is_pod; // Deprecated in C++20 + template struct is_pod; // deprecated in C++20 template struct is_trivially_copyable; template struct is_standard_layout; - template struct is_literal_type; // Deprecated in C++17; removed in C++20 + template struct is_literal_type; // deprecated in C++17; removed in C++20 template struct is_empty; template struct is_polymorphic; template struct is_abstract; - template struct is_final; // C++14 - template struct is_aggregate; // C++17 + template struct is_final; // since C++14 + template struct is_aggregate; // since C++17 template struct is_constructible; template struct is_default_constructible; @@ -113,8 +111,8 @@ namespace std template struct is_assignable; template struct is_copy_assignable; template struct is_move_assignable; - template struct is_swappable_with; // C++17 - template struct is_swappable; // C++17 + template struct is_swappable_with; // since C++17 + template struct is_swappable; // since C++17 template struct is_destructible; template struct is_trivially_constructible; @@ -133,24 +131,27 @@ namespace std template struct is_nothrow_assignable; template struct is_nothrow_copy_assignable; template struct is_nothrow_move_assignable; - template struct is_nothrow_swappable_with; // C++17 - template struct is_nothrow_swappable; // C++17 + template + struct is_nothrow_swappable_with; // since C++17 + template + struct is_nothrow_swappable; // since C++17 template struct is_nothrow_destructible; - template struct is_implicit_lifetime; // Since C++23 + template struct is_implicit_lifetime; // since C++23 template struct has_virtual_destructor; - template struct has_unique_object_representations; // C++17 + template struct has_unique_object_representations; // since C++17 // Relationships between types: template struct is_same; template struct is_base_of; - template struct is_virtual_base_of; // C++26 + template + struct is_virtual_base_of; // since C++26 template struct is_convertible; - template struct is_nothrow_convertible; // C++20 - template inline constexpr bool is_nothrow_convertible_v; // C++20 + template + struct is_nothrow_convertible; // since C++20 template struct is_invocable; template struct is_invocable_r; @@ -161,264 +162,282 @@ namespace std // Alignment properties and transformations: template struct alignment_of; template - struct aligned_storage; // deprecated in C++23 + struct aligned_storage; // deprecated in C++23 template struct aligned_union; // deprecated in C++23 - template struct remove_cvref; // C++20 + template struct remove_cvref; // since C++20 template struct decay; template struct common_type; template struct underlying_type; - template class result_of; // undefined; deprecated in C++17; removed in C++20 - template class result_of; // deprecated in C++17; removed in C++20 - template struct invoke_result; // C++17 + template struct result_of; // undefined; deprecated in C++17; removed in C++20 + template + struct result_of; // deprecated in C++17; removed in C++20 + template + struct invoke_result; // since C++17 // const-volatile modifications: template - using remove_const_t = typename remove_const::type; // C++14 + using remove_const_t = typename remove_const::type; // since C++14 template - using remove_volatile_t = typename remove_volatile::type; // C++14 + using remove_volatile_t + = typename remove_volatile::type; // since C++14 template - using remove_cv_t = typename remove_cv::type; // C++14 + using remove_cv_t = typename remove_cv::type; // since C++14 template - using add_const_t = typename add_const::type; // C++14 + using add_const_t = typename add_const::type; // since C++14 template - using add_volatile_t = typename add_volatile::type; // C++14 + using add_volatile_t = typename add_volatile::type; // since C++14 template - using add_cv_t = typename add_cv::type; // C++14 + using add_cv_t = typename add_cv::type; // since C++14 // reference modifications: template - using remove_reference_t = typename remove_reference::type; // C++14 + using remove_reference_t + = typename remove_reference::type; // since C++14 template - using add_lvalue_reference_t = typename add_lvalue_reference::type; // C++14 + using add_lvalue_reference_t + = typename add_lvalue_reference::type; // since C++14 template - using add_rvalue_reference_t = typename add_rvalue_reference::type; // C++14 + using add_rvalue_reference_t + = typename add_rvalue_reference::type; // since C++14 // sign modifications: template - using make_signed_t = typename make_signed::type; // C++14 + using make_signed_t = typename make_signed::type; // since C++14 template - using make_unsigned_t = typename make_unsigned::type; // C++14 + using make_unsigned_t = typename make_unsigned::type; // since C++14 // array modifications: template - using remove_extent_t = typename remove_extent::type; // C++14 + using remove_extent_t + = typename remove_extent::type; // since C++14 template - using remove_all_extents_t = typename remove_all_extents::type; // C++14 + using remove_all_extents_t + = typename remove_all_extents::type; // since C++14 template inline constexpr bool is_bounded_array_v - = is_bounded_array::value; // C++20 + = is_bounded_array::value; // since C++20 inline constexpr bool is_unbounded_array_v - = is_unbounded_array::value; // C++20 + = is_unbounded_array::value; // since C++20 // pointer modifications: template - using remove_pointer_t = typename remove_pointer::type; // C++14 + using remove_pointer_t + = typename remove_pointer::type; // since C++14 template - using add_pointer_t = typename add_pointer::type; // C++14 + using add_pointer_t = typename add_pointer::type; // since C++14 // other transformations: template - using aligned_storage_t = typename aligned_storage::type; // C++14 + using aligned_storage_t + = typename aligned_storage::type; // since C++14 template - using aligned_union_t = typename aligned_union::type; // C++14 + using aligned_union_t + = typename aligned_union::type; // since C++14 template - using remove_cvref_t = typename remove_cvref::type; // C++20 + using remove_cvref_t + = typename remove_cvref::type; // since C++20 template - using decay_t = typename decay::type; // C++14 + using decay_t = typename decay::type; // since C++14 template - using enable_if_t = typename enable_if::type; // C++14 + using enable_if_t = typename enable_if::type; // since C++14 template - using conditional_t = typename conditional::type; // C++14 + using conditional_t + = typename conditional::type; // since C++14 template - using common_type_t = typename common_type::type; // C++14 + using common_type_t + = typename common_type::type; // since C++14 template - using underlying_type_t = typename underlying_type::type; // C++14 + using underlying_type_t + = typename underlying_type::type; // since C++14 template - using result_of_t = typename result_of::type; // C++14; deprecated in C++17; removed in C++20 + using result_of_t = typename result_of::type; // since C++14; deprecated in C++17; removed in C++20 template - using invoke_result_t = typename invoke_result::type; // C++17 + using invoke_result_t + = typename invoke_result::type; // since C++17 template - using void_t = void; // C++17 + using void_t = void; // since C++17 // See C++14 20.10.4.1, primary type categories template inline constexpr bool is_void_v - = is_void::value; // C++17 + = is_void::value; // since C++17 template inline constexpr bool is_null_pointer_v - = is_null_pointer::value; // C++17 + = is_null_pointer::value; // since C++17 template inline constexpr bool is_integral_v - = is_integral::value; // C++17 + = is_integral::value; // since C++17 template inline constexpr bool is_floating_point_v - = is_floating_point::value; // C++17 + = is_floating_point::value; // since C++17 template inline constexpr bool is_array_v - = is_array::value; // C++17 + = is_array::value; // since C++17 template inline constexpr bool is_pointer_v - = is_pointer::value; // C++17 + = is_pointer::value; // since C++17 template inline constexpr bool is_lvalue_reference_v - = is_lvalue_reference::value; // C++17 + = is_lvalue_reference::value; // since C++17 template inline constexpr bool is_rvalue_reference_v - = is_rvalue_reference::value; // C++17 + = is_rvalue_reference::value; // since C++17 template inline constexpr bool is_member_object_pointer_v - = is_member_object_pointer::value; // C++17 + = is_member_object_pointer::value; // since C++17 template inline constexpr bool is_member_function_pointer_v - = is_member_function_pointer::value; // C++17 + = is_member_function_pointer::value; // since C++17 template inline constexpr bool is_enum_v - = is_enum::value; // C++17 + = is_enum::value; // since C++17 template inline constexpr bool is_union_v - = is_union::value; // C++17 + = is_union::value; // since C++17 template inline constexpr bool is_class_v - = is_class::value; // C++17 + = is_class::value; // since C++17 template inline constexpr bool is_function_v - = is_function::value; // C++17 + = is_function::value; // since C++17 // See C++14 20.10.4.2, composite type categories template inline constexpr bool is_reference_v - = is_reference::value; // C++17 + = is_reference::value; // since C++17 template inline constexpr bool is_arithmetic_v - = is_arithmetic::value; // C++17 + = is_arithmetic::value; // since C++17 template inline constexpr bool is_fundamental_v - = is_fundamental::value; // C++17 + = is_fundamental::value; // since C++17 template inline constexpr bool is_object_v - = is_object::value; // C++17 + = is_object::value; // since C++17 template inline constexpr bool is_scalar_v - = is_scalar::value; // C++17 + = is_scalar::value; // since C++17 template inline constexpr bool is_compound_v - = is_compound::value; // C++17 + = is_compound::value; // since C++17 template inline constexpr bool is_member_pointer_v - = is_member_pointer::value; // C++17 + = is_member_pointer::value; // since C++17 template inline constexpr bool is_scoped_enum_v - = is_scoped_enum::value; // C++23 + = is_scoped_enum::value; // since C++23 // See C++14 20.10.4.3, type properties template inline constexpr bool is_const_v - = is_const::value; // C++17 + = is_const::value; // since C++17 template inline constexpr bool is_volatile_v - = is_volatile::value; // C++17 + = is_volatile::value; // since C++17 template inline constexpr bool is_trivial_v - = is_trivial::value; // C++17 + = is_trivial::value; // since C++17 template inline constexpr bool is_trivially_copyable_v - = is_trivially_copyable::value; // C++17 + = is_trivially_copyable::value; // since C++17 template inline constexpr bool is_standard_layout_v - = is_standard_layout::value; // C++17 + = is_standard_layout::value; // since C++17 template inline constexpr bool is_pod_v - = is_pod::value; // C++17; deprecated in C++20 + = is_pod::value; // since C++17; deprecated in C++20 template inline constexpr bool is_literal_type_v - = is_literal_type::value; // C++17; deprecated in C++17; removed in C++20 + = is_literal_type::value; // since C++17; deprecated in C++17; removed in C++20 template inline constexpr bool is_empty_v - = is_empty::value; // C++17 + = is_empty::value; // since C++17 template inline constexpr bool is_polymorphic_v - = is_polymorphic::value; // C++17 + = is_polymorphic::value; // since C++17 template inline constexpr bool is_abstract_v - = is_abstract::value; // C++17 + = is_abstract::value; // since C++17 template inline constexpr bool is_final_v - = is_final::value; // C++17 + = is_final::value; // since C++17 template inline constexpr bool is_aggregate_v - = is_aggregate::value; // C++17 + = is_aggregate::value; // since C++17 template inline constexpr bool is_signed_v - = is_signed::value; // C++17 + = is_signed::value; // since C++17 template inline constexpr bool is_unsigned_v - = is_unsigned::value; // C++17 + = is_unsigned::value; // since C++17 template inline constexpr bool is_constructible_v - = is_constructible::value; // C++17 + = is_constructible::value; // since C++17 template inline constexpr bool is_default_constructible_v - = is_default_constructible::value; // C++17 + = is_default_constructible::value; // since C++17 template inline constexpr bool is_copy_constructible_v - = is_copy_constructible::value; // C++17 + = is_copy_constructible::value; // since C++17 template inline constexpr bool is_move_constructible_v - = is_move_constructible::value; // C++17 + = is_move_constructible::value; // since C++17 template inline constexpr bool is_assignable_v - = is_assignable::value; // C++17 + = is_assignable::value; // since C++17 template inline constexpr bool is_copy_assignable_v - = is_copy_assignable::value; // C++17 + = is_copy_assignable::value; // since C++17 template inline constexpr bool is_move_assignable_v - = is_move_assignable::value; // C++17 + = is_move_assignable::value; // since C++17 template inline constexpr bool is_swappable_with_v - = is_swappable_with::value; // C++17 + = is_swappable_with::value; // since C++17 template inline constexpr bool is_swappable_v - = is_swappable::value; // C++17 + = is_swappable::value; // since C++17 template inline constexpr bool is_destructible_v - = is_destructible::value; // C++17 + = is_destructible::value; // since C++17 template inline constexpr bool is_trivially_constructible_v - = is_trivially_constructible::value; // C++17 + = is_trivially_constructible::value; // since C++17 template inline constexpr bool is_trivially_default_constructible_v - = is_trivially_default_constructible::value; // C++17 + = is_trivially_default_constructible::value; // since C++17 template inline constexpr bool is_trivially_copy_constructible_v - = is_trivially_copy_constructible::value; // C++17 + = is_trivially_copy_constructible::value; // since C++17 template inline constexpr bool is_trivially_move_constructible_v - = is_trivially_move_constructible::value; // C++17 + = is_trivially_move_constructible::value; // since C++17 template inline constexpr bool is_trivially_assignable_v - = is_trivially_assignable::value; // C++17 + = is_trivially_assignable::value; // since C++17 template inline constexpr bool is_trivially_copy_assignable_v - = is_trivially_copy_assignable::value; // C++17 + = is_trivially_copy_assignable::value; // since C++17 template inline constexpr bool is_trivially_move_assignable_v - = is_trivially_move_assignable::value; // C++17 + = is_trivially_move_assignable::value; // since C++17 template inline constexpr bool is_trivially_destructible_v - = is_trivially_destructible::value; // C++17 + = is_trivially_destructible::value; // since C++17 template inline constexpr bool is_nothrow_constructible_v - = is_nothrow_constructible::value; // C++17 + = is_nothrow_constructible::value; // since C++17 template inline constexpr bool is_nothrow_default_constructible_v - = is_nothrow_default_constructible::value; // C++17 + = is_nothrow_default_constructible::value; // since C++17 template inline constexpr bool is_nothrow_copy_constructible_v - = is_nothrow_copy_constructible::value; // C++17 + = is_nothrow_copy_constructible::value; // since C++17 template inline constexpr bool is_nothrow_move_constructible_v - = is_nothrow_move_constructible::value; // C++17 + = is_nothrow_move_constructible::value; // since C++17 template inline constexpr bool is_nothrow_assignable_v - = is_nothrow_assignable::value; // C++17 + = is_nothrow_assignable::value; // since C++17 template inline constexpr bool is_nothrow_copy_assignable_v - = is_nothrow_copy_assignable::value; // C++17 + = is_nothrow_copy_assignable::value; // since C++17 template inline constexpr bool is_nothrow_move_assignable_v - = is_nothrow_move_assignable::value; // C++17 + = is_nothrow_move_assignable::value; // since C++17 template inline constexpr bool is_nothrow_swappable_with_v - = is_nothrow_swappable_with::value; // C++17 + = is_nothrow_swappable_with::value; // since C++17 template inline constexpr bool is_nothrow_swappable_v - = is_nothrow_swappable::value; // C++17 + = is_nothrow_swappable::value; // since C++17 template inline constexpr bool is_nothrow_destructible_v - = is_nothrow_destructible::value; // C++17 - template - constexpr bool is_implicit_lifetime_v = is_implicit_lifetime::value; // Since C++23 + = is_nothrow_destructible::value; // since C++17 + template inline constexpr bool is_implicit_lifetime_v + = is_implicit_lifetime::value; // since C++23 template inline constexpr bool has_virtual_destructor_v - = has_virtual_destructor::value; // C++17 - template inline constexpr bool has_unique_object_representations_v // C++17 - = has_unique_object_representations::value; + = has_virtual_destructor::value; // since C++17 + template inline constexpr bool has_unique_object_representations_v + = has_unique_object_representations::value; // since C++17 // See C++14 20.10.5, type property queries template inline constexpr size_t alignment_of_v - = alignment_of::value; // C++17 + = alignment_of::value; // since C++17 template inline constexpr size_t rank_v - = rank::value; // C++17 + = rank::value; // since C++17 template inline constexpr size_t extent_v - = extent::value; // C++17 + = extent::value; // since C++17 // See C++14 20.10.6, type relations template inline constexpr bool is_same_v - = is_same::value; // C++17 + = is_same::value; // since C++17 template inline constexpr bool is_base_of_v - = is_base_of::value; // C++17 + = is_base_of::value; // since C++17 template inline constexpr bool is_virtual_base_of_v - = is_virtual_base_of::value; // C++26 + = is_virtual_base_of::value; // since C++26 template inline constexpr bool is_convertible_v - = is_convertible::value; // C++17 + = is_convertible::value; // since C++17 + template inline constexpr bool is_nothrow_convertible_v + = is_nothrow_convertible::value; // since C++20 template inline constexpr bool is_invocable_v - = is_invocable::value; // C++17 + = is_invocable::value; // since C++17 template inline constexpr bool is_invocable_r_v - = is_invocable_r::value; // C++17 + = is_invocable_r::value; // since C++17 template inline constexpr bool is_nothrow_invocable_v - = is_nothrow_invocable::value; // C++17 + = is_nothrow_invocable::value; // since C++17 template inline constexpr bool is_nothrow_invocable_r_v - = is_nothrow_invocable_r::value; // C++17 + = is_nothrow_invocable_r::value; // since C++17 // [meta.logical], logical operator traits: - template struct conjunction; // C++17 - template - inline constexpr bool conjunction_v = conjunction::value; // C++17 - template struct disjunction; // C++17 - template - inline constexpr bool disjunction_v = disjunction::value; // C++17 - template struct negation; // C++17 - template - inline constexpr bool negation_v = negation::value; // C++17 + template struct conjunction; // since C++17 + template inline constexpr bool conjunction_v + = conjunction::value; // since C++17 + template struct disjunction; // since C++17 + template inline constexpr bool disjunction_v + = disjunction::value; // since C++17 + template struct negation; // since C++17 + template inline constexpr bool negation_v + = negation::value; // since C++17 } From 920fdf38f5c88be3e1e618c50abeeacf25001046 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 7 Mar 2025 09:57:20 +0800 Subject: [PATCH 4/4] Revert "Drive-by changes in ``" This reverts commit 372e8a98990879ceb85e72c9972434ffa83a4a24. --- libcxx/include/type_traits | 313 +++++++++++++++++-------------------- 1 file changed, 147 insertions(+), 166 deletions(-) diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 88ebdc3e1a784..772e4cb876469 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -18,11 +18,13 @@ namespace std // helper class: template struct integral_constant; - typedef integral_constant true_type; // since C++11 - typedef integral_constant false_type; // since C++11 + typedef integral_constant true_type; // C++11 + typedef integral_constant false_type; // C++11 - template - using bool_constant = integral_constant; // since C++17 + template // C++14 + using bool_constant = integral_constant; // C++14 + typedef bool_constant true_type; // C++14 + typedef bool_constant false_type; // C++14 // helper traits template struct enable_if; @@ -30,7 +32,7 @@ namespace std // Primary classification traits: template struct is_void; - template struct is_null_pointer; // since C++14 + template struct is_null_pointer; // C++14 template struct is_integral; template struct is_floating_point; template struct is_array; @@ -49,7 +51,7 @@ namespace std template struct is_arithmetic; template struct is_fundamental; template struct is_member_pointer; - template struct is_scoped_enum; // since C++23 + template struct is_scoped_enum; // C++23 template struct is_scalar; template struct is_object; template struct is_compound; @@ -73,9 +75,9 @@ namespace std template struct remove_pointer; template struct add_pointer; - template struct type_identity; // since C++20 + template struct type_identity; // C++20 template - using type_identity_t = typename type_identity::type; // since C++20 + using type_identity_t = typename type_identity::type; // C++20 // Integral properties: template struct is_signed; @@ -89,20 +91,20 @@ namespace std template struct remove_extent; template struct remove_all_extents; - template struct is_bounded_array; // since C++20 - template struct is_unbounded_array; // since C++20 + template struct is_bounded_array; // C++20 + template struct is_unbounded_array; // C++20 // Member introspection: template struct is_trivial; - template struct is_pod; // deprecated in C++20 + template struct is_pod; // Deprecated in C++20 template struct is_trivially_copyable; template struct is_standard_layout; - template struct is_literal_type; // deprecated in C++17; removed in C++20 + template struct is_literal_type; // Deprecated in C++17; removed in C++20 template struct is_empty; template struct is_polymorphic; template struct is_abstract; - template struct is_final; // since C++14 - template struct is_aggregate; // since C++17 + template struct is_final; // C++14 + template struct is_aggregate; // C++17 template struct is_constructible; template struct is_default_constructible; @@ -111,8 +113,8 @@ namespace std template struct is_assignable; template struct is_copy_assignable; template struct is_move_assignable; - template struct is_swappable_with; // since C++17 - template struct is_swappable; // since C++17 + template struct is_swappable_with; // C++17 + template struct is_swappable; // C++17 template struct is_destructible; template struct is_trivially_constructible; @@ -131,27 +133,24 @@ namespace std template struct is_nothrow_assignable; template struct is_nothrow_copy_assignable; template struct is_nothrow_move_assignable; - template - struct is_nothrow_swappable_with; // since C++17 - template - struct is_nothrow_swappable; // since C++17 + template struct is_nothrow_swappable_with; // C++17 + template struct is_nothrow_swappable; // C++17 template struct is_nothrow_destructible; - template struct is_implicit_lifetime; // since C++23 + template struct is_implicit_lifetime; // Since C++23 template struct has_virtual_destructor; - template struct has_unique_object_representations; // since C++17 + template struct has_unique_object_representations; // C++17 // Relationships between types: template struct is_same; template struct is_base_of; - template - struct is_virtual_base_of; // since C++26 + template struct is_virtual_base_of; // C++26 template struct is_convertible; - template - struct is_nothrow_convertible; // since C++20 + template struct is_nothrow_convertible; // C++20 + template inline constexpr bool is_nothrow_convertible_v; // C++20 template struct is_invocable; template struct is_invocable_r; @@ -162,282 +161,264 @@ namespace std // Alignment properties and transformations: template struct alignment_of; template - struct aligned_storage; // deprecated in C++23 + struct aligned_storage; // deprecated in C++23 template struct aligned_union; // deprecated in C++23 - template struct remove_cvref; // since C++20 + template struct remove_cvref; // C++20 template struct decay; template struct common_type; template struct underlying_type; - template struct result_of; // undefined; deprecated in C++17; removed in C++20 - template - struct result_of; // deprecated in C++17; removed in C++20 - template - struct invoke_result; // since C++17 + template class result_of; // undefined; deprecated in C++17; removed in C++20 + template class result_of; // deprecated in C++17; removed in C++20 + template struct invoke_result; // C++17 // const-volatile modifications: template - using remove_const_t = typename remove_const::type; // since C++14 + using remove_const_t = typename remove_const::type; // C++14 template - using remove_volatile_t - = typename remove_volatile::type; // since C++14 + using remove_volatile_t = typename remove_volatile::type; // C++14 template - using remove_cv_t = typename remove_cv::type; // since C++14 + using remove_cv_t = typename remove_cv::type; // C++14 template - using add_const_t = typename add_const::type; // since C++14 + using add_const_t = typename add_const::type; // C++14 template - using add_volatile_t = typename add_volatile::type; // since C++14 + using add_volatile_t = typename add_volatile::type; // C++14 template - using add_cv_t = typename add_cv::type; // since C++14 + using add_cv_t = typename add_cv::type; // C++14 // reference modifications: template - using remove_reference_t - = typename remove_reference::type; // since C++14 + using remove_reference_t = typename remove_reference::type; // C++14 template - using add_lvalue_reference_t - = typename add_lvalue_reference::type; // since C++14 + using add_lvalue_reference_t = typename add_lvalue_reference::type; // C++14 template - using add_rvalue_reference_t - = typename add_rvalue_reference::type; // since C++14 + using add_rvalue_reference_t = typename add_rvalue_reference::type; // C++14 // sign modifications: template - using make_signed_t = typename make_signed::type; // since C++14 + using make_signed_t = typename make_signed::type; // C++14 template - using make_unsigned_t = typename make_unsigned::type; // since C++14 + using make_unsigned_t = typename make_unsigned::type; // C++14 // array modifications: template - using remove_extent_t - = typename remove_extent::type; // since C++14 + using remove_extent_t = typename remove_extent::type; // C++14 template - using remove_all_extents_t - = typename remove_all_extents::type; // since C++14 + using remove_all_extents_t = typename remove_all_extents::type; // C++14 template inline constexpr bool is_bounded_array_v - = is_bounded_array::value; // since C++20 + = is_bounded_array::value; // C++20 inline constexpr bool is_unbounded_array_v - = is_unbounded_array::value; // since C++20 + = is_unbounded_array::value; // C++20 // pointer modifications: template - using remove_pointer_t - = typename remove_pointer::type; // since C++14 + using remove_pointer_t = typename remove_pointer::type; // C++14 template - using add_pointer_t = typename add_pointer::type; // since C++14 + using add_pointer_t = typename add_pointer::type; // C++14 // other transformations: template - using aligned_storage_t - = typename aligned_storage::type; // since C++14 + using aligned_storage_t = typename aligned_storage::type; // C++14 template - using aligned_union_t - = typename aligned_union::type; // since C++14 + using aligned_union_t = typename aligned_union::type; // C++14 template - using remove_cvref_t - = typename remove_cvref::type; // since C++20 + using remove_cvref_t = typename remove_cvref::type; // C++20 template - using decay_t = typename decay::type; // since C++14 + using decay_t = typename decay::type; // C++14 template - using enable_if_t = typename enable_if::type; // since C++14 + using enable_if_t = typename enable_if::type; // C++14 template - using conditional_t - = typename conditional::type; // since C++14 + using conditional_t = typename conditional::type; // C++14 template - using common_type_t - = typename common_type::type; // since C++14 + using common_type_t = typename common_type::type; // C++14 template - using underlying_type_t - = typename underlying_type::type; // since C++14 + using underlying_type_t = typename underlying_type::type; // C++14 template - using result_of_t = typename result_of::type; // since C++14; deprecated in C++17; removed in C++20 + using result_of_t = typename result_of::type; // C++14; deprecated in C++17; removed in C++20 template - using invoke_result_t - = typename invoke_result::type; // since C++17 + using invoke_result_t = typename invoke_result::type; // C++17 template - using void_t = void; // since C++17 + using void_t = void; // C++17 // See C++14 20.10.4.1, primary type categories template inline constexpr bool is_void_v - = is_void::value; // since C++17 + = is_void::value; // C++17 template inline constexpr bool is_null_pointer_v - = is_null_pointer::value; // since C++17 + = is_null_pointer::value; // C++17 template inline constexpr bool is_integral_v - = is_integral::value; // since C++17 + = is_integral::value; // C++17 template inline constexpr bool is_floating_point_v - = is_floating_point::value; // since C++17 + = is_floating_point::value; // C++17 template inline constexpr bool is_array_v - = is_array::value; // since C++17 + = is_array::value; // C++17 template inline constexpr bool is_pointer_v - = is_pointer::value; // since C++17 + = is_pointer::value; // C++17 template inline constexpr bool is_lvalue_reference_v - = is_lvalue_reference::value; // since C++17 + = is_lvalue_reference::value; // C++17 template inline constexpr bool is_rvalue_reference_v - = is_rvalue_reference::value; // since C++17 + = is_rvalue_reference::value; // C++17 template inline constexpr bool is_member_object_pointer_v - = is_member_object_pointer::value; // since C++17 + = is_member_object_pointer::value; // C++17 template inline constexpr bool is_member_function_pointer_v - = is_member_function_pointer::value; // since C++17 + = is_member_function_pointer::value; // C++17 template inline constexpr bool is_enum_v - = is_enum::value; // since C++17 + = is_enum::value; // C++17 template inline constexpr bool is_union_v - = is_union::value; // since C++17 + = is_union::value; // C++17 template inline constexpr bool is_class_v - = is_class::value; // since C++17 + = is_class::value; // C++17 template inline constexpr bool is_function_v - = is_function::value; // since C++17 + = is_function::value; // C++17 // See C++14 20.10.4.2, composite type categories template inline constexpr bool is_reference_v - = is_reference::value; // since C++17 + = is_reference::value; // C++17 template inline constexpr bool is_arithmetic_v - = is_arithmetic::value; // since C++17 + = is_arithmetic::value; // C++17 template inline constexpr bool is_fundamental_v - = is_fundamental::value; // since C++17 + = is_fundamental::value; // C++17 template inline constexpr bool is_object_v - = is_object::value; // since C++17 + = is_object::value; // C++17 template inline constexpr bool is_scalar_v - = is_scalar::value; // since C++17 + = is_scalar::value; // C++17 template inline constexpr bool is_compound_v - = is_compound::value; // since C++17 + = is_compound::value; // C++17 template inline constexpr bool is_member_pointer_v - = is_member_pointer::value; // since C++17 + = is_member_pointer::value; // C++17 template inline constexpr bool is_scoped_enum_v - = is_scoped_enum::value; // since C++23 + = is_scoped_enum::value; // C++23 // See C++14 20.10.4.3, type properties template inline constexpr bool is_const_v - = is_const::value; // since C++17 + = is_const::value; // C++17 template inline constexpr bool is_volatile_v - = is_volatile::value; // since C++17 + = is_volatile::value; // C++17 template inline constexpr bool is_trivial_v - = is_trivial::value; // since C++17 + = is_trivial::value; // C++17 template inline constexpr bool is_trivially_copyable_v - = is_trivially_copyable::value; // since C++17 + = is_trivially_copyable::value; // C++17 template inline constexpr bool is_standard_layout_v - = is_standard_layout::value; // since C++17 + = is_standard_layout::value; // C++17 template inline constexpr bool is_pod_v - = is_pod::value; // since C++17; deprecated in C++20 + = is_pod::value; // C++17; deprecated in C++20 template inline constexpr bool is_literal_type_v - = is_literal_type::value; // since C++17; deprecated in C++17; removed in C++20 + = is_literal_type::value; // C++17; deprecated in C++17; removed in C++20 template inline constexpr bool is_empty_v - = is_empty::value; // since C++17 + = is_empty::value; // C++17 template inline constexpr bool is_polymorphic_v - = is_polymorphic::value; // since C++17 + = is_polymorphic::value; // C++17 template inline constexpr bool is_abstract_v - = is_abstract::value; // since C++17 + = is_abstract::value; // C++17 template inline constexpr bool is_final_v - = is_final::value; // since C++17 + = is_final::value; // C++17 template inline constexpr bool is_aggregate_v - = is_aggregate::value; // since C++17 + = is_aggregate::value; // C++17 template inline constexpr bool is_signed_v - = is_signed::value; // since C++17 + = is_signed::value; // C++17 template inline constexpr bool is_unsigned_v - = is_unsigned::value; // since C++17 + = is_unsigned::value; // C++17 template inline constexpr bool is_constructible_v - = is_constructible::value; // since C++17 + = is_constructible::value; // C++17 template inline constexpr bool is_default_constructible_v - = is_default_constructible::value; // since C++17 + = is_default_constructible::value; // C++17 template inline constexpr bool is_copy_constructible_v - = is_copy_constructible::value; // since C++17 + = is_copy_constructible::value; // C++17 template inline constexpr bool is_move_constructible_v - = is_move_constructible::value; // since C++17 + = is_move_constructible::value; // C++17 template inline constexpr bool is_assignable_v - = is_assignable::value; // since C++17 + = is_assignable::value; // C++17 template inline constexpr bool is_copy_assignable_v - = is_copy_assignable::value; // since C++17 + = is_copy_assignable::value; // C++17 template inline constexpr bool is_move_assignable_v - = is_move_assignable::value; // since C++17 + = is_move_assignable::value; // C++17 template inline constexpr bool is_swappable_with_v - = is_swappable_with::value; // since C++17 + = is_swappable_with::value; // C++17 template inline constexpr bool is_swappable_v - = is_swappable::value; // since C++17 + = is_swappable::value; // C++17 template inline constexpr bool is_destructible_v - = is_destructible::value; // since C++17 + = is_destructible::value; // C++17 template inline constexpr bool is_trivially_constructible_v - = is_trivially_constructible::value; // since C++17 + = is_trivially_constructible::value; // C++17 template inline constexpr bool is_trivially_default_constructible_v - = is_trivially_default_constructible::value; // since C++17 + = is_trivially_default_constructible::value; // C++17 template inline constexpr bool is_trivially_copy_constructible_v - = is_trivially_copy_constructible::value; // since C++17 + = is_trivially_copy_constructible::value; // C++17 template inline constexpr bool is_trivially_move_constructible_v - = is_trivially_move_constructible::value; // since C++17 + = is_trivially_move_constructible::value; // C++17 template inline constexpr bool is_trivially_assignable_v - = is_trivially_assignable::value; // since C++17 + = is_trivially_assignable::value; // C++17 template inline constexpr bool is_trivially_copy_assignable_v - = is_trivially_copy_assignable::value; // since C++17 + = is_trivially_copy_assignable::value; // C++17 template inline constexpr bool is_trivially_move_assignable_v - = is_trivially_move_assignable::value; // since C++17 + = is_trivially_move_assignable::value; // C++17 template inline constexpr bool is_trivially_destructible_v - = is_trivially_destructible::value; // since C++17 + = is_trivially_destructible::value; // C++17 template inline constexpr bool is_nothrow_constructible_v - = is_nothrow_constructible::value; // since C++17 + = is_nothrow_constructible::value; // C++17 template inline constexpr bool is_nothrow_default_constructible_v - = is_nothrow_default_constructible::value; // since C++17 + = is_nothrow_default_constructible::value; // C++17 template inline constexpr bool is_nothrow_copy_constructible_v - = is_nothrow_copy_constructible::value; // since C++17 + = is_nothrow_copy_constructible::value; // C++17 template inline constexpr bool is_nothrow_move_constructible_v - = is_nothrow_move_constructible::value; // since C++17 + = is_nothrow_move_constructible::value; // C++17 template inline constexpr bool is_nothrow_assignable_v - = is_nothrow_assignable::value; // since C++17 + = is_nothrow_assignable::value; // C++17 template inline constexpr bool is_nothrow_copy_assignable_v - = is_nothrow_copy_assignable::value; // since C++17 + = is_nothrow_copy_assignable::value; // C++17 template inline constexpr bool is_nothrow_move_assignable_v - = is_nothrow_move_assignable::value; // since C++17 + = is_nothrow_move_assignable::value; // C++17 template inline constexpr bool is_nothrow_swappable_with_v - = is_nothrow_swappable_with::value; // since C++17 + = is_nothrow_swappable_with::value; // C++17 template inline constexpr bool is_nothrow_swappable_v - = is_nothrow_swappable::value; // since C++17 + = is_nothrow_swappable::value; // C++17 template inline constexpr bool is_nothrow_destructible_v - = is_nothrow_destructible::value; // since C++17 - template inline constexpr bool is_implicit_lifetime_v - = is_implicit_lifetime::value; // since C++23 + = is_nothrow_destructible::value; // C++17 + template + constexpr bool is_implicit_lifetime_v = is_implicit_lifetime::value; // Since C++23 template inline constexpr bool has_virtual_destructor_v - = has_virtual_destructor::value; // since C++17 - template inline constexpr bool has_unique_object_representations_v - = has_unique_object_representations::value; // since C++17 + = has_virtual_destructor::value; // C++17 + template inline constexpr bool has_unique_object_representations_v // C++17 + = has_unique_object_representations::value; // See C++14 20.10.5, type property queries template inline constexpr size_t alignment_of_v - = alignment_of::value; // since C++17 + = alignment_of::value; // C++17 template inline constexpr size_t rank_v - = rank::value; // since C++17 + = rank::value; // C++17 template inline constexpr size_t extent_v - = extent::value; // since C++17 + = extent::value; // C++17 // See C++14 20.10.6, type relations template inline constexpr bool is_same_v - = is_same::value; // since C++17 + = is_same::value; // C++17 template inline constexpr bool is_base_of_v - = is_base_of::value; // since C++17 + = is_base_of::value; // C++17 template inline constexpr bool is_virtual_base_of_v - = is_virtual_base_of::value; // since C++26 + = is_virtual_base_of::value; // C++26 template inline constexpr bool is_convertible_v - = is_convertible::value; // since C++17 - template inline constexpr bool is_nothrow_convertible_v - = is_nothrow_convertible::value; // since C++20 + = is_convertible::value; // C++17 template inline constexpr bool is_invocable_v - = is_invocable::value; // since C++17 + = is_invocable::value; // C++17 template inline constexpr bool is_invocable_r_v - = is_invocable_r::value; // since C++17 + = is_invocable_r::value; // C++17 template inline constexpr bool is_nothrow_invocable_v - = is_nothrow_invocable::value; // since C++17 + = is_nothrow_invocable::value; // C++17 template inline constexpr bool is_nothrow_invocable_r_v - = is_nothrow_invocable_r::value; // since C++17 + = is_nothrow_invocable_r::value; // C++17 // [meta.logical], logical operator traits: - template struct conjunction; // since C++17 - template inline constexpr bool conjunction_v - = conjunction::value; // since C++17 - template struct disjunction; // since C++17 - template inline constexpr bool disjunction_v - = disjunction::value; // since C++17 - template struct negation; // since C++17 - template inline constexpr bool negation_v - = negation::value; // since C++17 + template struct conjunction; // C++17 + template + inline constexpr bool conjunction_v = conjunction::value; // C++17 + template struct disjunction; // C++17 + template + inline constexpr bool disjunction_v = disjunction::value; // C++17 + template struct negation; // C++17 + template + inline constexpr bool negation_v = negation::value; // C++17 }