Iros
 
Loading...
Searching...
No Matches
default_construct_at.h
Go to the documentation of this file.
1#pragma once
2
4#include "di/util/std_new.h"
5#include "di/util/voidify.h"
6
7namespace di::util {
8namespace detail {
10 template<typename T>
11 requires(requires(void* pointer) { ::new (pointer) T; })
12 constexpr auto operator()(T* location) const -> T* {
13 // NOTE: this is not actually the same behavior, as the
14 // expression shown below leaves trivial types
15 // uninitialized. However, placement new is not
16 // usable in constexpr context, so we cannot
17 // call it here.
18 if consteval {
19 return std::construct_at(location);
20 } else {
21 return ::new (util::voidify(location)) T;
22 }
23 }
24 };
25}
26
28}
29
30namespace di {
32}
Definition clamp.h:9
Definition vocab.h:96
constexpr auto default_construct_at
Definition default_construct_at.h:27
constexpr auto voidify
Definition voidify.h:13
Definition zstring_parser.h:9
Definition default_construct_at.h:9