oneapi::tbb::parallel_sort range overload - get the "range" argument by a forwarding reference #650
ivankochin
started this conversation in
Design discussions
Replies: 1 comment 3 replies
-
As far as I understand, the change in PR #605 formally allows applying parallel_sort to const containers. I guess it will still result in compile-time error somewhere around the use of swap, but does not that worsen the diagnostics? Maybe it makes sense to add an explicitly deleted overload for const ranges, so that the rvalue overload is only applicable for temporaries? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
parallel_sort
overload for ranges is thestd::ranges::sort()
function template. Thestd::ranged::sort()
gets the range argument by the forwarding reference. So it was decided to get the argument by the forwarding reference and then use perfect forwarding to get begin/end pair for this range.std::ranges::begin()/end()
to get iterators. Butoneapi::tbb::parallel_sort
ranges overload usesstd::begin()/end()
.std::begin()/end()
and C++20std::ranges::begin()/end()
interfaces:std::begin()/end()
has only overloads for const and non-const lvalue references.std::ranges::begin()
uses forwarding reference to call the correspondingobj.begin()
method.std::ranges::sort()
calls thestd::ranges::begin()/end()
methods without passing the range without callingstd::forward
for the arguments, so the arguments passed to thestd::ranges::begin()/end()
are always lvalue.std::begin()/end()
andstd::ranges::begin()/end()
in this case.Beta Was this translation helpful? Give feedback.
All reactions