|
Boost : |
From: Phillip Hellewell (sshock_at_[hidden])
Date: 2006-08-27 20:10:16
Hi,
I posted about this a week or so ago, but didn't get any response. So
I'm trying again.
Is there any reason we wouldn't want to add this constructor to
shared_ptr so that it can work more like a real pointer and not result
in ambiguous function call error with overloaded functions?
template<class Y>
shared_ptr(shared_ptr<Y> const & r, typename enable_if<
typename is_convertible<Y*, T*>::type, void*>::type = 0): px(r.px), pn(r.pn)
{
}
Thanks,
Phillip Hellewell
P.S. This is an example of code that will result in an ambiguous
call, taken directly from
http://lists.boost.org/Archives/boost/2005/12/97817.php
class A{};
class B{};
class C : public A{};
void foo( boost::shared_ptr<A> pa ){
std::cout << "A";
}
void foo( boost::shared_ptr<B> pb ){
std::cout << "B";
}
int main(){
boost::shared_ptr<C> ptr(new C);
foo( ptr );
return 0;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk