smart_ptr subclass as template function parameter issues with Sun Studio

Hi, I have the following problem, when using the Sun Studio C++ compiler and boost::smart_ptr. Consider the following code: class A {}; class B : public A {}; template<typename T> void fn(shared_ptr<A> a, T t) { } void foo() { shared_ptr<A> a; shared_ptr<B> b; fn(a, 1); fn(b, 1); } this compiles fine with a number of compilers, including gcc, icc and MS Visual Studio. But when I try to compile it using the Sun Studio compiler, I get: Error: Could not find a match for fn<T>(boost::shared_ptr<B>, int) needed in foo(). it only works if I explicitly cast the derived class' shared_ptr to that of the base class, that is, instead of: fn(b, 1); I need to use: fn((shared_ptr<A>) b, 1); which seems rather inconvenient. is the fn(b, 1); style really bad? is there a way to make the Sun compiler accept this form? Akos
participants (1)
-
Maróy Ákos