Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / utilities / utility / pairs / pair.astuple / get_const_rv.pass.cpp
blob88b646c09d26a0afd065bc6cee2012a6f4a4915c
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 // const typename tuple_element<I, std::pair<T1, T2> >::type&&
15 // get(const pair<T1, T2>&&);
17 // UNSUPPORTED: c++03 && !stdlib=libc++
19 #include <utility>
20 #include <memory>
21 #include <type_traits>
22 #include <cassert>
24 #include "test_macros.h"
26 int main(int, char**)
29 #if TEST_STD_VER >= 11
30 typedef std::pair<std::unique_ptr<int>, short> P;
31 const P p(std::unique_ptr<int>(new int(3)), static_cast<short>(4));
32 static_assert(std::is_same<const std::unique_ptr<int>&&, decltype(std::get<0>(std::move(p)))>::value, "");
33 static_assert(noexcept(std::get<0>(std::move(p))), "");
34 const std::unique_ptr<int>&& ptr = std::get<0>(std::move(p));
35 assert(*ptr == 3);
36 #endif
40 int x = 42;
41 int const y = 43;
42 std::pair<int&, int const&> const p(x, y);
43 static_assert(std::is_same<int&, decltype(std::get<0>(std::move(p)))>::value, "");
44 static_assert(std::is_same<int const&, decltype(std::get<1>(std::move(p)))>::value, "");
45 #if TEST_STD_VER >= 11
46 static_assert(noexcept(std::get<0>(std::move(p))), "");
47 static_assert(noexcept(std::get<1>(std::move(p))), "");
48 #endif
52 #if TEST_STD_VER >= 11
53 int x = 42;
54 int const y = 43;
55 std::pair<int&&, int const&&> const p(std::move(x), std::move(y));
56 static_assert(std::is_same<int&&, decltype(std::get<0>(std::move(p)))>::value, "");
57 static_assert(noexcept(std::get<0>(std::move(p))), "");
58 static_assert(std::is_same<int const&&, decltype(std::get<1>(std::move(p)))>::value, "");
59 static_assert(noexcept(std::get<1>(std::move(p))), "");
60 #endif
63 #if TEST_STD_VER > 11
65 typedef std::pair<int, short> P;
66 constexpr const P p1(3, static_cast<short>(4));
67 static_assert(std::get<0>(std::move(p1)) == 3, "");
68 static_assert(std::get<1>(std::move(p1)) == 4, "");
70 #endif
72 return 0;