List и Allocator [std::initializer_list]
Есть проблемы со следующими конструкторами
List(const List& ls)
: List(std::allocator_traits<Allocator>::select_on_container_copy_construction(ls.get_allocator())) {
genList(ls.sz);
for (Node* cur = root->right, *curLs = ls.root->right;
cur != root; cur = cur->right, curLs = curLs->right) {
NodeAllocTraits::construct(allocN, cur, curLs->value, cur->left, cur->right);
}
}
List(std::initializer_list<int> c, const Allocator& alloc = Allocator()) : allocN(alloc) {
genList(c.size());
for (Node* it = root->right; it != root; it = it->right) {
NodeAllocTraits::construct(allocN, it, it->left, it->right);
}
}
Для проверки работы конструкторов есть следующий тест
TEST_CASE("List(const List& other)", "[List: Construct]") {
SetupTest();
const size_t size = 5;
List<TypeWithCounts, AllocatorWithCount<TypeWithCounts>> l1 = {1, 2, 3, 4, 5};
List<TypeWithCounts, AllocatorWithCount<TypeWithCounts>> l2(l1);
REQUIRE(l2.size() == size);
REQUIRE(MemoryManager::allocator_allocated != 0);
REQUIRE(MemoryManager::allocator_constructed == size * 2);
REQUIRE(AreListsEqual(l1, l2));
for (auto& value : l1) {
REQUIRE(*value.copy_c == 2); // тест не проходит,получается 1 == 2
}
}
Как создать копии элементов при вызове конструктора List(const List& other)?