Boost logo

Boost :

From: Ulrich Eckhardt (uli_at_[hidden])
Date: 2004-02-12 04:13:51

Firstly, this is not a regression, the behaviour was present in 1.30, too.
I have attached a simple program that should demonstrate the behaviour, but
the core is these lines, with foo being derived from enable_shared_from_this:

  // 1
  std::auto_ptr<foo> g(new foo);
  boost::shared_ptr<foo> f(g);
  // 2
  std::auto_ptr<foo> g(new foo);
  boost::shared_ptr<foo const> f(g);
  // 3
  std::auto_ptr<foo const> g(new foo);
  boost::shared_ptr<foo const> f(g);

In all three cases, I'd expect to be able to call shared_from_this(). However,
only the first two cases really work. I think it boils down to the function
detail::sp_enable_shared_from_this() in the ctor of shared_ptr<> that takes
an auto_ptr<>.

I'm not certain if there is a fix for this and what that fix would be, but I
think the problem is that the 'right' function is not taken because at one
place we have a 'foo' and at the other we have a 'foo const'.

BTW: I believe that a conversion from auto_ptr<T> to shared_ptr<T const>
doesn't compile on VC6, but I can't test that ATM(I'm not at work). If any
kind soul wants to, they could add such a conversion to the regression-tests.
Same goes for volatile probably.

greetings and thumbs up

Ulrich Eckhardt

Boost list run by bdawes at, gregod at, cpdaniel at, john at