20 #ifndef GEOS_COMMON_SPAN_HPP
21 #define GEOS_COMMON_SPAN_HPP
23 #include "codingUtilities/traits.hpp"
28 #include <type_traits>
40 template<
typename T >
60 constexpr
Span() noexcept = default;
78 template<
typename ITER >
80 : m_data(
begin ==
end ?
nullptr : std::addressof( *
begin ) ),
81 m_size( std::distance(
begin,
end ) )
90 constexpr
Span( T (& arr)[N] ) noexcept
91 :
Span( std::addressof( arr[0] ), N )
100 template<
typename R,
typename std::enable_if_t< traits::is_range_like< R > > * =
nullptr >
101 constexpr
Span( R
const & range )
124 constexpr
bool empty() const noexcept
132 constexpr T *
data() const noexcept
140 constexpr T *
begin() const noexcept
148 constexpr T *
end() const noexcept
150 return m_data + m_size;
156 constexpr std::reverse_iterator< T * >
rbegin() const noexcept
158 return std::reverse_iterator< T * >( m_data + m_size - 1 );
164 constexpr std::reverse_iterator< T * >
rend() const noexcept
166 return std::reverse_iterator< T * >( m_data - 1 );
186 return m_data[m_size-1];
207 return { m_data, count };
217 return { m_data + (m_size - count), count };
228 return { m_data + offset, count };
#define GEOS_ASSERT_GT(lhs, rhs)
Assert that one value compares greater than the other in debug builds.
#define GEOS_ASSERT_GE(lhs, rhs)
Assert that one value compares greater than or equal to the other in debug builds.
Lightweight non-owning wrapper over a contiguous range of elements.
Span< element_type > last(size_type const count) const
constexpr bool empty() const noexcept
constexpr Span(R const &range)
Construct a span from a range-like object (anything that has begin() and end()).
constexpr T * data() const noexcept
std::remove_cv_t< T > value_type
Type of underlying value.
constexpr std::reverse_iterator< T * > rend() const noexcept
constexpr Span() noexcept=default
Construct an empty span.
T & operator[](size_type const i) const
constexpr T * begin() const noexcept
constexpr size_type size_bytes() const noexcept
constexpr Span(T(&arr)[N]) noexcept
Construct a span from a c-array.
constexpr T * end() const noexcept
T element_type
Type of range element.
constexpr std::reverse_iterator< T * > rbegin() const noexcept
std::ptrdiff_t difference_type
Type used for indexing the range.
Span< element_type > subspan(size_type const offset, size_type const count) const
constexpr size_type size() const noexcept
constexpr Span(ITER const begin, ITER const end) noexcept
Construct a span from pair of iterators.
Span< element_type > first(size_type const count) const
std::size_t size_type
Type used for indexing the range.
std::size_t size_t
Unsigned size type.