Boost logo

Boost Users :

From: artc_prismcs (artc_at_[hidden])
Date: 2002-05-09 15:00:31


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;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net