template <typename FwdIt>
void use_iterator(FwdIt it) {
auto f0 = std::async([&]{ ++it; return true; });
auto f1 = std::async([&]{ ++it; return true; });
f0.get();
f1.get();
}
Of course, this use is silly and I don't think any parallel implementation of an algorithm would do something like this. However, I don't see it prohibited. Since the element access functions are required to not cause data races it seems the iterators would need to synchronise their state which is almost certainly not intended.
Is there somewhere a guarantee that the element access functions are invoked only on different objects from different threads or when invoked in an interleaved manner? ...or this lack of guarantee a defect which needs to be addressed?
The specification in this area seems to be written along the lines of "everybody knows what is meant here". Although I agree with the general sentiment, I think it is necessary to formulate both how users are constrained with respect to the customization points as well as how algorithms are contrained on how these are used. Especially the latter is entirely lacking. Neither the user of the parallel algorithms will be entirely free on what can be used with these algorithms nor will the implementer of the algorithms be entirely free on how the entities passed are used.