runtime lists vs compiletime lists
Hello,
i have 2 choices:
1) runtime
class BaseD
class D1 .... D200 derived from BaseD (all of them singletons,
don't really store any data in them, they just provide policy)
and class C1... C100 (also all derived from BaseC)
for each Cxxx, there is a perferred D to deal with it, but "some" other Ds work also...
the library user creates instances of Cxxx,
I could then have a global runtime std::map
AMDG Hicham Mouline wrote:
Hello,
i have 2 choices:
1) runtime
class BaseD class D1 .... D200 derived from BaseD (all of them singletons, don't really store any data in them, they just provide policy)
and class C1... C100 (also all derived from BaseC) for each Cxxx, there is a perferred D to deal with it, but "some" other Ds work also... the library user creates instances of Cxxx, I could then have a global runtime std::map
, that stores singletons of Cxxx, and preferred Dxxx 2) compiletime or i could store this mpl::map<> to associate each type Cxxx with its favorite Dxxx i suppose i could construct this by extending in each header file (for each Cxxx), the mpl::map with the Cxxx and its associated Dxxx
Remember that all mpl sequences are immutable.
Any comments are appreciated re this choice, for e.g. the max number of elts for map<>
I doubt that an MPL map would work well. The default limit is 50 elements. My personal preference in this case would be to use specialization: template<class C> struct preferedD; template<> struct preferedD<C1> { typedef Dx type; }; //... In Christ, Steven Watanabe
participants (2)
-
Hicham Mouline
-
Steven Watanabe