File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
cpp/common/test/includes/standard-library Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change 11#include " type_traits.h"
22#ifndef _GHLIBCPP_UTILITY
33#define _GHLIBCPP_UTILITY
4+ #include " tuple.h"
45
56namespace std {
67template <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
1213template <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
You can’t perform that action at this time.
0 commit comments