
9 Nov
2006
9 Nov
'06
5:41 a.m.
ClassyK_Danad wrote:
#include <iostream> #include
template
boost::any min(const A& a,const B& b) { return a < b ? a : b; } void main() { //got a bad_any_cast exception ! std::cout << boost::any_cast<int>( min( 1, 1.1)) << std::endl; }
Because in your example, min is returning a double, and you're trying to extract an int. -- Eric Niebler Boost Consulting www.boost-consulting.com