1#ifndef MILLICAST_API_SPAN_H
2#define MILLICAST_API_SPAN_H
10template <
typename T,
typename E,
typename =
void>
14template <
typename T,
typename E>
18 typename
std::enable_if<
19 !std::is_same<typename std::remove_cv<decltype(std::data(
20 std::declval<T>()))>::type,
23 std::remove_pointer_t<decltype(std::declval<T>().data())> (*)[],
24 E (*)[]>::value>::type> : std::true_type {};
34 constexpr Span() noexcept = default;
38 constexpr Span(T (&arr)[N]) noexcept :
Span(arr, N) {}
39 constexpr Span(
const Span&)
noexcept =
default;
43 typename std::enable_if<
44 std::is_same_v<typename C::value_type, T> ||
47 constexpr Span(
const C& container) noexcept
48 : _ptr(std::data(container)), _size(std::size(container)) {}
51 typename std::enable_if<
52 std::is_same_v<typename C::value_type, T> ||
55 constexpr Span(C& container) noexcept
56 : _ptr(std::data(container)), _size(std::size(container)) {}
59 typename OtherElementType,
60 typename std::enable_if<!std::is_same_v<OtherElementType, T> &&
66 : _ptr(other._ptr), _size(other._size) {}
68 constexpr T*
data()
const {
return _ptr; }
72 [[nodiscard]]
constexpr size_t size()
const {
return _size; }
74 return size() *
sizeof(T);
76 [[nodiscard]]
constexpr bool empty()
const {
return size() == 0; }
constexpr Span(const C &container) noexcept
Definition span.h:47
constexpr Span(const Span &) noexcept=default
constexpr bool empty() const
Definition span.h:76
constexpr Span() noexcept=default
element_type & reference
Definition span.h:32
constexpr Span(C &container) noexcept
Definition span.h:55
constexpr T * data() const
Definition span.h:68
constexpr Span(const Span< OtherElementType > &other) noexcept
Definition span.h:65
constexpr T * begin() const
Definition span.h:69
element_type * pointer
Definition span.h:31
constexpr size_t size() const
Definition span.h:72
constexpr size_t size_bytes() const
Definition span.h:73
constexpr Span(T(&arr)[N]) noexcept
Definition span.h:38
T element_type
Definition span.h:30
constexpr T * end() const
Definition span.h:70
Definition capabilities.h:15