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

A pair that uses Empty Base Class Optimization to elide storage for one or both of its members where possible.

Template parameters
First First member type.
Second Second member type.

Public types

using first_type = First
The pair's first member type.
using second_type = Second
The pair's second member type.

Constructors, destructors, conversion operators

compressed_pair() defaulted
Default constructor.
compressed_pair(const compressed_pair&) defaulted
Copy constructor.
compressed_pair(compressed_pair&&) defaulted
Move constructor.
template <typename F, typename S>
compressed_pair(F&& first_init, S&& second_init) constexpr noexcept(…)
Constructs a compressed pair from two values.

Public functions

auto first() & -> first_type& constexpr noexcept
Returns an lvalue reference to the first member.
auto first() && -> first_type&& constexpr noexcept
Returns an rvalue reference to the first member.
auto first() const & -> constfirst_type& constexpr noexcept
Returns a const lvalue reference to the first member.
auto first() const && -> constfirst_type&& constexpr noexcept
Returns a const rvalue reference to the first member.
template <size_t I>
auto get() & -> auto& constexpr noexcept
Returns an lvalue reference to the selected member.
template <size_t I>
auto get() && -> auto&& constexpr noexcept
Returns an rvalue reference to the selected member.
template <size_t I>
auto get() const & -> const auto& constexpr noexcept
Returns a const lvalue reference to the selected member.
template <size_t I>
auto get() const && -> const auto&& constexpr noexcept
Returns a const rvalue reference to the selected member.
auto operator=(const compressed_pair&) -> compressed_pair& defaulted
Copy-assignment operator.
auto operator=(compressed_pair&&) -> compressed_pair& defaulted
Move-assignment operator.
auto second() & -> second_type& constexpr noexcept
Returns an lvalue reference to the second member.
auto second() && -> second_type&& constexpr noexcept
Returns an rvalue reference to the second member.
auto second() const & -> constsecond_type& constexpr noexcept
Returns a const lvalue reference to the second member.
auto second() const && -> constsecond_type&& constexpr noexcept
Returns a const rvalue reference to the second member.
void swap(compressed_pair& other) noexcept(…)
Swaps two pairs.

Function documentation

template <typename First, typename Second>
template <typename F, typename S>
muu::compressed_pair::compressed_pair(F&& first_init, S&& second_init) constexpr noexcept(…)

Constructs a compressed pair from two values.

Template parameters
F First member initializer type.
S Second member initializer type.
Parameters
first_init First member initializer.
second_init Second member initializer.

template <typename First, typename Second>
void muu::compressed_pair::swap(compressed_pair& other) noexcept(…)

Swaps two pairs.