From 0fbb14395daff3a57174da9be77bcffef52ad27e Mon Sep 17 00:00:00 2001
From: Jonathan Wakely
-I implemented the fix for LWG
Fix the allocator model to deal with const elements somehow, which breaks compatibility -with existing allocators unprepared for const elements here. We would need to extend the allocator +
Fix the allocator model to deal with const elements somehow, which breaks compatibility +with existing allocators unprepared for const elements here. We would need to extend the allocator requirements to allow const T* to be passed here, and fix our default to const_cast.
Fix allocate_shared to remove const before calling construct, which -changes the experience for C++17 customers because allocate_shared constructs a T -instead of a const T, but not in a way substantially different to edits +
Fix allocate_shared to remove const before calling construct, which +changes the experience for C++17 customers because allocate_shared constructs a T +instead of a const T, but not in a way substantially different to edits P0674 already made here.
Back out allocate_shared's interaction with this part of the allocator model (reverting +
Back out allocate_shared's interaction with this part of the allocator model (reverting
this part of P0674 and reopening LWG
Go around the problem by prohibiting allocate_shared<const T>, which breaks +
Go around the problem by prohibiting allocate_shared<const T>, which breaks existing C++17 customers.
-Billy O'Neal argues that only (2) preserves the design intent P0674 +Billy O'Neal argues that only (2) preserves the design intent P0674 while maintaining compatibility for most allocators and most C++17 customers.
Peter Dimov argues that (1) isn't likely to break enough to matter. @@ -80,8 +80,8 @@ template<class T, class A, ...>(7.1) — […]
[…]
(7.5) — When a (sub)object of a non-array type U is specified to have an initial -value of v, or U(l...), where l... is a list of constructor arguments, +
(7.5) — When a (sub)object of a non-array type U is specified to have an initial +value of v, or U(l...), where l... is a list of constructor arguments, allocate_shared shall initialize this (sub)object via the expression
(7.5.2) — allocator_traits<A2>::construct(a2, pv, l...)
-respectively, where pv points to storage suitable to hold an object of type -remove_cv_t<U> and a2 of type A2 is a -rebound copy of the allocator a passed to allocate_shared such that its value_type +respectively, where pv points to storage suitable to hold an object of type +remove_cv_t<U> and a2 of type A2 is a +rebound copy of the allocator a passed to allocate_shared such that its value_type is remove_cv_t<U>.
-The currently proposed resolution is meaningless, because "(allocated) storage suitable to hold an object of type -remove_cv_t<U>" is always "storage suitable to hold an object of type U", and vice versa. -Also, the current specification doesn't seem to specify the type of pv in the cases of allocator_shared, +The currently proposed resolution is meaningless, because "(allocated) storage suitable to hold an object of type +remove_cv_t<U>" is always "storage suitable to hold an object of type U", and vice versa. +Also, the current specification doesn't seem to specify the type of pv in the cases of allocator_shared, because pv is merely specified to point some storage instead of an object.
+ +(7.1) — […]
[…]
(7.5) — When a (sub)object of a non-array type U is specified to have an initial -value of v, or U(l...), where l... is a list of constructor arguments, +
(7.5) — When a (sub)object of a non-array type U is specified to have an initial +value of v, or U(l...), where l... is a list of constructor arguments, allocate_shared shall initialize this (sub)object via the expression
(7.5.2) — allocator_traits<A2>::construct(a2, pv, l...)
-respectively, where pv has type remove_cv_t<U>* and points to storage -suitable to hold an object of type U and a2 of type A2 is a rebound copy of -the allocator a passed to allocate_shared such that its value_type is +respectively, where pv has type remove_cv_t<U>* and points to storage +suitable to hold an object of type U and a2 of type A2 is a rebound copy of +the allocator a passed to allocate_shared such that its value_type is remove_cv_t<U>.
(7.6) — […]
(7.7) — When a (sub)object of non-array type U is specified to have a default -initial value, allocate_shared shall initialize this (sub)object via the expression -allocator_traits<A2>::construct(a2, pv), where pv has type remove_cv_t<U>* -and points to storage suitable to hold an object of type U and a2 of type A2 -is a rebound copy of the allocator a passed to allocate_shared such that its value_type +
(7.7) — When a (sub)object of non-array type U is specified to have a default +initial value, allocate_shared shall initialize this (sub)object via the expression +allocator_traits<A2>::construct(a2, pv), where pv has type remove_cv_t<U>* +and points to storage suitable to hold an object of type U and a2 of type A2 +is a rebound copy of the allocator a passed to allocate_shared such that its value_type is remove_cv_t<U>.
remove_cv_t<U>*
.
Accepting this proposed resolution would also resolve issue +Set status to Tentatively Ready after six votes in favour during reflector poll. +
+