
The marked call in the code below requires implicit conversion between compatible shared pointer types. At least two compilers (MSVC6 and Sun Workshop6) consider the marked call ambiguous. Remove the second overloaded() function, and the marked call is compiled without error. Replace all the shared pointers by raw, and all three calls to the overloaded methods would be resolved correctly. Is this a shortcoming of the compilers, boost::shared_ptr or the language? #include <boost/shared_ptr.hpp> class MyType { }; class DerivedType : public MyType { }; class OtherType {}; void overloaded( const boost::shared_ptr<MyType> & p ) {} void overloaded( const boost::shared_ptr<OtherType> & p ) {} int main() { boost::shared_ptr<MyType> pm( new MyType() ); boost::shared_ptr<DerivedType> pd( new DerivedType() ); boost::shared_ptr<OtherType> po( new OtherType() ); overloaded( pm ); overloaded( pd ); // Compilers complain of ambiguous call to overloaded function. overloaded( po ); return 0; }