alloc_last.h 1.3 KB

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