Drake
SortedPair< T > Struct Template Reference

Detailed Description

template<class T>
struct drake::SortedPair< T >

This class is similar to the std::pair class.

However, this class uses a pair of homogeneous types (std::pair can use heterogeneous types) and sorts the first and second values such that the first value is less than or equal to the second one). Note that the sort is a stable one. Thus the SortedPair class is able to be used to generate keys (e.g., for std::map, etc.) from pairs of objects.

Template Parameters
TA template type that provides operator< and supports default construction.

#include <drake/common/sorted_pair.h>

Public Member Functions

 SortedPair ()=default
 The default constructor creates first() and second() using their respective default constructors. More...
 
 SortedPair (T &&a, T &&b)
 Rvalue reference constructor, permits constructing with std::unique_ptr types, for example. More...
 
 SortedPair (const T &a, const T &b)
 Constructs a SortedPair from two objects. More...
 
template<class U >
 SortedPair (SortedPair< U > &&u)
 Type-converting copy constructor. More...
 
template<class U >
void set (U &&a, U &&b)
 Resets the stored objects. More...
 
const T & first () const
 Gets the first (according to operator<) of the objects. More...
 
const T & second () const
 Gets the second (according to operator<) of the objects. More...
 
void Swap (drake::SortedPair< T > &t)
 Swaps this and t. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 SortedPair (const SortedPair &)=default
 
SortedPairoperator= (const SortedPair &)=default
 
 SortedPair (SortedPair &&)=default
 
SortedPairoperator= (SortedPair &&)=default
 

Friends

template<class HashAlgorithm >
void hash_append (HashAlgorithm &hasher, const SortedPair &p) noexcept
 Implements the hash_append generic hashing concept. More...
 

Constructor & Destructor Documentation

◆ SortedPair() [1/6]

SortedPair ( const SortedPair< T > &  )
default

◆ SortedPair() [2/6]

SortedPair ( SortedPair< T > &&  )
default

◆ SortedPair() [3/6]

SortedPair ( )
default

The default constructor creates first() and second() using their respective default constructors.

◆ SortedPair() [4/6]

SortedPair ( T &&  a,
T &&  b 
)

Rvalue reference constructor, permits constructing with std::unique_ptr types, for example.

◆ SortedPair() [5/6]

SortedPair ( const T &  a,
const T &  b 
)

Constructs a SortedPair from two objects.

◆ SortedPair() [6/6]

SortedPair ( SortedPair< U > &&  u)

Type-converting copy constructor.

Member Function Documentation

◆ first()

const T& first ( ) const

Gets the first (according to operator<) of the objects.

◆ operator=() [1/2]

SortedPair& operator= ( const SortedPair< T > &  )
default

◆ operator=() [2/2]

SortedPair& operator= ( SortedPair< T > &&  )
default

◆ second()

const T& second ( ) const

Gets the second (according to operator<) of the objects.

◆ set()

void set ( U &&  a,
U &&  b 
)

Resets the stored objects.

◆ Swap()

void Swap ( drake::SortedPair< T > &  t)

Swaps this and t.

Friends And Related Function Documentation

◆ hash_append

void hash_append ( HashAlgorithm &  hasher,
const SortedPair< T > &  p 
)
friend

Implements the hash_append generic hashing concept.


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