1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
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++
21 #include <type_traits>
24 #include "test_macros.h"
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
));
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
))), "");
52 #if TEST_STD_VER >= 11
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
))), "");
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, "");