DPC++ Runtime
Runtime libraries for oneAPI DPC++
|
|
Go to the documentation of this file.
131 #include <type_traits>
133 #define _SYCL_SPAN_TEMPLATE_VIS
134 #define _SYCL_SPAN_INLINE_VISIBILITY inline
140 using byte =
unsigned char;
144 #if defined(__SYCL_DEVICE_ONLY__)
145 #define _SYCL_SPAN_ASSERT(x, m) ((void)0)
147 #define _SYCL_SPAN_ASSERT(x, m) assert(((x) && m))
151 template <
typename _Tp,
size_t _Extent = dynamic_extent>
class span;
155 template <
class _Tp,
size_t _Extent>
163 template <
class _Tp,
size_t _Sz>
169 template <
class _Tp,
class _ElementType,
class =
void>
172 template <
class _Tp,
class _ElementType>
177 typename std::enable_if<!__is_span<_Tp>::value, std::nullptr_t>::type,
179 typename std::enable_if<!__is_std_array<_Tp>::value,
180 std::nullptr_t>::type,
182 typename std::enable_if<!std::is_array_v<_Tp>, std::nullptr_t>::type,
184 decltype(data(std::declval<_Tp>())),
185 decltype(size(std::declval<_Tp>())),
188 typename std::enable_if<
189 std::is_convertible_v<std::remove_pointer_t<decltype(data(
190 std::declval<_Tp &>()))> (*)[],
192 std::nullptr_t>::type>> :
public std::true_type {};
211 template <
size_t _Sz = _Extent,
212 std::enable_if_t<_Sz == 0, std::nullptr_t> =
nullptr>
215 constexpr
span(
const span &) noexcept =
default;
218 template <
size_t _Sz = _Extent>
224 "size mismatch in span's constructor (&_arr)[_Sz]");
232 "size mismatch in span's constructor (ptr, len)");
238 "size mismatch in span's constructor (ptr, ptr)");
241 template <
class _OtherElementType,
244 std::nullptr_t> =
nullptr>
246 std::array<_OtherElementType, _Extent> &__arr) noexcept
247 : __data{__arr.data()} {}
250 class _OtherElementType,
253 std::nullptr_t> =
nullptr>
255 const std::array<_OtherElementType, _Extent> &__arr) noexcept
256 : __data{__arr.data()} {}
258 template <
class _Container>
262 std::nullptr_t> =
nullptr)
263 : __data{std::data(__c)} {
265 "size mismatch in span's constructor (range)");
268 template <
class _Container>
270 const _Container &__c,
273 std::nullptr_t> =
nullptr)
274 : __data{std::data(__c)} {
276 "size mismatch in span's constructor (range)");
279 template <
class _OtherElementType>
283 std::is_convertible_v<_OtherElementType (*)[],
element_type (*)[]>,
284 std::nullptr_t> =
nullptr)
285 : __data{__other.
data()} {}
289 template <
size_t _Count>
292 static_assert(_Count <= _Extent,
"Count out of range in span::first()");
296 template <
size_t _Count>
299 static_assert(_Count <= _Extent,
"Count out of range in span::last()");
307 "Count out of range in span::first(count)");
308 return {data(), __count};
315 "Count out of range in span::last(count)");
316 return {data() + size() - __count, __count};
319 template <
size_t _Offset,
size_t _Count = dynamic_extent>
323 static_assert(_Offset <= _Extent,
"Offset out of range in span::subspan()");
324 static_assert(_Count ==
dynamic_extent || _Count <= _Extent - _Offset,
325 "Offset + count out of range in span::subspan()");
330 return _ReturnType{data() + _Offset,
339 "Offset out of range in span::subspan(offset, count)");
341 "Count out of range in span::subspan(offset, count)");
343 return {data() + __offset, size() - __offset};
345 __count <= size() - __offset,
346 "Offset + count out of range in span::subspan(offset, count)");
347 return {data() + __offset, __count};
363 return __data[__idx];
373 return __data[size() - 1];
397 reinterpret_cast<const byte *
>(data()), size_bytes()};
403 reinterpret_cast<byte *
>(data()), size_bytes()};
410 template <
typename _Tp>
430 : __data{
nullptr}, __size{0} {}
432 constexpr
span(
const span &) noexcept =
default;
436 : __data{__ptr}, __size{__count} {}
438 : __data{__f}, __size{
static_cast<size_t>(std::distance(__f, __l))} {}
440 template <
size_t _Sz>
443 : __data{__arr}, __size{_Sz} {}
445 template <
class _OtherElementType,
size_t _Sz,
448 std::nullptr_t> =
nullptr>
450 std::array<_OtherElementType, _Sz> &__arr) noexcept
451 : __data{__arr.data()}, __size{_Sz} {}
454 class _OtherElementType,
size_t _Sz,
457 std::nullptr_t> =
nullptr>
459 const std::array<_OtherElementType, _Sz> &__arr) noexcept
460 : __data{__arr.data()}, __size{_Sz} {}
462 template <
class _Container>
466 std::nullptr_t> =
nullptr)
467 : __data{std::data(__c)}, __size{(size_type)std::size(__c)} {}
469 template <
class _Container>
471 const _Container &__c,
474 std::nullptr_t> =
nullptr)
475 : __data{std::data(__c)}, __size{(size_type)std::size(__c)} {}
477 template <
class _OtherElementType,
size_t _OtherExtent>
481 std::is_convertible_v<_OtherElementType (*)[],
element_type (*)[]>,
482 std::nullptr_t> =
nullptr) noexcept
483 : __data{__other.
data()}, __size{__other.
size()} {}
487 template <
size_t _Count>
494 template <
size_t _Count>
505 "Count out of range in span::first(count)");
506 return {data(), __count};
513 "Count out of range in span::last(count)");
514 return {data() + size() - __count, __count};
517 template <
size_t _Offset,
size_t _Count = dynamic_extent>
521 "Offset out of range in span::subspan()");
523 "Offset + count out of range in span::subspan()");
525 data() + _Offset, _Count ==
dynamic_extent ? size() - _Offset : _Count};
532 "Offset out of range in span::subspan(offset, count)");
534 "count out of range in span::subspan(offset, count)");
536 return {data() + __offset, size() - __offset};
538 __count <= size() - __offset,
539 "Offset + count out of range in span::subspan(offset, count)");
540 return {data() + __offset, __count};
556 return __data[__idx];
566 return __data[size() - 1];
589 return {
reinterpret_cast<const byte *
>(data()), size_bytes()};
594 return {
reinterpret_cast<byte *
>(data()), size_bytes()};
603 template <
class _Tp,
size_t _Extent>
605 -> decltype(__s.__as_bytes()) {
606 return __s.__as_bytes();
609 template <
class _Tp,
size_t _Extent>
612 -> std::enable_if_t<!std::is_const_v<_Tp>,
613 decltype(__s.__as_writable_bytes())> {
614 return __s.__as_writable_bytes();
620 template <
class _Tp,
size_t _Sz>
621 span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;
623 template <
class _Tp,
size_t _Sz>
span(std::array<_Tp, _Sz> &) -> span<_Tp, _Sz>;
625 template <
class _Tp,
size_t _Sz>
626 span(
const std::array<_Tp, _Sz> &) -> span<const _Tp, _Sz>;
628 template <
class _Container>
629 span(_Container &) -> span<typename _Container::value_type>;
631 template <
class _Container>
632 span(
const _Container &) -> span<const typename _Container::value_type>;
constexpr _SYCL_SPAN_INLINE_VISIBILITY span< element_type, _Count > subspan() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY rev_iterator rbegin() const noexcept
const _Tp * const_pointer
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(const std::array< _OtherElementType, _Extent > &__arr) noexcept
std::remove_cv_t< _Tp > value_type
constexpr _SYCL_SPAN_INLINE_VISIBILITY span< element_type, _Count > last() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span< element_type, _Count > first() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(_Container &__c, std::enable_if_t< __is_span_compatible_container< _Container, _Tp >::value, std::nullptr_t >=nullptr)
constexpr _SYCL_SPAN_INLINE_VISIBILITY auto subspan() const noexcept -> span< element_type,(_Count !=dynamic_extent ? _Count :_Extent - _Offset)>
constexpr _SYCL_SPAN_INLINE_VISIBILITY span< element_type, dynamic_extent > last(size_type __count) const noexcept
#define __SYCL_INLINE_VER_NAMESPACE(X)
#define _SYCL_SPAN_ASSERT(x, m)
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(pointer __ptr, size_type __count)
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(std::array< _OtherElementType, _Sz > &__arr) noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY bool empty() const noexcept
span(const _Container &) -> span< const typename _Container::value_type >
constexpr _SYCL_SPAN_INLINE_VISIBILITY size_type size_bytes() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY pointer data() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span< element_type, _Count > last() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(pointer __f, pointer __l)
---— Error handling, matching OpenCL plugin semantics.
constexpr _SYCL_SPAN_INLINE_VISIBILITY reference operator[](size_type __idx) const noexcept
constexpr size_t dynamic_extent
constexpr _SYCL_SPAN_INLINE_VISIBILITY size_type size() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY iterator end() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY size_type size() const noexcept
const _Tp * const_pointer
_SYCL_SPAN_INLINE_VISIBILITY span< byte, _Extent *sizeof(element_type)> __as_writable_bytes() const noexcept
typename std::enable_if< B, T >::type enable_if_t
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(pointer __ptr, size_type __count)
constexpr _SYCL_SPAN_INLINE_VISIBILITY size_type size_bytes() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY rev_iterator rend() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY reference back() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(element_type(&__arr)[_Sz]) noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY reference operator[](size_type __idx) const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(_Container &__c, std::enable_if_t< __is_span_compatible_container< _Container, _Tp >::value, std::nullptr_t >=nullptr)
std::reverse_iterator< pointer > rev_iterator
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(element_type(&__arr)[_Sz])
constexpr _SYCL_SPAN_INLINE_VISIBILITY span< element_type, _Count > first() const noexcept
const _Tp & const_reference
constexpr _SYCL_SPAN_INLINE_VISIBILITY iterator begin() const noexcept
annotated_arg & operator=(annotated_arg &)=default
constexpr _SYCL_SPAN_INLINE_VISIBILITY span< element_type, dynamic_extent > first(size_type __count) const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY iterator begin() const noexcept
ptrdiff_t difference_type
constexpr _SYCL_SPAN_INLINE_VISIBILITY rev_iterator rend() const noexcept
std::remove_cv_t< _Tp > value_type
constexpr _SYCL_SPAN_INLINE_VISIBILITY reference back() const noexcept
_SYCL_SPAN_INLINE_VISIBILITY span< byte, dynamic_extent > __as_writable_bytes() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY reference front() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY rev_iterator rbegin() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(const _Container &__c, std::enable_if_t< __is_span_compatible_container< const _Container, _Tp >::value, std::nullptr_t >=nullptr)
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(const std::array< _OtherElementType, _Sz > &__arr) noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(std::array< _OtherElementType, _Extent > &__arr) noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span< element_type, dynamic_extent > first(size_type __count) const noexcept
std::reverse_iterator< pointer > rev_iterator
#define _SYCL_SPAN_INLINE_VISIBILITY
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(const _Container &__c, std::enable_if_t< __is_span_compatible_container< const _Container, _Tp >::value, std::nullptr_t >=nullptr)
constexpr _SYCL_SPAN_INLINE_VISIBILITY pointer data() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY reference front() const noexcept
constexpr span< element_type, dynamic_extent > _SYCL_SPAN_INLINE_VISIBILITY subspan(size_type __offset, size_type __count=dynamic_extent) const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(const span< _OtherElementType, _Extent > &__other, std::enable_if_t< std::is_convertible_v< _OtherElementType(*)[], element_type(*)[]>, std::nullptr_t >=nullptr)
constexpr _SYCL_SPAN_INLINE_VISIBILITY span< element_type, dynamic_extent > subspan(size_type __offset, size_type __count=dynamic_extent) const noexcept
const _Tp & const_reference
constexpr _SYCL_SPAN_INLINE_VISIBILITY span() noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(pointer __f, pointer __l)
constexpr _SYCL_SPAN_INLINE_VISIBILITY iterator end() const noexcept
_SYCL_SPAN_INLINE_VISIBILITY span< const byte, _Extent *sizeof(element_type)> __as_bytes() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span< element_type, dynamic_extent > last(size_type __count) const noexcept
_SYCL_SPAN_INLINE_VISIBILITY auto as_bytes(span< _Tp, _Extent > __s) noexcept -> decltype(__s.__as_bytes())
_SYCL_SPAN_INLINE_VISIBILITY span< const byte, dynamic_extent > __as_bytes() const noexcept
constexpr _SYCL_SPAN_INLINE_VISIBILITY span(const span< _OtherElementType, _OtherExtent > &__other, std::enable_if_t< std::is_convertible_v< _OtherElementType(*)[], element_type(*)[]>, std::nullptr_t >=nullptr) noexcept
_SYCL_SPAN_INLINE_VISIBILITY auto as_writable_bytes(span< _Tp, _Extent > __s) noexcept -> std::enable_if_t<!std::is_const_v< _Tp >, decltype(__s.__as_writable_bytes())>
#define _SYCL_SPAN_TEMPLATE_VIS
sycl::ext::oneapi::experimental::annotated_ref< T, property_list_t > reference
constexpr _SYCL_SPAN_INLINE_VISIBILITY span() noexcept
ptrdiff_t difference_type
constexpr _SYCL_SPAN_INLINE_VISIBILITY bool empty() const noexcept