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

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

Priority: Not Prioritized

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

View all issues with NAD status.


The standard library uses the operator unspecified-bool-type() const idiom in five places. In three of those places ( [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 [unique.ptr.single.observers] paragraph 11 and [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. ]