Title
weak_ptr::element_type needs remove_extent_t
Status
c++20
Section
[util.smartptr.weak]
Submitter
Stephan T. Lavavej

Created on 2017-07-14.00:00:00 last changed 46 months ago

Messages

Date: 2017-07-17.16:37:46

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 {
    public:
      using element_type = remove_extent_t<T>;
      […]
    };
    
Date: 2017-07-17.00:00:00

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

Date: 2017-07-14.00:00:00

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 {
  public:
    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:

  • 8.2.2 Class template weak_ptr

    • 8.2.2.1 weak_ptr constructors

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".

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2017-11-13 19:01:36adminsetstatus: voting -> wp
2017-10-17 18:35:42adminsetstatus: ready -> voting
2017-07-17 16:37:46adminsetmessages: + msg9431
2017-07-17 16:37:46adminsetstatus: new -> ready
2017-07-16 13:18:32adminsetmessages: + msg9408
2017-07-14 00:00:00admincreate