EnTT 3.13.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
entt::compressed_pair< First, Second > Class Template Referencefinal

A compressed pair. More...

#include <compressed_pair.hpp>

Inheritance diagram for entt::compressed_pair< First, Second >:
Inheritance graph
[legend]
Collaboration diagram for entt::compressed_pair< First, Second >:
Collaboration graph
[legend]

Public Types

using first_type = First
 The type of the first element that the pair stores.
 
using second_type = Second
 The type of the second element that the pair stores.
 

Public Member Functions

template<bool Dummy = true, typename = std::enable_if_t<Dummy && std::is_default_constructible_v<first_type> && std::is_default_constructible_v<second_type>>>
constexpr compressed_pair () noexcept(std::is_nothrow_default_constructible_v< first_base > &&std::is_nothrow_default_constructible_v< second_base >)
 Default constructor, conditionally enabled.
 
constexpr compressed_pair (const compressed_pair &other) noexcept(std::is_nothrow_copy_constructible_v< first_base > &&std::is_nothrow_copy_constructible_v< second_base >)=default
 Copy constructor.
 
constexpr compressed_pair (compressed_pair &&other) noexcept(std::is_nothrow_move_constructible_v< first_base > &&std::is_nothrow_move_constructible_v< second_base >)=default
 Move constructor.
 
template<typename Arg , typename Other >
constexpr compressed_pair (Arg &&arg, Other &&other) noexcept(std::is_nothrow_constructible_v< first_base, Arg > &&std::is_nothrow_constructible_v< second_base, Other >)
 Constructs a pair from its values.
 
template<typename... Args, typename... Other>
constexpr compressed_pair (std::piecewise_construct_t, std::tuple< Args... > args, std::tuple< Other... > other) noexcept(std::is_nothrow_constructible_v< first_base, Args... > &&std::is_nothrow_constructible_v< second_base, Other... >)
 Constructs a pair by forwarding the arguments to its parts.
 
constexpr compressed_pairoperator= (const compressed_pair &other) noexcept(std::is_nothrow_copy_assignable_v< first_base > &&std::is_nothrow_copy_assignable_v< second_base >)=default
 Copy assignment operator.
 
constexpr compressed_pairoperator= (compressed_pair &&other) noexcept(std::is_nothrow_move_assignable_v< first_base > &&std::is_nothrow_move_assignable_v< second_base >)=default
 Move assignment operator.
 
constexpr first_typefirst () noexcept
 Returns the first element that a pair stores.
 
constexpr const first_typefirst () const noexcept
 Returns the first element that a pair stores.
 
constexpr second_typesecond () noexcept
 Returns the second element that a pair stores.
 
constexpr const second_typesecond () const noexcept
 Returns the second element that a pair stores.
 
constexpr void swap (compressed_pair &other) noexcept(std::is_nothrow_swappable_v< first_type > &&std::is_nothrow_swappable_v< second_type >)
 Swaps two compressed pair objects.
 
template<std::size_t Index>
constexpr decltype(auto) get () noexcept
 Extracts an element from the compressed pair.
 
template<std::size_t Index>
constexpr decltype(auto) get () const noexcept
 Extracts an element from the compressed pair.
 

Detailed Description

template<typename First, typename Second>
class entt::compressed_pair< First, Second >

A compressed pair.

A pair that exploits the Empty Base Class Optimization (or EBCO) to reduce its final size to a minimum.

Template Parameters
FirstThe type of the first element that the pair stores.
SecondThe type of the second element that the pair stores.

Definition at line 84 of file compressed_pair.hpp.

Member Typedef Documentation

◆ first_type

template<typename First , typename Second >
using entt::compressed_pair< First, Second >::first_type = First

The type of the first element that the pair stores.

Definition at line 92 of file compressed_pair.hpp.

◆ second_type

template<typename First , typename Second >
using entt::compressed_pair< First, Second >::second_type = Second

The type of the second element that the pair stores.

Definition at line 94 of file compressed_pair.hpp.

Constructor & Destructor Documentation

◆ compressed_pair() [1/5]

template<typename First , typename Second >
template<bool Dummy = true, typename = std::enable_if_t<Dummy && std::is_default_constructible_v<first_type> && std::is_default_constructible_v<second_type>>>
constexpr entt::compressed_pair< First, Second >::compressed_pair ( )
inlineconstexprnoexcept

Default constructor, conditionally enabled.

This constructor is only available when the types that the pair stores are both at least default constructible.

Template Parameters
DummyDummy template parameter used for internal purposes.

Definition at line 105 of file compressed_pair.hpp.

◆ compressed_pair() [2/5]

template<typename First , typename Second >
constexpr entt::compressed_pair< First, Second >::compressed_pair ( const compressed_pair< First, Second > &  other) const &&
constexprdefaultnoexcept

Copy constructor.

Parameters
otherThe instance to copy from.

◆ compressed_pair() [3/5]

template<typename First , typename Second >
constexpr entt::compressed_pair< First, Second >::compressed_pair ( compressed_pair< First, Second > &&  other) const &&
constexprdefaultnoexcept

Move constructor.

Parameters
otherThe instance to move from.

◆ compressed_pair() [4/5]

template<typename First , typename Second >
template<typename Arg , typename Other >
constexpr entt::compressed_pair< First, Second >::compressed_pair ( Arg &&  arg,
Other &&  other 
)
inlineconstexprnoexcept

Constructs a pair from its values.

Template Parameters
ArgType of value to use to initialize the first element.
OtherType of value to use to initialize the second element.
Parameters
argValue to use to initialize the first element.
otherValue to use to initialize the second element.

Definition at line 129 of file compressed_pair.hpp.

◆ compressed_pair() [5/5]

template<typename First , typename Second >
template<typename... Args, typename... Other>
constexpr entt::compressed_pair< First, Second >::compressed_pair ( std::piecewise_construct_t  ,
std::tuple< Args... >  args,
std::tuple< Other... >  other 
)
inlineconstexprnoexcept

Constructs a pair by forwarding the arguments to its parts.

Template Parameters
ArgsTypes of arguments to use to initialize the first element.
OtherTypes of arguments to use to initialize the second element.
Parameters
argsArguments to use to initialize the first element.
otherArguments to use to initialize the second element.

Definition at line 141 of file compressed_pair.hpp.

Member Function Documentation

◆ first() [1/2]

template<typename First , typename Second >
constexpr const first_type & entt::compressed_pair< First, Second >::first ( ) const
inlineconstexprnoexcept

Returns the first element that a pair stores.

Returns
The first element that a pair stores.

Definition at line 168 of file compressed_pair.hpp.

◆ first() [2/2]

template<typename First , typename Second >
constexpr first_type & entt::compressed_pair< First, Second >::first ( )
inlineconstexprnoexcept

Returns the first element that a pair stores.

Returns
The first element that a pair stores.

Definition at line 163 of file compressed_pair.hpp.

◆ get() [1/2]

template<typename First , typename Second >
template<std::size_t Index>
constexpr decltype(auto) entt::compressed_pair< First, Second >::get ( ) const
inlineconstexprnoexcept

Extracts an element from the compressed pair.

Template Parameters
IndexAn integer value that is either 0 or 1.
Returns
Returns a reference to the first element if Index is 0 and a reference to the second element if Index is 1.

Definition at line 213 of file compressed_pair.hpp.

◆ get() [2/2]

template<typename First , typename Second >
template<std::size_t Index>
constexpr decltype(auto) entt::compressed_pair< First, Second >::get ( )
inlineconstexprnoexcept

Extracts an element from the compressed pair.

Template Parameters
IndexAn integer value that is either 0 or 1.
Returns
Returns a reference to the first element if Index is 0 and a reference to the second element if Index is 1.

Definition at line 202 of file compressed_pair.hpp.

◆ operator=() [1/2]

template<typename First , typename Second >
constexpr compressed_pair & entt::compressed_pair< First, Second >::operator= ( compressed_pair< First, Second > &&  other) &&
constexprdefaultnoexcept

Move assignment operator.

Parameters
otherThe instance to move from.
Returns
This compressed pair object.

◆ operator=() [2/2]

template<typename First , typename Second >
constexpr compressed_pair & entt::compressed_pair< First, Second >::operator= ( const compressed_pair< First, Second > &  other) &&
constexprdefaultnoexcept

Copy assignment operator.

Parameters
otherThe instance to copy from.
Returns
This compressed pair object.

◆ second() [1/2]

template<typename First , typename Second >
constexpr const second_type & entt::compressed_pair< First, Second >::second ( ) const
inlineconstexprnoexcept

Returns the second element that a pair stores.

Returns
The second element that a pair stores.

Definition at line 181 of file compressed_pair.hpp.

◆ second() [2/2]

template<typename First , typename Second >
constexpr second_type & entt::compressed_pair< First, Second >::second ( )
inlineconstexprnoexcept

Returns the second element that a pair stores.

Returns
The second element that a pair stores.

Definition at line 176 of file compressed_pair.hpp.

◆ swap()

template<typename First , typename Second >
constexpr void entt::compressed_pair< First, Second >::swap ( compressed_pair< First, Second > &  other)
inlineconstexprnoexcept

Swaps two compressed pair objects.

Parameters
otherThe compressed pair to swap with.

Definition at line 189 of file compressed_pair.hpp.


The documentation for this class was generated from the following file: