Iros
Loading...
Searching...
No Matches
default_construct_at.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
di/util/construct_at.h
"
4
#include "
di/util/std_new.h
"
5
#include "
di/util/voidify.h
"
6
7
namespace
di::util
{
8
namespace
detail
{
9
struct
DefaultConstructAtFunction
{
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
27
constexpr
inline
auto
default_construct_at
=
detail::DefaultConstructAtFunction
{};
28
}
29
30
namespace
di
{
31
using
util::default_construct_at
;
32
}
construct_at.h
di::util::detail
Definition
clamp.h:9
di::util
Definition
vocab.h:96
di::util::default_construct_at
constexpr auto default_construct_at
Definition
default_construct_at.h:27
di::util::voidify
constexpr auto voidify
Definition
voidify.h:13
di
Definition
zstring_parser.h:9
std_new.h
di::util::detail::DefaultConstructAtFunction
Definition
default_construct_at.h:9
voidify.h
libs
di
include
di
util
default_construct_at.h
Generated by
1.13.0