31template <
typename A,
typename B>
48 Pair(
const A &a,
const B &b) : d(a, b) {}
61 Pair(
const std::pair<A, B> &p) : d(p) {}
88 const A &
first()
const {
return d.first; }
94 const B &
second()
const {
return d.second; }
130 return Pair(std::move(a), std::move(b));
153 template <std::
size_t I>
155 if constexpr (
I == 0)
return d.first;
156 else return d.second;
160 template <std::
size_t I>
162 if constexpr (
I == 0)
return d.first;
163 else return d.second;
167 template <std::
size_t I>
169 if constexpr (
I == 0)
return std::move(d.first);
170 else return std::move(d.second);
181template <
typename A,
typename B>
184template <
typename A,
typename B>
187template <
typename A,
typename B>
Dynamic array container wrapping std::vector.
Definition list.h:40
Typed pair container wrapping std::pair.
Definition pair.h:32
Pair(std::pair< A, B > &&p)
Constructs from an existing std::pair (move overload).
Definition pair.h:67
const std::pair< A, B > & toStdPair() const
Returns a const reference to the underlying std::pair.
Definition pair.h:112
void setFirst(const A &a)
Sets the first element.
Definition pair.h:100
Pair(Pair &&other) noexcept=default
Move constructor.
Pair & operator=(Pair &&other) noexcept=default
Move assignment operator.
B & second()
Returns a mutable reference to the second element.
Definition pair.h:91
A & first()
Returns a mutable reference to the first element.
Definition pair.h:85
Pair(const Pair &other)=default
Copy constructor.
auto && get() &&
Structured bindings support: element access by index.
Definition pair.h:168
Pair(const std::pair< A, B > &p)
Constructs from an existing std::pair.
Definition pair.h:61
friend bool operator==(const Pair &lhs, const Pair &rhs)
Returns true if both pairs have identical contents.
Definition pair.h:134
friend bool operator<(const Pair &lhs, const Pair &rhs)
Lexicographic less-than comparison.
Definition pair.h:144
Pair & operator=(const Pair &other)=default
Copy assignment operator.
void setSecond(const B &b)
Sets the second element.
Definition pair.h:106
const auto & get() const &
Structured bindings support: element access by index.
Definition pair.h:161
static Pair make(A a, B b)
Factory function to create a Pair.
Definition pair.h:129
~Pair()=default
Destructor.
Pair()=default
Default constructor. Value-initializes both elements.
Pair(const A &a, const B &b)
Constructs a pair from two values.
Definition pair.h:48
const A & first() const
Returns a const reference to the first element.
Definition pair.h:88
auto & get() &
Structured bindings support: element access by index.
Definition pair.h:154
Pair(A &&a, B &&b)
Constructs a pair by moving two values.
Definition pair.h:55
void swap(Pair &other) noexcept
Swaps contents with another pair.
Definition pair.h:118
friend bool operator!=(const Pair &lhs, const Pair &rhs)
Returns true if the pairs differ.
Definition pair.h:139
const B & second() const
Returns a const reference to the second element.
Definition pair.h:94
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19