From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2002-06-26 19:50:57
"Douglas Gregor" <gregod_at_[hidden]> wrote in message
An idea just occured to me. Storing the pseudo-vtable as an integral index
instead of a pointer to a table of functions has a nice fringe benefit:
given a Variant object, we can easily and efficiently retrieve its index in
the typelist. This in turn would help implementing switch-on-type
efficiently in both library and client code, something like:
typedef Variant<TYPELIST_3(int, double, string)> Field;
// it's an int!
// it's a double!
// it's a string!
// it's a boy!
Of course, you can just as well use 0, 1, 2, instead of
Field::tag<xxx>::result, but the formulation above is more resilient in face
of changing the typedef.
So I guess this would be the second useful change to Variant.
Andrei the mischievous one
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk