blob: bdcf46d19ff2dd80c5fbbb42c02ecc4527e8792c [file] [log] [blame]
Howard Hinnantc51e1022010-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
Howard Hinnant7b452d42010-08-22 00:15:28 +000026#endif // DEFAULTONLY_H