Skip to content

Commit 94218db

Browse files
stdlib fixes after merge
1 parent 5348743 commit 94218db

File tree

1 file changed

+17
-4
lines changed
  • cpp/common/test/includes/standard-library

1 file changed

+17
-4
lines changed

cpp/common/test/includes/standard-library/utility.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "type_traits.h"
22
#ifndef _GHLIBCPP_UTILITY
33
#define _GHLIBCPP_UTILITY
4+
#include "tuple.h"
45

56
namespace std {
67
template <class T> constexpr T &&forward(remove_reference_t<T> &t) noexcept;
@@ -11,11 +12,23 @@ template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
1112

1213
template <class T> void swap(T &a, T &b) noexcept;
1314

14-
template <class T1, class T2> struct pair {
15-
T1 first;
16-
T2 second;
17-
pair(const T1 &a, const T2 &b);
15+
template <class T, class U> struct pair : tuple<T, U> {
16+
T first;
17+
U second;
18+
pair(T t, U u);
1819
};
20+
template <class T, class U> std::pair<T, U> make_pair(T &&x, U &&y);
21+
22+
template<size_t N, class T, class U>
23+
constexpr auto get(const std::pair<T, U> &p) noexcept {
24+
if constexpr (N == 0) {
25+
return p.first;
26+
} else if constexpr (N == 1) {
27+
return p.second;
28+
} else {
29+
static_assert(N < 2, "Index out of bounds for pair");
30+
}
31+
}
1932

2033
} // namespace std
2134

0 commit comments

Comments
 (0)