
Hi, Following snippet compiles fine with 1.34.1 -------------------------- #include "boost/shared_ptr.hpp" class Base { public: virtual ~Base() {} }; class Derived; boost::shared_ptr<Base> foo() { return boost::shared_ptr<Derived>(); } class Derived : public Base {}; -------------------------- It fails though with boost 1.36: a.cpp: In function `boost::shared_ptr<Base> foo()': a.cpp:13: error: conversion from `boost::shared_ptr<Derived>' to non-scalar type `boost::shared_ptr<Base>' requested Looks like it caused by additional argument in template constructor sp_enable_if_convertible. Is it intentional? Can we still support old use case? Gennadiy

Gennadiy Rozental:
Hi,
Following snippet compiles fine with 1.34.1
-------------------------- #include "boost/shared_ptr.hpp"
class Base { public: virtual ~Base() {} };
class Derived;
boost::shared_ptr<Base> foo() { return boost::shared_ptr<Derived>(); }
class Derived : public Base {};
This doesn't look legal to me. It does compile with MSVC (7.1) and g++ (3.4.6), and doesn't (as I would expect) with Como and Borland. At the point where foo is defined, there is no conversion from Derived* to Base*, so the instantiation of shared_ptr<Base>::shared_ptr<Base>( shared_ptr<Derived> const& ) would fail. I don't think that the compiler is required to postpone all template instantiations until the end of the translation unit.
participants (2)
-
Gennadiy Rozental
-
Peter Dimov