Skip to content

Commit 94714fb

Browse files
[libc++] Deprecate is_pod(_v) since C++20 (#129471)
Previously, commit 042f07e claimed that P0767R1 was implemented in LLVM 7.0, but no deprecation warning was implemented. This patch adds the missing warnings.
1 parent 3a67c7c commit 94714fb

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

libcxx/docs/ReleaseNotes/21.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Implemented Papers
3939
------------------
4040

4141
- N4258: Cleaning-up noexcept in the Library (`Github <https://github.com/llvm/llvm-project/issues/99937>`__)
42+
- P0767R1: Deprecate POD (`Github <https://github.com/llvm/llvm-project/issues/104013>`__)
4243
- P1361R2: Integration of chrono with text formatting (`Github <https://github.com/llvm/llvm-project/issues/100014>`__)
4344

4445
Improvements and New Features
@@ -58,6 +59,8 @@ Improvements and New Features
5859
Deprecations and Removals
5960
-------------------------
6061

62+
- ``std::is_pod`` and ``std::is_pod_v`` are deprecated in C++20 and later.
63+
6164
Upcoming Deprecations and Removals
6265
----------------------------------
6366

libcxx/docs/Status/Cxx20Papers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"`P0616R0 <https://wg21.link/P0616R0>`__","de-pessimize legacy <numeric> algorithms with std::move","2017-11 (Albuquerque)","|Complete|","12",""
1414
"`P0653R2 <https://wg21.link/P0653R2>`__","Utility to convert a pointer to a raw pointer","2017-11 (Albuquerque)","|Complete|","6",""
1515
"`P0718R2 <https://wg21.link/P0718R2>`__","Atomic shared_ptr","2017-11 (Albuquerque)","","",""
16-
"`P0767R1 <https://wg21.link/P0767R1>`__","Deprecate POD","2017-11 (Albuquerque)","|Complete|","7",""
16+
"`P0767R1 <https://wg21.link/P0767R1>`__","Deprecate POD","2017-11 (Albuquerque)","|Complete|","21","It was previously erroneously marked as complete in LLVM 7."
1717
"`P0768R1 <https://wg21.link/P0768R1>`__","Library Support for the Spaceship (Comparison) Operator","2017-11 (Albuquerque)","|Complete|","",""
1818
"`P0777R1 <https://wg21.link/P0777R1>`__","Treating Unnecessary ``decay``\ ","2017-11 (Albuquerque)","|Complete|","7",""
1919
"","","","","",""

libcxx/include/__type_traits/is_pod.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
_LIBCPP_BEGIN_NAMESPACE_STD
2020

2121
template <class _Tp>
22-
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant<bool, __is_pod(_Tp)> {};
22+
struct _LIBCPP_TEMPLATE_VIS
23+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant<bool, __is_pod(_Tp)> {};
2324

2425
#if _LIBCPP_STD_VER >= 17
2526
template <class _Tp>
26-
_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp);
27+
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp);
2728
#endif
2829

2930
_LIBCPP_END_NAMESPACE_STD

libcxx/include/type_traits

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ namespace std
9595
template <class T> struct is_unbounded_array; // C++20
9696
9797
// Member introspection:
98-
template <class T> struct is_pod;
9998
template <class T> struct is_trivial;
99+
template <class T> struct is_pod; // Deprecated in C++20
100100
template <class T> struct is_trivially_copyable;
101101
template <class T> struct is_standard_layout;
102102
template <class T> struct is_literal_type; // Deprecated in C++17; removed in C++20
@@ -303,7 +303,7 @@ namespace std
303303
template <class T> inline constexpr bool is_standard_layout_v
304304
= is_standard_layout<T>::value; // C++17
305305
template <class T> inline constexpr bool is_pod_v
306-
= is_pod<T>::value; // C++17
306+
= is_pod<T>::value; // C++17; deprecated in C++20
307307
template <class T> inline constexpr bool is_literal_type_v
308308
= is_literal_type<T>::value; // C++17; deprecated in C++17; removed in C++20
309309
template <class T> inline constexpr bool is_empty_v
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// REQUIRES: std-at-least-c++20
10+
11+
// <type_traits>
12+
13+
// is_pod and is_pod_v are deprecated in C++20 by P0767R1
14+
15+
#include <type_traits>
16+
17+
static_assert(std::is_pod<int>::value); // expected-warning {{'is_pod<int>' is deprecated}}
18+
static_assert(std::is_pod_v<int>); // expected-warning {{'is_pod_v<int>' is deprecated}}

libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// is_pod
1212

13+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
14+
1315
#include <type_traits>
1416
#include "test_macros.h"
1517

0 commit comments

Comments
 (0)