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