Is implicit casting with boost::any possible?
I'm curious if there's any way to get code like the following to work:
boost::any a = char(10);
int i = boost::any_cast<int>(a);
More specifically, what I mean is, I'd like to be able to place a value
of type T1 in 'a' and then retrieve it as type T2 which it can be
implicitly cast to. Is this possible without the part that extracts the
value from 'a' adding a lot of extra code to test all possibilities?
What I would like to do is fill a map
(Second attempt to post) Matthew Dempsky wrote:
I'm curious if there's any way to get code like the following to work:
boost::any a = char(10); int i = boost::any_cast<int>(a);
You can customize boost::dynamic_any::any. Example:
#include <string>
#include <stdexcept>
#include <iostream>
#include
participants (2)
-
Alexander Nasonov
-
Matthew Dempsky