storage_ptr::storage_ptr

Constructors.

Synopsis

storage_ptr() noexcept; (1)

template<
    class T>
storage_ptr(
    T* r) noexcept; (2)

template<
    class V>
storage_ptr(
    boost::container::pmr::polymorphic_allocator< V > const& alloc) noexcept; (3)

storage_ptr(
    storage_ptr&& other) noexcept; (4)

storage_ptr(
    storage_ptr const& other) noexcept; (5)

Description

  • (1) constructs a non-owning pointer that refers to the default memory resource.

  • (2) constructs a non-owning pointer that points to the memory resource r.

  • (3) constructs a non-owning pointer that points to the same memory resource as alloc, obtained by calling alloc.resource().

  • (4), (5) construct a pointer to the same memory resource as other, with the same ownership.

After (4) and (5) if other was owning, then the constructed pointer is also owning. In particular, (4) transfers ownership to the constructed pointer while (5) causes it to share ownership with other. Otherwise, and with other overloads the constructed pointer doesn’t own its memory resource and the caller is responsible for maintaining the lifetime of the pointed-to boost::container::pmr::memory_resource.

After (4), other will point to the default memory resource.

Constraints

std::is_convertible< T*, boost::container::pmr::memory_resource* >::value == true

Preconditions

r != nullptr

Complexity

Constant.

Exception Safety

No-throw guarantee.

Template Parameters

Type Description

T

The type of memory resource.

V

Any type.

Parameters

Name Description

r

A non-null pointer to the memory resource to use.

alloc

A boost::container::pmr::polymorphic_allocator to construct from.

other

Another pointer.