1*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===// 2*0a6a1f1dSLionel Sambuc // 3*0a6a1f1dSLionel Sambuc // The LLVM Compiler Infrastructure 4*0a6a1f1dSLionel Sambuc // 5*0a6a1f1dSLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open 6*0a6a1f1dSLionel Sambuc // Source Licenses. See LICENSE.TXT for details. 7*0a6a1f1dSLionel Sambuc // 8*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===// 9*0a6a1f1dSLionel Sambuc 10*0a6a1f1dSLionel Sambuc #ifndef DEFAULTONLY_H 11*0a6a1f1dSLionel Sambuc #define DEFAULTONLY_H 12*0a6a1f1dSLionel Sambuc 13*0a6a1f1dSLionel Sambuc #include <cassert> 14*0a6a1f1dSLionel Sambuc 15*0a6a1f1dSLionel Sambuc class DefaultOnly 16*0a6a1f1dSLionel Sambuc { 17*0a6a1f1dSLionel Sambuc int data_; 18*0a6a1f1dSLionel Sambuc 19*0a6a1f1dSLionel Sambuc DefaultOnly(const DefaultOnly&); 20*0a6a1f1dSLionel Sambuc DefaultOnly& operator=(const DefaultOnly&); 21*0a6a1f1dSLionel Sambuc public: 22*0a6a1f1dSLionel Sambuc static int count; 23*0a6a1f1dSLionel Sambuc DefaultOnly()24*0a6a1f1dSLionel Sambuc DefaultOnly() : data_(-1) {++count;} ~DefaultOnly()25*0a6a1f1dSLionel Sambuc ~DefaultOnly() {data_ = 0; --count;} 26*0a6a1f1dSLionel Sambuc 27*0a6a1f1dSLionel Sambuc friend bool operator==(const DefaultOnly& x, const DefaultOnly& y) 28*0a6a1f1dSLionel Sambuc {return x.data_ == y.data_;} 29*0a6a1f1dSLionel Sambuc friend bool operator< (const DefaultOnly& x, const DefaultOnly& y) 30*0a6a1f1dSLionel Sambuc {return x.data_ < y.data_;} 31*0a6a1f1dSLionel Sambuc }; 32*0a6a1f1dSLionel Sambuc 33*0a6a1f1dSLionel Sambuc int DefaultOnly::count = 0; 34*0a6a1f1dSLionel Sambuc 35*0a6a1f1dSLionel Sambuc #endif // DEFAULTONLY_H 36