blob: edd2f3d0752fc1086c8b1352a1e9ba5e818e3c72 [file] [log] [blame]
Eric Fiselier199bee02015-12-18 00:36:55 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <utility>
11
12// template <class T1, class T2> struct pair
13
14// template<size_t I, class T1, class T2>
15// const typename tuple_element<I, std::pair<T1, T2> >::type&&
16// get(const pair<T1, T2>&&);
17
18// UNSUPPORTED: c++98, c++03
19
20#include <utility>
21#include <memory>
22#include <type_traits>
23#include <cassert>
24
25#include "test_macros.h"
26
27int main()
28{
29 {
30 typedef std::pair<std::unique_ptr<int>, short> P;
31 const P p(std::unique_ptr<int>(new int(3)), 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 }
37
38 {
39 int x = 42;
40 int const y = 43;
41 std::pair<int&, int const&> const p(x, y);
42 static_assert(std::is_same<int&, decltype(std::get<0>(std::move(p)))>::value, "");
43 static_assert(noexcept(std::get<0>(std::move(p))), "");
44 static_assert(std::is_same<int const&, decltype(std::get<1>(std::move(p)))>::value, "");
45 static_assert(noexcept(std::get<1>(std::move(p))), "");
46 }
47
48 {
49 int x = 42;
50 int const y = 43;
51 std::pair<int&&, int const&&> const p(std::move(x), std::move(y));
52 static_assert(std::is_same<int&&, decltype(std::get<0>(std::move(p)))>::value, "");
53 static_assert(noexcept(std::get<0>(std::move(p))), "");
54 static_assert(std::is_same<int const&&, decltype(std::get<1>(std::move(p)))>::value, "");
55 static_assert(noexcept(std::get<1>(std::move(p))), "");
56 }
57
58#if TEST_STD_VER > 11
59 {
60 typedef std::pair<int, short> P;
61 constexpr const P p1(3, 4);
62 static_assert(std::get<0>(std::move(p1)) == 3, "");
63 static_assert(std::get<1>(std::move(p1)) == 4, "");
64 }
65#endif
66}