AsmGrader 0.0.0
Loading...
Searching...
No Matches
pair.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <concepts>
4
5namespace asmgrader {
6
7// Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97930 for gcc versions < 12.2
8// *Partially* conformant to std::pair spec https://en.cppreference.com/w/cpp/utility/pair.html
9template <typename T1, typename T2>
10struct pair // NOLINT(readability-identifier-naming)
11{
12 constexpr pair() = default;
13
14 constexpr pair(const T1& x, const T2& y)
15 : first{x}
16 , second{y} {}
17
18 template <typename U1, typename U2>
19 requires std::constructible_from<T1, U1> && std::constructible_from<T2, U2>
20 constexpr pair(U1&& x, U2&& y)
21 : first{std::forward<U1>(x)}
22 , second{std::forward<U2>(y)} {}
23
24 constexpr pair(const pair&) = default;
25 constexpr pair(pair&&) = default;
26 constexpr pair& operator=(const pair&) = default;
27 constexpr pair& operator=(pair&&) = default;
28 constexpr ~pair() = default;
29
30 template <typename U1, typename U2>
31 requires std::constructible_from<T1, const U1&> && std::constructible_from<T2, const U2&>
32 constexpr explicit(false) pair(const pair<U1, U2>& other)
33 : first{other.first}
34 , second{other.second} {}
35
36 template <typename U1, typename U2>
37 requires std::constructible_from<T1, U1> && std::constructible_from<T2, U2>
38 constexpr explicit(false) pair(pair<U1, U2>&& other)
39 : first{std::forward<U1>(other.first)}
40 , second{std::forward<U2>(other.second)} {}
41
42 template <typename U1, typename U2>
43 requires std::constructible_from<T1, const U1> && std::constructible_from<T2, const U2>
44 constexpr explicit(false) pair(const pair<U1, U2>&& other)
45 : first{std::forward<const U1>(other.first)}
46 , second{std::forward<const U2>(other.second)} {}
47
48 T1 first{};
49 T2 second{};
50};
51
52template <typename T1, typename T2>
53pair(T1, T2) -> pair<T1, T2>;
54
55} // namespace asmgrader
Definition asm_buffer.hpp:20
pair(T1, T2) -> pair< T1, T2 >
Definition byte_array.hpp:94
Definition pair.hpp:11
constexpr U2 second
Definition pair.hpp:34
constexpr pair & operator=(pair &&)=default
constexpr pair()=default
constexpr pair(const T1 &x, const T2 &y)
Definition pair.hpp:14
constexpr pair(U1 &&x, U2 &&y)
Definition pair.hpp:20
constexpr U2 & other
Definition pair.hpp:34
constexpr ~pair()=default
constexpr pair & operator=(const pair &)=default
constexpr pair(pair &&)=default
constexpr pair(const pair &)=default