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.
The availability of construction and assignment operations (i.e., default constructor, copy constructor, copy assignment, move constructor, move assignment) is the same as whatever T provides . All comparison operations (including equality, etc.) are always available.
To format this class for logging, include <fmt/ranges.h> (exactly the same as for std::pair).
- Template Parameters
-
| T | A template type that provides operator<. |
|
| | SortedPair () |
| | The default constructor creates first() and second() using T's default constructor, iff T has a default constructor.
|
| | SortedPair (T &&a, T &&b) |
| | Rvalue reference constructor, permits constructing with std::unique_ptr types, for example.
|
| | SortedPair (const T &a, const T &b) |
| | Constructs a SortedPair from two objects.
|
| template<class U> |
| | SortedPair (SortedPair< U > &&u) |
| | Type-converting copy constructor.
|
| template<class U> |
| void | set (U &&a, U &&b) |
| | Resets the stored objects.
|
| const T & | first () const |
| | Gets the first (according to operator<) of the objects.
|
| const T & | second () const |
| | Gets the second (according to operator<) of the objects.
|
| void | Swap (drake::SortedPair< T > &t) |
| | Swaps this and t.
|