Make retrieval of the vector size more generic

This also enables the use of the function with "containers" that
don't have a size function but implement an overload for `std::size()`,
like c-arrays with fixed sizes.
This commit is contained in:
Johannes Schmidt 2026-03-12 14:10:07 +01:00
parent b094b164a0
commit eb97638743

View file

@ -75,10 +75,10 @@ public:
template<typename VectorType, typename FuncType>
void ParallelFor(const VectorType& items, bool preChunk, const FuncType& func)
{
using SizeType = decltype(items.size());
SizeType totalCount = items.size();
SizeType chunks = preChunk ? m_ThreadCount : totalCount;
const auto totalCount = std::size(items);
using SizeType = std::remove_const_t<decltype(totalCount)>;
const auto chunks = preChunk ? m_ThreadCount : totalCount;
auto lock = AcquireLock();
@ -103,7 +103,7 @@ public:
offset += count;
}
ASSERT(offset == items.size());
ASSERT(offset == totalCount);
}
bool IsWorkerThread() const;