Search code examples
c++tbb

TBB parallel_for: why Body::operator() argument is not const?


This page from the Intel TBB Developer Reference lists requirements for the parallel_for template parameter Body, among them this one:

void Body::operator()( Range& range ) const

Why is the Range argument passed to the operator() without const? It'd be good to see an example where it's necessary and/or useful.


Solution

  • I think we were just trying to keep the requirements as minimal as possible, and not trying to guess what creative uses people might come up with. But it would seem now that const usage is the only use case in practice. The most creative use of parallel_for I came up with was the one in tbb::parallel_sort, and even that one takes a const Range.