brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 4f91e5c Raw
60 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef ALLOC_FIRST_H10#define ALLOC_FIRST_H11 12#include <cassert>13 14#include "allocators.h"15 16struct alloc_first17{18    static bool allocator_constructed;19 20    typedef A1<int> allocator_type;21 22    int data_;23 24    alloc_first() : data_(0) {}25    alloc_first(int d) : data_(d) {}26    alloc_first(std::allocator_arg_t, const A1<int>& a)27        : data_(0)28    {29        assert(a.id() == 5);30        allocator_constructed = true;31    }32 33    alloc_first(std::allocator_arg_t, const A1<int>& a, int d)34        : data_(d)35    {36        assert(a.id() == 5);37        allocator_constructed = true;38    }39 40    alloc_first(std::allocator_arg_t, const A1<int>& a, const alloc_first& d)41        : data_(d.data_)42    {43        assert(a.id() == 5);44        allocator_constructed = true;45    }46 47    alloc_first(const alloc_first&) = default;48    alloc_first& operator=(const alloc_first&) = default;49    ~alloc_first() {data_ = -1;}50 51    friend bool operator==(const alloc_first& x, const alloc_first& y)52        {return x.data_ == y.data_;}53    friend bool operator< (const alloc_first& x, const alloc_first& y)54        {return x.data_ < y.data_;}55};56 57bool alloc_first::allocator_constructed = false;58 59#endif // ALLOC_FIRST_H60