[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-users
Subject:    Re: [Boost-users] runtime lists vs compiletime lists
From:       Steven Watanabe <watanabesj () gmail ! com>
Date:       2008-08-30 20:26:41
Message-ID: 48B9AD01.6050505 () providere-consulting ! com
[Download RAW message or body]

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<BaseC&, BaseD&>, 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

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic