Transform a boost::variant into its former type

If I have a variant variable such as

boost::variant<int, float, double, string> var

and I give to it a value...lets' suppose an int:

var = 1;

Of course I know that is an int but the compiler doesn't. So I obtain an error if I do

int a = var;

Is there a way to convert a variant variable into one of its possible types?
Yeah, it was not so difficult:

int a = boost::get<int>(var)

Thanks!
Topic archived. No new replies allowed.