Boost logo

Boost Users :

From: Jeffrey Holle (jeffreyholle_at_[hidden])
Date: 2007-05-09 12:53:21


Boost::variant if you want your variable to hold just one of the types,
and hopefully you know what type is holds.
You have to use a variant visitor to access it if you don't.
Attempts to use get<int> when the type isn't castable to it will throw
an exception.

Ares Lagae wrote:
> I have a list of fundamental types (known at compile time). For each of
> these types I want to declare a templated member in a class.
>
> So, instead of
>
> class foo {
> private:
> int int_variable;
> double double_variable;
> ... /* rest of types */
> };
>
> I want something like
>
> class foo {
> private:
> variable_list<int, double, ... /* rest of types */> variable;
> };
>
> and then access "foo::variable" with a template-like syntax.
> E.g. "variable.get<int>()".
>
> Does anyone have any idea how I can accomplish this?
>


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