Boost logo

Boost :

From: Sid Sacek (ssacek_at_[hidden])
Date: 2007-11-19 16:11:37


template<class T> class shared_ptr
{
    template<class Y>
    explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be complete
    {
        detail::sp_enable_shared_from_this( pn, p, p );
    }
};

I've tried really hard to figure out what it means when a constructor is both a template as well as explicit. The keywords have
incompatible meanings to me and therefore I fail to make sense of it. If you template the argument, then you're saying you'll accept
any type of pointer as long as it will still compile, and the explicit implies no explicit conversions to Y, which shouldn't happen
anyway due to the template indicating any argument is valid as long as it complies.

I googled for this and researched the C++ Templates book without success. Also, nobody I've asked this about could give me a
satisfactory answer, and so I'm hoping somebody on the boost list won't mind enlightening me by providing a few concrete examples
where it comes into play.

And I apologize for wasting everybody else's time with this.

Thanks,
-Sid


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk