Boost logo

Boost Users :

From: Hicham Mouline (hicham_at_[hidden])
Date: 2008-01-23 16:49:52


Hi,

I have a template class with 6 template arguments as :

template <typename contractType,
          typename treeType,
          int n,
          enum1 rtype,
          enum2 qtype,
          enum3 vtype>
class TreeImpl {};

I need to write partial specializations for the cases n=2, n=3, for 2 cases of rtype, 2 cases of qtype and 3 cases of vtype,
therefore I will write 2*2*2*3 = 24 partial specializations.

Any fully specialized template instance should be a singleton.

I would like to find a way to store any instanciated full specialization in some common list, so that in other parts of the code,
i can deal with the various singletons without having to write actual arguments n,rtype,qtype and vtype.

I thought of having all these templates inherit from a template base class

template <typename contractType, typename treeType>
class TreeImplBase;

Each specialization of these holds a
static std::map< boost::tuple<int,enum1,enum2,enum3>, const TreeImplBase* >;
which contains the list of the derived template classes.

Any comments are appreciated,

Perhaps this is a known design pattern,
perhaps there is an easier way of doing this,
perhaps there is a boost library which helps with this,

regards,


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net