Jon Stewart on 27 Jun 2003 00:01:02 -0000 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
[ALACPP] hot or not? |
Consider: template<class T> class MonoState { public: T& Instance(void) { static T singleton; return singleton; } T* operator->(void) { return &Instance(); } }; Good or evil? I thought about implicit type conversion. operator T*() is equivalent to operator->() and I can't get operator T&() to compile -- anyone know why? It's what I really want. Then your MonoState usage looks like this: MonoState< Foo > aFoo; // gesundheit ... aFoo.DoBar(); // if this ain't easy to refactor, what is? Jon -- Jon Stewart stew1@xxxxxxxxxxx _______________________________________________ alacpp mailing list alacpp@xxxxxxxxxxx http://lists.ellipsis.cx/mailman/listinfo/alacpp