Custom iterator works with std::sort but not with tbb::parallel_sort?

前端 未结 4 651
日久生厌
日久生厌 2021-02-15 18:13

I am trying to use tbb::parallel_sort to sort 2 arrays at the same time. Intel\'s documentation here says https://software.intel.com/en-us/node/506167 The req

4条回答
  •  一向
    一向 (楼主)
    2021-02-15 18:57

    The class quick_sort_range in tbb/parallel_sort.h contains RandomAccessIterator begin; member which is copy-initialized in one its constructor and default-initialized and then assigned in the other constructor. Thus it requires iterators which are default©-constructable and assignable.

    So, the TBB documentation is not correct claiming the same requirements as std::sort since the later requires just random-access iterators which are not required to be assignable while TBB implementation requires it for versions <= 4.4.

    The default-constructable and assignable requirements can be fixed but move or copy-constructable will likely remain (making the claim in the documentation correct). You can report this issue on TBB Forum.

    You can safely add default© constructors and assignment operator to your code to compile it with tbb::parallel_sort as far as I can see.

    Here is the online compiler with your snippet: http://coliru.stacked-crooked.com/a/47dafd091d36a9c4

提交回复
热议问题