Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Differential D58879 Diff 199196 test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair.pass.cpp
Changeset View
Changeset View
Standalone View
Standalone View
test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair.pass.cpp
Show All 38 Lines | AllocController P; | ||||
static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); | static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); | ||||
Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); | Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); | ||||
assert(ptr); | assert(ptr); | ||||
Alloc CA(P); | Alloc CA(P); | ||||
SA A(CA); | SA A(CA); | ||||
A.construct(ptr); | A.construct(ptr); | ||||
assert(checkConstruct<>(ptr->first, UA_AllocArg, CA)); | assert(checkConstruct<>(ptr->first, UA_AllocArg, CA)); | ||||
assert(checkConstruct<>(ptr->second, UA_AllocLast, CA)); | assert(checkConstruct<>(ptr->second, UA_AllocLast, CA)); | ||||
assert((P.checkConstruct<std::piecewise_construct_t const&, | assert((P.checkConstruct<std::piecewise_construct_t&&, | ||||
std::tuple<std::allocator_arg_t, SA&>&&, | std::tuple<std::allocator_arg_t const&, SA const&>&&, | ||||
std::tuple<SA&>&& | std::tuple<SA const&>&& | ||||
Quuxplusone: What's the rationale for all these test changes? I strongly suspect that they are a bad idea… | |||||
These are all simply adding const or changing the reference type (I am not saying that necessarily makes them okay though). Because of how uses_allocator_construction_args is defined in the standard, make_tuple is passed an rvalue piecewise_construct (that is why the first part of this changed). I think the others are similar. I will take a closer look at this and see which test is correct. zoecarver: These are all simply adding `const` or changing the reference type (I am not saying that… | |||||
>(CA, ptr))); | >(CA, ptr))); | ||||
A.destroy(ptr); | A.destroy(ptr); | ||||
std::free(ptr); | std::free(ptr); | ||||
} | } | ||||
P.reset(); | P.reset(); | ||||
{ | { | ||||
using T = UsesAllocatorV3<VoidAlloc, 0>; | using T = UsesAllocatorV3<VoidAlloc, 0>; | ||||
using U = NotUsesAllocator<VoidAlloc, 0>; | using U = NotUsesAllocator<VoidAlloc, 0>; | ||||
using Pair = std::pair<T, U>; | using Pair = std::pair<T, U>; | ||||
using Alloc = CountingAllocator<Pair>; | using Alloc = CountingAllocator<Pair>; | ||||
using SA = std::scoped_allocator_adaptor<Alloc>; | using SA = std::scoped_allocator_adaptor<Alloc>; | ||||
static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); | static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); | ||||
Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); | Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); | ||||
assert(ptr); | assert(ptr); | ||||
Alloc CA(P); | Alloc CA(P); | ||||
SA A(CA); | SA A(CA); | ||||
A.construct(ptr); | A.construct(ptr); | ||||
assert(checkConstruct<>(ptr->first, UA_AllocArg, CA)); | assert(checkConstruct<>(ptr->first, UA_AllocArg, CA)); | ||||
assert(checkConstruct<>(ptr->second, UA_None)); | assert(checkConstruct<>(ptr->second, UA_None)); | ||||
assert((P.checkConstruct<std::piecewise_construct_t const&, | assert((P.checkConstruct<std::piecewise_construct_t&&, | ||||
std::tuple<std::allocator_arg_t, SA&>&&, | std::tuple<std::allocator_arg_t const&, SA const&>&&, | ||||
std::tuple<>&& | std::tuple<>&& | ||||
>(CA, ptr))); | >(CA, ptr))); | ||||
A.destroy(ptr); | A.destroy(ptr); | ||||
std::free(ptr); | std::free(ptr); | ||||
} | } | ||||
} | } | ||||
void test_with_inner_alloc() | void test_with_inner_alloc() | ||||
Show All 15 Lines | AllocController PInner; | ||||
Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); | Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); | ||||
assert(ptr); | assert(ptr); | ||||
Outer O(POuter); | Outer O(POuter); | ||||
Inner I(PInner); | Inner I(PInner); | ||||
SA A(O, I); | SA A(O, I); | ||||
A.construct(ptr); | A.construct(ptr); | ||||
assert(checkConstruct<>(ptr->first, UA_AllocArg, I)); | assert(checkConstruct<>(ptr->first, UA_AllocArg, I)); | ||||
assert(checkConstruct<>(ptr->second, UA_AllocLast)); | assert(checkConstruct<>(ptr->second, UA_AllocLast)); | ||||
assert((POuter.checkConstruct<std::piecewise_construct_t const&, | assert((POuter.checkConstruct<std::piecewise_construct_t&&, | ||||
std::tuple<std::allocator_arg_t, SAInner&>&&, | std::tuple<std::allocator_arg_t const&, SAInner const&>&&, | ||||
std::tuple<SAInner&>&& | std::tuple<SAInner const&>&& | ||||
>(O, ptr))); | >(O, ptr))); | ||||
A.destroy(ptr); | A.destroy(ptr); | ||||
std::free(ptr); | std::free(ptr); | ||||
} | } | ||||
PInner.reset(); | PInner.reset(); | ||||
POuter.reset(); | POuter.reset(); | ||||
{ | { | ||||
using T = UsesAllocatorV3<VoidAlloc2, 0>; | using T = UsesAllocatorV3<VoidAlloc2, 0>; | ||||
using U = NotUsesAllocator<VoidAlloc2, 0>; | using U = NotUsesAllocator<VoidAlloc2, 0>; | ||||
using Pair = std::pair<T, U>; | using Pair = std::pair<T, U>; | ||||
using Outer = CountingAllocator<Pair, 1>; | using Outer = CountingAllocator<Pair, 1>; | ||||
using Inner = CountingAllocator<Pair, 2>; | using Inner = CountingAllocator<Pair, 2>; | ||||
using SA = std::scoped_allocator_adaptor<Outer, Inner>; | using SA = std::scoped_allocator_adaptor<Outer, Inner>; | ||||
using SAInner = std::scoped_allocator_adaptor<Inner>; | using SAInner = std::scoped_allocator_adaptor<Inner>; | ||||
static_assert(!std::uses_allocator<T, Outer>::value, ""); | static_assert(!std::uses_allocator<T, Outer>::value, ""); | ||||
static_assert(std::uses_allocator<T, Inner>::value, ""); | static_assert(std::uses_allocator<T, Inner>::value, ""); | ||||
Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); | Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); | ||||
assert(ptr); | assert(ptr); | ||||
Outer O(POuter); | Outer O(POuter); | ||||
Inner I(PInner); | Inner I(PInner); | ||||
SA A(O, I); | SA A(O, I); | ||||
A.construct(ptr); | A.construct(ptr); | ||||
assert(checkConstruct<>(ptr->first, UA_AllocArg, I)); | assert(checkConstruct<>(ptr->first, UA_AllocArg, I)); | ||||
assert(checkConstruct<>(ptr->second, UA_None)); | assert(checkConstruct<>(ptr->second, UA_None)); | ||||
assert((POuter.checkConstruct<std::piecewise_construct_t const&, | assert((POuter.checkConstruct<std::piecewise_construct_t&&, | ||||
std::tuple<std::allocator_arg_t, SAInner&>&&, | std::tuple<std::allocator_arg_t const&, SAInner const&>&&, | ||||
std::tuple<>&& | std::tuple<>&& | ||||
>(O, ptr))); | >(O, ptr))); | ||||
A.destroy(ptr); | A.destroy(ptr); | ||||
std::free(ptr); | std::free(ptr); | ||||
} | } | ||||
} | } | ||||
int main(int, char**) { | int main(int, char**) { | ||||
test_no_inner_alloc(); | test_no_inner_alloc(); | ||||
test_with_inner_alloc(); | test_with_inner_alloc(); | ||||
return 0; | return 0; | ||||
} | } |
What's the rationale for all these test changes? I strongly suspect that they are a bad idea: if the original tests fail after your patch, I think there must be something wrong with your patch.