Boost logo

Boost Users :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-06-29 16:36:22

"Delfin Rojas" <drojas_at_[hidden]> wrote in message
> Hi everybody,
> I am writing a template class that processes several types. However
> problem is that when the type of the template is
boost::shared_ptr<P> (and
> only in that case) I need to do a boost::dynamic_pointer_cast<P>
inside a
> method.
> So, I searched boost::type_traits library but could not find
anything to
> detect a shared_ptr type at compile time. I would appreciate any
ideas of
> how this could be implemented.

Here's one way:

    template<typename T>
    struct is_shared_ptr : mpl::false_ { };

    template<typename P>
    struct is_shared_ptr< shared_ptr<P> > : mpl::true_ { };

You can get approximately the same effect without partial
specialization, if necessary.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at