This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.
Section: 126.96.36.199 [util.smartptr.shared] Status: CD1 Submitter: Peter Dimov Opened: 2007-08-24 Last modified: 2016-02-10
Priority: Not Prioritized
View all other issues in [util.smartptr.shared].
View all issues with CD1 status.
A discussion on comp.std.c++ has identified a contradiction in the shared_ptr specification. The shared_ptr move constructor and the cast functions are missing postconditions for the get() accessor.
[ Bellevue: ]
Move to "ready", adopting the first (Peter's) proposed resolution.
Note to the project editor: there is an editorial issue here. The wording for the postconditions of the casts is slightly awkward, and the editor should consider rewording "If w is the return value...", e. g. as "For a return value w...".
Add to 188.8.131.52.2 [util.smartptr.shared.const]:
shared_ptr(shared_ptr&& r); template<class Y> shared_ptr(shared_ptr<Y>&& r);
Postconditions: *this shall contain the old value of r. r shall be empty.
Add to 184.108.40.206.10 [util.smartptr.shared.cast]:
template<class T, class U> shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r);
template<class T, class U> shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r);
template<class T, class U> shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r);
Alberto Ganesh Barbati has written an alternative proposal where he suggests (among other things) that the casts be respecified in terms of the aliasing constructor as follows:
Change 220.127.116.11.10 [util.smartptr.shared.cast]:
If r is empty, an empty shared_ptr<T>; otherwise, a shared_ptr<T> object that stores static_cast<T*>(r.get()) and shares ownership with r.
When dynamic_cast<T*>(r.get()) returns a nonzero value, a shared_ptr<T> object that stores a copy of it and shares ownership with r;
Otherwise, an empty shared_ptr<T> object.
If r is empty, an empty shared_ptr<T>; otherwise, a shared_ptr<T> object that stores const_cast<T*>(r.get()) and shares ownership with r.
This takes care of the missing postconditions for the casts by bringing in the aliasing constructor postcondition "by reference".