Boost logo

Boost :

Subject: Re: [boost] [smart_ptr][thread][test] breaking change on shared_ptr operator bool.
From: Peter Dimov (lists_at_[hidden])
Date: 2012-12-10 11:23:14


Olaf van der Spek wrote:
> On Mon, Dec 10, 2012 at 4:27 PM, Peter Dimov <lists_at_[hidden]> 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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk