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

### 2411. `shared_ptr` is only contextually convertible to `bool`

Section: 20.11.3 [util.smartptr.shared] Status: C++17 Submitter: Jonathan Wakely Opened: 2014-06-21 Last modified: 2017-07-30

Priority: 0

View all other issues in [util.smartptr.shared].

View all issues with C++17 status.

Discussion:

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 20.11.3 [util.smartptr.shared] and 20.11.3.6 [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`.

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

Proposed resolution:

This wording is relative to N3936.

1. Change 20.11.3 [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.