private_constructor.hpp revision 4a0a98166c0ca6117c74592eaeb12833c9913b49
1#ifndef __PRIVATE_CONSTRUCTOR__H
2#define __PRIVATE_CONSTRUCTOR__H
3
4#include <iostream>
5
6struct PrivateConstructor {
7
8    PrivateConstructor static make ( int v ) { return PrivateConstructor(v); }
9    int get () const { return val; }
10private:
11    PrivateConstructor ( int v ) : val(v) {}
12    int val;
13    };
14
15bool operator < ( const PrivateConstructor &lhs, const PrivateConstructor &rhs ) { return lhs.get() < rhs.get(); }
16
17bool operator < ( const PrivateConstructor &lhs, int rhs ) { return lhs.get() < rhs; }
18bool operator < ( int lhs, const PrivateConstructor &rhs ) { return lhs < rhs.get(); }
19
20std::ostream & operator << ( std::ostream &os, const PrivateConstructor &foo ) { return os << foo.get (); }
21
22#endif
23