Skip to content

[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

Merged
merged 7 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libcxx/docs/ReleaseNotes/21.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
----------------------------------

Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx20Papers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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",""
"","","","","",""
Expand Down
5 changes: 3 additions & 2 deletions libcxx/include/__type_traits/is_pod.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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}}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

// is_pod

// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS

#include <type_traits>
#include "test_macros.h"

Expand Down