Suppose I have two unrelated classes A and B. I also have a class Bla that uses boost::shared_ptr like t
shared_ptr has a template single-argument constructor, which is considered for the conversion here. That's what allows an actual parameter shared_ptr to be supplied where a shared_ptr is needed.
Since both shared_ptr and shared_ptr have this implicit conversion, it's ambiguous.
At least in C++0x, the standard requires that shared_ptr use some SFINAE tricks to make sure that the template constructor only matches types that actually can be converted.
The signature is (see section [util.smartptr.shared.const]):
shared_ptr::shared_ptr(const shared_ptr& r) noexcept;
template shared_ptr::shared_ptr(const shared_ptr& r) noexcept;
Requires: The second constructor shall not participate in the overload resolution unless
Y*is implicitly convertible toT*.
Possibly the library hasn't yet been updated to comply with that requirement. You might try a newer version of libc++.
Boost won't work, because it's missing that requirement.
Here's a simpler test case: http://ideone.com/v4boA (This test case will fail on a conforming compiler, if it compiles successfully, it means the original case will be incorrectly reported as ambiguous.)
VC++ 2010 gets it right (for std::shared_ptr).