Gennadiy Rozental wrote:
> "Eric Friedman" <[EMAIL PROTECTED]> wrote:
[snip]
> > If variant is given types as a MPL-sequence (e.g., variant<
mpl::list<T1,
> > T2, ..., TN> instead of variant<T1, T2, ..., TN>), then technique you
> > propose will not work. Please prove me incorrect, but I don't think you
> > can.
> > (Note, however, that loop-unrolling is still possible, though ultimately
> > it doesn't change the O(N) complexity of visitation.)
>
> I don't think there is a differrence. In both cases we either rely on
actual
> number of types that need to be computed (IOW is not sutable for PP) or on
> upper limit of types amount (that is PP constant in both cases).
>
> Here how  the second case could be implemented:
>
> template<typename Typelist, typename Storage,typename Visitor>
> void switch_visitor_selector( Storage& storage, int witch, Visitor
visitor )
> {
>       switch( witch ) {
>       case 1:
>            visitor( Typelist[1](storage) );
>            break;
>       case 2:
>            visitor( Typelist[2](storage) );
>            break;
>       ...
>       case MAX_WITCH:
>            visitor( Typelist[MAX_WITCH](storage) );
>            break;
>       }
> }

Your pseudo-code is misleading. There is no "MAX_WHICH" available to the
preprocessor when MPL-sequences are given because there is no theoretical
upper limit on the size of a type-sequence.

If your example is to demonstrate the feasibility of a special case
optimization, well then I have already agreed with you.

Thanks,
Eric



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to