Backport
memory.hpp File Reference

This header provides definitions from the C++ header <memory> More...

#include "detail/config.hpp"
#include "type_traits.hpp"
#include "utility.hpp"
#include <memory>
#include <cstddef>
#include <type_traits>
+ Include dependency graph for memory.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

template<typename T >
using bpstd::detail::to_address_result_t = typename to_address_result< T >::type
 

Functions

template<typename T , typename... Args>
std::unique_ptr< typename detail::make_unique_result< T >::object > bpstd::make_unique (Args &&...args)
 Constructs an object of type T and wraps it in a std::unique_ptr. More...
 
template<typename T >
std::unique_ptr< typename detail::make_unique_result< T >::unbounded_array > bpstd::make_unique (std::size_t size)
 Constructs an object of type T[] and wraps it in a std::unique_ptr. More...
 
template<typename T >
std::unique_ptr< typename detail::make_unique_result< T >::bounded_array > bpstd::make_unique ()=delete
 
template<typename T >
std::unique_ptr< typename detail::make_unique_result< T >::object > bpstd::make_unique_for_overwrite ()
 Constructs an object of type T through default-initialization and wraps it in a std::unique_ptr. More...
 
template<typename T >
std::unique_ptr< typename detail::make_unique_result< T >::unbounded_array > bpstd::make_unique_for_overwrite (std::size_t size)
 Constructs an object of type T[] through default-initialization and wraps it in a std::unique_ptr. More...
 
template<typename T >
std::unique_ptr< typename detail::make_unique_result< T >::bounded_array > bpstd::make_unique_for_overwrite ()=delete
 
template<typename T >
constexpr BPSTD_INLINE_VISIBILITY auto bpstd::detail::to_address_impl (const T &p, std::true_type) -> decltype(std::pointer_traits< T >::to_address(std::declval< const T & >()))
 
template<typename T >
constexpr BPSTD_INLINE_VISIBILITY auto bpstd::detail::to_address_impl (const T &p, std::false_type) -> decltype(std::declval< const T & >().operator->())
 
template<typename T >
constexpr T * bpstd::to_address (T *p) noexcept
 Converts a pointer-like type to a raw pointer by recursively calling to_address on it. More...
 
template<typename T >
constexpr detail::to_address_result_t< T > bpstd::to_address (const T &p) noexcept
 Converts a pointer-like type to a raw pointer by recursively calling to_address on it. More...
 
template<typename T >
constexpr T * bpstd::to_address (T *p) noexcept
 Converts a pointer-like type to a raw pointer by recursively calling to_address on it. More...
 
template<typename T >
constexpr detail::to_address_result_t< T > bpstd::to_address (const T &p) noexcept
 Converts a pointer-like type to a raw pointer by recursively calling to_address on it. More...
 

Detailed Description

This header provides definitions from the C++ header <memory>

Definition in file memory.hpp.

Function Documentation

◆ make_unique() [1/2]

template<typename T , typename... Args>
std::unique_ptr<typename detail::make_unique_result<T>::object> bpstd::make_unique ( Args &&...  args)

Constructs an object of type T and wraps it in a std::unique_ptr.

Constructs a non-array type T. The arguments args are passed to the constructor of T. This overload only participates in overload resolution if T is not an array type.

Template Parameters
Tthe type to construct
Parameters
argsthe arguments to forward to T's constructor
Returns
the unique_ptr

◆ make_unique() [2/2]

template<typename T >
std::unique_ptr<typename detail::make_unique_result<T>::unbounded_array> bpstd::make_unique ( std::size_t  size)

Constructs an object of type T[] and wraps it in a std::unique_ptr.

Constructs an array of unknown bound T. This overload only participates in overload resolution if T is an array of unknown bound.

Template Parameters
Tthe type to construct
Parameters
sizethe size of the array
Returns
the unique_ptr

◆ make_unique_for_overwrite() [1/2]

template<typename T >
std::unique_ptr<typename detail::make_unique_result<T>::object> bpstd::make_unique_for_overwrite ( )

Constructs an object of type T through default-initialization and wraps it in a std::unique_ptr.

Constructs a non-array type T. This overload only participates in overload resolution if T is not an array type. The object is default-initialised, which may mean it will need to be overwritten before it is legal to be read

Template Parameters
Tthe type to construct
Returns
the unique_ptr

◆ make_unique_for_overwrite() [2/2]

template<typename T >
std::unique_ptr<typename detail::make_unique_result<T>::unbounded_array> bpstd::make_unique_for_overwrite ( std::size_t  size)

Constructs an object of type T[] through default-initialization and wraps it in a std::unique_ptr.

Constructs an array of unknown bound T. This overload only participates in overload resolution if T is an array of unknown bound. The array is default-initialised, which may mean it will need to be overwritten before it is legal to be read

Template Parameters
Tthe type to construct
Returns
the unique_ptr

◆ to_address() [1/2]

template<typename T >
constexpr detail::to_address_result_t<T> bpstd::to_address ( const T &  p)
constexprnoexcept

Converts a pointer-like type to a raw pointer by recursively calling to_address on it.

Parameters
pthe pointer-like type
Returns
the pointer

◆ to_address() [2/2]

template<typename T >
constexpr T* bpstd::to_address ( T *  p)
constexprnoexcept

Converts a pointer-like type to a raw pointer by recursively calling to_address on it.

Parameters
pthe pointer-like type
Returns
the pointer