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