Skip to content

Commit 3d059e3

Browse files
authored
Fix the default template argument for the new value type in replace[_if] (#2605)
1 parent 971feb5 commit 3d059e3

2 files changed

Lines changed: 15 additions & 18 deletions

File tree

documentation/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Fixed Issues
1515
------------
1616
- Fixed validation of minimal requirements for range-based algorithms. They require clang 16 and newer
1717
instead of the corresponding libc++ versions.
18+
- Fixed the default template argument for the new value type in `ranges::replace` and `ranges::replace_if`
19+
to not use projections.
1820

1921
New in 2022.11.0
2022
=======================

include/oneapi/dpl/pstl/glue_algorithm_ranges_impl.h

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,19 +1027,17 @@ struct __swap_ranges_fn
10271027

10281028
inline constexpr __internal::__swap_ranges_fn swap_ranges;
10291029

1030-
// [alg.replace_if]
1030+
// [alg.replace]
10311031

10321032
namespace __internal
10331033
{
1034-
10351034
struct __replace_if_fn
10361035
{
1037-
template<typename _ExecutionPolicy, std::ranges::random_access_range _R,
1038-
typename _Proj = std::identity, typename _T = oneapi::dpl::projected_value_t<std::ranges::iterator_t<_R>, _Proj>,
1039-
std::indirect_unary_predicate<std::projected<std::ranges::iterator_t<_R>, _Proj>> _Pred>
1036+
template <typename _ExecutionPolicy, std::ranges::random_access_range _R, typename _Proj = std::identity,
1037+
typename _T = std::ranges::range_value_t<_R>,
1038+
std::indirect_unary_predicate<std::projected<std::ranges::iterator_t<_R>, _Proj>> _Pred>
10401039
requires oneapi::dpl::is_execution_policy_v<std::remove_cvref_t<_ExecutionPolicy>>
1041-
&& std::indirectly_writable<std::ranges::iterator_t<_R>, const _T&>
1042-
&& std::ranges::sized_range<_R>
1040+
&& std::ranges::sized_range<_R> && std::indirectly_writable<std::ranges::iterator_t<_R>, const _T&>
10431041

10441042
std::ranges::borrowed_iterator_t<_R>
10451043
operator()(_ExecutionPolicy&& __exec, _R&& __r, _Pred __pred, const _T& __new_value, _Proj __proj = {}) const
@@ -1056,23 +1054,21 @@ struct __replace_if_fn
10561054

10571055
inline constexpr __internal::__replace_if_fn replace_if;
10581056

1059-
// [alg.replace]
1060-
10611057
namespace __internal
10621058
{
1063-
10641059
struct __replace_fn
10651060
{
1066-
template<typename _ExecutionPolicy, std::ranges::random_access_range _R, typename _Proj = std::identity,
1067-
typename _T1 = oneapi::dpl::projected_value_t<std::ranges::iterator_t<_R>, _Proj>, typename _T2 = _T1>
1061+
template <typename _ExecutionPolicy, std::ranges::random_access_range _R, typename _Proj = std::identity,
1062+
typename _T1 = oneapi::dpl::projected_value_t<std::ranges::iterator_t<_R>, _Proj>,
1063+
typename _T2 = std::ranges::range_value_t<_R>>
10681064
requires oneapi::dpl::is_execution_policy_v<std::remove_cvref_t<_ExecutionPolicy>>
1069-
&& std::indirectly_writable<std::ranges::iterator_t<_R>, const _T2&>
1070-
&& std::indirect_binary_predicate<std::ranges::equal_to,
1071-
std::projected<std::ranges::iterator_t<_R>, _Proj>, const _T1*>
1072-
&& std::ranges::sized_range<_R>
1065+
&& std::ranges::sized_range<_R> && std::indirectly_writable<std::ranges::iterator_t<_R>, const _T2&>
1066+
&& std::indirect_binary_predicate<std::ranges::equal_to,
1067+
std::projected<std::ranges::iterator_t<_R>, _Proj>, const _T1*>
10731068

10741069
std::ranges::borrowed_iterator_t<_R>
1075-
operator()(_ExecutionPolicy&& __exec, _R&& __r, const _T1& __old_value, const _T2& __new_value, _Proj __proj = {}) const
1070+
operator()(_ExecutionPolicy&& __exec, _R&& __r, const _T1& __old_value, const _T2& __new_value,
1071+
_Proj __proj = {}) const
10761072
{
10771073
return oneapi::dpl::ranges::replace_if(
10781074
std::forward<_ExecutionPolicy>(__exec), std::forward<_R>(__r),
@@ -1081,7 +1077,6 @@ struct __replace_fn
10811077
__new_value, __proj);
10821078
}
10831079
}; //__replace_fn
1084-
10851080
} //__internal
10861081

10871082
inline constexpr __internal::__replace_fn replace;

0 commit comments

Comments
 (0)