Boost logo

Boost Users :

Subject: [Boost-users] [variant][any] template parameterized variant
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-10-08 15:42:28


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<dimension, System>, double>

suppose dimension is fixed, e.g. typedef boost::units::length
dimension

is it possible to define a variant over that family of types? 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.

 to simplify the question:

 template<class T>
 class dummy{ ... };

 variant< "dummy<T>" > v; //for all T

 If it simplifies things, suppose that all dummy<T> have the same
sizeof and that all are convertible to each other.

Or should I be using an extension of boost::any with some adhoc
restriction over the possible types on construction?

Thank you,
Alfredo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net