-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc++] Deprecate is_pod(_v)
since C++20
#129471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-libcxx Author: A. Jiang (frederick-vs-ja) ChangesPreviously, commit 042f07e claimed that P0767R1 was implemented in LLVM 7.0, but no deprecation warning was implemented. This patch adds the missing warnings. Full diff: https://github.com/llvm/llvm-project/pull/129471.diff 5 Files Affected:
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 <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant<bool, __is_pod(_Tp)> {};
+struct _LIBCPP_TEMPLATE_VIS
+_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant<bool, __is_pod(_Tp)> {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
-_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 <class T> struct is_unbounded_array; // C++20
// Member introspection:
- template <class T> struct is_pod;
template <class T> struct is_trivial;
+ template <class T> struct is_pod; // Deprecated in C++20
template <class T> struct is_trivially_copyable;
template <class T> struct is_standard_layout;
template <class T> struct is_literal_type; // Deprecated in C++17; removed in C++20
@@ -303,7 +303,7 @@ namespace std
template <class T> inline constexpr bool is_standard_layout_v
= is_standard_layout<T>::value; // C++17
template <class T> inline constexpr bool is_pod_v
- = is_pod<T>::value; // C++17
+ = is_pod<T>::value; // C++17; deprecated in C++20
template <class T> inline constexpr bool is_literal_type_v
= is_literal_type<T>::value; // C++17; deprecated in C++17; removed in C++20
template <class T> 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..df8ce7bfb9ac2
--- /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
+
+// <type_traits>
+
+// is_pod and is_pod_v are deprecated in C++20 by P0767R1
+
+#include <type_traits>
+
+static_assert(std::is_pod<int>::value); // expected-warning {{'is_pod<int>' is deprecated}}
+static_assert(std::is_pod_v<int>); // expected-warning {{'is_pod_v<int>' 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 <type_traits>
#include "test_macros.h"
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Previously, commit 042f07e claimed that P0767R1 was implemented in LLVM 7.0, but no deprecation warning was implemented. This patch adds the missing warnings.
13764f8
to
919fa85
Compare
The entry for P0767R1 in Cxx20Papers.csv looks quite superfluous. Should we also change it?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I've some requests.
- 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`.
This reverts commit 372e8a9.
Previously, commit 042f07e claimed that P0767R1 was implemented in LLVM 7.0, but no deprecation warning was implemented. This patch adds the missing warnings.
Previously, commit 042f07e claimed that P0767R1 was implemented in LLVM 7.0, but no deprecation warning was implemented. This patch adds the missing warnings.