
Hi, I have a function template like : template <class A> A what_type ( const boost::any &operand ){ A a; a = boost::any_cast<a>(operand); return a; } The idea is to provide the client code an easy way extract the type hidden by the boost::any value, Now there is no way to make the compiler deduce the type to return from an expression like below: std::string s = "hello"; boost::any a = s; some_op( what_type(a) ); //calls some_op(string &); Instead now the client has to write code using type() which returns std::typeinfo & if ( a.type().name() == "Ss" ) some_op(what_type<string> a); else if ( a.type().name() == "d" ) some_op(what_type<double> a); Or use functions to test type and cast: if ( is_string (a) ) some_op( what_type<string>(a)); else ( is_int(a) ) some_op ( what_type<int>(a)); ….. Is there any elegant way to handle this problem ?? --Digz