@@ -109,20 +109,61 @@ struct test_non_const
109109 }
110110};
111111
112+ struct not_implicitly_convertible
113+ {
114+ explicit not_implicitly_convertible (int v) {}
115+ };
116+
117+ template <typename It, typename DestIt, typename Void = void >
118+ struct is_replace_copy_well_formed : std::false_type {};
119+
120+ template <typename It, typename DestIt>
121+ struct is_replace_copy_well_formed <It, DestIt,
122+ std::void_t <decltype (oneapi::dpl::replace_copy(oneapi::dpl::execution::seq,
123+ std::declval<It>(),
124+ std::declval<It>(),
125+ std::declval<DestIt>(),
126+ {2 },
127+ {3 }))>> : std::true_type {};
128+
129+ template <typename It, typename DestIt, typename Void = void >
130+ struct is_replace_copy_if_well_formed : std::false_type {};
131+
132+ template <typename It, typename DestIt>
133+ struct is_replace_copy_if_well_formed <It, DestIt,
134+ std::void_t <decltype (oneapi::dpl::replace_copy_if(oneapi::dpl::execution::seq,
135+ std::declval<It>(),
136+ std::declval<It>(),
137+ std::declval<DestIt>(),
138+ int {}, // actually, some callable should be here but since the function does not have any constraints any type will work
139+ {3 }))>> : std::true_type {};
140+
141+ constexpr void test_default_template_argument_from_output_iterator ()
142+ {
143+ static_assert (is_replace_copy_well_formed<std::vector<not_implicitly_convertible>::iterator, std::vector<int >::iterator>::value,
144+ " Positive: The default argument of replace_copy shall be taken from output iterator" );
145+ static_assert (!is_replace_copy_well_formed<std::vector<int >::iterator, std::vector<not_implicitly_convertible>::iterator>::value,
146+ " Negative: The default argument of replace_copy shall be taken from output iterator" );
147+ static_assert (is_replace_copy_if_well_formed<std::vector<not_implicitly_convertible>::iterator, std::vector<int >::iterator>::value,
148+ " Positive: The default argument of replace_copy_if shall be taken from output iterator" );
149+ static_assert (!is_replace_copy_if_well_formed<std::vector<int >::iterator, std::vector<not_implicitly_convertible>::iterator>::value,
150+ " Positive: The default argument of replace_copy_if shall be taken from output iterator" );
151+ }
152+
112153void test_empty_list_initialization_for_replace_copy ()
113154{
114155 {
115156 std::vector<int > v{3 ,6 ,0 ,4 ,0 ,7 ,8 ,0 ,3 ,4 };
116157 std::vector<int > dest (v.size ());
117158 std::vector<int > expected{0 ,6 ,0 ,4 ,0 ,7 ,8 ,0 ,0 ,4 };
118- oneapi::dpl::replace_copy (oneapi::dpl::execution::seq, v.begin (), v.end (), dest.begin (), 3 , {});
159+ oneapi::dpl::replace_copy (oneapi::dpl::execution::seq, v.begin (), v.end (), dest.begin (), { 3 } , {});
119160 EXPECT_TRUE (dest == expected, " wrong effect from calling oneapi::dpl::replace_copy with empty list-initialized value and with `seq` policy" );
120161 }
121162 {
122163 std::vector<int > v{3 ,6 ,0 ,4 ,0 ,7 ,8 ,0 ,3 ,4 };
123164 std::vector<int > dest (v.size ());
124165 std::vector<int > expected{0 ,6 ,0 ,4 ,0 ,7 ,8 ,0 ,0 ,4 };
125- oneapi::dpl::replace_copy (oneapi::dpl::execution::unseq, v.begin (), v.end (), dest.begin (), 3 , {});
166+ oneapi::dpl::replace_copy (oneapi::dpl::execution::unseq, v.begin (), v.end (), dest.begin (), { 3 } , {});
126167 EXPECT_TRUE (dest == expected, " wrong effect from calling oneapi::dpl::replace_copy with empty list-initialized value and with `unseq` policy" );
127168 }
128169
@@ -148,7 +189,7 @@ void test_empty_list_initialization_for_replace_copy()
148189 std::vector<int > expected{0 ,6 ,0 ,4 ,0 ,7 ,8 ,0 ,0 ,4 };
149190 sycl::buffer<int > buf (v);
150191 sycl::buffer<int > dest_buf (v);
151- oneapi::dpl::replace_copy (oneapi::dpl::execution::dpcpp_default, oneapi::dpl::begin (buf), oneapi::dpl::end (buf), oneapi::dpl::begin (dest_buf), 3 , {});
192+ oneapi::dpl::replace_copy (oneapi::dpl::execution::dpcpp_default, oneapi::dpl::begin (buf), oneapi::dpl::end (buf), oneapi::dpl::begin (dest_buf), { 3 } , {});
152193 EXPECT_TRUE (dest == expected, " wrong effect from calling oneapi::dpl::replace_copy with empty list-initialized value and with `device_policy` policy" );
153194#endif
154195}
@@ -220,6 +261,7 @@ main()
220261 test_algo_basic_double<std::int32_t >(run_for_rnd_fw<test_non_const<std::int32_t >>());
221262#endif
222263
264+ test_default_template_argument_from_output_iterator ();
223265 test_empty_list_initialization_for_replace_copy ();
224266 test_empty_list_initialization_for_replace_copy_if ();
225267
0 commit comments