span.h
Go to the documentation of this file.
61 #if !defined(TCB_SPAN_THROW_ON_CONTRACT_VIOLATION) && !defined(TCB_SPAN_TERMINATE_ON_CONTRACT_VIOLATION) && \
83 #define TCB_SPAN_EXPECT(cond) cond ? (void)0 : contract_violation("Expected " TCB_SPAN_STRINGIFY(cond))
236 T, void_t<decltype(detail::size(std::declval<T>())), decltype(detail::data(std::declval<T>()))> >
242 !is_span<U>::value && !is_std_array<U>::value && !std::is_array<U>::value && has_size_and_data<C>::value;
255 !std::is_same<typename std::remove_cv<decltype(detail::data(std::declval<T>()))>::type, void>::value>::type>
256 : std::is_convertible<remove_pointer_t<decltype(detail::data(std::declval<T>()))> (*)[], E (*)[]> {};
274 static_assert(!std::is_abstract<ElementType>::value, "A span's ElementType cannot be an abstract class type");
294 template <std::size_t E = Extent, typename std::enable_if<(E == dynamic_extent || E <= 0), int>::type = 0>
295 constexpr span() noexcept {}
301 TCB_SPAN_CONSTEXPR11 span(pointer first_elem, pointer last_elem) : storage_(first_elem, last_elem - first_elem) {
302 TCB_SPAN_EXPECT(extent == dynamic_extent || last_elem - first_elem == static_cast<std::ptrdiff_t>(extent));
306 typename std::enable_if<(E == dynamic_extent || N == E) && detail::is_container_element_type_compatible<
316 TCB_SPAN_ARRAY_CONSTEXPR span(std::array<value_type, N>& arr) noexcept : storage_(arr.data(), N) {}
323 TCB_SPAN_ARRAY_CONSTEXPR span(const std::array<value_type, N>& arr) noexcept : storage_(arr.data(), N) {}
344 constexpr span(const span<OtherElementType, OtherExtent>& other) noexcept : storage_(other.data(), other.size()) {}
366 Count != dynamic_extent ? Count : (Extent != dynamic_extent ? Extent - Offset : dynamic_extent)>;
420 TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
422 TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
479 span<const byte, ((Extent == dynamic_extent) ? dynamic_extent : sizeof(ElementType) * Extent)> as_bytes(
486 span<byte, ((Extent == dynamic_extent) ? dynamic_extent : sizeof(ElementType) * Extent)> as_writable_bytes(
501 class tuple_size<TCB_SPAN_NAMESPACE_NAME::span<ElementType, Extent> > : public integral_constant<size_t, Extent> {};
504 class tuple_size<TCB_SPAN_NAMESPACE_NAME::span<ElementType, TCB_SPAN_NAMESPACE_NAME::dynamic_extent> >; // not
508 class tuple_element<I, TCB_SPAN_NAMESPACE_NAME::span<ElementType, Extent> > {
Definition: span.h:267
TCB_SPAN_CONSTEXPR11 span< element_type, Count > last() const
Definition: span.h:358
TCB_SPAN_CONSTEXPR11 subspan_return_t< Offset, Count > subspan() const
Definition: span.h:369
constexpr TCB_SPAN_NODISCARD bool empty() const noexcept
Definition: span.h:395
TCB_SPAN_ARRAY_CONSTEXPR span(const std::array< value_type, N > &arr) noexcept
Definition: span.h:323
~span() noexcept=default
std::reverse_iterator< iterator > reverse_iterator
Definition: span.h:289
TCB_SPAN_ARRAY_CONSTEXPR span(std::array< value_type, N > &arr) noexcept
Definition: span.h:316
const element_type * const_pointer
Definition: span.h:285
constexpr span(const span &other) noexcept=default
TCB_SPAN_CONSTEXPR11 span< element_type, dynamic_extent > first(size_type count) const
Definition: span.h:374
typename std::remove_cv< ElementType >::type value_type
Definition: span.h:281
TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rbegin() const noexcept
Definition: span.h:420
const element_type & const_reference
Definition: span.h:287
TCB_SPAN_CONSTEXPR11 span< element_type, Count > first() const
Definition: span.h:352
TCB_SPAN_CONSTEXPR11 span< element_type, dynamic_extent > last(size_type count) const
Definition: span.h:379
TCB_SPAN_CONSTEXPR11 reference back() const
Definition: span.h:408
TCB_SPAN_CONSTEXPR11 reference front() const
Definition: span.h:403
constexpr size_type size_bytes() const noexcept
Definition: span.h:393
TCB_SPAN_CONSTEXPR11 reference operator[](size_type idx) const
Definition: span.h:398
constexpr span(element_type(&arr)[N]) noexcept
Definition: span.h:309
TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rend() const noexcept
Definition: span.h:422
constexpr span(const span< OtherElementType, OtherExtent > &other) noexcept
Definition: span.h:344
TCB_SPAN_CONSTEXPR11 span< element_type, dynamic_extent > subspan(size_type offset, size_type count=dynamic_extent) const
Definition: span.h:384
ElementType type
Definition: span.h:511
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition: span.h:217
constexpr std::size_t size(const T(&)[N]) noexcept
Definition: span.h:184
constexpr auto size(const C &c) -> decltype(c.size())
Definition: span.h:179
typename std::remove_pointer< T >::type remove_pointer_t
Definition: span.h:246
constexpr const E * data(std::initializer_list< E > il) noexcept
Definition: span.h:204
constexpr auto data(C &c) -> decltype(c.data())
Definition: span.h:189
Definition: span.h:58
span< byte,((Extent==dynamic_extent) ? dynamic_extent :sizeof(ElementType) *Extent)> as_writable_bytes(span< ElementType, Extent > s) noexcept
Definition: span.h:486
constexpr span< ElementType, Extent > make_span(span< ElementType, Extent > s) noexcept
Definition: span.h:449
constexpr auto get(span< E, S > s) -> decltype(s[N])
Definition: span.h:492
span< const byte,((Extent==dynamic_extent) ? dynamic_extent :sizeof(ElementType) *Extent)> as_bytes(span< ElementType, Extent > s) noexcept
Definition: span.h:479
constexpr TCB_SPAN_INLINE_VAR std::size_t dynamic_extent
Definition: span.h:146
static constexpr bool value
Definition: span.h:241
constexpr span_storage() noexcept=default
constexpr span_storage() noexcept=default
static constexpr std::size_t size
Definition: span.h:160