xentara-utils v2.0.3
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::tools::DataAllocatorPair< Data, Allocator > Class Template Reference

A compound class pairing a possibly empty allocator with data. More...

#include <xentara/utils/tools/DataAllocatorPair.hpp>

Public Member Functions

 DataAllocatorPair ()=default
 Default constructor.
 
constexpr DataAllocatorPair (const Allocator &allocator) noexcept(std::is_nothrow_copy_constructible_v< Allocator > &&std::is_nothrow_constructible_v< Data >)
 Constructor that initializes the allocator.
 
constexpr DataAllocatorPair (Allocator &&allocator) noexcept(std::is_nothrow_move_constructible_v< Allocator > &&std::is_nothrow_constructible_v< Data >)
 Constructor that initializes the allocator.
 
constexpr auto allocator () noexcept -> Allocator &
 Gets the allocator.
 
constexpr auto allocator () const noexcept -> const Allocator &
 Gets the allocator.
 
constexpr auto data () noexcept -> Data &
 Gets the data.
 
constexpr auto data () const noexcept -> const Data &
 Gets the data.
 
constexpr auto operator* () noexcept -> Data &
 Access to the data.
 
constexpr auto operator* () const noexcept -> const Data &
 Access to the data.
 
constexpr auto operator-> () noexcept -> Data *
 Access to a member of the data.
 
constexpr auto operator-> () const noexcept -> const Data *
 Access to a member of the data.
 

Detailed Description

template<typename Data, typename Allocator>
class xentara::utils::tools::DataAllocatorPair< Data, Allocator >

A compound class pairing a possibly empty allocator with data.

This class combines an allocator with some data, for use in collection classes and the like. If the allocator class is empty, the space for the allocator is optimized out, either using the [[no_unique_address]] attribute if the compiler supports it, or using empty base optimation if it doesn’t.

Note
On compilers that do no support [[no_unique_address]], the Allocator class cannot be both empty and final.

Constructor & Destructor Documentation

◆ DataAllocatorPair() [1/3]

template<typename Data , typename Allocator >
xentara::utils::tools::DataAllocatorPair< Data, Allocator >::DataAllocatorPair ( )
default

Default constructor.

◆ DataAllocatorPair() [2/3]

template<typename Data , typename Allocator >
constexpr xentara::utils::tools::DataAllocatorPair< Data, Allocator >::DataAllocatorPair ( const Allocator &  allocator)
explicitconstexprnoexcept

Constructor that initializes the allocator.

◆ DataAllocatorPair() [3/3]

template<typename Data , typename Allocator >
constexpr xentara::utils::tools::DataAllocatorPair< Data, Allocator >::DataAllocatorPair ( Allocator &&  allocator)
explicitconstexprnoexcept

Constructor that initializes the allocator.

Member Function Documentation

◆ allocator() [1/2]

template<typename Data , typename Allocator >
constexpr auto xentara::utils::tools::DataAllocatorPair< Data, Allocator >::allocator ( ) const -> const Allocator &
constexprnoexcept

Gets the allocator.

◆ allocator() [2/2]

template<typename Data , typename Allocator >
constexpr auto xentara::utils::tools::DataAllocatorPair< Data, Allocator >::allocator ( ) -> Allocator &
constexprnoexcept

Gets the allocator.

◆ data() [1/2]

template<typename Data , typename Allocator >
constexpr auto xentara::utils::tools::DataAllocatorPair< Data, Allocator >::data ( ) const -> const Data &
constexprnoexcept

Gets the data.

◆ data() [2/2]

template<typename Data , typename Allocator >
constexpr auto xentara::utils::tools::DataAllocatorPair< Data, Allocator >::data ( ) -> Data &
constexprnoexcept

Gets the data.

◆ operator*() [1/2]

template<typename Data , typename Allocator >
constexpr auto xentara::utils::tools::DataAllocatorPair< Data, Allocator >::operator* ( ) const -> const Data &
constexprnoexcept

Access to the data.

◆ operator*() [2/2]

template<typename Data , typename Allocator >
constexpr auto xentara::utils::tools::DataAllocatorPair< Data, Allocator >::operator* ( ) -> Data &
constexprnoexcept

Access to the data.

◆ operator->() [1/2]

template<typename Data , typename Allocator >
constexpr auto xentara::utils::tools::DataAllocatorPair< Data, Allocator >::operator-> ( ) const -> const Data *
constexprnoexcept

Access to a member of the data.

◆ operator->() [2/2]

template<typename Data , typename Allocator >
constexpr auto xentara::utils::tools::DataAllocatorPair< Data, Allocator >::operator-> ( ) -> Data *
constexprnoexcept

Access to a member of the data.