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

@@ -206,7 +206,7 @@ public:
void construct(_Tp* __p, _Ts &&... __args)
{
_VSTD_LFTS::__lfts_user_alloc_construct(
__p, resource(), _VSTD::forward<_Ts>(__args)...
__p, *this, _VSTD::forward<_Ts>(__args)...
);
}
@@ -218,14 +218,14 @@ public:
::new ((void*)__p) pair<_T1, _T2>(piecewise_construct
, __transform_tuple(
typename __lfts_uses_alloc_ctor<
_T1, memory_resource*, _Args1...
_T1, polymorphic_allocator&, _Args1...
>::type()
, _VSTD::move(__x)
, typename __make_tuple_indices<sizeof...(_Args1)>::type{}
)
, __transform_tuple(
typename __lfts_uses_alloc_ctor<
_T2, memory_resource*, _Args2...
_T2, polymorphic_allocator&, _Args2...
>::type()
, _VSTD::move(__y)
, typename __make_tuple_indices<sizeof...(_Args2)>::type{}
@@ -289,23 +289,23 @@ private:
template <class ..._Args, size_t ..._Idx>
_LIBCPP_INLINE_VISIBILITY
tuple<allocator_arg_t const&, memory_resource*, _Args&&...>
tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>
__transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,
__tuple_indices<_Idx...>) const
__tuple_indices<_Idx...>)
{
using _Tup = tuple<allocator_arg_t const&, memory_resource*, _Args&&...>;
return _Tup(allocator_arg, resource(),
using _Tup = tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>;
return _Tup(allocator_arg, *this,
_VSTD::get<_Idx>(_VSTD::move(__t))...);
}
template <class ..._Args, size_t ..._Idx>
_LIBCPP_INLINE_VISIBILITY
tuple<_Args&&..., memory_resource*>
tuple<_Args&&..., polymorphic_allocator&>
__transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,
__tuple_indices<_Idx...>) const
__tuple_indices<_Idx...>)
{
using _Tup = tuple<_Args&&..., memory_resource*>;
return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource());
using _Tup = tuple<_Args&&..., polymorphic_allocator&>;
return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., *this);
}
_LIBCPP_INLINE_VISIBILITY