Skip to content

Commit 9441e5c

Browse files
committed
Implement local_accessor iterator funcs
1 parent 7d6106d commit 9441e5c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

sycl/include/sycl/accessor.hpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,12 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
23472347
// Use base classes constructors
23482348
using local_acc::local_acc;
23492349

2350+
using value_type = DataT;
2351+
using iterator = value_type *;
2352+
using const_iterator = const DataT *;
2353+
using reverse_iterator = std::reverse_iterator<iterator>;
2354+
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
2355+
23502356
#ifdef __SYCL_DEVICE_ONLY__
23512357

23522358
// __init needs to be defined within the class not through inheritance.
@@ -2366,6 +2372,23 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
23662372
}
23672373

23682374
#endif
2375+
2376+
public:
2377+
iterator begin() const noexcept { return &this->operator[](id<Dimensions>()); }
2378+
iterator end() const noexcept { return begin() + this->size(); }
2379+
2380+
const_iterator cbegin() const noexcept { return const_iterator(begin()); }
2381+
const_iterator cend() const noexcept { return const_iterator(end()); }
2382+
2383+
reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
2384+
reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
2385+
2386+
const_reverse_iterator crbegin() const noexcept {
2387+
return const_reverse_iterator(end());
2388+
}
2389+
const_reverse_iterator crend() const noexcept {
2390+
return const_reverse_iterator(begin());
2391+
}
23692392
};
23702393

23712394
/// Image accessors.

0 commit comments

Comments
 (0)