Home | History | Annotate | Download | only in tuple.assign
      1 //===----------------------------------------------------------------------===//
      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 // <tuple>
     11 
     12 // template <class... Types> class tuple;
     13 
     14 // template <class U1, class U2>
     15 //   tuple& operator=(pair<U1, U2>&& u);
     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 = 0) : 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<double, std::unique_ptr<D>> T0;
     41         typedef std::tuple<int, std::unique_ptr<B>> T1;
     42         T0 t0(2.5, std::unique_ptr<D>(new D(3)));
     43         T1 t1;
     44         t1 = std::move(t0);
     45         assert(std::get<0>(t1) == 2);
     46         assert(std::get<1>(t1)->id_ == 3);
     47     }
     48 }
     49