This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.

### 686. `unique_ptr` and `shared_ptr` fail to specify non-convertibility to int for unspecified-bool-type

Section: 20.11.1.3.5 [unique.ptr.single.observers], 20.11.3.6 [util.smartptr.shared.obs] Status: NAD Submitter: Beman Dawes Opened: 2007-06-14 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [unique.ptr.single.observers].

View all issues with NAD status.

Discussion:

The standard library uses the `operator unspecified-bool-type() const` idiom in five places. In three of those places (20.14.17.3.4 [func.wrap.func.cap], function capacity for example) the returned value is constrained to disallow unintended conversions to int. The standardese is

> The return type shall not be convertible to `int`.

This constraint is omitted for `unique_ptr` and `shared_ptr`. It should be added for those.

[ Bellevue: ]

> Close as NAD. Accepting paper N2435 makes it irrelevant.

Proposed resolution:

To the Returns paragraph for `operator unspecified-bool-type() const` of 20.11.1.3.5 [unique.ptr.single.observers] paragraph 11 and 20.11.3.6 [util.smartptr.shared.obs] paragraph 16, add the sentence:

> The return type shall not be convertible to `int`.

[ Kona (2007): Uncertain if `nullptr` will address this issue. ]