default.pass.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. // UNSUPPORTED: c++98, c++03
  9. // <memory>
  10. // template <class OuterAlloc, class... InnerAllocs>
  11. // class scoped_allocator_adaptor
  12. // scoped_allocator_adaptor();
  13. #include <scoped_allocator>
  14. #include <cassert>
  15. #include "test_macros.h"
  16. #include "allocators.h"
  17. int main(int, char**)
  18. {
  19. {
  20. typedef std::scoped_allocator_adaptor<A1<int>> A;
  21. A a;
  22. assert(a.outer_allocator() == A1<int>());
  23. assert(a.inner_allocator() == a);
  24. assert(A1<int>::copy_called == false);
  25. assert(A1<int>::move_called == false);
  26. }
  27. {
  28. typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
  29. A a;
  30. assert(a.outer_allocator() == A1<int>());
  31. assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>());
  32. assert(A1<int>::copy_called == false);
  33. assert(A1<int>::move_called == false);
  34. assert(A2<int>::copy_called == false);
  35. assert(A2<int>::move_called == false);
  36. }
  37. {
  38. typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
  39. A a;
  40. assert(a.outer_allocator() == A1<int>());
  41. assert((a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>, A3<int>>()));
  42. assert(A1<int>::copy_called == false);
  43. assert(A1<int>::move_called == false);
  44. assert(A2<int>::copy_called == false);
  45. assert(A2<int>::move_called == false);
  46. assert(A3<int>::copy_called == false);
  47. assert(A3<int>::move_called == false);
  48. }
  49. return 0;
  50. }