15#ifndef AMINO_CORE_SPAN_H
16#define AMINO_CORE_SPAN_H
38 static inline constexpr bool is_span =
39 std::is_same_v<std::remove_cv_t<std::remove_reference_t<R>>,
Span<T>>;
54 constexpr Span() noexcept = default;
68 template <
typename R,
typename = std::enable_if_t<!is_span<R>>>
69 constexpr explicit Span(R&& r)
70 : m_begin{r.
data()}, m_end{m_begin + r.
size()} {}
75 constexpr Span(T*, std::nullptr_t) =
delete;
76 constexpr Span(std::nullptr_t, T*) =
delete;
80 constexpr bool empty()
const {
return m_begin == m_end; }
114 constexpr T
const&
back()
const {
140 constexpr T*
data()
const {
return m_begin; }
144 return static_cast<size_type>(m_end - m_begin);
180 template <
typename R>
181 static inline constexpr bool is_span_param =
182 std::is_same_v<std::remove_cv_t<std::remove_reference_t<R>>,
Span<T>>;
187 template <
typename R,
typename = std::enable_if_t<!is_span_param<R>>>
SpanParam(T *, size_t) -> SpanParam< T >
Deduction guides for SpanParam.
Span(T *, size_t) -> Span< T >
Deduction guides for Span.
The class template span describes an object that can refer to a contiguous sequence of objects with t...
constexpr bool empty() const
Check if the Span is empty.
ptrdiff_t difference_type
constexpr Span(std::nullptr_t, T *)=delete
Span is not constructible from a nullptr.
constexpr T const & operator[](size_type i) const
Access the ith element.
constexpr const_iterator cbegin() const
Returns an iterator to the beginning of the Span.
constexpr iterator begin()
Returns an iterator to the beginning of the Span.
constexpr const_iterator cend() const
Returns an iterator to the end of the Span.
constexpr Span() noexcept=default
Default constructor (empty Span).
constexpr Span(std::nullptr_t, size_type)=delete
Span is not constructible from a nullptr.
constexpr T const & back() const
Access the last element.
constexpr T * data() const
Direct access to the underlying contiguous storage of the Span.
constexpr const_iterator end() const
Returns an iterator to the end of the Span.
constexpr T & front()
Access the first element.
constexpr T & back()
Access the last element.
constexpr size_type size() const
Returns the number of elements in the Span.
std::remove_cv_t< T > value_type
constexpr T const & front() const
Access the first element.
constexpr Span(T *begin, T *end)
Construct a Span from a pointer to the beginning and a pointer to the end.
constexpr Span(T *, std::nullptr_t)=delete
Span is not constructible from a nullptr.
constexpr iterator end()
Returns an iterator to the end of the Span.
constexpr const_iterator begin() const
Returns an iterator to the beginning of the Span.
constexpr T & operator[](size_type i)
Access the ith element.
Same as Span but the constructor from a range is implicit, making it more convenient and safe to use ...
constexpr SpanParam(R &&r)
constexpr SpanParam(Span< T > const &other)