Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-01-24 07:38:54


On 01/24/2005 04:04 AM, Pavel Vozenilek wrote:
[snip]

>The problem is what syntax to use to define Multiton, like:
>
>template
><
> typename T,
> typename Parameters = TYPELIST2(std::string, std::string),
> typename Lifetime = ...
>
>
>class Multiton
>{
> ....
>};
>
>and how to 'generate' flat structure from the typelist.
>(The structure would be then used as key in lookup map.)
>
>
Use:

    reverse_fold<Parameters,empty_base,SingletonNode>

described here:

http://www.boost.org/libs/mpl/doc/refmanual/reverse-fold.html

as a superclass of Multiton. The instantiations of last argument
would define the singleton's for the various elements in the typelist
while inheriting the succeeding ones in the typelist.
Accessing the ith-singleton can be done with the code in:

    get_side_type.zip

in http://boost-sandbox.sourceforge.net/vault/ .
The code in get_ith_head_test.cpp can be used as a model
for making a get<i> member function for accessing the
i-th singleton.

HTH.

Regards,
Larry


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk