di 0.1.0
Loading...
Searching...
No Matches
unsafe_forget.h
Go to the documentation of this file.
1#pragma once
2
5#include "di/util/move.h"
6
7namespace di::util::detail {
8template<typename T>
9struct Union {
10 Union() {}
11 ~Union() {}
12
13 union {
14 T value;
15 };
16};
17
18struct UnsafeForget {
19 template<concepts::MoveConstructible T>
20 static void operator()(T value) {
21 auto slot = Union<T> {};
22 di::construct_at(&slot.value, di::move(value));
23 }
24};
25}
26
27namespace di {
32constexpr inline auto unsafe_forget = util::detail::UnsafeForget {};
33}
Definition any_storable.h:9
constexpr auto unsafe_forget
Steal ownership of an object and do not its destructor.
Definition unsafe_forget.h:32
constexpr auto construct_at
Definition construct_at.h:35