weak_ptr::element_type
needs remove_extent_t
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.
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.)
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
.
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>; […] };