Marshall Clow | 25d3402 | 2013-08-13 01:11:06 +0000 | [diff] [blame^] | 1 | #ifndef __PRIVATE_CONSTRUCTOR__H |
| 2 | #define __PRIVATE_CONSTRUCTOR__H |
| 3 | |
| 4 | #include <iostream> |
| 5 | |
| 6 | struct PrivateConstructor { |
| 7 | |
| 8 | PrivateConstructor static make ( int v ) { return PrivateConstructor(v); } |
| 9 | int get () const { return val; } |
| 10 | private: |
| 11 | PrivateConstructor ( int v ) : val(v) {} |
| 12 | int val; |
| 13 | }; |
| 14 | |
| 15 | bool operator < ( const PrivateConstructor &lhs, const PrivateConstructor &rhs ) { return lhs.get() < rhs.get(); } |
| 16 | |
| 17 | bool operator < ( const PrivateConstructor &lhs, int rhs ) { return lhs.get() < rhs; } |
| 18 | bool operator < ( int lhs, const PrivateConstructor &rhs ) { return lhs < rhs.get(); } |
| 19 | |
| 20 | std::ostream & operator << ( std::ostream &os, const PrivateConstructor &foo ) { return os << foo.get (); } |
| 21 | |
| 22 | #endif |