Skip to content

Commit 903b4a7

Browse files
committed
util/Manual: use array instead of std::aligned_storage_t
std::aligned_storage_t is deprecated in C++23.
1 parent d7f8b64 commit 903b4a7

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/util/Manual.hxx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#pragma once
55

66
#include <cassert>
7+
#include <cstddef>
78
#include <new>
8-
#include <type_traits>
99
#include <utility>
1010

1111
/**
@@ -16,9 +16,7 @@
1616
*/
1717
template<class T>
1818
class Manual {
19-
using Storage = std::aligned_storage_t<sizeof(T), alignof(T)>;
20-
21-
Storage storage;
19+
alignas(T) std::byte data[sizeof(T)];
2220

2321
#ifndef NDEBUG
2422
bool initialized = false;
@@ -48,7 +46,7 @@ public:
4846
void Construct(Args&&... args) {
4947
assert(!initialized);
5048

51-
::new(&storage) T(std::forward<Args>(args)...);
49+
::new(data) T(std::forward<Args>(args)...);
5250

5351
#ifndef NDEBUG
5452
initialized = true;
@@ -69,13 +67,13 @@ public:
6967
reference Get() noexcept {
7068
assert(initialized);
7169

72-
return *std::launder(reinterpret_cast<pointer>(&storage));
70+
return *std::launder(reinterpret_cast<pointer>(data));
7371
}
7472

7573
const_reference Get() const noexcept {
7674
assert(initialized);
7775

78-
return *std::launder(reinterpret_cast<const_pointer>(&storage));
76+
return *std::launder(reinterpret_cast<const_pointer>(data));
7977
}
8078

8179
operator reference() noexcept {

0 commit comments

Comments
 (0)