True that I just need limited type supported and not entire universe of types, I have also seen following, but it would mean to put it in series of if(is_int), elseif(is_char_ptr) kind of statements, switch statement would be more cleaner, that why I thought type_traits may offer cleaner solution.
 
Performance is also criteria.

 
On 10/10/05, Christian Henning <chhenning@gmail.com> wrote:
I took a look at the examples in the Boost::Any documentation and found this:

bool is_int(const boost::any & operand)
{
   return operand.type() == typeid(int);
}

bool is_char_ptr(const boost::any & operand)
{
   try
   {
       any_cast<const char *>(operand);
       return true;
   }
   catch(const boost::bad_any_cast &)
   {
       return false;
   }
}

bool is_string(const boost::any & operand)
{
   return any_cast<std::string>(&operand);
}


Is that what you're looking for?

Christian

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users