Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / utilities / utility / pairs / pair.astuple / get_non_const.pass.cpp
blob6119cd5c8ce970b4aba21d39bca67a5611a52089
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <utility>
11 // template <class T1, class T2> struct pair
13 // template<size_t I, class T1, class T2>
14 // typename tuple_element<I, std::pair<T1, T2> >::type&
15 // get(pair<T1, T2>&);
17 #include <utility>
18 #include <cassert>
20 #include "test_macros.h"
22 #if TEST_STD_VER > 11
23 struct S {
24 std::pair<int, int> a;
25 int k;
26 constexpr S() : a{1,2}, k(std::get<0>(a)) {}
29 constexpr std::pair<int, int> getP () { return { 3, 4 }; }
30 #endif
32 int main(int, char**)
35 typedef std::pair<int, short> P;
36 P p(3, static_cast<short>(4));
37 assert(std::get<0>(p) == 3);
38 assert(std::get<1>(p) == 4);
39 std::get<0>(p) = 5;
40 std::get<1>(p) = 6;
41 assert(std::get<0>(p) == 5);
42 assert(std::get<1>(p) == 6);
45 #if TEST_STD_VER > 11
47 static_assert(S().k == 1, "");
48 static_assert(std::get<1>(getP()) == 4, "");
50 #endif
53 return 0;