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 >
89 constexpr
Span( T (& arr)[N] ) noexcept
90 :
Span( std::addressof( arr[0] ), N )
99 template<
typename R,
typename std::enable_if_t< traits::is_range_like< R > > * =
nullptr >
100 constexpr
Span( R
const & range )
123 constexpr
bool empty() const noexcept
131 constexpr T *
data() const noexcept
139 constexpr T *
begin() const noexcept
147 constexpr T *
end() const noexcept
149 return m_data + m_size;
155 constexpr std::reverse_iterator< T * >
rbegin() const noexcept
157 return std::reverse_iterator< T * >( m_data + m_size - 1 );
163 constexpr std::reverse_iterator< T * >
rend() const noexcept
165 return std::reverse_iterator< T * >( m_data - 1 );
185 return m_data[m_size-1];
206 return { m_data, count };
216 return { m_data + (m_size - count), count };
227 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.