Skip to content

Commit e5f1766

Browse files
committed
Fix max_size()
1 parent 332e5fe commit e5f1766

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

sycl/include/sycl/accessor.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,7 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
11461146
using value_type = DataT;
11471147
using reference = DataT &;
11481148
using const_reference = const DataT &;
1149+
using difference_type = size_t;
11491150

11501151
// The list of accessor constructors with their arguments
11511152
// -------+---------+-------+----+-----+--------------
@@ -1873,7 +1874,9 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
18731874

18741875
size_t byte_size() const noexcept { return size() * sizeof(DataT); }
18751876

1876-
size_t max_size() const noexcept { return std::vector<DataT>().max_size(); }
1877+
size_t max_size() const noexcept {
1878+
std::numeric_limits<difference_type>::max();
1879+
}
18771880

18781881
bool empty() const noexcept { return size() == 0; }
18791882

@@ -2503,6 +2506,8 @@ class __SYCL_SPECIAL_CLASS accessor<DataT, Dimensions, AccessMode,
25032506
// Use base classes constructors
25042507
using local_acc::local_acc;
25052508

2509+
using difference_type = size_t;
2510+
25062511
#ifdef __SYCL_DEVICE_ONLY__
25072512

25082513
// __init needs to be defined within the class not through inheritance.
@@ -2561,7 +2566,9 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
25612566

25622567
size_t byte_size() const noexcept { return this->size() * sizeof(DataT); }
25632568

2564-
size_t max_size() const noexcept { return std::vector<DataT>().max_size(); }
2569+
size_t max_size() const noexcept {
2570+
return std::numeric_limits<difference_type>::max();
2571+
}
25652572

25662573
bool empty() const noexcept { return this->size() == 0; }
25672574
};

0 commit comments

Comments
 (0)