This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.
Section: 20.3.2.3 [util.smartptr.weak] Status: C++20 Submitter: Stephan T. Lavavej Opened: 2017-07-14 Last modified: 2021-02-25
Priority: 0
View all other issues in [util.smartptr.weak].
View all issues with C++20 status.
Discussion:
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".[ 2017-07-17 Moved to Tentatively Ready after 6 positive votes on c++std-lib. ]
Proposed resolution:
This resolution is relative to N4659.
Edit 20.3.2.3 [util.smartptr.weak], class template weak_ptr synopsis, as indicated:
template<class T> class weak_ptr { public: using element_type = remove_extent_t<T>; […] };