Marshall Clow | 354d39c | 2014-01-16 16:58:45 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 10 | #ifndef DEFAULTONLY_H |
| 11 | #define DEFAULTONLY_H |
| 12 | |
| 13 | #include <cassert> |
| 14 | |
| 15 | class DefaultOnly |
| 16 | { |
| 17 | int data_; |
| 18 | |
| 19 | DefaultOnly(const DefaultOnly&); |
| 20 | DefaultOnly& operator=(const DefaultOnly&); |
| 21 | public: |
| 22 | static int count; |
| 23 | |
| 24 | DefaultOnly() : data_(-1) {++count;} |
| 25 | ~DefaultOnly() {data_ = 0; --count;} |
| 26 | |
| 27 | friend bool operator==(const DefaultOnly& x, const DefaultOnly& y) |
| 28 | {return x.data_ == y.data_;} |
| 29 | friend bool operator< (const DefaultOnly& x, const DefaultOnly& y) |
| 30 | {return x.data_ < y.data_;} |
| 31 | }; |
| 32 | |
| 33 | int DefaultOnly::count = 0; |
| 34 | |
Howard Hinnant | 8f2f7e7 | 2010-08-22 00:15:28 +0000 | [diff] [blame] | 35 | #endif // DEFAULTONLY_H |