19 #ifndef GEOS_COMMON_SPAN_HPP
20 #define GEOS_COMMON_SPAN_HPP
22 #include "codingUtilities/traits.hpp"
27 #include <type_traits>
39 template<
typename T >
59 constexpr
Span() noexcept = default;
77 template<
typename ITER >
88 constexpr
Span( T (& arr)[N] ) noexcept
89 :
Span( std::addressof( arr[0] ), N )
98 template<
typename R,
typename std::enable_if_t< traits::is_range_like< R > > * =
nullptr >
99 constexpr
Span( R
const & range )
122 constexpr
bool empty() const noexcept
130 constexpr T *
data() const noexcept
138 constexpr T *
begin() const noexcept
146 constexpr T *
end() const noexcept
148 return m_data + m_size;
154 constexpr std::reverse_iterator< T * >
rbegin() const noexcept
156 return std::reverse_iterator< T * >( m_data + m_size - 1 );
162 constexpr std::reverse_iterator< T * >
rend() const noexcept
164 return std::reverse_iterator< T * >( m_data - 1 );
184 return m_data[m_size-1];
205 return { m_data, count };
215 return { m_data + (m_size - count), count };
226 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.