Using shared_ptr needlessly results in ambiguous function call

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; }
participants (1)
-
Phillip Hellewell