20#if __cpp_lib_span >= 202002L
48template <
typename ElementType, std::
size_t Extent = dynamic_extent>
53template <
typename E, std::
size_t S>
62 static constexpr std::size_t
size = S;
79 typename std::remove_cv<typename std::remove_reference<T>::type>::type;
84template <
typename T, std::
size_t S>
90template <
typename T, std::
size_t N>
93template <
typename,
typename =
void>
98 decltype(std::data(std::declval<T>()))>>
101template <
typename C,
typename U = uncvref_t<C>>
111template <
typename,
typename,
typename =
void>
114template <
typename T,
typename E>
117 typename
std::enable_if<
118 !std::is_same<typename std::remove_cv<decltype(
119 std::data(std::declval<T>()))>::type,
121 : std::is_convertible<
122 remove_pointer_t<decltype(std::data(std::declval<T>()))> (*)[],
125template <
typename,
typename =
size_t>
133template <
typename ElementType, std::
size_t Extent>
135 static_assert(std::is_object<ElementType>::value,
136 "A span's ElementType must be an object type (not a "
137 "reference type or void)");
139 "A span's ElementType must be a complete type (not a forward "
141 static_assert(!std::is_abstract<ElementType>::value,
142 "A span's ElementType cannot be an abstract class type");
149 using value_type =
typename std::remove_cv<ElementType>::type;
163 std::size_t E = Extent,
164 typename std::enable_if<(E ==
dynamic_extent || E <= 0), int>::type = 0>
169 : storage_(ptr, count)
175 : storage_(first_elem, last_elem - first_elem)
178 last_elem - first_elem ==
179 static_cast<std::ptrdiff_t
>(extent));
182 template <std::size_t N, std::size_t E = Extent,
183 typename std::enable_if<
191 template <std::size_t N, std::size_t E = Extent,
192 typename std::enable_if<
195 std::array<value_type, N>&, ElementType>::value,
197 constexpr span(std::array<value_type, N>& arr) noexcept
198 : storage_(arr.data(), N)
201 template <std::size_t N, std::size_t E = Extent,
202 typename std::enable_if<
205 const std::array<value_type, N>&, ElementType>::value,
207 constexpr span(
const std::array<value_type, N>& arr) noexcept
208 : storage_(arr.data(), N)
212 typename Container, std::size_t E = Extent,
213 typename std::enable_if<
216 Container&, ElementType>::value,
218 constexpr span(Container& cont)
223 typename Container, std::size_t E = Extent,
224 typename std::enable_if<
227 const Container&, ElementType>::value,
229 constexpr span(
const Container& cont)
233 constexpr span(
const span& other)
noexcept =
default;
235 template <
typename OtherElementType, std::size_t OtherExtent,
236 typename std::enable_if<
238 std::is_convertible<OtherElementType (*)[],
239 ElementType (*)[]>::value,
242 : storage_(other.data(), other.size())
248 operator=(const
span& other) noexcept = default;
251 template <
std::
size_t Count>
254 assert(Count <=
size());
255 return {
data(), Count};
258 template <std::
size_t Count>
261 assert(Count <=
size());
262 return {
data() + (
size() - Count), Count};
265 template <std::
size_t Offset, std::
size_t Count = dynamic_extent>
272 template <std::
size_t Offset, std::
size_t Count = dynamic_extent>
275 assert(Offset <=
size() &&
277 return {
data() + Offset,
284 assert(count <=
size());
285 return {
data(), count};
291 assert(count <=
size());
292 return {
data() + (
size() - count), count};
298 assert(offset <=
size() &&
300 return {
data() + offset,
312 [[nodiscard]]
constexpr bool empty() const noexcept
320 assert(idx <
size());
321 return *(
data() + idx);
354 storage_type storage_{};
358template <
class T,
size_t N>
361template <
class T,
size_t N>
362span(std::array<T, N>&)->span<T, N>;
364template <
class T,
size_t N>
365span(
const std::array<T, N>&)->span<
const T, N>;
367template <
class Container>
368span(Container&)->span<
typename Container::value_type>;
370template <
class Container>
371span(
const Container&)->span<
const typename Container::value_type>;
373template <
typename ElementType, std::
size_t Extent>
375 : sizeof(ElementType) * Extent)>
378 return {
reinterpret_cast<const std::byte*
>(s.data()), s.
size_bytes()};
382 class ElementType,
size_t Extent,
383 typename std::enable_if<!std::is_const<ElementType>::value,
int>::type = 0>
385 : sizeof(ElementType) * Extent)>
388 return {
reinterpret_cast<std::byte*
>(s.data()), s.size_bytes()};
391template <std::
size_t N,
typename E, std::
size_t S>
403template <
typename ElementType,
size_t Extent>
404class tuple_size<
ctre::phoenix6::swerve::span<ElementType, Extent>>
405 :
public integral_constant<size_t, Extent> {};
407template <
typename ElementType>
408class tuple_size<
ctre::phoenix6::swerve::span<
409 ElementType, ctre::phoenix6::swerve::dynamic_extent>>;
411template <size_t I, typename ElementType, size_t Extent>
412class tuple_element<I, ctre::phoenix6::swerve::span<ElementType, Extent>> {
constexpr span< element_type, Count > last() const
Definition span.hpp:259
constexpr subspan_return_t< Offset, Count > subspan() const
Definition span.hpp:273
constexpr span() noexcept
Definition span.hpp:165
std::size_t size_type
Definition span.hpp:150
constexpr reference back() const
Definition span.hpp:330
element_type & reference
Definition span.hpp:154
constexpr span(const std::array< value_type, N > &arr) noexcept
Definition span.hpp:207
constexpr pointer data() const noexcept
Definition span.hpp:336
typename std::remove_cv< ElementType >::type value_type
Definition span.hpp:149
std::reverse_iterator< iterator > reverse_iterator
Definition span.hpp:157
constexpr span< element_type, Count > first() const
Definition span.hpp:252
constexpr iterator begin() const noexcept
Definition span.hpp:339
const element_type * const_pointer
Definition span.hpp:153
constexpr span(Container &cont)
Definition span.hpp:218
const element_type & const_reference
Definition span.hpp:155
constexpr reference front() const
Definition span.hpp:324
std::ptrdiff_t difference_type
Definition span.hpp:151
constexpr bool empty() const noexcept
Definition span.hpp:312
pointer iterator
Definition span.hpp:156
constexpr span(pointer first_elem, pointer last_elem)
Definition span.hpp:174
constexpr span(std::array< value_type, N > &arr) noexcept
Definition span.hpp:197
constexpr span< element_type, dynamic_extent > subspan(size_type offset, size_type count=dynamic_extent) const
Definition span.hpp:296
constexpr size_type size_bytes() const noexcept
Definition span.hpp:307
constexpr span(element_type(&arr)[N]) noexcept
Definition span.hpp:188
constexpr iterator end() const noexcept
Definition span.hpp:341
ElementType element_type
Definition span.hpp:148
constexpr reverse_iterator rbegin() const noexcept
Definition span.hpp:343
constexpr span(const span &other) noexcept=default
constexpr reference operator[](size_type idx) const
Definition span.hpp:318
element_type * pointer
Definition span.hpp:152
constexpr span(pointer ptr, size_type count)
Definition span.hpp:168
constexpr size_type size() const noexcept
Definition span.hpp:305
constexpr span< element_type, dynamic_extent > first(size_type count) const
Definition span.hpp:282
constexpr span(const span< OtherElementType, OtherExtent > &other) noexcept
Definition span.hpp:241
constexpr span< element_type, dynamic_extent > last(size_type count) const
Definition span.hpp:289
constexpr span(const Container &cont)
Definition span.hpp:229
constexpr reverse_iterator rend() const noexcept
Definition span.hpp:348
ElementType type
Definition span.hpp:417
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition span.hpp:78
typename std::remove_pointer< T >::type remove_pointer_t
Definition span.hpp:109
span< std::byte,((Extent==dynamic_extent) ? dynamic_extent :sizeof(ElementType) *Extent)> as_writable_bytes(span< ElementType, Extent > s) noexcept
Definition span.hpp:386
constexpr std::size_t dynamic_extent
Definition span.hpp:46
span< const std::byte,((Extent==dynamic_extent) ? dynamic_extent :sizeof(ElementType) *Extent)> as_bytes(span< ElementType, Extent > s) noexcept
Definition span.hpp:376
span(T(&)[N]) -> span< T, N >
constexpr auto get(span< E, S > s) -> decltype(s[N])
Definition span.hpp:392
Definition StatusCodes.h:18
static constexpr bool value
Definition span.hpp:103
constexpr span_storage() noexcept=default
static constexpr std::size_t size
Definition span.hpp:62
E * ptr
Definition span.hpp:61
constexpr span_storage() noexcept=default