mirror of
https://github.com/Icinga/icinga2.git
synced 2026-05-28 04:12:13 -04:00
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:
parent
b094b164a0
commit
eb97638743
1 changed files with 4 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue