Drake
SortedPair< T > Struct Template Reference

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

#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...
 

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.

Constructor & Destructor Documentation

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

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

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

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

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

Constructs a SortedPair from two objects.

SortedPair ( SortedPair< U > &&  u)
inline

Type-converting copy constructor.

Member Function Documentation

const T& first ( ) const
inline

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

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

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

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

Resets the stored objects.

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

Swaps this and t.

Here is the caller graph for this function:

Friends And Related Function Documentation

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: