8#ifndef BOOST_CORE_SPAN_HPP
9#define BOOST_CORE_SPAN_HPP
20template<
class T, std::
size_t E = dynamic_extent>
25template<
class U,
class T>
27 static constexpr bool value = std::is_convertible<U(*)[], T(*)[]>
::value;
30template<std::
size_t E, std::
size_t N>
35template<
class T, std::
size_t E,
class U, std::
size_t N>
43 std::remove_reference<T>::type>::type;
47 static constexpr bool value =
false;
50template<
class T, std::
size_t E>
52 static constexpr bool value =
true;
57 static constexpr bool value =
false;
60template<
class T, std::
size_t N>
62 static constexpr bool value =
true;
68template<
class,
class =
void>
73 typename std::enable_if<std::is_pointer<span_ptr<T> >::value>::type> {
74 typedef typename std::remove_pointer<span_ptr<T> >::type
type;
77template<
class,
class,
class =
void>
79 static constexpr bool value =
false;
82template<
class R,
class T>
83struct span_has_data<R, T, typename std::enable_if<span_convertible<typename
84 span_data<R>::type, T>::value>::type> {
85 static constexpr bool value =
true;
88template<
class,
class =
void>
90 static constexpr bool value =
false;
95 std::enable_if<std::is_convertible<decltype(std::declval<R&>().size()),
96 std::size_t>::value>::type> {
97 static constexpr bool value =
true;
100template<
class R,
class T>
102 static constexpr bool value = (std::is_const<T>::value ||
103 std::is_lvalue_reference<R>::value) &&
111template<std::
size_t E, std::
size_t N>
117template<
class T, std::
size_t E,
class U, std::
size_t N>
123template<std::
size_t E, std::
size_t O>
129template<
class T, std::
size_t E>
133 static constexpr std::size_t
n = E;
146template<
class T, std::
size_t E>
148 static constexpr std::size_t
value =
sizeof(T) * E;
158template<
class T, std::
size_t E>
176 template<std::size_t N = E,
177 typename std::enable_if<N == dynamic_extent || N == 0, int>::type = 0>
193 template<
class I,
class L,
199 template<
class I,
class L,
202 explicit constexpr span(I* f, L* l)
205 template<std::size_t N,
206 typename std::enable_if<detail::span_capacity<E, N>::value,
208 constexpr span(
typename std::enable_if<true, T>::type (&a)[N]) noexcept
211 template<
class U, std::size_t N,
212 typename std::enable_if<detail::span_compatible<T, E, U, N>::value,
214 constexpr span(std::array<U, N>& a) noexcept
215 : s_(a.data(), N) { }
217 template<
class U, std::size_t N,
219 N>::value,
int>::type = 0>
220 constexpr span(
const std::array<U, N>& a) noexcept
221 : s_(a.data(), N) { }
237 template<
class U, std::size_t N,
238 typename std::enable_if<detail::span_implicit<E, N>::value &&
241 : s_(s.data(), s.size()) { }
243 template<
class U, std::size_t N,
244 typename std::enable_if<!detail::span_implicit<E, N>::value &&
247 : s_(s.data(), s.size()) { }
249 template<std::
size_t C>
251 static_assert(C <= E,
"Count <= Extent");
255 template<std::
size_t C>
257 static_assert(C <= E,
"Count <= Extent");
261 template<std::
size_t O, std::
size_t C = dynamic_extent>
264 static_assert(O <= E,
"Offset <= Extent");
268 template<std::
size_t O, std::
size_t C = dynamic_extent>
271 static_assert(O <= E && C <= E - O,
272 "Offset <= Extent && Count <= Extent - Offset");
295 return s_.n *
sizeof(T);
298 constexpr bool empty() const noexcept {
311 return s_.p[s_.n - 1];
354template<
class T, std::
size_t E>
357#ifdef __cpp_deduction_guides
358template<
class I,
class L>
359span(I*, L) -> span<I>;
361template<
class T, std::
size_t N>
362span(T(&)[N]) -> span<T, N>;
364template<
class T, std::
size_t N>
365span(std::array<T, N>&) -> span<T, N>;
367template<
class T, std::
size_t N>
368span(
const std::array<T, N>&) -> span<const T, N>;
371span(R&&) -> span<typename detail::span_data<R>::type>;
373template<
class T, std::
size_t E>
374span(span<T, E>) -> span<T, E>;
378template<
class T, std::
size_t E>
379inline span<const std::byte, detail::span_bytes<T, E>::value>
380as_bytes(span<T, E> s)
noexcept
382 return span<
const std::byte, detail::span_bytes<T,
383 E>::value>(
reinterpret_cast<const std::byte*
>(s.data()),
387template<
class T, std::
size_t E>
388inline typename std::enable_if<!std::is_const<T>::value,
389 span<std::byte, detail::span_bytes<T, E>::value> >::type
390as_writable_bytes(span<T, E> s)
noexcept
392 return span<std::byte, detail::span_bytes<T,
393 E>::value>(
reinterpret_cast<std::byte*
>(s.data()), s.size_bytes());
constexpr reverse_iterator rbegin() const noexcept
std::remove_cv< T >::type value_type
constexpr reference operator[](size_type i) const
constexpr iterator end() const noexcept
std::reverse_iterator< const T * > const_reverse_iterator
constexpr std::enable_if< C!=dynamic_extent, span< T, C > >::type subspan() const
constexpr const_reverse_iterator crbegin() const noexcept
constexpr std::enable_if< C==dynamic_extent, span< T, detail::span_sub< E, O >::value > >::type subspan() const
constexpr span< T, dynamic_extent > last(size_type c) const
constexpr span(std::array< U, N > &a) noexcept
constexpr span(R &&r) noexcept(noexcept(boost::data(r)) &&noexcept(r.size()))
constexpr span(typename std::enable_if< true, T >::type(&a)[N]) noexcept
constexpr const_reverse_iterator crend() const noexcept
constexpr const_iterator cbegin() const noexcept
constexpr bool empty() const noexcept
constexpr pointer data() const noexcept
std::ptrdiff_t difference_type
std::reverse_iterator< T * > reverse_iterator
constexpr size_type size_bytes() const noexcept
constexpr span< T, C > first() const
constexpr span() noexcept
constexpr iterator begin() const noexcept
static constexpr std::size_t extent
constexpr const_iterator cend() const noexcept
constexpr span(const span< U, N > &s) noexcept
constexpr reference front() const
constexpr span< T, C > last() const
constexpr span< T, dynamic_extent > first(size_type c) const
constexpr reference back() const
constexpr reverse_iterator rend() const noexcept
constexpr span< T, dynamic_extent > subspan(size_type o, size_type c=dynamic_extent) const
constexpr size_type size() const noexcept
constexpr span(I *f, size_type c)
const T & const_reference
constexpr span(const std::array< U, N > &a) noexcept
constexpr span(I *f, L *l)
decltype(boost::data(std::declval< T & >())) span_ptr
typename std::remove_cv< typename std::remove_reference< T >::type >::type span_uncvref
constexpr std::size_t dynamic_extent
constexpr auto data(C &c) noexcept(noexcept(c.data())) -> decltype(c.data())
static constexpr std::size_t value
static constexpr bool value
static constexpr bool value
static constexpr bool value
static constexpr bool value
std::remove_pointer< span_ptr< T > >::type type
static constexpr bool value
static constexpr bool value
static constexpr bool value
static constexpr bool value
static constexpr bool value
static constexpr bool value
constexpr span_store(T *p_, std::size_t n_) noexcept
constexpr span_store(T *p_, std::size_t) noexcept
static constexpr std::size_t n
static constexpr std::size_t value