allocate_shared should rebind allocator to cv-unqualified value_type for constructionSection: 20.3.2.2.7 [util.smartptr.shared.create] Status: C++20 Submitter: Glen Joseph Fernandes Opened: 2017-08-06 Last modified: 2021-02-25
Priority: 0
View all other issues in [util.smartptr.shared.create].
View all issues with C++20 status.
Discussion:
The remarks for the allocate_shared family of functions
specify that when constructing a (sub)object of type U, it uses a
rebound copy of the allocator a passed to
allocate_shared such that its value_type is
U. However U can be a const or
volatile qualified type, and [allocator.requirements] specify
that the value_type must be cv-unqualified.
[ 2017-11-01 Moved to Tentatively Ready after 6 positive votes for P0 on c++std-lib. ]
[2018-3-17 Adopted in Jacksonville]
Proposed resolution:
This resolution is relative to N4687.
Edit 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);[…]
-7- Remarks:
[…]
(7.5) — When a (sub)object of a non-array type
Uis specified to have an initial value ofv, orU(l...), wherel...is a list of constructor arguments,allocate_sharedshall initialize this (sub)object via the expression
(7.5.1) —
allocator_traits<A2>::construct(a2, pv, v)or(7.5.2) —
allocator_traits<A2>::construct(a2, pv, l...)respectively, where
pvpoints to storage suitable to hold an object of typeUanda2of typeA2is a rebound copy of the allocator a passed toallocate_sharedsuch that itsvalue_typeisremove_cv_t<U>.(7.6) — When a (sub)object of non-array type
Uis specified to have a default initial value,make_sharedshall initialize this (sub)object via the expression::new(pv) U(), wherepvhas typevoid*and points to storage suitable to hold an object of typeU.(7.7) — When a (sub)object of non-array type
Uis specified to have a default initial value,allocate_sharedshall initialize this (sub)object via the expressionallocator_traits<A2>::construct(a2, pv), wherepvpoints to storage suitable to hold an object of typeUanda2of typeA2is a rebound copy of the allocator a passed toallocate_sharedsuch that itsvalue_typeisremove_cv_t<U>.[…]