I'm using TBB library like this:
// Concurrency.hpp
#include <tbb/spin_mutex.h>
#include <tbb/mutex.h>
#include <tbb/parallel_for.h>
#include <tbb/parallel_reduce.h>
// Restrict templates to work for only the specified set of types
template<class T, class O = T>
using IntegerOnly = std::enable_if_t<std::is_integral<T>::value, O>;
// An extra helper template
template<class Fn, class I>
static IntegerOnly<I, void> loop_(const tbb::blocked_range<I> &range, Fn &&fn)
{
for (I i = range.begin(); i < range.end(); ++i) fn(i);
}
// Calling TBB parallel-for by this template
template<class It, class Fn>
static void for_each(It from, It to, Fn &&fn, size_t granularity = 1)
{
tbb::parallel_for(tbb::blocked_range{from, to, granularity}, // => Error happens at this line
[&fn, from](const auto &range) {
loop_(range, std::forward<Fn>(fn));
});
}
I'm receiving this error:
Concurrency.hpp:43:32: error: use of class template 'blocked_range' requires template arguments blocked_range.h:45:7: note: template is declared here
Did anybody run into this error before? How to resolve it?