File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change 44#pragma once
55
66#include < cassert>
7+ #include < cstddef>
78#include < new>
8- #include < type_traits>
99#include < utility>
1010
1111/* *
1616 */
1717template <class T >
1818class 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 {
You can’t perform that action at this time.
0 commit comments