Boost logo

Boost :

Subject: Re: [boost] [smart_ptr][thread][test] breaking change on shared_ptr operator bool.
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2012-12-12 05:45:14

Olaf van der Spek-3 wrote
> On Mon, Dec 10, 2012 at 5:23 PM, Peter Dimov <

> lists@

> > wrote:
>> Olaf van der Spek wrote:
>>> On Mon, Dec 10, 2012 at 4:27 PM, Peter Dimov <

> lists@

> > wrote:
>>> > Olaf van der Spek wrote:
>>> >
>>> >> What's the rationale for this breaking change?
>>> >
>>> > Compatibility with C++11?
>>> The 'old' boost::shared_ptr seemed to work fine on C++11.
>> Sure. It seems that you're being deliberately obtuse for rhetorical
>> reasons,
>> but all right.
>> In C++11, the idiomatic way to make a class convertible to bool is via an
>> explicit operator bool. The language has been specifically changed to
>> support this use case. The standard library has been changed to use this
>> idiom for each of its convertible to bool types, including
>> std::shared_ptr.
>> For better or worse, this will be how convertible to bool C++11 types
>> will
>> behave.
> I know. And boost::shared_ptr behaving the same as std::shared_ptr is
> nice, I'm just wondering whether that's more important than
> maintaining compatibility with older Boost releases.
> What real problem with keeping the old behavor have?

Imagine you need to use boost::shared_ptr in a part of your application and
std::shared_ptr in another part. It would be surprising if the behavior for
the same operation is not the same, isn't it?

I think Boost libraries implementing c++11 libraries should be as close as
possible as the standard. This doesn't mean that the author can not make
some deviations.

Respect to compatibility, it is always better to have a deprecation period,
but the required change in this case is so minor that documenting the break
and how to take care of it should be enough.

View this message in context:
Sent from the Boost - Dev mailing list archive at

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