ctor_alloc.pass.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. // <stack>
  10. // template <class Alloc>
  11. // explicit stack(const Alloc& a);
  12. #include <stack>
  13. #include <cassert>
  14. #include "test_allocator.h"
  15. struct test
  16. : private std::stack<int, std::deque<int, test_allocator<int> > >
  17. {
  18. typedef std::stack<int, std::deque<int, test_allocator<int> > > base;
  19. explicit test(const test_allocator<int>& a) : base(a) {}
  20. test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
  21. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  22. test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
  23. test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
  24. #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
  25. test_allocator<int> get_allocator() {return c.get_allocator();}
  26. };
  27. int main()
  28. {
  29. test q(test_allocator<int>(3));
  30. assert(q.get_allocator() == test_allocator<int>(3));
  31. }