3333#include " parallel_backend.h"
3434#include " parallel_impl.h"
3535#include " iterator_impl.h"
36- #include " functional_impl.h" // for oneapi::dpl::identity
36+ #include " functional_impl.h" // for oneapi::dpl::identity, std::invoke
3737
3838#if _ONEDPL_HETERO_BACKEND
3939# include " hetero/algorithm_impl_hetero.h" // for __pattern_fill_n, __pattern_generate_n
@@ -2442,7 +2442,9 @@ __pattern_sort_by_key(_Tag, _ExecutionPolicy&&, _RandomAccessIterator1 __keys_fi
24422442
24432443 auto __beg = oneapi::dpl::make_zip_iterator (__keys_first, __values_first);
24442444 auto __end = __beg + (__keys_last - __keys_first);
2445- auto __cmp_f = [__comp](const auto & __a, const auto & __b) { return __comp (std::get<0 >(__a), std::get<0 >(__b)); };
2445+ auto __cmp_f = [__comp](const auto & __a, const auto & __b) {
2446+ return std::invoke (__comp, std::get<0 >(__a), std::get<0 >(__b));
2447+ };
24462448
24472449 __leaf_sort (__beg, __end, __cmp_f);
24482450}
@@ -2456,7 +2458,9 @@ __pattern_sort_by_key(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _Ran
24562458{
24572459 auto __beg = oneapi::dpl::make_zip_iterator (__keys_first, __values_first);
24582460 auto __end = __beg + (__keys_last - __keys_first);
2459- auto __cmp_f = [__comp](const auto & __a, const auto & __b) { return __comp (std::get<0 >(__a), std::get<0 >(__b)); };
2461+ auto __cmp_f = [__comp](const auto & __a, const auto & __b) {
2462+ return std::invoke (__comp, std::get<0 >(__a), std::get<0 >(__b));
2463+ };
24602464
24612465 using __backend_tag = typename __parallel_tag<_IsVector>::__backend_tag;
24622466
@@ -2699,8 +2703,9 @@ __pattern_nth_element(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec
26992703 _RandomAccessIterator __x;
27002704 do
27012705 {
2702- __x = __internal::__pattern_partition (__tag, ::std::forward<_ExecutionPolicy>(__exec), __first + 1 , __last,
2703- [&__comp, __first](const _Tp& __x) { return __comp (__x, *__first); });
2706+ __x = __internal::__pattern_partition (
2707+ __tag, std::forward<_ExecutionPolicy>(__exec), __first + 1 , __last,
2708+ [&__comp, __first](const _Tp& __x) { return std::invoke (__comp, __x, *__first); });
27042709 --__x;
27052710 if (__x != __first)
27062711 {
@@ -2715,7 +2720,7 @@ __pattern_nth_element(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec
27152720 else if (__x - __nth < 0 )
27162721 {
27172722 // if *x == *nth then we start the new partition at the next index where *x != *nth
2718- while (!__comp ( *__nth, *__x) && !__comp ( *__x, *__nth) && __x - __nth < 0 )
2723+ while (!std::invoke (__comp, *__nth, *__x) && !std::invoke (__comp, *__x, *__nth) && __x - __nth < 0 )
27192724 {
27202725 ++__x;
27212726 }
@@ -3220,15 +3225,15 @@ __pattern_includes(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _
32203225 if (__first1 == __last1 || __last2 - __first2 > __last1 - __first1 ||
32213226 // {1}: [**********] or [**********]
32223227 // {2}: [***********] [***********]
3223- __comp ( *__first2, *__first1) || __comp ( *(__last1 - 1 ), *(__last2 - 1 )))
3228+ std::invoke (__comp, *__first2, *__first1) || std::invoke (__comp, *(__last1 - 1 ), *(__last2 - 1 )))
32243229 return false ;
32253230
32263231 __first1 = ::std::lower_bound (__first1, __last1, *__first2, __comp);
32273232 if (__first1 == __last1)
32283233 return false ;
32293234
32303235 if (__last2 - __first2 == 1 )
3231- return !__comp ( *__first1, *__first2) && !__comp ( *__first2, *__first1);
3236+ return !std::invoke (__comp, *__first1, *__first2) && !std::invoke (__comp, *__first2, *__first1);
32323237
32333238 return __internal::__except_handler ([&]() {
32343239 return !__internal::__parallel_or (
@@ -3240,7 +3245,7 @@ __pattern_includes(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _
32403245 // 1. moving boundaries to "consume" subsequence of equal elements
32413246 auto __is_equal_sorted = [&__comp](_RandomAccessIterator2 __a, _RandomAccessIterator2 __b) -> bool {
32423247 // enough one call of __comp due to compared couple belongs to one sorted sequence
3243- return !__comp ( *__a, *__b);
3248+ return !std::invoke (__comp, *__a, *__b);
32443249 };
32453250
32463251 // 1.1 left bound, case "aaa[aaaxyz...]" - searching "x"
@@ -3260,8 +3265,8 @@ __pattern_includes(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _
32603265 // 2. testing is __a subsequence of the second range included into the first range
32613266 auto __b = ::std::lower_bound (__first1, __last1, *__i, __comp);
32623267
3263- assert (!__comp ( *(__last1 - 1 ), *__b));
3264- assert (!__comp ( *(__j - 1 ), *__i));
3268+ assert (!std::invoke (__comp, *(__last1 - 1 ), *__b));
3269+ assert (!std::invoke (__comp, *(__j - 1 ), *__i));
32653270 return !::std::includes (__b, __last1, __i, __j, __comp);
32663271 });
32673272 });
@@ -3846,9 +3851,10 @@ __brick_is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __las
38463851 /* __is_vector = */ ::std::true_type) noexcept
38473852{
38483853 using _SizeType = typename std::iterator_traits<_RandomAccessIterator>::difference_type;
3849- return __unseq_backend::__simd_first (
3850- __first, _SizeType (0 ), __last - __first,
3851- [&__comp](_RandomAccessIterator __it, _SizeType __i) { return __comp (__it[(__i - 1 ) / 2 ], __it[__i]); });
3854+ return __unseq_backend::__simd_first (__first, _SizeType (0 ), __last - __first,
3855+ [&__comp](_RandomAccessIterator __it, _SizeType __i) {
3856+ return std::invoke (__comp, __it[(__i - 1 ) / 2 ], __it[__i]);
3857+ });
38523858}
38533859
38543860template <class _Tag , class _ExecutionPolicy , class _RandomAccessIterator , class _Compare >
@@ -3868,7 +3874,7 @@ __is_heap_until_local(_RandomAccessIterator __first, _DifferenceType __begin, _D
38683874{
38693875 _DifferenceType __i = __begin;
38703876 for (; __i < __end; ++__i)
3871- if (__comp ( __first[(__i - 1 ) / 2 ], __first[__i]))
3877+ if (std::invoke (__comp, __first[(__i - 1 ) / 2 ], __first[__i]))
38723878 break ;
38733879 return __first + __i;
38743880}
@@ -3878,9 +3884,10 @@ _RandomAccessIterator
38783884__is_heap_until_local (_RandomAccessIterator __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp,
38793885 /* __is_vector = */ ::std::true_type) noexcept
38803886{
3881- return __unseq_backend::__simd_first (
3882- __first, __begin, __end,
3883- [&__comp](_RandomAccessIterator __it, _DifferenceType __i) { return __comp (__it[(__i - 1 ) / 2 ], __it[__i]); });
3887+ return __unseq_backend::__simd_first (__first, __begin, __end,
3888+ [&__comp](_RandomAccessIterator __it, _DifferenceType __i) {
3889+ return std::invoke (__comp, __it[(__i - 1 ) / 2 ], __it[__i]);
3890+ });
38843891}
38853892
38863893template <class _IsVector , class _ExecutionPolicy , class _RandomAccessIterator , class _Compare >
@@ -3916,7 +3923,7 @@ __brick_is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
39163923 /* __is_vector = */ ::std::true_type) noexcept
39173924{
39183925 return !__unseq_backend::__simd_or_iter (__first, __last - __first, [__first, &__comp](_RandomAccessIterator __it) {
3919- return __comp ( *(__first + (__it - __first - 1 ) / 2 ), *__it);
3926+ return std::invoke (__comp, *(__first + (__it - __first - 1 ) / 2 ), *__it);
39203927 });
39213928}
39223929
@@ -3933,10 +3940,10 @@ bool
39333940__is_heap_local (_RandomAccessIterator __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp,
39343941 /* __is_vector = */ ::std::true_type) noexcept
39353942{
3936- return !__unseq_backend::__simd_or_iter (__first + __begin, __end - __begin,
3937- [__first, &__comp](_RandomAccessIterator __it) {
3938- return __comp ( *(__first + (__it - __first - 1 ) / 2 ), *__it);
3939- });
3943+ return !__unseq_backend::__simd_or_iter (
3944+ __first + __begin, __end - __begin, [__first, &__comp](_RandomAccessIterator __it) {
3945+ return std::invoke (__comp, *(__first + (__it - __first - 1 ) / 2 ), *__it);
3946+ });
39403947}
39413948
39423949template <class _Tag , class _ExecutionPolicy , class _RandomAccessIterator , class _Compare >
@@ -4205,16 +4212,16 @@ __brick_lexicographical_compare(_RandomAccessIterator1 __first1, _RandomAccessIt
42054212 auto __n = ::std::min (__last1 - __first1, __last2 - __first2);
42064213 ::std::pair<_RandomAccessIterator1, _RandomAccessIterator2> __result = __unseq_backend::__simd_first (
42074214 __first1, __n, __first2, [__comp](const ref_type1 __x, const ref_type2 __y) mutable {
4208- return __comp ( __x, __y) || __comp ( __y, __x);
4215+ return std::invoke (__comp, __x, __y) || std::invoke (__comp, __y, __x);
42094216 });
42104217
42114218 if (__result.first == __last1 && __result.second != __last2)
42124219 { // if first sequence shorter than second
4213- return !__comp ( *__result.second , *__result.first );
4220+ return !std::invoke (__comp, *__result.second , *__result.first );
42144221 }
42154222 else
42164223 { // if second sequence shorter than first or both have the same number of elements
4217- return __comp ( *__result.first , *__result.second );
4224+ return std::invoke (__comp, *__result.first , *__result.second );
42184225 }
42194226 }
42204227}
@@ -4261,7 +4268,7 @@ __pattern_lexicographical_compare(__parallel_tag<_IsVector> __tag, _ExecutionPol
42614268 return __internal::__brick_mismatch (
42624269 __i, __j, __first2 + (__i - __first1), __first2 + (__j - __first1),
42634270 [&__comp](const _RefType1 __x, const _RefType2 __y) {
4264- return !__comp ( __x, __y) && !__comp ( __y, __x);
4271+ return !std::invoke (__comp, __x, __y) && !std::invoke (__comp, __y, __x);
42654272 },
42664273 _IsVector{})
42674274 .first ;
@@ -4270,11 +4277,11 @@ __pattern_lexicographical_compare(__parallel_tag<_IsVector> __tag, _ExecutionPol
42704277
42714278 if (__result == __last1 && __first2 + (__result - __first1) != __last2)
42724279 { // if first sequence shorter than second
4273- return !__comp ( *(__first2 + (__result - __first1)), *__result);
4280+ return !std::invoke (__comp, *(__first2 + (__result - __first1)), *__result);
42744281 }
42754282 else
42764283 { // if second sequence shorter than first or both have the same number of elements
4277- return __comp ( *__result, *(__first2 + (__result - __first1)));
4284+ return std::invoke (__comp, *__result, *(__first2 + (__result - __first1)));
42784285 }
42794286 });
42804287 }
0 commit comments