diff options
Diffstat (limited to 'test/support/DefaultOnly.h')
-rw-r--r-- | test/support/DefaultOnly.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/support/DefaultOnly.h b/test/support/DefaultOnly.h new file mode 100644 index 000000000000..a3d4303f8158 --- /dev/null +++ b/test/support/DefaultOnly.h @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef DEFAULTONLY_H +#define DEFAULTONLY_H + +#include <cassert> + +class DefaultOnly +{ + int data_; + + DefaultOnly(const DefaultOnly&); + DefaultOnly& operator=(const DefaultOnly&); +public: + static int count; + + DefaultOnly() : data_(-1) {++count;} + ~DefaultOnly() {data_ = 0; --count;} + + friend bool operator==(const DefaultOnly& x, const DefaultOnly& y) + {return x.data_ == y.data_;} + friend bool operator< (const DefaultOnly& x, const DefaultOnly& y) + {return x.data_ < y.data_;} +}; + +int DefaultOnly::count = 0; + +#endif // DEFAULTONLY_H |