Boost logo

Boost Users :

From: Piyush Kapadia (piyush.kapadia_at_[hidden])
Date: 2005-10-10 12:07:25


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_at_[hidden]> 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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net