blob: d40e9c134466c191574586527f965d4ec50f6e84 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001#ifndef DEFAULTONLY_H
2#define DEFAULTONLY_H
3
4#include <cassert>
5
6class DefaultOnly
7{
8 int data_;
9
10 DefaultOnly(const DefaultOnly&);
11 DefaultOnly& operator=(const DefaultOnly&);
12public:
13 static int count;
14
15 DefaultOnly() : data_(-1) {++count;}
16 ~DefaultOnly() {data_ = 0; --count;}
17
18 friend bool operator==(const DefaultOnly& x, const DefaultOnly& y)
19 {return x.data_ == y.data_;}
20 friend bool operator< (const DefaultOnly& x, const DefaultOnly& y)
21 {return x.data_ < y.data_;}
22};
23
24int DefaultOnly::count = 0;
25
26#endif