>Possibly both of these solve the problem. Unforunately, I probably cannot
use any of them! First, function f in my code is actually a template:
template<class T> void f(T &t) { cin >> t; }
So I cannot make the cast :-(
Yes you can! :) Here's how:
#include "boost/mpl/is_same.hpp"
struct streamAsNormal { template<typename T> static void go(const
std::istream & i, T & t) { i >> t; } };
struct streamAsBase { template<typename T> static void go(const
std::istream & i, T & t) { i >> (A)t; } };
template<class T> void f(T &t)
{
boost::if<boost::is_same<T, B>::type, streamAsBase,
streamAsNormal>::type::go(cin, t);
}
--Steve