
for example, is the following approach correct? boost::any t(2); std::string str = boost::any_caststd::string(t);
I don't believe that will work. I don't think boost::any supports implicit conversions like that.
From the docs: [Boost Any is in a class of] Discriminated types that contain values of different types but do not attempt conversion between them, i.e. 5 is held strictly as an int and is not implicitly convertible either to "5" or to 5.0. Their indifference to interpretation but awareness of type effectively makes them safe, generic containers of single values, with no scope for surprises from ambiguous conversions.
For that you would need something like: std::string str = boost::lexical_caststd::string(boost::any_cast<int>(t));
In addition, from searching archieves I understand that there is no serialization for boost::any. Currently I plan to examine "name" in type_info returned from boost::any::type() and serialize accordingly. I'll appreciate any advise for better approach.
I'm afraid I can't comment on this. . . Nate