copy.pass.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. // <tuple>
  10. // template <class... Types> class tuple;
  11. // tuple& operator=(const tuple& u);
  12. // UNSUPPORTED: c++98, c++03
  13. #include <tuple>
  14. #include <string>
  15. #include <cassert>
  16. int main()
  17. {
  18. {
  19. typedef std::tuple<> T;
  20. T t0;
  21. T t;
  22. t = t0;
  23. }
  24. {
  25. typedef std::tuple<int> T;
  26. T t0(2);
  27. T t;
  28. t = t0;
  29. assert(std::get<0>(t) == 2);
  30. }
  31. {
  32. typedef std::tuple<int, char> T;
  33. T t0(2, 'a');
  34. T t;
  35. t = t0;
  36. assert(std::get<0>(t) == 2);
  37. assert(std::get<1>(t) == 'a');
  38. }
  39. {
  40. typedef std::tuple<int, char, std::string> T;
  41. const T t0(2, 'a', "some text");
  42. T t;
  43. t = t0;
  44. assert(std::get<0>(t) == 2);
  45. assert(std::get<1>(t) == 'a');
  46. assert(std::get<2>(t) == "some text");
  47. }
  48. }