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

Section: 23.11.1.2.4 [unique.ptr.single.observers], 23.11.3.5 [util.smartptr.shared.obs] Status: NAD Submitter: Beman Dawes Opened: 2007-06-14 Last modified: 2016-02-10

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 (23.14.13.2.3 [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 23.11.1.2.4 [unique.ptr.single.observers] paragraph 11 and 23.11.3.5 [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. ]