9 Oct
2010
9 Oct
'10
12:52 p.m.
On 08/10/2010 20:42, alfC wrote:
Hi,
I need a variant type object that can hold any type characterized by a template. For example Boost.Units have a family of types parameterized by "System".
quantity< unit
, double> suppose dimension is fixed, e.g. typedef boost::units::length dimension
is it possible to define a variant over that family of types?
No.
I could create a make_variant_over< list of all types> but that can be that list will be fixed and each time I defined a new System the list will have to grow.
Variant can only work with a fixed list of possible types.
Or should I be using an extension of boost::any with some adhoc restriction over the possible types on construction?
You could use type erasure.