[libcxx-commits] [libcxx] 94714fb - [libc++] Deprecate `is_pod(_v)` since C++20 (#129471)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 7 00:03:00 PST 2025


Author: A. Jiang
Date: 2025-03-07T16:02:57+08:00
New Revision: 94714fb3032fb4707c70f12a5f246bbaadaa73b2

URL: https://github.com/llvm/llvm-project/commit/94714fb3032fb4707c70f12a5f246bbaadaa73b2
DIFF: https://github.com/llvm/llvm-project/commit/94714fb3032fb4707c70f12a5f246bbaadaa73b2.diff

LOG: [libc++] Deprecate `is_pod(_v)` since C++20 (#129471)

Previously, commit 042f07eed8c1acba19ea04310137bee12b18045a claimed that
P0767R1 was implemented in LLVM 7.0, but no deprecation warning was
implemented. This patch adds the missing warnings.

Added: 
    libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.deprecated.verify.cpp

Modified: 
    libcxx/docs/ReleaseNotes/21.rst
    libcxx/docs/Status/Cxx20Papers.csv
    libcxx/include/__type_traits/is_pod.h
    libcxx/include/type_traits
    libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst
index f45a448e52cc0..c45adbaec3953 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 <https://github.com/llvm/llvm-project/issues/99937>`__)
+- P0767R1: Deprecate POD (`Github <https://github.com/llvm/llvm-project/issues/104013>`__)
 - P1361R2: Integration of chrono with text formatting (`Github <https://github.com/llvm/llvm-project/issues/100014>`__)
 
 Improvements and New Features
@@ -58,6 +59,8 @@ Improvements and New Features
 Deprecations and Removals
 -------------------------
 
+- ``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 <https://wg21.link/P0616R0>`__","de-pessimize legacy <numeric> algorithms with std::move","2017-11 (Albuquerque)","|Complete|","12",""
 "`P0653R2 <https://wg21.link/P0653R2>`__","Utility to convert a pointer to a raw pointer","2017-11 (Albuquerque)","|Complete|","6",""
 "`P0718R2 <https://wg21.link/P0718R2>`__","Atomic shared_ptr","2017-11 (Albuquerque)","","",""
-"`P0767R1 <https://wg21.link/P0767R1>`__","Deprecate POD","2017-11 (Albuquerque)","|Complete|","7",""
+"`P0767R1 <https://wg21.link/P0767R1>`__","Deprecate POD","2017-11 (Albuquerque)","|Complete|","21","It was previously erroneously marked as complete in LLVM 7."
 "`P0768R1 <https://wg21.link/P0768R1>`__","Library Support for the Spaceship (Comparison) Operator","2017-11 (Albuquerque)","|Complete|","",""
 "`P0777R1 <https://wg21.link/P0777R1>`__","Treating Unnecessary ``decay``\ ","2017-11 (Albuquerque)","|Complete|","7",""
 "","","","","",""

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..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
+
+// <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"
 


        


More information about the libcxx-commits mailing list