I’ve been using the Intel Threading Building Blocks (TBB) library for a while now, and I finally figured out how to overcome one of the annoyances I had with it.

All of the examples I’ve been able to find show how to iterate over a range of integers. I couldn’t find how to directly iterate over a range of doubles. I worked around this by iterating over integers and translating back to doubles in the inner operator() function. I finally figured out the answer, after reading the Reference Manual (as they say, rtfm).

The trick is that the blocked_range construct can accept, in addition to integers, random access iterators. So, with a range:

    tbb::blocked_range< std::vector<double>::iterator > (
    bunch_of_doubles.start(), bunch_of_doubles.end() );  

I can now parallelize a group of doubles.

Of course, this assumes that you have a container ready. Luckily, I happened to have one ready. In other cases, it’s probably best to continue and shuffle between ints and doubles.