| 36 | namespace internal { |
| 37 | |
| 38 | struct HeapInt { |
| 39 | HeapInt() : HeapInt(0) {} |
| 40 | |
| 41 | explicit HeapInt(int x) : ptr(new int(x)) {} |
| 42 | |
| 43 | HeapInt& operator=(int x) { |
| 44 | ptr.reset(new int(x)); |
| 45 | return *this; |
| 46 | } |
| 47 | |
| 48 | HeapInt(const HeapInt& other) : HeapInt(other.ToInt()) {} |
| 49 | |
| 50 | HeapInt& operator=(const HeapInt& other) { |
| 51 | *this = other.ToInt(); |
| 52 | return *this; |
| 53 | } |
| 54 | |
| 55 | int ToInt() const { return ptr == nullptr ? -98 : *ptr; } |
| 56 | |
| 57 | bool operator==(const HeapInt& other) const { |
| 58 | return ptr != nullptr && other.ptr != nullptr && *ptr == *other.ptr; |
| 59 | } |
| 60 | bool operator<(const HeapInt& other) const { |
| 61 | return ptr == nullptr || (other.ptr != nullptr && *ptr < *other.ptr); |
| 62 | } |
| 63 | |
| 64 | bool operator==(int other) const { return ptr != nullptr && *ptr == other; } |
| 65 | friend bool operator==(int left, const HeapInt& right) { return right == left; } |
| 66 | |
| 67 | std::unique_ptr<int> ptr; |
| 68 | }; |
| 69 | |
| 70 | template <typename Vector> |
| 71 | bool UsesStaticStorage(const Vector& v) { |