|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-12-10 10:57:25
"art" <art_at_[hidden]> writes:
> Does intrusive_ptr work with overloading on any other compiler?
>
> This is a general problem and as I proposed above to solve the ambiguity you
> have to use SFINE in template constructor of intrusive_ptr/shared pointer.
>
> template< class T2 >
> shared_ptr( const shared_ptr<T2>& s_ptr, typename
> enable_if<is_convertible<T*,T2*>::result, void* >::type = 0)
> { ... }
>
> I think it should be added to boost smartptr.
That isn't really a complete solution:
struct Base {};
struct Derived : Base {};
struct Bottom : Derived {};
int f(shared_ptr<Base>); // #1
int f(shared_ptr<Derived>); // #2
shared_ptr<Bottom> x(new Bottom);
int y = f(x); // Should call #2, but is ambiguous
will still fail, and there's not really any way to make it work.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk