const_pair.pass.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. // template <class U1, class U2> tuple(const pair<U1, U2>& u);
  12. // UNSUPPORTED: c++98, c++03
  13. #include <tuple>
  14. #include <utility>
  15. #include <cassert>
  16. int main()
  17. {
  18. {
  19. typedef std::pair<double, char> T0;
  20. typedef std::tuple<int, short> T1;
  21. T0 t0(2.5, 'a');
  22. T1 t1 = t0;
  23. assert(std::get<0>(t1) == 2);
  24. assert(std::get<1>(t1) == short('a'));
  25. }
  26. #if _LIBCPP_STD_VER > 11
  27. {
  28. typedef std::pair<double, char> P0;
  29. typedef std::tuple<int, short> T1;
  30. constexpr P0 p0(2.5, 'a');
  31. constexpr T1 t1 = p0;
  32. static_assert(std::get<0>(t1) != std::get<0>(p0), "");
  33. static_assert(std::get<1>(t1) == std::get<1>(p0), "");
  34. static_assert(std::get<0>(t1) == 2, "");
  35. static_assert(std::get<1>(t1) == short('a'), "");
  36. }
  37. #endif
  38. }