From: Emily Winch (emily_at_[hidden])
Date: 2002-02-08 12:13:43
[ my example of choosing between static and dynamic polymorphism
at compile time ]
> I see. But how does the user choose one way or the other ? If
> suddenly a type is no more accessible at compile time (header split,
> etc.), the user has to change his code from static_poly to
> dynamic_poly in all the places instances of the type were beeing
Then the user needs another layer of abstraction, to make sure the
decision is only made in one place.
> I would prefer one of the following scenarii:
> 1- Only the dynamic case is taken into account. After all, if the
> dynamic case works, why bother with the static case ?
I'd like to be able to do something a bit like
typedef typelist<foo, bar, baz, haddock> list_type;
tuple<list_type> t = /* something */;
and not have to build into my code a bunch of stuff designed for
more heavyweight serialisation than I need. Nevertheless I'd like
to be able to write
std::vector<variant<list_type> > v;
in some cases where I need that kind of behaviour.
I'm not suggesting that anyone else necessarily wants to do
this, maybe it's only me :)
> 2- dynamic and static case are handled, but automatically (for
> example, the dynamic mechanism is turned on for a type by the use of
> the macro that registers this type into the factory).
What if I'd like to have static polymorphism for type foo in the common case
where I'm stuffing the data in a file to look at later (versioning isn't a
problem in this case), and dynamic polymorphism for foos when I'm reading
from XML that came over the network?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk