How to print boost::any to a stream?
I have a Map std::map<std::string, boost::any> , which comes from the boost::program_options package. Now I would like to print the content of that map: for(po::variables_map::const_iterator it = vm.begin(); it != vm.end(); ++it) { std::cerr << it->first << ": " << it->second << std::endl; } Unfortunately, that is not possible because boost::any doesn't have an operator<< defined. What is the easiest way to print that map? I could define my own output operator for any that automatically tries to cast each any to an int, then double, then string, etc., each time ignoring errors and trying to