xo-alloc: utest: revert allocator changes in nested type

This commit is contained in:
Roland Conybeare 2025-12-03 00:14:38 -05:00
commit 67cf4cc625

View file

@ -94,13 +94,13 @@ namespace xo {
/** gc-enabled allocator **/ /** gc-enabled allocator **/
namespace { namespace {
/** Setup test with custom allocator /** Setup test with custom allocator
* *
**/ **/
template <typename Nested, typename GcObjectInterface> template <typename Nested, typename GcObjectInterface>
struct TestClass : public GcObjectInterface { struct TestClass : public GcObjectInterface {
TestClass() = default; TestClass() = default;
explicit TestClass(const Nested & member1) : member1_{member1} {} explicit TestClass(const Nested & member1) : member1_{member1} {}
// using allocator_type = Allocator; // using allocator_type = Allocator;
// using allocator_traits = xo::gc::gc_allocator_traits<Allocator>; // using allocator_traits = xo::gc::gc_allocator_traits<Allocator>;
@ -182,21 +182,22 @@ namespace xo {
Nested member1_; Nested member1_;
}; };
template <typename Allocator> //template <typename Allocator>
struct MemberType { struct MemberType {
public: public:
using allocator_type = Allocator; //using allocator_type = Allocator;
using vector_allocator_type = typename std::allocator_traits<Allocator>::template rebind_alloc<gp<Object>>; //using vector_allocator_type = typename std::allocator_traits<Allocator>::template rebind_alloc<gp<Object>>;
using vector_type = std::vector<gp<Object>, vector_allocator_type>; using vector_type = std::vector<gp<Object>>;
//using vector_type = std::vector<gp<Object>, vector_allocator_type>;
public: public:
MemberType() : ctor_ran_{true} {} MemberType() : ctor_ran_{true} {}
explicit MemberType(const Allocator & alloc) //explicit MemberType(const Allocator & alloc)
: member2_{vector_allocator_type(alloc)}, ctor_ran_{true} {} //: member2_{vector_allocator_type(alloc)}, ctor_ran_{true} {}
explicit MemberType(const vector_type & mem2) : member2_{mem2}, ctor_ran_{true} {} explicit MemberType(const vector_type & mem2) : member2_{mem2}, ctor_ran_{true} {}
MemberType(const vector_type & mem2, const Allocator & alloc) //MemberType(const vector_type & mem2, const Allocator & alloc)
: member2_{mem2, vector_allocator_type(alloc)}, ctor_ran_{true} {} //: member2_{mem2, vector_allocator_type(alloc)}, ctor_ran_{true} {}
vector_type member2_; vector_type member2_;
std::size_t ctor_ran_ = false; std::size_t ctor_ran_ = false;
@ -223,6 +224,7 @@ namespace xo {
using MyObjectInterface = gc_allocator_traits<ex_allocator>::template object_interface<ex_allocator>; using MyObjectInterface = gc_allocator_traits<ex_allocator>::template object_interface<ex_allocator>;
using NestedElementAllocator = xo::gc::allocator<gp<Object>>; using NestedElementAllocator = xo::gc::allocator<gp<Object>>;
using NestedType = MemberType; using NestedType = MemberType;
//using NestedType = MemberType<NestedElementAllocator>;
using MyType = TestClass<NestedType, MyObjectInterface>; using MyType = TestClass<NestedType, MyObjectInterface>;
using MyAllocator = xo::gc::allocator<MyType>; using MyAllocator = xo::gc::allocator<MyType>;
@ -273,7 +275,7 @@ namespace xo {
REQUIRE(false); REQUIRE(false);
} }
} }
} }
} /*namespace ut*/ } /*namespace ut*/