deallocate.pass.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. // void deallocate(pointer p, size_type n);
  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. a.deallocate((int*)10, 20);
  23. assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
  24. }
  25. {
  26. typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
  27. A a;
  28. a.deallocate((int*)10, 20);
  29. assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
  30. }
  31. {
  32. typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
  33. A a;
  34. a.deallocate((int*)10, 20);
  35. assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
  36. }
  37. return 0;
  38. }