My Project
Functions
construct_at.hpp File Reference
#include "discard.hpp"
#include "declval.hpp"
#include "forward.hpp"

Go to the source code of this file.

Functions

constexpr void * operator new (bsl::uintmax count, void *ptr) noexcept
 This function implements the placement new operator. Note that this function is passed a count and pointer, both of which are ignored. More...
 
template<typename T , typename... ARGS>
constexpr void std::construct_at_impl (void *const ptr, ARGS &&... args) noexcept(noexcept(new(ptr) T{bsl::declval< ARGS >()...}))
 Implements a constexpr version of placement new. that can be used by BSL's APIs to support constexpr based APIs. More...
 
template<typename T , typename... ARGS>
constexpr void bsl::construct_at (void *const ptr, ARGS &&... args) noexcept(noexcept(std::construct_at_impl< T, ARGS... >(ptr, bsl::declval< ARGS >()...)))
 Implements a constexpr version of placement new. that can be used by BSL's APIs to support constexpr based APIs. More...
 

Detailed Description

Function Documentation

◆ operator new()

constexpr void* operator new ( bsl::uintmax  count,
void *  ptr 
)
noexcept

This function implements the placement new operator. Note that this function is passed a count and pointer, both of which are ignored.

Parameters
countignored
ptrthe ptr to return
Returns
returns ptr

◆ construct_at_impl()

template<typename T , typename... ARGS>
constexpr void std::construct_at_impl ( void *const  ptr,
ARGS &&...  args 
)
noexcept

Implements a constexpr version of placement new. that can be used by BSL's APIs to support constexpr based APIs.

Note
C++20 right now only allows for constexpr placement new to occur from the standard library (a practice I hope changes in the next release as that is horrible). For this reason, we implement the placement new from the std namespace (uhg) and then call this from our BSL function. This rule is so easy to bypass, I am at a loss as to why they did this, but at least this approach works so that third party libraries can still take advantage of this C++20 feature.
Template Parameters
Tthe type of object to initialize
ARGSthe types of args to initialize T with
Parameters
ptra pointer to the object to initialize
argsthe args to initialize T with
Exceptions
throwsif T throws during construction

◆ construct_at()

template<typename T , typename... ARGS>
constexpr void bsl::construct_at ( void *const  ptr,
ARGS &&...  args 
)
noexcept

Implements a constexpr version of placement new. that can be used by BSL's APIs to support constexpr based APIs.

Template Parameters
Tthe type of object to initialize
ARGSthe types of args to initialize T with
Parameters
ptra pointer to the object to initialize
argsthe args to initialize T with
Exceptions
throwsif T throws during construction