xentara-utils v1.2.1
Xentara utilities library
Loading...
Searching...
No Matches
xentara::utils::tools::UnownedPointer< Element[], Deleter > Class Template Reference

Template specialization of UnownedPointer for array types. More...

#include <tools/UnownedPointer.hpp>

Public Types

using pointer = typename std::unique_ptr< Element[], Deleter >::pointer
 A type alias for a raw pointer.
 
using element_type = typename std::unique_ptr< Element[], Deleter >::element_type
 A type alias for the element type.
 

Public Member Functions

constexpr UnownedPointer () noexcept=default
 Constructor for an empty pointer.
 
constexpr UnownedPointer (const UnownedPointer &) noexcept=default
 Copy constructor.
 
template<typename RelatedElement , typename RelatedDeleter >
requires std::is_constructible_v<std::unique_ptr<Element[], Deleter>, std::unique_ptr<RelatedElement, RelatedDeleter> &&>
constexpr UnownedPointer (const UnownedPointer< RelatedElement, RelatedDeleter > &value) noexcept
 Constructor that sets the value from a related pointer.
 
constexpr UnownedPointer (const std::unique_ptr< Element[], Deleter > &value) noexcept
 Constructor that sets the value from an std::unique_ptr.
 
template<typename RelatedElement , typename RelatedDeleter >
requires std::is_constructible_v<std::unique_ptr<Element[], Deleter>, std::unique_ptr<RelatedElement, RelatedDeleter> &&>
constexpr UnownedPointer (const std::unique_ptr< RelatedElement, RelatedDeleter > &value) noexcept
 Constructor that sets the value from a related std::unique_ptr.
 
template<class RawPointer >
requires std::is_constructible_v<std::unique_ptr<Element[], Deleter>, RawPointer>
constexpr UnownedPointer (RawPointer value) noexcept
 Constructor that sets the value from a raw pointer.
 
constexpr UnownedPointer (std::nullptr_t) noexcept
 Constructor that sets the value to an empty pointer.
 
constexpr auto operator= (const UnownedPointer &) noexcept -> UnownedPointer &=default
 Assignment operator.
 
template<typename RelatedElement , typename RelatedDeleter >
requires std::is_constructible_v<std::unique_ptr<Element[], Deleter>, std::unique_ptr<RelatedElement, RelatedDeleter> &&>
constexpr auto operator= (const UnownedPointer< RelatedElement, RelatedDeleter > &value) noexcept -> UnownedPointer &
 Assignment operator that sets the value from a related pointer.
 
constexpr auto operator= (const std::unique_ptr< Element[], Deleter > &value) noexcept -> UnownedPointer &
 Assignment operator that sets the value from an std::unique_ptr.
 
template<typename RelatedElement , typename RelatedDeleter >
requires std::is_constructible_v<std::unique_ptr<Element[], Deleter>, std::unique_ptr<RelatedElement, RelatedDeleter> &&>
constexpr auto operator= (const std::unique_ptr< RelatedElement, RelatedDeleter > &value) noexcept -> UnownedPointer &
 Assignment operator that sets the value from a related std::unique_ptr.
 
constexpr auto operator= (std::nullptr_t) noexcept -> UnownedPointer &
 Assignment operator that sets the value to an empty pointer.
 
auto operator[] (std::size_t index) const -> Element &
 Access to elements of the pointed-to array.
 
 operator bool () const noexcept
 Checks whether the value is non-empty.
 
auto get () const noexcept -> pointer
 Gets the current value.
 
auto reset (pointer value=pointer()) noexcept -> void
 Sets a new value.
 
auto reset (std::nullptr_t=nullptr) noexcept -> void
 Empties the pointer.
 
auto swap (UnownedPointer &other) noexcept -> void
 Swaps the value with another unowned pointer.
 

Detailed Description

template<typename Element, typename Deleter>
class xentara::utils::tools::UnownedPointer< Element[], Deleter >

Template specialization of UnownedPointer for array types.

Member Typedef Documentation

◆ element_type

template<typename Element , typename Deleter >
using xentara::utils::tools::UnownedPointer< Element[], Deleter >::element_type = typename std::unique_ptr<Element[], Deleter>::element_type

A type alias for the element type.

◆ pointer

template<typename Element , typename Deleter >
using xentara::utils::tools::UnownedPointer< Element[], Deleter >::pointer = typename std::unique_ptr<Element[], Deleter>::pointer

A type alias for a raw pointer.

Constructor & Destructor Documentation

◆ UnownedPointer() [1/7]

template<typename Element , typename Deleter >
constexpr xentara::utils::tools::UnownedPointer< Element[], Deleter >::UnownedPointer ( )
constexprdefaultnoexcept

Constructor for an empty pointer.

◆ UnownedPointer() [2/7]

template<typename Element , typename Deleter >
constexpr xentara::utils::tools::UnownedPointer< Element[], Deleter >::UnownedPointer ( const UnownedPointer< Element[], Deleter > &  )
constexprdefaultnoexcept

Copy constructor.

◆ UnownedPointer() [3/7]

template<typename Element , typename Deleter >
template<typename RelatedElement , typename RelatedDeleter >
requires std::is_constructible_v<std::unique_ptr<Element[], Deleter>, std::unique_ptr<RelatedElement, RelatedDeleter> &&>
constexpr xentara::utils::tools::UnownedPointer< Element[], Deleter >::UnownedPointer ( const UnownedPointer< RelatedElement, RelatedDeleter > &  value)
constexprnoexcept

Constructor that sets the value from a related pointer.

◆ UnownedPointer() [4/7]

template<typename Element , typename Deleter >
constexpr xentara::utils::tools::UnownedPointer< Element[], Deleter >::UnownedPointer ( const std::unique_ptr< Element[], Deleter > &  value)
constexprnoexcept

Constructor that sets the value from an std::unique_ptr.

◆ UnownedPointer() [5/7]

template<typename Element , typename Deleter >
template<typename RelatedElement , typename RelatedDeleter >
requires std::is_constructible_v<std::unique_ptr<Element[], Deleter>, std::unique_ptr<RelatedElement, RelatedDeleter> &&>
constexpr xentara::utils::tools::UnownedPointer< Element[], Deleter >::UnownedPointer ( const std::unique_ptr< RelatedElement, RelatedDeleter > &  value)
constexprnoexcept

Constructor that sets the value from a related std::unique_ptr.

◆ UnownedPointer() [6/7]

template<typename Element , typename Deleter >
template<class RawPointer >
requires std::is_constructible_v<std::unique_ptr<Element[], Deleter>, RawPointer>
constexpr xentara::utils::tools::UnownedPointer< Element[], Deleter >::UnownedPointer ( RawPointer  value)
explicitconstexprnoexcept

Constructor that sets the value from a raw pointer.

◆ UnownedPointer() [7/7]

template<typename Element , typename Deleter >
constexpr xentara::utils::tools::UnownedPointer< Element[], Deleter >::UnownedPointer ( std::nullptr_t  )
constexprnoexcept

Constructor that sets the value to an empty pointer.

Member Function Documentation

◆ get()

template<typename Element , typename Deleter >
auto xentara::utils::tools::UnownedPointer< Element[], Deleter >::get ( ) const -> pointer
noexcept

Gets the current value.

◆ operator bool()

template<typename Element , typename Deleter >
xentara::utils::tools::UnownedPointer< Element[], Deleter >::operator bool ( ) const
explicitnoexcept

Checks whether the value is non-empty.

Returns
Return true if the object contains a pointer, or false is it is empty (contains a null pointer).

◆ operator=() [1/5]

template<typename Element , typename Deleter >
constexpr auto xentara::utils::tools::UnownedPointer< Element[], Deleter >::operator= ( const std::unique_ptr< Element[], Deleter > &  value) -> UnownedPointer &
constexprnoexcept

Assignment operator that sets the value from an std::unique_ptr.

◆ operator=() [2/5]

template<typename Element , typename Deleter >
template<typename RelatedElement , typename RelatedDeleter >
requires std::is_constructible_v<std::unique_ptr<Element[], Deleter>, std::unique_ptr<RelatedElement, RelatedDeleter> &&>
constexpr auto xentara::utils::tools::UnownedPointer< Element[], Deleter >::operator= ( const std::unique_ptr< RelatedElement, RelatedDeleter > &  value) -> UnownedPointer &
constexprnoexcept

Assignment operator that sets the value from a related std::unique_ptr.

◆ operator=() [3/5]

template<typename Element , typename Deleter >
constexpr auto xentara::utils::tools::UnownedPointer< Element[], Deleter >::operator= ( const UnownedPointer< Element[], Deleter > &  ) -> UnownedPointer &=default
constexprdefaultnoexcept

Assignment operator.

◆ operator=() [4/5]

template<typename Element , typename Deleter >
template<typename RelatedElement , typename RelatedDeleter >
requires std::is_constructible_v<std::unique_ptr<Element[], Deleter>, std::unique_ptr<RelatedElement, RelatedDeleter> &&>
constexpr auto xentara::utils::tools::UnownedPointer< Element[], Deleter >::operator= ( const UnownedPointer< RelatedElement, RelatedDeleter > &  value) -> UnownedPointer &
constexprnoexcept

Assignment operator that sets the value from a related pointer.

◆ operator=() [5/5]

template<typename Element , typename Deleter >
constexpr auto xentara::utils::tools::UnownedPointer< Element[], Deleter >::operator= ( std::nullptr_t  ) -> UnownedPointer &
constexprnoexcept

Assignment operator that sets the value to an empty pointer.

◆ operator[]()

template<typename Element , typename Deleter >
auto xentara::utils::tools::UnownedPointer< Element[], Deleter >::operator[] ( std::size_t  index) const -> Element &

Access to elements of the pointed-to array.

Precondition
This function must not be called on an empty pointer
Parameters
indexThe index. Must be less than the number of elements contained in the pointed-to array.
Returns
A reference to the element.

◆ reset() [1/2]

template<typename Element , typename Deleter >
auto xentara::utils::tools::UnownedPointer< Element[], Deleter >::reset ( pointer  value = pointer()) -> void
noexcept

Sets a new value.

◆ reset() [2/2]

template<typename Element , typename Deleter >
auto xentara::utils::tools::UnownedPointer< Element[], Deleter >::reset ( std::nullptr_t  = nullptr) -> void
noexcept

Empties the pointer.

◆ swap()

template<typename Element , typename Deleter >
auto xentara::utils::tools::UnownedPointer< Element[], Deleter >::swap ( UnownedPointer< Element[], Deleter > &  other) -> void
noexcept

Swaps the value with another unowned pointer.