
David A. Greene wrote:
I got home and realized that I still have quite a bit of documenting to do. In order to make this more immediately useful to Jason and others, I'll get something into the vault this weekend.
That does sound useful, I look forward to playing with it. In the mean time, what do people think of the following solution? namespace boost { namespace singleton { struct name { // typedef all default policies here }; typedef name unnamed; } template < typename Type, typename Name = singleton::unnamed > class singleton_ptr { /*...*/ }; } The name acts as both the policy mechanism and as a unique identifier to allow multiple singletons of the same type to exist. Client code can define a name by deriving from singleton::name and typedefing any policies needed, allowing the defaults for the others to be inherited from the base class. Ex: using namespace boost; struct score : public singleton::name { typedef singleton::dependency_lifetime lifetime_policy; // leave defaults for other policies }; struct lives : public singleton::name { typedef singleton::dependency_lifetime lifetime_policy; // leave defaults for other policies }; typedef singleton_ptr < int, score > score_ptr; typedef singleton_ptr < int, lives > lives_ptr; -Jason