There are no tests for the aliases because clang doesn't diagnose deprecated template aliases currently.
Reviewed By: ldionne, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D127678
.. [#note-P2273] P2273: ``make_unique_for_overwrite`` isn't done yet since `P1020` hasn't been implemented yet.
.. [#note-P0533R9] P0533R9: ``isfinite``, ``isinf``, ``isnan`` and ``isnormal`` are implemented.
+ .. [#note-P1413R3] P1413R3: ``std::aligned_storage_t`` and ``std::aligned_union_t`` are marked deprecated, but
+ clang doesn't issue a diagnostic for deprecated using template declarations.
.. _issues-status-cxx2b:
"`P0533R9 <https://wg21.link/P0533R9>`__","LWG","``constexpr`` for ``<cmath>`` and ``<cstdlib>``","February 2022","|In progress| [#note-P0533R9]_",""
"`P0627R6 <https://wg21.link/P0627R6>`__","LWG","Function to mark unreachable code","February 2022","|Complete|","15.0"
"`P1206R7 <https://wg21.link/P1206R7>`__","LWG","``ranges::to``: A function to convert any range to a container","February 2022","","","|ranges|"
-"`P1413R3 <https://wg21.link/P1413R3>`__","LWG","Deprecate ``std::aligned_storage`` and ``std::aligned_union``","February 2022","",""
+"`P1413R3 <https://wg21.link/P1413R3>`__","LWG","Deprecate ``std::aligned_storage`` and ``std::aligned_union``","February 2022","|Complete| [#note-P1413R3]_",""
"`P2255R2 <https://wg21.link/P2255R2>`__","LWG","A type trait to detect reference binding to temporary","February 2022","",""
"`P2273R3 <https://wg21.link/P2273R3>`__","LWG","Making ``std::unique_ptr`` constexpr","February 2022","|Partial| [#note-P2273]_","16.0"
"`P2387R3 <https://wg21.link/P2387R3>`__","LWG","Pipe support for user-defined range adaptors","February 2022","","","|ranges|"
# define _LIBCPP_DEPRECATED_IN_CXX20
# endif
+#if _LIBCPP_STD_VER >= 23
+# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
+#else
+# define _LIBCPP_DEPRECATED_IN_CXX23
+#endif
+
# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
# else
template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
{
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
typename aligned_storage<3 * sizeof(void*)>::type __buf_;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
typedef __base<_Rp(_ArgTypes...)> __func;
__func* __f_;
return;
if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_)
{
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
__func* __t = __as_base(&__tempbuf);
__f_->__clone(__t);
__f_->destroy();
: public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
-struct _LIBCPP_TEMPLATE_VIS aligned_storage
+struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage
{
typedef typename __find_pod<__all_types, _Align>::type _Aligner;
union type
};
#if _LIBCPP_STD_VER > 11
+
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
- using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
+ using aligned_storage_t _LIBCPP_DEPRECATED_IN_CXX23 = typename aligned_storage<_Len, _Align>::type;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+
#endif
#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
template <size_t _Len>\
-struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
+struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
{\
struct _ALIGNAS(n) type\
{\
};
template <size_t _Len, class _Type0, class ..._Types>
-struct aligned_union
+struct _LIBCPP_DEPRECATED_IN_CXX23 aligned_union
{
static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
_LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
};
#if _LIBCPP_STD_VER > 11
-template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
+template <size_t _Len, class... _Types>
+using aligned_union_t _LIBCPP_DEPRECATED_IN_CXX23 = typename aligned_union<_Len, _Types...>::type;
#endif
_LIBCPP_END_NAMESPACE_STD
namespace __any_imp
{
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
using _Buffer = aligned_storage_t<3*sizeof(void*), alignment_of<void*>::value>;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
template <class _Tp>
using _IsSmallObject = integral_constant<bool
: public __assoc_sub_state
{
typedef __assoc_sub_state base;
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
typedef typename aligned_storage<sizeof(_Rp), alignment_of<_Rp>::value>::type _Up;
+_LIBCPP_SUPPRESS_DEPRECATED_POP
protected:
_Up __value_;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_NO_CFI
__base* __get_buf() { return (__base*)&__buf_; }
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
typename aligned_storage<3*sizeof(void*)>::type __buf_;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
__base* __f_;
public:
{
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
{
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
__base* __t = (__base*)&__tempbuf;
__f_->__move_to(__t);
__f_->destroy();
// Alignment properties and transformations:
template <class T> struct alignment_of;
template <size_t Len, size_t Align = most_stringent_alignment_requirement>
- struct aligned_storage;
- template <size_t Len, class... Types> struct aligned_union;
+ struct aligned_storage; // deprecated in C++23
+ template <size_t Len, class... Types> struct aligned_union; // deprecated in C++23
template <class T> struct remove_cvref; // C++20
template <class T> struct decay;
template <size_t S, size_t Align>
void testForSizeAndAlign() {
- using T = typename std::aligned_storage<S, Align>::type;
+ struct T { alignas(Align) char data[S]; };
TestResource R;
ex::polymorphic_allocator<T> a(&R);
#ifndef TEST_HAS_NO_EXCEPTIONS
template <size_t S>
void testAllocForSizeThrows() {
- using T = typename std::aligned_storage<S>::type;
+ struct T { char data[S]; };
using Alloc = ex::polymorphic_allocator<T>;
using Traits = std::allocator_traits<Alloc>;
NullResource R;
template <size_t S, size_t Align>
void testForSizeAndAlign() {
- using T = typename std::aligned_storage<S, Align>::type;
+ struct T { alignas(Align) char data[S]; };
TestResource R;
ex::polymorphic_allocator<T> a(&R);
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+#include <type_traits>
+
+std::aligned_storage<1, 1>::type s2; // expected-warning {{'aligned_storage<1, 1>' is deprecated}}
+std::aligned_storage<3, 1>::type s3; // expected-warning {{'aligned_storage<3, 1>' is deprecated}}
// Issue 3034 added:
// The member typedef type shall be a trivial standard-layout type.
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
#include <type_traits>
#include <cstddef> // for std::max_align_t
#include "test_macros.h"
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+#include <type_traits>
+
+std::aligned_union<1, int>::type s2; // expected-warning {{'aligned_union<1, int>' is deprecated}}
+std::aligned_union<3, char, char>::type s3; // expected-warning {{'aligned_union<3, char, char>' is deprecated}}
//
//===----------------------------------------------------------------------===//
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
// type_traits
// aligned_union<size_t Len, class ...Types>
template <size_t S, size_t Align>
void testForSizeAndAlign() {
- using T = typename std::aligned_storage<S, Align>::type;
+ struct T {
+ alignas(Align) std::byte buf[S];
+ };
+
TestResource R;
std::pmr::polymorphic_allocator<T> a(&R);
#ifndef TEST_HAS_NO_EXCEPTIONS
template <size_t S>
void testAllocForSizeThrows() {
- using T = typename std::aligned_storage<S>::type;
+ struct T {
+ std::byte buf[S];
+ };
+
using Alloc = std::pmr::polymorphic_allocator<T>;
using Traits = std::allocator_traits<Alloc>;
NullResource R;
template <size_t S, size_t Align>
void testForSizeAndAlign() {
- using T = typename std::aligned_storage<S, Align>::type;
+ struct T {
+ alignas(Align) std::byte buf[S];
+ };
TestResource R;
std::pmr::polymorphic_allocator<T> a(&R);