This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.
std::make_shared_for_overwrite/std::allocate_shared_for_overwrite
Section: 20.3.2.2.7 [util.smartptr.shared.create] Status: WP Submitter: Jiang An Opened: 2023-12-16 Last modified: 2024-11-28
Priority: 2
View all other issues in [util.smartptr.shared.create].
View all issues with WP status.
Discussion:
Currently, only destructions of non-array (sub)objects created in std::make_shared
and std::allocate_shared
are specified in 20.3.2.2.7 [util.smartptr.shared.create]. Presumably, objects created in
std::make_shared_for_overwrite
and std::allocate_shared_for_overwrite
should be destroyed by plain
destructor calls.
[2024-03-11; Reflector poll]
Set priority to 2 after reflector poll in December 2023.
This was the P1020R1 author's intent (see LWG reflector mail in November 2018) but it was never clarified in the wording. This fixes that.
[2024-08-21; Move to Ready at LWG telecon]
[Wrocław 2024-11-23; Status changed: Voting → WP.]
Proposed resolution:
This wording is relative to N4964.
Modify 20.3.2.2.7 [util.smartptr.shared.create] as indicated:
template<class T, ...> shared_ptr<T> make_shared(args); template<class T, class A, ...> shared_ptr<T> allocate_shared(const A& a, args); template<class T, ...> shared_ptr<T> make_shared_for_overwrite(args); template<class T, class A, ...> shared_ptr<T> allocate_shared_for_overwrite(const A& a, args);[…]
-7- Remarks:
[…]
(7.11) — When a (sub)object of non-array type
U
that was initialized bymake_shared
,make_shared_for_overwrite
, orallocate_shared_for_overwrite
is to be destroyed, it is destroyed via the expressionpv->~U()
wherepv
points to that object of typeU
.[…]