Re: [boost] singleton_ptr

struct MySingletonCategory;
// must provide specializations in singleton namespace namespace boost { namespace singleton {
// the following specifies that multi threading will be
used for
singletons which use MySingletonCategory template < > struct threading_policy < MySingletonCategory > { typedef multi_threaded type; };
This should be called *trait* not a policy. Policy is type orthogonal. And btw I don't think traits-based solution will work here. I most definitely may want different threading policies for the same singleton type in different circumstances.
why not simply pass the category as a template parameter: struct MyCategory ; namespace boost { namespace singleton { template < > struct threading_policy < MyCategory > { typedef multi_threaded type; }; } } // close namespace void test ( ) { singleton_ptr < MySingletonType,MyCategory > ptr; } you can have the same category for many type but also many category for one type. if you really want no policy in the type declaration, you can provide a default who would search for a type declared category as in your code (I am not very understandable I think, perhaps the following code while be more explicit): struct defaultcategory; tempate< class T, class category_param = defaultcategory > class singleton_ptr { typedef mpl::if< mpl::IsSame<category_param,defaultcategory>, category<T>::type, category_param>::type the_category; ... }; the syntaxe is perhaps not correct but it's the principe who count. so you can use: struct another_type; template<> category<another_type> { typedef MT_category type; }; int main() { singleton_ptr<MyType> a_defaut_singleton; singleton_ptr<another_type> a_MT_singleton; singleton_ptr<MyType,MT_category> another_MT_singleton; } perhaps it don't work, or it's stupid, but perhaps it can help you. And sorry for my poor english. you can also want to read the papers here: http://www.prakinf.tu-ilmenau.de/~czarn/cpe2000/ --(space [webmail cut my space :( ) Cédric Venet ECP student Accédez au courrier électronique de La Poste : www.laposte.net ; 3615 LAPOSTENET (0,34/mn) ; tél : 08 92 68 13 50 (0,34/mn)

I don't have time at the moment to respond to anything in individual emails (but thanks for the large amount of interest!). I just thought I should mention that there was another template parameter that I left out of my previous description for the sake of simplicity: Name. This would exist solely so that different singletons of the same type could exist within the same application, and the category could then be specialized for just one specific type/name pair, for all singletons of a given type, or for all singletons with the same name. The name itself could simply be a forward declared and undefined struct. I'll post a code example later if this description doesn't explain the idea well. -Jason
participants (2)
-
cedric.venet
-
Jason Hise