Skip to content

Commit 919fa85

Browse files
[libc++] Deprecate is_pod(_v) since C++20
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 e42ab4c commit 919fa85

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

libcxx/docs/ReleaseNotes/21.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Improvements and New Features
5555
Deprecations and Removals
5656
-------------------------
5757

58+
- ``std::is_pod`` and ``std::is_pod_v`` are deprecated since C++20 according to the standard.
59+
5860
Upcoming Deprecations and Removals
5961
----------------------------------
6062

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)