1#ifndef SDL3PP_SPAN_REF_H_
2#define SDL3PP_SPAN_REF_H_
10template<
class T,
class BASE>
11concept DerivedWrapper =
12 std::derived_from<T, BASE> &&
sizeof(T) ==
sizeof(BASE);
31 template<DerivedWrapper<T> U,
size_t N>
33 : value(static_cast<T*>(other), N)
38 template<DerivedWrapper<T> U>
39 constexpr SpanRef(
const std::span<U>& other)
45 template<std::contiguous_iterator It>
46 requires DerivedWrapper<std::iter_value_t<It>, T>
48 : value((T*)(&*first), count)
53 template<std::contiguous_iterator It, std::sized_sentinel_for<It> End>
54 requires DerivedWrapper<std::iter_value_t<It>, T>
56 : value((T*)(&*first), size_t(last - first))
61 template<std::ranges::contiguous_range R>
62 requires DerivedWrapper<std::iter_value_t<std::ranges::iterator_t<R>>, T>
64 :
SpanRef(std::begin(range), std::end(range))
69 constexpr size_t size()
const {
return value.size(); }
72 constexpr size_t size_bytes()
const {
return value.size_bytes(); }
75 constexpr T*
data()
const {
return value.data(); }
span-like for empty-derived structs
Definition: SDL3pp_spanRef.h:24
constexpr SpanRef(It first, End last)
Constructor.
Definition: SDL3pp_spanRef.h:55
constexpr SpanRef(U(&other)[N])
Constructor.
Definition: SDL3pp_spanRef.h:32
constexpr T * data() const
Retrieves contained data.
Definition: SDL3pp_spanRef.h:75
constexpr SpanRef(It first, size_t count)
Constructor.
Definition: SDL3pp_spanRef.h:47
constexpr SpanRef(const std::span< U > &other)
Constructor.
Definition: SDL3pp_spanRef.h:39
constexpr SpanRef(R &&range)
Constructor.
Definition: SDL3pp_spanRef.h:63
constexpr size_t size() const
Retrieves contained size.
Definition: SDL3pp_spanRef.h:69
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition: SDL3pp_spanRef.h:72
Main include header for the SDL3pp library.