Title
shared_ptr is only contextually convertible to bool
Status
c++17
Section
[util.smartptr.shared]
Submitter
Jonathan Wakely

Created on 2014-06-21.00:00:00 last changed 89 months ago

Messages

Date: 2014-11-08.16:43:57

Proposed resolution:

This wording is relative to N3936.

  1. Change [util.smartptr.shared] p2 as indicated:

    -2- Specializations of shared_ptr shall be CopyConstructible, CopyAssignable, and LessThanComparable, allowing their use in standard containers. Specializations of shared_ptr shall be contextually convertible to bool, allowing their use in boolean expressions and declarations in conditions. The template parameter T of shared_ptr may be an incomplete type.

Date: 2014-11-08.16:43:57

[ Urbana 2014-11-07: Move to Ready ]

Date: 2014-06-21.00:00:00

N3920 made this edit, which is correct but unrelated to the support for arrays:

Change 20.7.2.2 [util.smartptr.shared] p2 as follows:

Specializations of shared_ptr shall be CopyConstructible, CopyAssignable, and LessThanComparable, allowing their use in standard containers. Specializations of shared_ptr shall be contextually convertible to bool, allowing their use in boolean expressions and declarations in conditions. […]

That change is actually fixing a defect in the current wording and should be applied directly to the working paper, not just to the Library Fundamentals TS. The declarations of the conversion operator in [util.smartptr.shared] and [util.smartptr.shared.obs] are explicit which contradicts the "convertible to bool" statement. The intention is definitely for shared_ptr to only be contextually convertible to bool.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2015-05-22 18:31:21adminsetstatus: ready -> wp
2014-11-08 16:43:57adminsetmessages: + msg7175
2014-11-08 16:43:57adminsetstatus: new -> ready
2014-06-29 11:48:08adminsetmessages: + msg7083
2014-06-21 00:00:00admincreate