File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,11 @@ public:
50
50
...template <typename T>
51
51
...class Slice<T>::iterator final {
52
52
...public:
53
+ ...#if __cplusplus >= 202002L
54
+ ... using iterator_category = std::contiguous_iterator_tag;
55
+ ...#else
53
56
... using iterator_category = std::random_access_iterator_tag;
57
+ ...#endif
54
58
... using value_type = T;
55
59
... using pointer = T *;
56
60
... using reference = T &;
Original file line number Diff line number Diff line change @@ -216,7 +216,11 @@ class Slice final
216
216
template <typename T>
217
217
class Slice <T>::iterator final {
218
218
public:
219
+ #if __cplusplus >= 202002L
220
+ using iterator_category = std::contiguous_iterator_tag;
221
+ #else
219
222
using iterator_category = std::random_access_iterator_tag;
223
+ #endif
220
224
using value_type = T;
221
225
using difference_type = std::ptrdiff_t ;
222
226
using pointer = typename std::add_pointer<T>::type;
@@ -234,6 +238,9 @@ class Slice<T>::iterator final {
234
238
iterator &operator +=(difference_type) noexcept ;
235
239
iterator &operator -=(difference_type) noexcept ;
236
240
iterator operator +(difference_type) const noexcept ;
241
+ friend inline iterator operator +(difference_type lhs, iterator rhs) {
242
+ return rhs + lhs;
243
+ }
237
244
iterator operator -(difference_type) const noexcept ;
238
245
difference_type operator -(const iterator &) const noexcept ;
239
246
@@ -249,6 +256,12 @@ class Slice<T>::iterator final {
249
256
void *pos;
250
257
std::size_t stride;
251
258
};
259
+
260
+ #if __cplusplus >= 202002L
261
+ static_assert (std::ranges::contiguous_range<rust::Slice<const uint8_t >>);
262
+ static_assert (std::contiguous_iterator<rust::Slice<const uint8_t >::iterator>);
263
+ #endif
264
+
252
265
#endif // CXXBRIDGE1_RUST_SLICE
253
266
254
267
#ifndef CXXBRIDGE1_RUST_BOX
You can’t perform that action at this time.
0 commit comments