di 0.1.0
Loading...
Searching...
No Matches
construct_at.h
Go to the documentation of this file.
1#pragma once
2
4#include "di/util/forward.h"
5#include "di/util/std_new.h"
6
7#ifndef DI_NO_USE_STD
8#include <memory>
9#else
10namespace std {
11#ifdef DI_GCC
12#pragma GCC diagnostic push
13#pragma GCC diagnostic ignored "-Wdangling-pointer"
14#endif
15template<typename T, typename... Args>
16constexpr auto construct_at(T* location, Args&&... args) -> T* {
17 return ::new (const_cast<void*>(static_cast<void const volatile*>(location))) T(di::util::forward<Args>(args)...);
18}
19}
20#ifdef DI_GCC
21#pragma GCC diagnostic pop
22#endif
23#endif
24
25namespace di::util {
26namespace detail {
27 struct ConstructAtFunction {
28 template<typename T, typename... Args>
29 constexpr auto operator()(T* location, Args&&... args) const -> T* requires(requires {
30 std::construct_at(location, util::forward<Args>(args)...);
31 }) { return std::construct_at(location, util::forward<Args>(args)...); }
32 };
33}
34
35constexpr inline auto construct_at = detail::ConstructAtFunction {};
36}
37
38namespace di {
40}
Definition vocab.h:96
constexpr auto construct_at
Definition construct_at.h:35
Definition any_storable.h:9
Definition enable_generate_structed_bindings.h:46