Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-08-05 22:27:29

----- Original Message -----
From: "Brian Simpson" <wheber_at_[hidden]>
> The general case devolves into an else-if-then:
> Let us assume that we have specializations up to a certain number,
> 'max_specialization_count'. Then we know that we can get switch-based
> runtime type selection ("rtts") on any mpl::Sequence whose size is not
> greater than 'max_specialization_count'. To provide rtts for Sequences
> whose size is greater than 'max_specialization_count', we provide a more
> general template definition. Its "invoke" function sets up a switch-based
> selection among the first 'max_specialization_count' types, and then sets
> a (recursive) selection among the remaining types.

Of course, you can do slightly better than this by switching in chunks of
size max_specialization_count, so there there are only a few if statements
(to determine which chunk we're in). Granted, the effort would be large and
the return potentially small, so it may not be of interest. (My assumption
is that most people do not use variants with huge numbers of possibilities,
so that few variants require the if statements).

> Questions or comments?

I haven't reviewed the code itself, but the idea is good and I believe this
would be a boon to the variant library. Itay and/or Eric will need to look
this over if it is to be included.


Boost list run by bdawes at, gregod at, cpdaniel at, john at