You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement P2248R8: Enable list-initialization for algorithms (#2398)
Implementing Iterator-based algorithms only. Ranges-based implementation is going on separately.
There are no breaking changes. All the breaking changes in C++ standard come into `std::range`s namespace but even they are irrelevant to oneDPL because we implement list-initialization enabling right away, so there is no template parameters swapping.
There are two oversights for P2248:
- `find_last` was not included. However, it's irrelevant for Iterator-based algorithms because `find_last` exists in `std::ranges` namespace only.
- uninitialized_fill was not included. I've implemented that proactively as was requested. There is a NB comment to include this oversight for C++26 but it's not done at this moment.
Binary Search-like algorithms from P2248 (e.g., lower_bound, upper_bound, etc.) are also irrelevant because our API for those does not have T-like template parameter.
auto it = oneapi::dpl::remove(oneapi::dpl::execution::par_unseq, v_custom.begin(), v_custom.end(), {});
139
+
EXPECT_TRUE(it == v_custom.begin() + 6, "not all empty list-initialized values are properly removed by oneapi::dpl::remove with `par_unseq` policy");
140
+
v_custom.erase(it, v_custom.end());
141
+
EXPECT_TRUE(v_custom == expected_custom, "wrong effect from calling oneapi::dpl::remove with empty list-initialized value and with `par_unseq` policy");
142
+
}
143
+
#if TEST_DPCPP_BACKEND_PRESENT
144
+
std::vector<int> v{3,6,0,4,0,7,8,0,3,4};
145
+
std::vector<int> expected{3,6,4,7,8,3,4};
146
+
std::size_t idx = 0;
147
+
{
148
+
sycl::buffer<int> buf(v);
149
+
auto it = oneapi::dpl::remove(oneapi::dpl::execution::dpcpp_default, oneapi::dpl::begin(buf), oneapi::dpl::end(buf), {});
150
+
idx = it.get_idx();
151
+
EXPECT_TRUE(idx == 7, "not all empty list-initialized values are properly removed by oneapi::dpl::remove with `device_policy` policy");
152
+
}
153
+
v.erase(v.begin() + idx, v.end());
154
+
EXPECT_TRUE(v == expected, "wrong effect from calling oneapi::dpl::remove with empty list-initialized value and with `device_policy` policy");
155
+
#endif
156
+
}
157
+
108
158
int
109
159
main()
110
160
{
@@ -133,5 +183,7 @@ main()
133
183
EXPECT_TRUE(MemoryChecker::alive_objects() == 0, "wrong effect from remove,remove_if: number of ctor and dtor calls is not equal");
0 commit comments