alloc_copy.pass.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 Alloc>
  12. // tuple(allocator_arg_t, const Alloc& a, const tuple&);
  13. // UNSUPPORTED: c++98, c++03
  14. #include <tuple>
  15. #include <cassert>
  16. #include "allocators.h"
  17. #include "../alloc_first.h"
  18. #include "../alloc_last.h"
  19. int main()
  20. {
  21. {
  22. typedef std::tuple<> T;
  23. T t0;
  24. T t(std::allocator_arg, A1<int>(), t0);
  25. }
  26. {
  27. typedef std::tuple<int> T;
  28. T t0(2);
  29. T t(std::allocator_arg, A1<int>(), t0);
  30. assert(std::get<0>(t) == 2);
  31. }
  32. {
  33. typedef std::tuple<alloc_first> T;
  34. T t0(2);
  35. alloc_first::allocator_constructed = false;
  36. T t(std::allocator_arg, A1<int>(5), t0);
  37. assert(alloc_first::allocator_constructed);
  38. assert(std::get<0>(t) == 2);
  39. }
  40. {
  41. typedef std::tuple<alloc_last> T;
  42. T t0(2);
  43. alloc_last::allocator_constructed = false;
  44. T t(std::allocator_arg, A1<int>(5), t0);
  45. assert(alloc_last::allocator_constructed);
  46. assert(std::get<0>(t) == 2);
  47. }
  48. // testing extensions
  49. #ifdef _LIBCPP_VERSION
  50. {
  51. typedef std::tuple<alloc_first, alloc_last> T;
  52. T t0(2, 3);
  53. alloc_first::allocator_constructed = false;
  54. alloc_last::allocator_constructed = false;
  55. T t(std::allocator_arg, A1<int>(5), t0);
  56. assert(alloc_first::allocator_constructed);
  57. assert(alloc_last::allocator_constructed);
  58. assert(std::get<0>(t) == 2);
  59. assert(std::get<1>(t) == 3);
  60. }
  61. {
  62. typedef std::tuple<int, alloc_first, alloc_last> T;
  63. T t0(1, 2, 3);
  64. alloc_first::allocator_constructed = false;
  65. alloc_last::allocator_constructed = false;
  66. T t(std::allocator_arg, A1<int>(5), t0);
  67. assert(alloc_first::allocator_constructed);
  68. assert(alloc_last::allocator_constructed);
  69. assert(std::get<0>(t) == 1);
  70. assert(std::get<1>(t) == 2);
  71. assert(std::get<2>(t) == 3);
  72. }
  73. #endif
  74. }