Go to the documentation of this file. 1 #ifndef EAGINE_VECT_VIEW_HPP
9 #define EAGINE_VECT_VIEW_HPP
11 #include "../span.hpp"
14 namespace eagine::vect {
16 template <
typename T,
int N,
bool V>
19 static auto _addr(
const data_t<T, N, V>& d, std::false_type) noexcept
21 return static_cast<const T*
>(d._v);
24 static auto _addr(
const data_t<T, N, V>& d, std::true_type) noexcept
27 return reinterpret_cast<const T*
>(&d);
31 static auto apply(
const data_t<T, N, V>& d) noexcept -> span<const T> {
32 static_assert(
sizeof(T[N]) ==
sizeof(data_t<T, N, V>));
33 return {_addr(d, has_vect_data<T, N, V>()), N};
37 static auto apply(
const data_t<T, N, V> (&d)[M]) noexcept -> span<const T> {
38 static_assert(
sizeof(T[N][M]) ==
sizeof(data_t<T, N, V>[M]));
39 return {_addr(d[0], has_vect_data<T, N, V>()), N * M};
45 #endif // EAGINE_VECT_VIEW_HPP
static constexpr auto view(T *addr, S size) noexcept -> const_span< T >
Creates a view starting at the specified pointer and specified length.
Definition: span.hpp:458