LWG 2969 "polymorphic_allocator::construct() shouldn't pass resource()"

Patch from Arthur O'Dwyer.

In the TS, `uses_allocator` construction for `pair` tried to use an allocator
type of `memory_resource*`, which is incorrect because `memory_resource*` is
not an allocator type. LWG 2969 fixed it to use `polymorphic_allocator` as the
allocator type instead.

https://wg21.link/lwg2969

(D47090 included this in `<memory_resource>`; at Eric's request, I've split
this out into its own patch applied to the existing
`<experimental/memory_resource>` instead.)

Reviewed as https://reviews.llvm.org/D47109


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@333384 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2018-05-29 00:08:47 +00:00
parent d1e11a1a6f
commit 40a29e79c2
9 changed files with 318 additions and 35 deletions

View File

@@ -79,12 +79,12 @@ struct CountCopies {
};
struct CountCopiesAllocV1 {
typedef ex::memory_resource* allocator_type;
allocator_type alloc;
typedef ex::polymorphic_allocator<char> allocator_type;
ex::memory_resource *alloc;
int count;
CountCopiesAllocV1() : alloc(nullptr), count(0) {}
CountCopiesAllocV1(std::allocator_arg_t, allocator_type const& a,
CountCopiesAllocV1 const& o) : alloc(a), count(o.count + 1)
CountCopiesAllocV1 const& o) : alloc(a.resource()), count(o.count + 1)
{}
CountCopiesAllocV1(CountCopiesAllocV1 const& o) : count(o.count + 1) {}
@@ -92,12 +92,12 @@ struct CountCopiesAllocV1 {
struct CountCopiesAllocV2 {
typedef ex::memory_resource* allocator_type;
allocator_type alloc;
typedef ex::polymorphic_allocator<char> allocator_type;
ex::memory_resource *alloc;
int count;
CountCopiesAllocV2() : alloc(nullptr), count(0) {}
CountCopiesAllocV2(CountCopiesAllocV2 const& o, allocator_type const& a)
: alloc(a), count(o.count + 1)
: alloc(a.resource()), count(o.count + 1)
{ }
CountCopiesAllocV2(CountCopiesAllocV2 const& o) : count(o.count + 1) {}