Lines Matching refs:span
2 //===------------------------------ span ---------------------------------===//
14 span synopsis
21 // [views.span], class template span
23 class span;
26 inline constexpr bool ranges::enable_borrowed_range<span<ElementType, Extent>> = true;
28 // [span.objectrep], views of object representation
30 span<const byte, ((Extent == dynamic_extent) ? dynamic_extent :
31 (sizeof(ElementType) * Extent))> as_bytes(span<ElementType, Extent> s) noexcept;
34 span< byte, ((Extent == dynamic_extent) ? dynamic_extent :
35 (sizeof(ElementType) * Extent))> as_writable_bytes(span<ElementType, Extent> s) noexcept;
39 class span {
54 // [span.cons], span constructors, copy, assignment, and destructor
55 constexpr span() noexcept;
56 constexpr explicit(Extent != dynamic_extent) span(pointer ptr, size_type count);
57 constexpr explicit(Extent != dynamic_extent) span(pointer firstElem, pointer lastElem);
59 constexpr span(element_type (&arr)[N]) noexcept;
61 constexpr span(array<value_type, N>& arr) noexcept;
63 constexpr span(const array<value_type, N>& arr) noexcept;
65 constexpr explicit(Extent != dynamic_extent) span(Container& cont);
67 constexpr explicit(Extent != dynamic_extent) span(const Container& cont);
68 constexpr span(const span& other) noexcept = default;
70 …constexpr explicit(Extent != dynamic_extent) span(const span<OtherElementType, OtherExtent>& s) no…
71 ~span() noexcept = default;
72 constexpr span& operator=(const span& other) noexcept = default;
74 // [span.sub], span subviews
76 constexpr span<element_type, Count> first() const;
78 constexpr span<element_type, Count> last() const;
80 constexpr span<element_type, see below> subspan() const;
82 constexpr span<element_type, dynamic_extent> first(size_type count) const;
83 constexpr span<element_type, dynamic_extent> last(size_type count) const;
84 …constexpr span<element_type, dynamic_extent> subspan(size_type offset, size_type count = dynamic_e…
86 // [span.obs], span observers
91 // [span.elem], span element access
97 // [span.iterators], span iterator support
109 span(T (&)[N]) -> span<T, N>;
112 span(array<T, N>&) -> span<T, N>;
115 span(const array<T, N>&) -> span<const T, N>;
118 span(Container&) -> span<typename Container::value_type>;
121 span(const Container&) -> span<const typename Container::value_type>;
147 template <typename _Tp, size_t _Extent = dynamic_extent> class span;
154 struct __is_span_impl<span<_Tp, _Extent>> : public true_type {};
174 // is not a specialization of span
193 class _LIBCPP_TEMPLATE_VIS span {
213 // [span.cons], span constructors, copy, assignment, and destructor
215 _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {}
217 constexpr span (const span&) noexcept = default;
218 constexpr span& operator=(const span&) noexcept = default;
220 …_LIBCPP_INLINE_VISIBILITY constexpr explicit span(pointer __ptr, size_type __count) : __data{__ptr}
221 …{ (void)__count; _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (ptr, len…
222 _LIBCPP_INLINE_VISIBILITY constexpr explicit span(pointer __f, pointer __l) : __data{__f}
223 …{ (void)__l; _LIBCPP_ASSERT(_Extent == distance(__f, __l), "size mismatch in span's constructo…
225 …_LIBCPP_INLINE_VISIBILITY constexpr span(element_type (&__arr)[_Extent]) noexcept : __dat…
230 constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
235 … constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
239 constexpr explicit span( _Container& __c,
242 … _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (range)");
247 constexpr explicit span(const _Container& __c,
250 … _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (range)");
255 constexpr span(const span<_OtherElementType, _Extent>& __other,
263 constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other,
267 … { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }
270 // ~span() noexcept = default;
274 constexpr span<element_type, _Count> first() const noexcept
276 static_assert(_Count <= _Extent, "Count out of range in span::first()");
277 return span<element_type, _Count>{data(), _Count};
282 constexpr span<element_type, _Count> last() const noexcept
284 static_assert(_Count <= _Extent, "Count out of range in span::last()");
285 return span<element_type, _Count>{data() + size() - _Count, _Count};
289 constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
291 _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)");
296 constexpr span<element_type, dynamic_extent> last(size_type __count) const noexcept
298 _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)");
305 -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>
307 static_assert(_Offset <= _Extent, "Offset out of range in span::subspan()");
308 …= dynamic_extent || _Count <= _Extent - _Offset, "Offset + count out of range in span::subspan()");
310 … using _ReturnType = span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>;
316 constexpr span<element_type, dynamic_extent>
319 _LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)");
320 …_LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "Count out of range in span::subsp…
323 …_LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset,…
333 _LIBCPP_ASSERT(__idx < size(), "span<T,N>[] index out of bounds");
339 _LIBCPP_ASSERT(!empty(), "span<T, N>::front() on empty span");
345 _LIBCPP_ASSERT(!empty(), "span<T, N>::back() on empty span");
351 // [span.iter], span iterator support
357 …_LIBCPP_INLINE_VISIBILITY span<const byte, _Extent * sizeof(element_type)> __as_bytes() const noex…
358 …{ return span<const byte, _Extent * sizeof(element_type)>{reinterpret_cast<const byte *>(data()), …
360 …_LIBCPP_INLINE_VISIBILITY span<byte, _Extent * sizeof(element_type)> __as_writable_bytes() const n…
361 …{ return span<byte, _Extent * sizeof(element_type)>{reinterpret_cast<byte *>(data()), size_bytes()…
370 class _LIBCPP_TEMPLATE_VIS span<_Tp, dynamic_extent> {
392 // [span.cons], span constructors, copy, assignment, and destructor
393 _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr}, __size{0} {}
395 constexpr span (const span&) noexcept = default;
396 constexpr span& operator=(const span&) noexcept = default;
398 …_LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, size_type __count) : __data{__ptr}, __size…
399 …_LIBCPP_INLINE_VISIBILITY constexpr span(pointer __f, pointer __l) : __data{__f}, __size{static_ca…
403 constexpr span(element_type (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
408 …constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} …
413 …constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size…
417 constexpr span( _Container& __c,
423 constexpr span(const _Container& __c,
430 constexpr span(const span<_OtherElementType, _OtherExtent>& __other,
436 // ~span() noexcept = default;
440 constexpr span<element_type, _Count> first() const noexcept
442 _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::first()");
443 return span<element_type, _Count>{data(), _Count};
448 constexpr span<element_type, _Count> last() const noexcept
450 _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::last()");
451 return span<element_type, _Count>{data() + size() - _Count, _Count};
455 constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
457 _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)");
462 constexpr span<element_type, dynamic_extent> last (size_type __count) const noexcept
464 _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)");
470 constexpr span<element_type, _Count> subspan() const noexcept
472 _LIBCPP_ASSERT(_Offset <= size(), "Offset out of range in span::subspan()");
473 …== dynamic_extent || _Count <= size() - _Offset, "Offset + count out of range in span::subspan()");
474 …return span<element_type, _Count>{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : …
477 constexpr span<element_type, dynamic_extent>
481 _LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)");
482 …_LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "count out of range in span::subsp…
485 …_LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset,…
495 _LIBCPP_ASSERT(__idx < size(), "span<T>[] index out of bounds");
501 _LIBCPP_ASSERT(!empty(), "span<T>[].front() on empty span");
507 _LIBCPP_ASSERT(!empty(), "span<T>[].back() on empty span");
514 // [span.iter], span iterator support
520 _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> __as_bytes() const noexcept
523 _LIBCPP_INLINE_VISIBILITY span<byte, dynamic_extent> __as_writable_bytes() const noexcept
533 inline constexpr bool ranges::enable_borrowed_range<span<_Tp, _Extent> > = true;
539 auto as_bytes(span<_Tp, _Extent> __s) noexcept
545 auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept
551 span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;
554 span(array<_Tp, _Sz>&) -> span<_Tp, _Sz>;
557 span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
560 span(_Container&) -> span<typename _Container::value_type>;
563 span(const _Container&) -> span<const typename _Container::value_type>;