This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++20 status.
pair construction in scoped and polymorphic allocatorsSection: 20.5.3.3[mem.poly.allocator.mem], 20.6.4[allocator.adaptor.members]Status:C++20Submitter: Casey CarterOpened: 2017-06-13Last modified: 2021-02-25
Priority:3
View all otherissues in [mem.poly.allocator.mem].
View all issues withC++20 status.
Discussion:
scoped_allocator_adaptor ([allocator.adaptor.syn]) andpolymorphic_allocator ([mem.poly.allocator.class]) have identical families of members namedconstruct:
template <class T, class... Args> void construct(T* p, Args&&... args);template <class T1, class T2, class... Args1, class... Args2> void construct(pair<T1,T2>* p, piecewise_construct_t, tuple<Args1...> x, tuple<Args2...> y);template <class T1, class T2> void construct(pair<T1,T2>* p);template <class T1, class T2, class U, class V> void construct(pair<T1,T2>* p, U&& x, V&& y);template <class T1, class T2, class U, class V> void construct(pair<T1,T2>* p, const pair<U, V>& pr);template <class T1, class T2, class U, class V> void construct(pair<T1,T2>* p, pair<U, V>&& pr);
Both allocators performuses_allocator construction, and therefore need special handling forpair constructions sincepair doesn't specializeuses_allocator (tuple gets all of that magic andpair is left out in the cold). Presumably, the intent is that theconstruct overloads whose first argument is a pointer topair capture allpair constructions. This is not the case: invokingconstruct with apair pointer and a non-constant lvaluepair resolves to thefirst overload when it is viable: it's a better match than thepair-pointer-and-const-lvalue-pair overload. The first overload notably does not properly perform piecewiseuses_allocator construction forpairs as intended.
[2017-07 Toronto Monday issue prioritization]
Priority 2; Marshall to work with Casey to reduce the negations in the wording.
Previous resolution [SUPERSEDED]:
Modify 20.5.3.3[mem.poly.allocator.mem] as indicated:
template <class T, class... Args> void construct(T* p, Args&&... args);-5-Requires: Uses-allocator construction of
-6-Effects: Construct aTwith allocatorresource()(see 20.2.8.2[allocator.uses.construction]) and constructor argumentsstd::forward<Args>(args)...is well-formed. [Note: Uses-allocator construction is always well formed for types that do not use allocators.—end note]Tobject in the storage whose address is represented bypby uses-allocator construction with allocatorresource()and constructor argumentsstd::forward<Args>(args)....-7-Throws: Nothing unless the constructor forTthrows.-?-Remarks: This function shall not participate in overload resolution unlessTis not a specialization ofpair.Modify 20.6.4[allocator.adaptor.members] as indicated:
template <class T, class... Args> void construct(T* p, Args&&... args);-9-Effects: […]
-?-Remarks: This function shall not participate in overload resolution unlessTis not a specialization ofpair.
[2017-11-02 Marshall and Casey provide updated wording]
[2017-11 Albuquerque Wednesday issue processing]
Move to Ready.
[2018-3-17 Adopted in Jacksonville]
Proposed resolution:
This wording is relative toN4659.
Modify 20.5.3.3[mem.poly.allocator.mem] as indicated:
template <class T, class... Args> void construct(T* p, Args&&... args);-5-Requires: Uses-allocator construction of
-6-Effects: Construct aTwith allocatorresource()(see 20.2.8.2[allocator.uses.construction]) and constructor argumentsstd::forward<Args>(args)...is well-formed. [Note: Uses-allocator construction is always well formed for types that do not use allocators.—end note]Tobject in the storage whose address is represented bypby uses-allocator construction with allocatorresource()and constructor argumentsstd::forward<Args>(args)....-7-Throws: Nothing unless the constructor forTthrows.-?-Remarks: This function shall not participate in overload resolution ifTis a specialization ofpair.
Modify 20.6.4[allocator.adaptor.members] as indicated:
template <class T, class... Args> void construct(T* p, Args&&... args);-9-Effects: […]
-?-Remarks: This function shall not participate in overload resolution ifTis a specialization ofpair.