tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
pair< T1, T2 > Struct Template Reference

etl::pair is a class template that provides a way to store two heterogeneous objects as a single unit. A pair is a specific case of a etl::tuple with two elements. If neither T1 nor T2 is a possibly cv-qualified class type with non-trivial destructor, or array thereof, the destructor of pair is trivial. More...

#include <pair.hpp>

Public Types

using first_type = T1
 
using second_type = T2
 

Public Member Functions

constexpr pair (pair &&p) noexcept=default
 Move constructor is defaulted, and is constexpr if moving of both elements satisfies the requirements on constexpr functions.
 
constexpr pair (pair const &p)=default
 Copy constructor is defaulted, and is constexpr if copying of both elements satisfies the requirements on constexpr functions.
 
 ~pair () noexcept=default
 Defaulted destructor.
 
 explicit (not is_convertible_v< T1 const &, T1 > or not is_convertible_v< T2 const &, T2 >) const expr pair(T1 const &t1
 Initializes first with x and second with y.
 
template<typename U1, typename U2>
requires (is_constructible_v<T1, U1 &&> and is_constructible_v<T2, U2 &&>)
 explicit (not is_convertible_v< U1 &&, T1 >||not is_convertible_v< U2 &&, T2 >) const expr pair(pair< U1
 Initializes first with forward<U1>(p.first) and second with forward<U2>(p.second).
 
template<typename U1 = T1, typename U2 = T2>
requires (is_constructible_v<T1, U1 &&> and is_constructible_v<T2, U2 &&>)
 explicit (not is_convertible_v< U1 &&, T1 >||not is_convertible_v< U2 &&, T2 >) const expr pair(U1 &&x
 Initializes first with forward<U1>(x) and second with forward<U2>(y).
 
template<typename U1, typename U2>
requires (is_constructible_v<T1, U1 const&> and is_constructible_v<T2, U2 const&>)
 explicit (not is_convertible_v< U1 const &, T1 > or not is_convertible_v< U2 const &, T2 >) const expr pair(pair< U1
 Initializes first with p.first and second with p.second.
 
 explicit (not is_implicit_default_constructible_v< T1 >||not is_implicit_default_constructible_v< T2 >) const expr pair()
 Default constructor. Value-initializes both elements.
 
constexpr auto operator= (pair &&p) noexcept -> pair &requires((is_move_assignable_v< first_type > and is_move_assignable_v< second_type >))
 
constexpr auto operator= (pair const &p) -> pair &=default
 
template<typename U1, typename U2>
requires (is_assignable_v<first_type&, U1> and is_assignable_v<second_type&, U2>)
constexpr auto operator= (pair< U1, U2 > &&p) -> pair &
 
template<typename U1, typename U2>
constexpr auto operator= (pair< U1, U2 > const &p) -> pair &requires((is_assignable_v< first_type &, U1 const & > and is_assignable_v< second_type &, U2 const & >))
 
U2 second (etl::forward< U2 >(p.second))
 
U2 second (etl::forward< U2 >(y))
 
U2 const second (p.second)
 
T2 const second (t2)
 
constexpr auto swap (pair &other) noexcept(is_nothrow_swappable_v< first_type > and is_nothrow_swappable_v< second_type >) -> void
 

Public Attributes

TETL_NO_UNIQUE_ADDRESS T1 first
 
U2 const & p: first(p.first)
 
U2 && p: first(etl::forward<U1>(p.first))
 
TETL_NO_UNIQUE_ADDRESS T2 second
 
T2 const & t2: first(t1)
 
U2 && y: first(etl::forward<U1>(x))
 

Detailed Description

template<typename T1, typename T2>
struct etl::pair< T1, T2 >

etl::pair is a class template that provides a way to store two heterogeneous objects as a single unit. A pair is a specific case of a etl::tuple with two elements. If neither T1 nor T2 is a possibly cv-qualified class type with non-trivial destructor, or array thereof, the destructor of pair is trivial.

https://en.cppreference.com/w/cpp/utility/pair

Examples
utility.cpp.

Member Typedef Documentation

◆ first_type

template<typename T1, typename T2>
using first_type = T1

◆ second_type

template<typename T1, typename T2>
using second_type = T2

Constructor & Destructor Documentation

◆ pair() [1/2]

template<typename T1, typename T2>
pair ( pair< T1, T2 > const & p)
constexprdefault

Copy constructor is defaulted, and is constexpr if copying of both elements satisfies the requirements on constexpr functions.

◆ pair() [2/2]

template<typename T1, typename T2>
pair ( pair< T1, T2 > && p)
constexprdefaultnoexcept

Move constructor is defaulted, and is constexpr if moving of both elements satisfies the requirements on constexpr functions.

◆ ~pair()

template<typename T1, typename T2>
~pair ( )
defaultnoexcept

Defaulted destructor.

Member Function Documentation

◆ explicit() [1/5]

template<typename T1, typename T2>
explicit ( not is_convertible_v< T1 const &, T1 > or not is_convertible_v< T2 const &, T2 > ) const &

Initializes first with x and second with y.

◆ explicit() [2/5]

template<typename T1, typename T2>
template<typename U1, typename U2>
requires (is_constructible_v<T1, U1 &&> and is_constructible_v<T2, U2 &&>)
explicit ( not is_convertible_v< U1 &&, T1 >||not is_convertible_v< U2 &&, T2 > ) const

Initializes first with forward<U1>(p.first) and second with forward<U2>(p.second).

◆ explicit() [3/5]

template<typename T1, typename T2>
template<typename U1 = T1, typename U2 = T2>
requires (is_constructible_v<T1, U1 &&> and is_constructible_v<T2, U2 &&>)
explicit ( not is_convertible_v< U1 &&, T1 >||not is_convertible_v< U2 &&, T2 > ) const &&

Initializes first with forward<U1>(x) and second with forward<U2>(y).

◆ explicit() [4/5]

template<typename T1, typename T2>
template<typename U1, typename U2>
requires (is_constructible_v<T1, U1 const&> and is_constructible_v<T2, U2 const&>)
explicit ( not is_convertible_v< U1 const &, T1 > or not is_convertible_v< U2 const &, T2 > ) const

Initializes first with p.first and second with p.second.

◆ explicit() [5/5]

template<typename T1, typename T2>
explicit ( not is_implicit_default_constructible_v< T1 >||not is_implicit_default_constructible_v< T2 > ) const
inline

Default constructor. Value-initializes both elements.

◆ operator=() [1/4]

template<typename T1, typename T2>
auto operator= ( pair< T1, T2 > && p) -> pair& requires((is_move_assignable_v<first_type> and is_move_assignable_v<second_type>))
inlineconstexprnoexcept

◆ operator=() [2/4]

template<typename T1, typename T2>
auto operator= ( pair< T1, T2 > const & p) -> pair &=default
constexprdefault

◆ operator=() [3/4]

template<typename T1, typename T2>
template<typename U1, typename U2>
requires (is_assignable_v<first_type&, U1> and is_assignable_v<second_type&, U2>)
auto operator= ( pair< U1, U2 > && p) -> pair&
inlineconstexpr

◆ operator=() [4/4]

template<typename T1, typename T2>
template<typename U1, typename U2>
auto operator= ( pair< U1, U2 > const & p) -> pair& requires((is_assignable_v<first_type&, U1 const&> and is_assignable_v<second_type&, U2 const&>))
inlineconstexpr

◆ second() [1/4]

template<typename T1, typename T2>
U2 second ( etl::forward< U2 > p.second)
inline

◆ second() [2/4]

template<typename T1, typename T2>
U2 second ( etl::forward< U2 > y)
inline

◆ second() [3/4]

template<typename T1, typename T2>
U2 const second ( p. second)
inline

◆ second() [4/4]

template<typename T1, typename T2>
T2 const second ( t2 )
inline

◆ swap()

template<typename T1, typename T2>
auto swap ( pair< T1, T2 > & other) -> void
inlineconstexprnoexcept

Member Data Documentation

◆ first

template<typename T1, typename T2>
TETL_NO_UNIQUE_ADDRESS T1 first

◆ p [1/2]

template<typename T1, typename T2>
U2 const& p

◆ p [2/2]

template<typename T1, typename T2>
U2&& p

◆ second

template<typename T1, typename T2>
TETL_NO_UNIQUE_ADDRESS T2 second

◆ t2

template<typename T1, typename T2>
T2 const& t2

◆ y

template<typename T1, typename T2>
U2&& y

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