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
From: "artc_prismcs"
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?
boost::shared_ptr and the language are at fault. The templated copy constructor is always considered by the overload resolution; its definition might not compile, but its declaration is fine. There are some tricks one can play with the language, but so far, I haven't been able to find a solution.
#include
class MyType { }; class DerivedType : public MyType { }; class OtherType {};
void overloaded( const boost::shared_ptr<MyType> & p ) {} void overloaded( const boost::shared_ptr<OtherType> & p ) {}
In this particular situation, you can turn the first overload into a template so that OtherType would go to the non-template version and the rest of the types would go to the template.
participants (2)
-
artc_prismcs
-
Peter Dimov