diff --git a/include/momo/Array.h b/include/momo/Array.h index a76bfae1..c08df38d 100644 --- a/include/momo/Array.h +++ b/include/momo/Array.h @@ -494,18 +494,8 @@ class Array template explicit Array(ArgIterator begin, ArgIterator end, MemManager memManager = MemManager()) - : mData(std::forward_iterator ? SMath::Dist(begin, end) : 0, - std::move(memManager)) + : Array(begin, end, std::move(memManager), nullptr) { - typedef typename ItemTraits::template Creator> IterCreator; - MemManager& thisMemManager = GetMemManager(); - for (ArgIterator iter = begin; iter != end; ++iter) - { - if constexpr (std::forward_iterator) - pvAddBackNogrow(FastMovableFunctor(IterCreator(thisMemManager, *iter))); - else - pvAddBack(FastMovableFunctor(IterCreator(thisMemManager, *iter))); - } } Array(std::initializer_list items) @@ -921,6 +911,27 @@ class Array { } + template + explicit Array(ArgIterator begin, ArgIterator end, MemManager&& memManager, std::nullptr_t) + : mData(SMath::Dist(begin, end), std::move(memManager)) + { + typedef typename ItemTraits::template Creator> IterCreator; + MemManager& thisMemManager = GetMemManager(); + for (ArgIterator iter = begin; iter != end; ++iter) + pvAddBackNogrow(FastMovableFunctor(IterCreator(thisMemManager, *iter))); + } + + template + requires (!std::forward_iterator) + explicit Array(ArgIterator begin, ArgIterator end, MemManager&& memManager, std::nullptr_t) + : mData(std::move(memManager)) + { + typedef typename ItemTraits::template Creator> IterCreator; + MemManager& thisMemManager = GetMemManager(); + for (ArgIterator iter = begin; iter != end; ++iter) + pvAddBack(FastMovableFunctor(IterCreator(thisMemManager, *iter))); + } + size_t pvGrowCapacity(size_t minNewCapacity, ArrayGrowCause growCause, bool linear) const { size_t newCapacity = Settings::GrowCapacity(GetCapacity(),