alloc_const_pair.pass.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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, class U1, class U2>
  12. // tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
  13. // UNSUPPORTED: c++98, c++03
  14. #include <tuple>
  15. #include <utility>
  16. #include <cassert>
  17. #include "allocators.h"
  18. #include "../alloc_first.h"
  19. #include "../alloc_last.h"
  20. int main()
  21. {
  22. {
  23. typedef std::pair<double, int> T0;
  24. typedef std::tuple<int, 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. }