Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

std::aligned_storage is deprecated as of C++23 #1908

Closed
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
66 changes: 0 additions & 66 deletions testing/alignment.cu
Original file line number Diff line number Diff line change
Expand Up @@ -209,72 +209,6 @@ void test_aligned_type()
}
DECLARE_UNITTEST(test_aligned_type);

template <std::size_t Len, std::size_t Align>
void test_aligned_storage_instantiation(thrust::detail::true_type /* Align is valid */)
{
typedef typename thrust::detail::aligned_storage<Len, Align>::type type;
ASSERT_GEQUAL(sizeof(type), Len);
ASSERT_EQUAL(THRUST_ALIGNOF(type), Align);
ASSERT_EQUAL(thrust::detail::alignment_of<type>::value, Align);
}

template <std::size_t Len, std::size_t Align>
void test_aligned_storage_instantiation(thrust::detail::false_type /* Align is invalid */)
{
// no-op -- alignment is > max_align_t and MSVC complains loudly.
}

template <std::size_t Len, std::size_t Align>
void test_aligned_storage_instantiation()
{
typedef thrust::detail::integral_constant<
bool, Align <= THRUST_ALIGNOF(thrust::detail::max_align_t)>
ValidAlign;
test_aligned_storage_instantiation<Len, Align>(ValidAlign());
}

template <std::size_t Len>
void test_aligned_storage_size()
{
test_aligned_storage_instantiation<Len, 1>();
test_aligned_storage_instantiation<Len, 2>();
test_aligned_storage_instantiation<Len, 4>();
test_aligned_storage_instantiation<Len, 8>();
test_aligned_storage_instantiation<Len, 16>();
test_aligned_storage_instantiation<Len, 32>();
test_aligned_storage_instantiation<Len, 64>();
test_aligned_storage_instantiation<Len, 128>();
}

void test_aligned_storage()
{
test_aligned_storage_size<1>();
test_aligned_storage_size<2>();
test_aligned_storage_size<4>();
test_aligned_storage_size<8>();
test_aligned_storage_size<16>();
test_aligned_storage_size<32>();
test_aligned_storage_size<64>();
test_aligned_storage_size<128>();
test_aligned_storage_size<256>();
test_aligned_storage_size<512>();
test_aligned_storage_size<1024>();
test_aligned_storage_size<2048>();
test_aligned_storage_size<4096>();
test_aligned_storage_size<8192>();
test_aligned_storage_size<16384>();

test_aligned_storage_size<3>();
test_aligned_storage_size<5>();
test_aligned_storage_size<7>();

test_aligned_storage_size<17>();
test_aligned_storage_size<42>();

test_aligned_storage_size<10000>();
}
DECLARE_UNITTEST(test_aligned_storage);

void test_max_align_t()
{
ASSERT_GEQUAL(
Expand Down
28 changes: 1 addition & 27 deletions thrust/detail/alignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <cstddef> // For `std::size_t` and `std::max_align_t`.

#if THRUST_CPP_DIALECT >= 2011
#include <type_traits> // For `std::alignment_of` and `std::aligned_storage`.
#include <type_traits> // For `std::alignment_of`.
#endif

THRUST_NAMESPACE_BEGIN
Expand Down Expand Up @@ -154,32 +154,6 @@ struct aligned_type;
};
#endif

/// \p aligned_storage provides the nested type `type`, which is a trivial type
/// suitable for use as uninitialized storage for any object whose size is at
/// most `Len` bytes and whose alignment requirement is a divisor of `Align`.
///
/// The behavior is undefined if `Len` is 0 or `Align` is not a power of 2.
///
/// It is an implementation of C++11's \p std::aligned_storage.
#if THRUST_CPP_DIALECT >= 2011
template <std::size_t Len, std::size_t Align>
using aligned_storage = std::aligned_storage<Len, Align>;
#else
template <std::size_t Len, std::size_t Align>
struct aligned_storage
{
union type
{
unsigned char data[Len];
// We put this into the union in case the alignment requirement of
// an array of `unsigned char` of length `Len` is greater than
// `Align`.

typename aligned_type<Align>::type align;
};
};
#endif

/// \p max_align_t is a trivial type whose alignment requirement is at least as
/// strict (as large) as that of every scalar type.
///
Expand Down