Skip to content

Commit eb97638

Browse files
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.
1 parent b094b16 commit eb97638

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/base/workqueue.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ class WorkQueue
7575
template<typename VectorType, typename FuncType>
7676
void ParallelFor(const VectorType& items, bool preChunk, const FuncType& func)
7777
{
78-
using SizeType = decltype(items.size());
7978

80-
SizeType totalCount = items.size();
81-
SizeType chunks = preChunk ? m_ThreadCount : totalCount;
79+
const auto totalCount = std::size(items);
80+
using SizeType = std::remove_const_t<decltype(totalCount)>;
81+
const auto chunks = preChunk ? m_ThreadCount : totalCount;
8282

8383
auto lock = AcquireLock();
8484

@@ -103,7 +103,7 @@ class WorkQueue
103103
offset += count;
104104
}
105105

106-
ASSERT(offset == items.size());
106+
ASSERT(offset == totalCount);
107107
}
108108

109109
bool IsWorkerThread() const;

0 commit comments

Comments
 (0)