Typed pair container wrapping std::pair. More...
#include <pair.h>
Public Types | |
| using | FirstType = A |
| Type of the first element. | |
| using | SecondType = B |
| Type of the second element. | |
Public Member Functions | |
| Pair ()=default | |
| Default constructor. Value-initializes both elements. | |
| Pair (const A &a, const B &b) | |
| Constructs a pair from two values. | |
| Pair (A &&a, B &&b) | |
| Constructs a pair by moving two values. | |
| Pair (const std::pair< A, B > &p) | |
| Constructs from an existing std::pair. | |
| Pair (std::pair< A, B > &&p) | |
| Constructs from an existing std::pair (move overload). | |
| Pair (const Pair &other)=default | |
| Copy constructor. | |
| Pair (Pair &&other) noexcept=default | |
| Move constructor. | |
| ~Pair ()=default | |
| Destructor. | |
| Pair & | operator= (const Pair &other)=default |
| Copy assignment operator. | |
| Pair & | operator= (Pair &&other) noexcept=default |
| Move assignment operator. | |
| A & | first () |
| Returns a mutable reference to the first element. | |
| const A & | first () const |
| Returns a const reference to the first element. | |
| B & | second () |
| Returns a mutable reference to the second element. | |
| const B & | second () const |
| Returns a const reference to the second element. | |
| void | setFirst (const A &a) |
| Sets the first element. | |
| void | setSecond (const B &b) |
| Sets the second element. | |
| const std::pair< A, B > & | toStdPair () const |
| Returns a const reference to the underlying std::pair. | |
| void | swap (Pair &other) noexcept |
| Swaps contents with another pair. | |
| template<std::size_t I> | |
| auto & | get () & |
| Structured bindings support: element access by index. | |
| template<std::size_t I> | |
| const auto & | get () const & |
| Structured bindings support: element access by index. | |
| template<std::size_t I> | |
| auto && | get () && |
| Structured bindings support: element access by index. | |
Static Public Member Functions | |
| static Pair | make (A a, B b) |
| Factory function to create a Pair. | |
Friends | |
| bool | operator== (const Pair &lhs, const Pair &rhs) |
| Returns true if both pairs have identical contents. | |
| bool | operator!= (const Pair &lhs, const Pair &rhs) |
| Returns true if the pairs differ. | |
| bool | operator< (const Pair &lhs, const Pair &rhs) |
| Lexicographic less-than comparison. | |
Typed pair container wrapping std::pair.
Provides a Qt-inspired API over std::pair with consistent naming conventions matching the rest of libpromeki. Simple value type — no PROMEKI_SHARED_FINAL.
Supports structured bindings via std::tuple_size/std::tuple_element specializations.
| A | First element type. |
| B | Second element type. |
Constructs a pair from two values.
| a | First element. |
| b | Second element. |
Constructs a pair by moving two values.
| a | First element (moved). |
| b | Second element (moved). |
Constructs from an existing std::pair.
| p | The std::pair to copy from. |
Constructs from an existing std::pair (move overload).
| p | The std::pair to move from. |
Structured bindings support: element access by index.
| I | Element index (0 for first, 1 for second). |
Structured bindings support: element access by index.
| I | Element index (0 for first, 1 for second). |
Structured bindings support: element access by index.
| I | Element index (0 for first, 1 for second). |
Sets the first element.
| a | The new value for the first element. |
Sets the second element.
| b | The new value for the second element. |
Swaps contents with another pair.
| other | The pair to swap with. |
Returns a const reference to the underlying std::pair.