alloc_last.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #ifndef ALLOC_LAST_H
  9. #define ALLOC_LAST_H
  10. #include <cassert>
  11. #include "allocators.h"
  12. struct alloc_last
  13. {
  14. static bool allocator_constructed;
  15. typedef A1<int> allocator_type;
  16. int data_;
  17. alloc_last() : data_(0) {}
  18. alloc_last(int d) : data_(d) {}
  19. alloc_last(const A1<int>& a)
  20. : data_(0)
  21. {
  22. assert(a.id() == 5);
  23. allocator_constructed = true;
  24. }
  25. alloc_last(int d, const A1<int>& a)
  26. : data_(d)
  27. {
  28. assert(a.id() == 5);
  29. allocator_constructed = true;
  30. }
  31. alloc_last(const alloc_last& d, const A1<int>& a)
  32. : data_(d.data_)
  33. {
  34. assert(a.id() == 5);
  35. allocator_constructed = true;
  36. }
  37. ~alloc_last() {data_ = -1;}
  38. friend bool operator==(const alloc_last& x, const alloc_last& y)
  39. {return x.data_ == y.data_;}
  40. friend bool operator< (const alloc_last& x, const alloc_last& y)
  41. {return x.data_ < y.data_;}
  42. };
  43. bool alloc_last::allocator_constructed = false;
  44. #endif // ALLOC_LAST_H