18 Slice(T* start,
size_t len) {
24 T*
data() {
return start; }
27 size_t size() {
return len; }
31 int result = len / sliceSize;
32 return len % sliceSize == 0 ? result : result+1;
36 operator bool() {
return len > 0 && start!=
nullptr; }
40 int start_pos = idx * sliceSize;
41 int end_pos = start_pos + sliceSize;
46 if (start_pos < len) {
47 assert(start!=
nullptr);
48 return Slice(start + start_pos, end_pos - start_pos);
50 return Slice(
nullptr, 0);