xref: /llvm-project/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp (revision 57b08b0944046a6a57ee9b7b479181f548a5b9b4)
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 //===----------------------------------------------------------------------===//
8 
9 // <tuple>
10 
11 // template <class... Types> class tuple;
12 
13 // template <class U1, class U2> tuple(pair<U1, U2>&& u);
14 
15 // UNSUPPORTED: c++98, c++03
16 
17 #include <tuple>
18 #include <utility>
19 #include <memory>
20 #include <cassert>
21 
22 struct B
23 {
24     int id_;
25 
26     explicit B(int i) : id_(i) {}
27 
28     virtual ~B() {}
29 };
30 
31 struct D
32     : B
33 {
34     explicit D(int i) : B(i) {}
35 };
36 
37 int main()
38 {
39     {
40         typedef std::pair<long, std::unique_ptr<D>> T0;
41         typedef std::tuple<long long, std::unique_ptr<B>> T1;
42         T0 t0(2, std::unique_ptr<D>(new D(3)));
43         T1 t1 = std::move(t0);
44         assert(std::get<0>(t1) == 2);
45         assert(std::get<1>(t1)->id_ == 3);
46     }
47 }
48