|
Boost : |
From: Larry Evans (cppljevans_at_[hidden])
Date: 2004-12-01 18:18:18
IIUC, the variant library is similar to a "dependent product"
which can be thought of as a pseudo_pair<Index,TypeList>.
where an instance:
pseudo_pair<I,T> dpIT;
is a pair of values (i,t) where:
I i;
T<i> t;
IOW, there is only one value, but it can be one of many
types depending on the valid values of I. BTW, would
variant be made for readable by making variant take
an enumeration:
enum I{i0, i1, ...., in-1}
as the discriminator?
Anyway, back to the original question. Is there any interest
in a "dependent function" where:
dependent_function<I,T> df;
where:
T<i0>& df<i0>();
T<i1>& df<i1>();
...
T<in-1>& df<in-1>():
IOW, this would be like a regular struct (a record type), however,
instead of:
df.ix
there would be:
df<ix>();
BTW, this idea comes from Nuprl:
http://www.cs.cornell.edu/Info/Projects/NuPrl/nuprl.html
and I've recently had a need for it because I've got a template
which is specialized on an enumeration; hence, this would come
in handy if I wanted to have a structure containing all
instances of the specializations.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk