Lines Matching refs:span
14 span synopsis
21 // [views.span], class template span
23 class span;
26 inline constexpr bool ranges::enable_view<span<ElementType, Extent>> = true;
29 inline constexpr bool ranges::enable_borrowed_range<span<ElementType, Extent>> = true;
31 // [span.objectrep], views of object representation
33 span<const byte, ((Extent == dynamic_extent) ? dynamic_extent :
34 (sizeof(ElementType) * Extent))> as_bytes(span<ElementType, Extent> s) noexcept;
37 span< byte, ((Extent == dynamic_extent) ? dynamic_extent :
38 (sizeof(ElementType) * Extent))> as_writable_bytes(span<ElementType, Extent> s) noexcept;
42 class span {
57 // [span.cons], span constructors, copy, assignment, and destructor
58 constexpr span() noexcept;
60 constexpr explicit(Extent != dynamic_extent) span(It first, size_type count);
62 constexpr explicit(Extent != dynamic_extent) span(It first, End last);
64 constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
66 constexpr span(array<value_type, N>& arr) noexcept;
68 constexpr span(const array<value_type, N>& arr) noexcept;
70 constexpr explicit(Extent != dynamic_extent) span(R&& r);
71 constexpr span(const span& other) noexcept = default;
73 …constexpr explicit(Extent != dynamic_extent) span(const span<OtherElementType, OtherExtent>& s) no…
74 ~span() noexcept = default;
75 constexpr span& operator=(const span& other) noexcept = default;
77 // [span.sub], span subviews
79 constexpr span<element_type, Count> first() const;
81 constexpr span<element_type, Count> last() const;
83 constexpr span<element_type, see below> subspan() const;
85 constexpr span<element_type, dynamic_extent> first(size_type count) const;
86 constexpr span<element_type, dynamic_extent> last(size_type count) const;
87 …constexpr span<element_type, dynamic_extent> subspan(size_type offset, size_type count = dynamic_e…
89 // [span.obs], span observers
94 // [span.elem], span element access
100 // [span.iterators], span iterator support
112 span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;
115 span(T (&)[N]) -> span<T, N>;
118 span(array<T, N>&) -> span<T, N>;
121 span(const array<T, N>&) -> span<const T, N>;
124 span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
133 #include <__fwd/span.h>
186 struct __is_std_span<span<_Tp, _Sz>> : true_type {};
190 // shipping <span> before its API was finalized, and we used to provide a constructor
226 class _LIBCPP_TEMPLATE_VIS span {
246 // [span.cons], span constructors, copy, assignment, and destructor
248 _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {}
250 constexpr span (const span&) noexcept = default;
251 constexpr span& operator=(const span&) noexcept = default;
255 constexpr explicit span(_It __first, size_type __count)
258 _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)");
263 constexpr explicit span(_It __first, _End __last) : __data{_VSTD::to_address(__first)} {
265 …_LIBCPP_ASSERT((__last - __first >= 0), "invalid range in span's constructor (iterator, sentinel)"…
267 … "invalid range in span's constructor (iterator, sentinel): last - first != extent");
270 …_LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept…
274 constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
279 … constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
285 constexpr explicit span(_Container& __c) : __data{std::data(__c)} {
286 _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");
291 constexpr explicit span(const _Container& __c) : __data{std::data(__c)} {
292 _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");
297 constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} {
298 _LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)");
304 constexpr span(const span<_OtherElementType, _Extent>& __other)
309 constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept
310 … { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }
313 // ~span() noexcept = default;
317 constexpr span<element_type, _Count> first() const noexcept
319 static_assert(_Count <= _Extent, "span<T, N>::first<Count>(): Count out of range");
320 return span<element_type, _Count>{data(), _Count};
325 constexpr span<element_type, _Count> last() const noexcept
327 static_assert(_Count <= _Extent, "span<T, N>::last<Count>(): Count out of range");
328 return span<element_type, _Count>{data() + size() - _Count, _Count};
332 constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
334 _LIBCPP_ASSERT(__count <= size(), "span<T, N>::first(count): count out of range");
339 constexpr span<element_type, dynamic_extent> last(size_type __count) const noexcept
341 _LIBCPP_ASSERT(__count <= size(), "span<T, N>::last(count): count out of range");
348 -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>
350 … static_assert(_Offset <= _Extent, "span<T, N>::subspan<Offset, Count>(): Offset out of range");
351 …static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "span<T, N>::subspan<Offset…
353 … using _ReturnType = span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>;
359 constexpr span<element_type, dynamic_extent>
362 … _LIBCPP_ASSERT(__offset <= size(), "span<T, N>::subspan(offset, count): offset out of range");
363 …_LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span<T, N>::subspan(offset, count…
366 …_LIBCPP_ASSERT(__count <= size() - __offset, "span<T, N>::subspan(offset, count): offset + count o…
376 _LIBCPP_ASSERT(__idx < size(), "span<T, N>::operator[](index): index out of range");
382 _LIBCPP_ASSERT(!empty(), "span<T, N>::front() on empty span");
388 _LIBCPP_ASSERT(!empty(), "span<T, N>::back() on empty span");
394 // [span.iter], span iterator support
412 …_LIBCPP_INLINE_VISIBILITY span<const byte, _Extent * sizeof(element_type)> __as_bytes() const noex…
413 …{ return span<const byte, _Extent * sizeof(element_type)>{reinterpret_cast<const byte *>(data()), …
415 …_LIBCPP_INLINE_VISIBILITY span<byte, _Extent * sizeof(element_type)> __as_writable_bytes() const n…
416 …{ return span<byte, _Extent * sizeof(element_type)>{reinterpret_cast<byte *>(data()), size_bytes()…
424 class _LIBCPP_TEMPLATE_VIS span<_Tp, dynamic_extent> {
444 // [span.cons], span constructors, copy, assignment, and destructor
445 _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr}, __size{0} {}
447 constexpr span (const span&) noexcept = default;
448 constexpr span& operator=(const span&) noexcept = default;
452 constexpr span(_It __first, size_type __count)
456 _LIBCPP_INLINE_VISIBILITY constexpr span(_It __first, _End __last)
458 … _LIBCPP_ASSERT(__last - __first >= 0, "invalid range in span's constructor (iterator, sentinel)");
463 …constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} …
467 …constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} …
472 …constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size…
478 constexpr span(_Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}
482 constexpr span(const _Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}
486 constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {}
491 constexpr span(const span<_OtherElementType, _OtherExtent>& __other) noexcept
494 // ~span() noexcept = default;
498 constexpr span<element_type, _Count> first() const noexcept
500 _LIBCPP_ASSERT(_Count <= size(), "span<T>::first<Count>(): Count out of range");
501 return span<element_type, _Count>{data(), _Count};
506 constexpr span<element_type, _Count> last() const noexcept
508 _LIBCPP_ASSERT(_Count <= size(), "span<T>::last<Count>(): Count out of range");
509 return span<element_type, _Count>{data() + size() - _Count, _Count};
513 constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept
515 _LIBCPP_ASSERT(__count <= size(), "span<T>::first(count): count out of range");
520 constexpr span<element_type, dynamic_extent> last (size_type __count) const noexcept
522 _LIBCPP_ASSERT(__count <= size(), "span<T>::last(count): count out of range");
528 constexpr span<element_type, _Count> subspan() const noexcept
530 _LIBCPP_ASSERT(_Offset <= size(), "span<T>::subspan<Offset, Count>(): Offset out of range");
531 …_LIBCPP_ASSERT(_Count == dynamic_extent || _Count <= size() - _Offset, "span<T>::subspan<Offset, C…
532 …return span<element_type, _Count>{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : …
535 constexpr span<element_type, dynamic_extent>
539 _LIBCPP_ASSERT(__offset <= size(), "span<T>::subspan(offset, count): offset out of range");
540 …_LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span<T>::subspan(offset, count): c…
543 …_LIBCPP_ASSERT(__count <= size() - __offset, "span<T>::subspan(offset, count): offset + count out …
553 _LIBCPP_ASSERT(__idx < size(), "span<T>::operator[](index): index out of range");
559 _LIBCPP_ASSERT(!empty(), "span<T>::front() on empty span");
565 _LIBCPP_ASSERT(!empty(), "span<T>::back() on empty span");
572 // [span.iter], span iterator support
590 _LIBCPP_INLINE_VISIBILITY span<const byte, dynamic_extent> __as_bytes() const noexcept
593 _LIBCPP_INLINE_VISIBILITY span<byte, dynamic_extent> __as_writable_bytes() const noexcept
602 inline constexpr bool ranges::enable_borrowed_range<span<_Tp, _Extent> > = true;
605 inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true;
610 auto as_bytes(span<_Tp, _Extent> __s) noexcept
615 auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept
620 span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;
624 span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;
627 span(array<_Tp, _Sz>&) -> span<_Tp, _Sz>;
630 span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
634 span(_Container&) -> span<typename _Container::value_type>;
637 span(const _Container&) -> span<const typename _Container::value_type>;
640 span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>;