|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-09-02 09:50:58
From: "Eric Woodruff" <Eric.Woodruff_at_[hidden]>
> Yes, of course, I implemented it with operator shared_ptr<T> () const. The
> problem is this:
>
> shared_ptr<AbstractType> someMethod () {
> return New<ConcreteType> (p1, p2, p3);
> }
You can use
template<class Y> operator shared_ptr<Y>() const;
but actually it seems to me that the above should work even with a
non-templated operator. This is the auto_ptr_ref idiom that somehow manages
to sneak two user-defined conversions:
auto_ptr<X> someMethod()
{
return auto_ptr<X>(new X);
}
goes through operator auto_ptr_ref(). Of course some compilers frown at it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk