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 9 #ifndef ALLOC_LAST_H 10 #define ALLOC_LAST_H 11 12 #include <cassert> 13 14 #include "allocators.h" 15 16 struct alloc_last 17 { 18 static bool allocator_constructed; 19 20 typedef A1<int> allocator_type; 21 22 int data_; 23 alloc_lastalloc_last24 alloc_last() : data_(0) {} alloc_lastalloc_last25 alloc_last(int d) : data_(d) {} alloc_lastalloc_last26 alloc_last(const A1<int>& a) 27 : data_(0) 28 { 29 assert(a.id() == 5); 30 allocator_constructed = true; 31 } 32 alloc_lastalloc_last33 alloc_last(int d, const A1<int>& a) 34 : data_(d) 35 { 36 assert(a.id() == 5); 37 allocator_constructed = true; 38 } 39 alloc_lastalloc_last40 alloc_last(const alloc_last& d, const A1<int>& a) 41 : data_(d.data_) 42 { 43 assert(a.id() == 5); 44 allocator_constructed = true; 45 } 46 47 alloc_last(const alloc_last&) = default; 48 alloc_last& operator=(const alloc_last&) = default; ~alloc_lastalloc_last49 ~alloc_last() {data_ = -1;} 50 51 friend bool operator==(const alloc_last& x, const alloc_last& y) 52 {return x.data_ == y.data_;} 53 friend bool operator< (const alloc_last& x, const alloc_last& y) 54 {return x.data_ < y.data_;} 55 }; 56 57 bool alloc_last::allocator_constructed = false; 58 59 #endif // ALLOC_LAST_H 60