StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Safe::Pair< First, Second > Class Template Referencefinal

std::pair whose members keep their own Safe storage. More...

#include <StormByte/safe/pair.hxx>

Collaboration diagram for StormByte::Safe::Pair< First, Second >:

Public Types

using first_type = First
 First member type.
using second_type = Second
 Second member type.

Public Member Functions

 Pair ()
 Value-initialize both members.
 Pair (const First &firstValue, const Second &secondValue)
 Copy two values into the pair.
 Pair (First &&firstValue, Second &&secondValue) noexcept(std::is_nothrow_move_constructible_v< First > &&std::is_nothrow_move_constructible_v< Second >)
 Move two values into the pair.
template<class U, class V>
requires Type::ConstructibleFrom<First, U> && Type::ConstructibleFrom<Second, V>
 Pair (U &&firstValue, V &&secondValue)
 Construct both members from convertible values.
template<class... FirstArgs, class... SecondArgs>
 Pair (std::piecewise_construct_t tag, std::tuple< FirstArgs... > firstArgs, std::tuple< SecondArgs... > secondArgs)
 Construct both members from argument tuples.
template<class OtherFirst, class OtherSecond>
requires Type::ConstructibleFrom<First, const OtherFirst&> && Type::ConstructibleFrom<Second, const OtherSecond&>
 Pair (const std::pair< OtherFirst, OtherSecond > &other)
 Copy a caller-owned STL pair.
template<class OtherFirst, class OtherSecond>
requires Type::ConstructibleFrom<First, OtherFirst> && Type::ConstructibleFrom<Second, OtherSecond>
 Pair (std::pair< OtherFirst, OtherSecond > &&other)
 Move a caller-owned STL pair.
template<class OtherFirst, class OtherSecond>
requires Type::ConstructibleFrom<First, const OtherFirst&> && Type::ConstructibleFrom<Second, const OtherSecond&>
 Pair (const Pair< OtherFirst, OtherSecond > &other)
 Copy a compatible Safe pair.
template<class OtherFirst, class OtherSecond>
requires Type::ConstructibleFrom<First, OtherFirst> && Type::ConstructibleFrom<Second, OtherSecond>
 Pair (Pair< OtherFirst, OtherSecond > &&other)
 Move a compatible Safe pair.
 Pair (const Pair &other)=default
 Copy a pair.
 Pair (Pair &&other) noexcept(std::is_nothrow_move_constructible_v< First > &&std::is_nothrow_move_constructible_v< Second >)=default
 Move a pair.
 ~Pair ()=default
 Destroy both members through their own Safe operations.
Pair & operator= (const Pair &other)=default
 Copy-assign a pair.
Pair & operator= (Pair &&other) noexcept(std::is_nothrow_move_assignable_v< First > &&std::is_nothrow_move_assignable_v< Second >)=default
 Move-assign a pair.
template<class OtherFirst, class OtherSecond>
requires Type::AssignableFrom<First&, const OtherFirst&> && Type::AssignableFrom<Second&, const OtherSecond&>
Pair & operator= (const Pair< OtherFirst, OtherSecond > &other)
 Copy-assign a compatible Safe pair.
template<class OtherFirst, class OtherSecond>
requires Type::AssignableFrom<First&, OtherFirst> && Type::AssignableFrom<Second&, OtherSecond>
Pair & operator= (Pair< OtherFirst, OtherSecond > &&other)
 Move-assign a compatible Safe pair.
template<class OtherFirst, class OtherSecond>
requires Type::AssignableFrom<First&, const OtherFirst&> && Type::AssignableFrom<Second&, const OtherSecond&>
Pair & operator= (const std::pair< OtherFirst, OtherSecond > &other)
 Copy-assign a caller-owned STL pair.
template<class OtherFirst, class OtherSecond>
requires Type::AssignableFrom<First&, OtherFirst> && Type::AssignableFrom<Second&, OtherSecond>
Pair & operator= (std::pair< OtherFirst, OtherSecond > &&other)
 Move-assign a caller-owned STL pair.
void swap (Pair &other) noexcept(Type::Swappable< First > &&Type::Swappable< Second >)
 Exchange both members.
bool operator== (const Pair &other) const
 Compare both members.
STORMBYTE_FORCE_INLINE auto operator<=> (const Pair &other) const
 Order by the first member, then the second.
STORMBYTE_FORCE_INLINE operator std::pair< First, Second > () const
 Copy the members into caller-owned STL storage.

Public Attributes

First first
 First value.
Second second
 Second value.

Friends

void swap (Pair &left, Pair &right) noexcept(noexcept(left.swap(right)))
 Exchange two pairs.

Detailed Description

template<Type::SafeValue First, Type::SafeValue Second>
class StormByte::Safe::Pair< First, Second >

std::pair whose members keep their own Safe storage.

Template Parameters
FirstSafe value stored in first.
SecondSafe value stored in second.

The pair allocates nothing. Copy, move and destruction of each member run through that member's Safe operations, so the pair may be created or destroyed in a consumer module.

Member Typedef Documentation

◆ first_type

template<Type::SafeValue First, Type::SafeValue Second>
using StormByte::Safe::Pair< First, Second >::first_type = First

First member type.

◆ second_type

template<Type::SafeValue First, Type::SafeValue Second>
using StormByte::Safe::Pair< First, Second >::second_type = Second

Second member type.

Constructor & Destructor Documentation

◆ Pair() [1/11]

template<Type::SafeValue First, Type::SafeValue Second>
StormByte::Safe::Pair< First, Second >::Pair ( )
inline

Value-initialize both members.

◆ Pair() [2/11]

template<Type::SafeValue First, Type::SafeValue Second>
StormByte::Safe::Pair< First, Second >::Pair ( const First & firstValue,
const Second & secondValue )

Copy two values into the pair.

Parameters
firstValueInitial first value.
secondValueInitial second value.

◆ Pair() [3/11]

template<Type::SafeValue First, Type::SafeValue Second>
StormByte::Safe::Pair< First, Second >::Pair ( First && firstValue,
Second && secondValue ) const &&
noexcept

Move two values into the pair.

Parameters
firstValueInitial first value.
secondValueInitial second value.

◆ Pair() [4/11]

template<Type::SafeValue First, Type::SafeValue Second>
template<class U, class V>
requires Type::ConstructibleFrom<First, U> && Type::ConstructibleFrom<Second, V>
StormByte::Safe::Pair< First, Second >::Pair ( U && firstValue,
V && secondValue )

Construct both members from convertible values.

Template Parameters
UFirst source type.
VSecond source type.
Parameters
firstValueInitial first value.
secondValueInitial second value.

◆ Pair() [5/11]

template<Type::SafeValue First, Type::SafeValue Second>
template<class... FirstArgs, class... SecondArgs>
StormByte::Safe::Pair< First, Second >::Pair ( std::piecewise_construct_t tag,
std::tuple< FirstArgs... > firstArgs,
std::tuple< SecondArgs... > secondArgs )

Construct both members from argument tuples.

Template Parameters
FirstArgsFirst constructor argument types.
SecondArgsSecond constructor argument types.
Parameters
tagPiecewise construction tag.
firstArgsArguments for the first member.
secondArgsArguments for the second member.

◆ Pair() [6/11]

template<Type::SafeValue First, Type::SafeValue Second>
template<class OtherFirst, class OtherSecond>
requires Type::ConstructibleFrom<First, const OtherFirst&> && Type::ConstructibleFrom<Second, const OtherSecond&>
StormByte::Safe::Pair< First, Second >::Pair ( const std::pair< OtherFirst, OtherSecond > & other)

Copy a caller-owned STL pair.

Its state is unchanged.

Template Parameters
OtherFirstSource first type.
OtherSecondSource second type.
Parameters
otherSource pair.

◆ Pair() [7/11]

template<Type::SafeValue First, Type::SafeValue Second>
template<class OtherFirst, class OtherSecond>
requires Type::ConstructibleFrom<First, OtherFirst> && Type::ConstructibleFrom<Second, OtherSecond>
StormByte::Safe::Pair< First, Second >::Pair ( std::pair< OtherFirst, OtherSecond > && other)

Move a caller-owned STL pair.

The source members are moved-from.

Template Parameters
OtherFirstSource first type.
OtherSecondSource second type.
Parameters
otherSource pair.

◆ Pair() [8/11]

template<Type::SafeValue First, Type::SafeValue Second>
template<class OtherFirst, class OtherSecond>
requires Type::ConstructibleFrom<First, const OtherFirst&> && Type::ConstructibleFrom<Second, const OtherSecond&>
StormByte::Safe::Pair< First, Second >::Pair ( const Pair< OtherFirst, OtherSecond > & other)

Copy a compatible Safe pair.

Template Parameters
OtherFirstSource first type.
OtherSecondSource second type.
Parameters
otherSource pair.

◆ Pair() [9/11]

template<Type::SafeValue First, Type::SafeValue Second>
template<class OtherFirst, class OtherSecond>
requires Type::ConstructibleFrom<First, OtherFirst> && Type::ConstructibleFrom<Second, OtherSecond>
StormByte::Safe::Pair< First, Second >::Pair ( Pair< OtherFirst, OtherSecond > && other)

Move a compatible Safe pair.

Template Parameters
OtherFirstSource first type.
OtherSecondSource second type.
Parameters
otherSource pair.

◆ Pair() [10/11]

template<Type::SafeValue First, Type::SafeValue Second>
StormByte::Safe::Pair< First, Second >::Pair ( const Pair< First, Second > & other)
default

Copy a pair.

Parameters
otherSource pair.

◆ Pair() [11/11]

template<Type::SafeValue First, Type::SafeValue Second>
StormByte::Safe::Pair< First, Second >::Pair ( Pair< First, Second > && other) const &&
defaultnoexcept

Move a pair.

Parameters
otherSource pair.

◆ ~Pair()

template<Type::SafeValue First, Type::SafeValue Second>
StormByte::Safe::Pair< First, Second >::~Pair ( )
default

Destroy both members through their own Safe operations.

Member Function Documentation

◆ operator std::pair< First, Second >()

template<Type::SafeValue First, Type::SafeValue Second>
STORMBYTE_FORCE_INLINE StormByte::Safe::Pair< First, Second >::operator std::pair< First, Second > ( ) const
inlineexplicit

Copy the members into caller-owned STL storage.

Returns
A std::pair owned by the caller.

◆ operator<=>()

template<Type::SafeValue First, Type::SafeValue Second>
STORMBYTE_FORCE_INLINE auto StormByte::Safe::Pair< First, Second >::operator<=> ( const Pair< First, Second > & other) const

Order by the first member, then the second.

Parameters
otherPair to compare.
Returns
Lexicographical order.

◆ operator=() [1/6]

template<Type::SafeValue First, Type::SafeValue Second>
Pair & StormByte::Safe::Pair< First, Second >::operator= ( const Pair< First, Second > & other)
default

Copy-assign a pair.

Parameters
otherSource pair.
Returns
This pair.

◆ operator=() [2/6]

template<Type::SafeValue First, Type::SafeValue Second>
template<class OtherFirst, class OtherSecond>
requires Type::AssignableFrom<First&, const OtherFirst&> && Type::AssignableFrom<Second&, const OtherSecond&>
Pair & StormByte::Safe::Pair< First, Second >::operator= ( const Pair< OtherFirst, OtherSecond > & other)

Copy-assign a compatible Safe pair.

Template Parameters
OtherFirstSource first type.
OtherSecondSource second type.
Parameters
otherSource pair.
Returns
This pair.

◆ operator=() [3/6]

template<Type::SafeValue First, Type::SafeValue Second>
template<class OtherFirst, class OtherSecond>
requires Type::AssignableFrom<First&, const OtherFirst&> && Type::AssignableFrom<Second&, const OtherSecond&>
Pair & StormByte::Safe::Pair< First, Second >::operator= ( const std::pair< OtherFirst, OtherSecond > & other)

Copy-assign a caller-owned STL pair.

Its state is unchanged.

Template Parameters
OtherFirstSource first type.
OtherSecondSource second type.
Parameters
otherSource pair.
Returns
This pair.

◆ operator=() [4/6]

template<Type::SafeValue First, Type::SafeValue Second>
Pair & StormByte::Safe::Pair< First, Second >::operator= ( Pair< First, Second > && other) &&
defaultnoexcept

Move-assign a pair.

Parameters
otherSource pair.
Returns
This pair.

◆ operator=() [5/6]

template<Type::SafeValue First, Type::SafeValue Second>
template<class OtherFirst, class OtherSecond>
requires Type::AssignableFrom<First&, OtherFirst> && Type::AssignableFrom<Second&, OtherSecond>
Pair & StormByte::Safe::Pair< First, Second >::operator= ( Pair< OtherFirst, OtherSecond > && other)

Move-assign a compatible Safe pair.

Template Parameters
OtherFirstSource first type.
OtherSecondSource second type.
Parameters
otherSource pair.
Returns
This pair.

◆ operator=() [6/6]

template<Type::SafeValue First, Type::SafeValue Second>
template<class OtherFirst, class OtherSecond>
requires Type::AssignableFrom<First&, OtherFirst> && Type::AssignableFrom<Second&, OtherSecond>
Pair & StormByte::Safe::Pair< First, Second >::operator= ( std::pair< OtherFirst, OtherSecond > && other)

Move-assign a caller-owned STL pair.

Template Parameters
OtherFirstSource first type.
OtherSecondSource second type.
Parameters
otherSource pair.
Returns
This pair.

◆ operator==()

template<Type::SafeValue First, Type::SafeValue Second>
bool StormByte::Safe::Pair< First, Second >::operator== ( const Pair< First, Second > & other) const

Compare both members.

Parameters
otherPair to compare.
Returns
Whether both members compare equal.

◆ swap()

template<Type::SafeValue First, Type::SafeValue Second>
void StormByte::Safe::Pair< First, Second >::swap ( Pair< First, Second > & other) &&
noexcept

Exchange both members.

Parameters
otherPair to exchange with.

◆ swap

template<Type::SafeValue First, Type::SafeValue Second>
void swap ( Pair< First, Second > & left,
Pair< First, Second > & right )
friend

Exchange two pairs.

Parameters
leftFirst pair.
rightSecond pair.

Member Data Documentation

◆ first

template<Type::SafeValue First, Type::SafeValue Second>
First StormByte::Safe::Pair< First, Second >::first

First value.

◆ second

template<Type::SafeValue First, Type::SafeValue Second>
Second StormByte::Safe::Pair< First, Second >::second

Second value.


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