const_pair.pass.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #include "test_macros.h"
  17. int main()
  18. {
  19. {
  20. typedef std::pair<long, char> T0;
  21. typedef std::tuple<long long, short> T1;
  22. T0 t0(2, 'a');
  23. T1 t1 = t0;
  24. assert(std::get<0>(t1) == 2);
  25. assert(std::get<1>(t1) == short('a'));
  26. }
  27. #if TEST_STD_VER > 11
  28. {
  29. typedef std::pair<long, char> P0;
  30. typedef std::tuple<long long, short> T1;
  31. constexpr P0 p0(2, 'a');
  32. constexpr T1 t1 = p0;
  33. static_assert(std::get<0>(t1) == std::get<0>(p0), "");
  34. static_assert(std::get<1>(t1) == std::get<1>(p0), "");
  35. static_assert(std::get<0>(t1) == 2, "");
  36. static_assert(std::get<1>(t1) == short('a'), "");
  37. }
  38. #endif
  39. }