Range-v3
Range algorithms, views, and actions for the Standard Library
ranges::v3::span< T, N > Struct Template Reference
+ Inheritance diagram for ranges::v3::span< T, N >:

Public Types

using difference_type = index_type
 
template<typename Rng >
using DynamicConversion = meta::bool_< N==dynamic_extent||(range_cardinality< Rng >::value< cardinality{})>
 
using element_type = T
 
using index_type = detail::span_index_t
 
using iterator = T *
 
using pointer = T *
 
using reference = T &
 
using reverse_iterator = ranges::reverse_iterator< iterator >
 
template<typename Rng >
using StaticConversion = meta::bool_< N !=dynamic_extent &&range_cardinality< Rng >::value==N >
 
using value_type = meta::_t< std::remove_cv< T > >
 

Public Member Functions

constexpr iterator begin () const noexcept
 
constexpr pointer data () const noexcept
 
constexpr bool empty () const noexcept
 
constexpr iterator end () const noexcept
 
template<index_type Count>
constexpr span< T, Count > first () const noexcept
 
constexpr span< T > first (index_type count) const noexcept
 
template<index_type Count>
constexpr span< T, Count > last () const noexcept
 
constexpr span< T > last (index_type count) const noexcept
 
template<typename U , index_type M, requires = (EqualityComparable<T, U>())>
bool operator!= (span< U, M > const &that) const
 
template<typename U , index_type M, requires = (TotallyOrdered<T, U>())>
bool operator< (span< U, M > const &that) const
 
template<typename U , index_type M, requires = (TotallyOrdered<T, U>())>
bool operator<= (span< U, M > const &that) const
 
template<typename U , index_type M, requires = (EqualityComparable<T, U>())>
bool operator== (span< U, M > const &that) const
 
template<typename U , index_type M, requires = (TotallyOrdered<T, U>())>
bool operator> (span< U, M > const &that) const
 
template<typename U , index_type M, requires = (TotallyOrdered<T, U>())>
bool operator>= (span< U, M > const &that) const
 
constexpr reference operator[] (index_type idx) const noexcept
 
constexpr reverse_iterator rbegin () const noexcept
 
constexpr reverse_iterator rend () const noexcept
 
constexpr index_type size_bytes () const noexcept
 
constexpr span (pointer ptr, index_type count) noexcept
 
template<typename Rng , requires = (CompatibleRange<Rng>()), requires = (DynamicConversion<Rng>())>
constexpr span (Rng &&rng) noexcept(noexcept(ranges::data(rng), ranges::size(rng)))
 
template<typename Rng , requires = (CompatibleRange<Rng>()), requires = (StaticConversion<Rng>())>
constexpr span (Rng &&rng) noexcept(noexcept(ranges::data(rng)))
 
template<index_type Offset, index_type Count>
constexpr span< T, Count > subspan () const noexcept
 
template<index_type Offset>
constexpr dynamic_extent subspan (index_type offset) const noexcept
 
constexpr span< T, dynamic_extent > subspan (index_type offset, index_type count) const noexcept
 
- Public Member Functions inherited from ranges::v3::view_interface< span< T, N >,(N==dynamic_extent ? finite :static_cast< cardinality >(N))>
auto at (range_difference_type_t< D > n) -> decltype(std::declval< D & >().begin()[n])
 Returns a reference to the element at specified location pos, with bounds checking.
 
auto at (range_difference_type_t< D > n) const -> decltype(std::declval< D const & >().begin()[n])
 
range_reference_t< D > back ()
 Access the last element in a range:
 
range_reference_t< D const > back () const
 
constexpr bool empty () const noexcept
 
constexpr bool empty () const noexcept(noexcept(bool(ranges::begin(std::declval< D const & >())==ranges::end(std::declval< D const & >()))))
 
range_reference_t< D > front ()
 Access the first element in a range:
 
range_reference_t< D const > front () const
 
constexpr operator bool () const noexcept(noexcept(ranges::empty(std::declval< D const & >())))
 
 operator Container ()
 Implicit conversion to something that looks like a container.
 
 operator Container () const
 
constexpr auto operator! () const noexcept(noexcept(decltype(ranges::empty(std::declval< D const & >()))(ranges::empty(std::declval< D const & >())))) -> decltype(ranges::empty(std::declval< D const & >()))
 
view_interfaceoperator= (view_interface &&)=default
 
view_interfaceoperator= (view_interface const &)=default
 
auto operator[] (range_difference_type_t< D > n) -> decltype(std::declval< D & >().begin()[n])
 Simple indexing:
 
auto operator[] (range_difference_type_t< D > n) const -> decltype(std::declval< D const & >().begin()[n])
 
auto operator[] (detail::slice_bounds< range_difference_type_t< D >> offs) &-> decltype(std::declval< Slice >()(std::declval< D & >(), offs.from, offs.to))
 Python-ic slicing:
 
auto operator[] (detail::slice_bounds< range_difference_type_t< D >> offs) const &-> decltype(std::declval< Slice >()(std::declval< D const & >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< range_difference_type_t< D >> offs) &&-> decltype(std::declval< Slice >()(std::declval< D >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< range_difference_type_t< D >, detail::from_end_< range_difference_type_t< D >>> offs) &-> decltype(std::declval< Slice >()(std::declval< D & >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< range_difference_type_t< D >, detail::from_end_< range_difference_type_t< D >>> offs) const &-> decltype(std::declval< Slice >()(std::declval< D const & >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< range_difference_type_t< D >, detail::from_end_< range_difference_type_t< D >>> offs) &&-> decltype(std::declval< Slice >()(std::declval< D >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< detail::from_end_< range_difference_type_t< D >>, detail::from_end_< range_difference_type_t< D >>> offs) &-> decltype(std::declval< Slice >()(std::declval< D & >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< detail::from_end_< range_difference_type_t< D >>, detail::from_end_< range_difference_type_t< D >>> offs) const &-> decltype(std::declval< Slice >()(std::declval< D const & >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< detail::from_end_< range_difference_type_t< D >>, detail::from_end_< range_difference_type_t< D >>> offs) &&-> decltype(std::declval< Slice >()(std::declval< D >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< range_difference_type_t< D >, end_fn > offs) &-> decltype(std::declval< Slice >()(std::declval< D & >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< range_difference_type_t< D >, end_fn > offs) const &-> decltype(std::declval< Slice >()(std::declval< D const & >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< range_difference_type_t< D >, end_fn > offs) &&-> decltype(std::declval< Slice >()(std::declval< D >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< detail::from_end_< range_difference_type_t< D >>, end_fn > offs) &-> decltype(std::declval< Slice >()(std::declval< D & >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< detail::from_end_< range_difference_type_t< D >>, end_fn > offs) const &-> decltype(std::declval< Slice >()(std::declval< D const & >(), offs.from, offs.to))
 
auto operator[] (detail::slice_bounds< detail::from_end_< range_difference_type_t< D >>, end_fn > offs) &&-> decltype(std::declval< Slice >()(std::declval< D >(), offs.from, offs.to))
 
constexpr range_size_type_t< D > size () const noexcept
 Access the size of the range, if it can be determined:
 
constexpr range_size_type_t< D > size () const
 
 view_interface (view_interface &&)=default
 
 view_interface (view_interface const &)=default
 

Public Attributes

 data_
 
template<index_type Offset>
constexpr span< T, N >
 

Static Public Attributes

static constexpr index_type extent = N
 

Additional Inherited Members

- Protected Member Functions inherited from ranges::v3::view_interface< span< T, N >,(N==dynamic_extent ? finite :static_cast< cardinality >(N))>
span< T, N > & derived () noexcept
 
constexpr span< T, N > const & derived () const noexcept
 

Member Data Documentation

◆ data_

template<typename T, detail::span_index_t N = dynamic_extent>
ranges::v3::span< T, N >::data_
Initial value:
{( assert ( 0 == count || ptr != nullptr ), ptr)}
{}
template<typename = void>
constexpr span(pointer first, pointer last) noexcept
: span{first, last - first}
{}
template<typename Rng>
using CompatibleRange =
SizedRange<Rng>, ContiguousRange<Rng>,
std::is_convertible<concepts::ContiguousRange::element_t<Rng>(*)[], T(*)[]>>

◆ span< T, N >

template<typename T, detail::span_index_t N = dynamic_extent>
template<index_type Offset>
constexpr ranges::v3::span< T, N >::span< T, N >
Initial value:
= Offset ? N - Offset : dynamic_extent> subspan() const noexcept
{
static_assert(Offset >= 0,
"Offset of first element to extract cannot be negative.");
static_assert(N == dynamic_extent || Offset <= N,
"Offset of first element to extract must be less than the static span extent.");
return assert ( size() >= Offset ),
assert ( (Offset == 0 && size() == 0) || data_ != nullptr ),
span<T, N >= Offset ? N - Offset : dynamic_extent>{
data_ + Offset, size() - Offset};
}
constexpr span<T