template<typename T , typename... Args, typename = std::enable_if_t<!std::is_array_v<T> || std::extent_v<T> != 0>, typename = decltype(::new (std::declval<void*>()) T(std::declval<Args>()...))>
| T * pw::construct_at |
( |
T * |
location, |
|
|
Args &&... |
args |
|
) |
| |
Constructs a T object initialized with args at location without allocating memory.
Backports C++20's std::construct_at so C++17-compatible code can perform constexpr in-place construction when compiled as C++20 or newer.
- Template Parameters
-
| T | The non-cv-qualified, non-array object type to construct. |
| Args | Argument types forwarded to T's constructor. |
- Parameters
-
| [out] | location | Pointer to uninitialized storage suitable for T. |
| [in] | args | Arguments forwarded to T's constructor. |
- Returns
location.