Issue 3007: allocate_shared should rebind allocator to cv-unqualified value_type for construction (original) (raw)
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.
3007. allocate_shared should rebind allocator to _cv_-unqualified value_type for construction
Section: 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 toallocate_shared such that its value_type isU. However U can be a const orvolatile 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 make_shared(args);
template<class T, class A, ...>
shared_ptr 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.1) —
2. (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>.
3. (7.6) — When a (sub)object of non-array typeUis 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.
4. (7.7) — When a (sub)object of non-array typeUis 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>.
5. […]