Marshall Clow | 354d39c | 2014-01-16 16:58:45 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 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 |
Marshall Clow | 354d39c | 2014-01-16 16:58:45 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 9 | #ifndef DEFAULTONLY_H |
| 10 | #define DEFAULTONLY_H |
| 11 | |
| 12 | #include <cassert> |
| 13 | |
| 14 | class DefaultOnly |
| 15 | { |
| 16 | int data_; |
| 17 | |
| 18 | DefaultOnly(const DefaultOnly&); |
| 19 | DefaultOnly& operator=(const DefaultOnly&); |
| 20 | public: |
| 21 | static int count; |
| 22 | |
| 23 | DefaultOnly() : data_(-1) {++count;} |
| 24 | ~DefaultOnly() {data_ = 0; --count;} |
| 25 | |
| 26 | friend bool operator==(const DefaultOnly& x, const DefaultOnly& y) |
| 27 | {return x.data_ == y.data_;} |
| 28 | friend bool operator< (const DefaultOnly& x, const DefaultOnly& y) |
| 29 | {return x.data_ < y.data_;} |
| 30 | }; |
| 31 | |
| 32 | int DefaultOnly::count = 0; |
| 33 | |
Howard Hinnant | 8f2f7e7 | 2010-08-22 00:15:28 +0000 | [diff] [blame] | 34 | #endif // DEFAULTONLY_H |