Revised 2017-07-31 at 03:39:37 UTC

Tentative Issues

3001. weak_ptr::element_type needs remove_extent_t

Section: [util.smartptr.weak] Status: Tentatively Ready Submitter: Stephan T. Lavavej Opened: 2017-07-14 Last modified: 2017-07-17

Priority: 0

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


C++17's shared_ptr<T>::element_type is remove_extent_t<T>, but weak_ptr<T>::element_type is T. They should be the same, but this was lost over time.

First, N4562 "Working Draft, C++ Extensions for Library Fundamentals, Version 2" 8.2.2 [memory.smartptr.weak] specified:

namespace std {
namespace experimental {
inline namespace fundamentals_v2 {

  template<class T> class weak_ptr {
    typedef typename remove_extent_t<T> element_type;

(The typename here was spurious.)

Then, P0220R1 "Adopt Library Fundamentals V1 TS Components for C++17 (R1)" listed:

This obscured the fact that the Library Fundamentals TS had altered weak_ptr::element_type.

Finally, P0414R2 "Merging shared_ptr changes from Library Fundamentals to C++17" missed the change to weak_ptr::element_type, so it wasn't applied to C++17.

Peter Dimov has confirmed that this was unintentionally lost, and that "boost::weak_ptr defines element_type in the same way as shared_ptr".

[ 2017-07-17 Moved to Tentatively Ready after 6 positive votes on c++std-lib. ]

Proposed resolution:

This resolution is relative to N4659.

  1. Edit [util.smartptr.weak], class template weak_ptr synopsis, as indicated:

    template<class T> class weak_ptr {
      using element_type = remove_extent_t<T>;