diff options
Diffstat (limited to 'test/support/private_constructor.hpp')
-rw-r--r-- | test/support/private_constructor.hpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/support/private_constructor.hpp b/test/support/private_constructor.hpp new file mode 100644 index 0000000000000..a9fcf6897233a --- /dev/null +++ b/test/support/private_constructor.hpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 __PRIVATE_CONSTRUCTOR__H +#define __PRIVATE_CONSTRUCTOR__H + +#include <iostream> + +struct PrivateConstructor { + + PrivateConstructor static make ( int v ) { return PrivateConstructor(v); } + int get () const { return val; } +private: + PrivateConstructor ( int v ) : val(v) {} + int val; + }; + +bool operator < ( const PrivateConstructor &lhs, const PrivateConstructor &rhs ) { return lhs.get() < rhs.get(); } + +bool operator < ( const PrivateConstructor &lhs, int rhs ) { return lhs.get() < rhs; } +bool operator < ( int lhs, const PrivateConstructor &rhs ) { return lhs < rhs.get(); } + +std::ostream & operator << ( std::ostream &os, const PrivateConstructor &foo ) { return os << foo.get (); } + +#endif |