move_pair.pass.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. // <tuple>
  9. // template <class... Types> class tuple;
  10. // template <class U1, class U2> tuple(pair<U1, U2>&& u);
  11. // UNSUPPORTED: c++98, c++03
  12. #include <tuple>
  13. #include <utility>
  14. #include <memory>
  15. #include <cassert>
  16. #include "test_macros.h"
  17. struct B
  18. {
  19. int id_;
  20. explicit B(int i) : id_(i) {}
  21. virtual ~B() {}
  22. };
  23. struct D
  24. : B
  25. {
  26. explicit D(int i) : B(i) {}
  27. };
  28. int main(int, char**)
  29. {
  30. {
  31. typedef std::pair<long, std::unique_ptr<D>> T0;
  32. typedef std::tuple<long long, std::unique_ptr<B>> T1;
  33. T0 t0(2, std::unique_ptr<D>(new D(3)));
  34. T1 t1 = std::move(t0);
  35. assert(std::get<0>(t1) == 2);
  36. assert(std::get<1>(t1)->id_ == 3);
  37. }
  38. return 0;
  39. }