alloc_const_pair.pass.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 Alloc, class U1, class U2>
  11. // tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
  12. // UNSUPPORTED: c++98, c++03
  13. #include <tuple>
  14. #include <utility>
  15. #include <cassert>
  16. #include "test_macros.h"
  17. #include "allocators.h"
  18. #include "../alloc_first.h"
  19. #include "../alloc_last.h"
  20. int main(int, char**)
  21. {
  22. {
  23. typedef std::pair<long, int> T0;
  24. typedef std::tuple<long long, double> T1;
  25. T0 t0(2, 3);
  26. T1 t1(std::allocator_arg, A1<int>(5), t0);
  27. assert(std::get<0>(t1) == 2);
  28. assert(std::get<1>(t1) == 3);
  29. }
  30. {
  31. typedef std::pair<int, int> T0;
  32. typedef std::tuple<alloc_first, double> T1;
  33. T0 t0(2, 3);
  34. alloc_first::allocator_constructed = false;
  35. T1 t1(std::allocator_arg, A1<int>(5), t0);
  36. assert(alloc_first::allocator_constructed);
  37. assert(std::get<0>(t1) == 2);
  38. assert(std::get<1>(t1) == 3);
  39. }
  40. {
  41. typedef std::pair<int, int> T0;
  42. typedef std::tuple<alloc_first, alloc_last> T1;
  43. T0 t0(2, 3);
  44. alloc_first::allocator_constructed = false;
  45. alloc_last::allocator_constructed = false;
  46. T1 t1(std::allocator_arg, A1<int>(5), t0);
  47. assert(alloc_first::allocator_constructed);
  48. assert(alloc_last::allocator_constructed);
  49. assert(std::get<0>(t1) == 2);
  50. assert(std::get<1>(t1) == 3);
  51. }
  52. return 0;
  53. }