9 #ifndef EAGINE_VECT_CAST_HPP
10 #define EAGINE_VECT_CAST_HPP
15 namespace eagine::vect {
17 template <
typename TF,
int NF,
bool VF,
typename TT,
int NT,
bool VT>
20 template <
typename T,
int N,
bool V>
21 struct cast<T, N, V, T, N, V> {
22 static constexpr
auto apply(data_param_t<T, N, V> v, T) noexcept
28 template <
typename TF,
int NF,
bool VF,
typename TT,
int NT,
bool VT>
32 using _idx_seq = std::integer_sequence<int, I...>;
34 using _make_idx_seq = std::make_integer_sequence<int, N>;
36 template <
int... I,
int... D>
37 static constexpr
auto _cast(
38 data_param_t<TF, NF, VF> v,
39 data_param_t<TT,
sizeof...(D), VT> d,
41 _idx_seq<D...>) noexcept {
42 return data_t<TT, NT, VT>{TT(v[I])..., TT(d[D])...};
46 static constexpr
auto _cast(
47 data_param_t<TF, NF, VF> v,
48 data_param_t<TT, 0U, VT>,
50 _idx_seq<>) noexcept {
51 return data_t<TT, NT, VT>{TT(v[I])...};
55 static constexpr
auto apply(
56 data_param_t<TF, NF, VF> v,
57 data_param_t<TT, (NT > NF) ? NT - NF : 0, VT> d) noexcept {
58 using is = _make_idx_seq<(NT > NF) ? NF : NT>;
59 using ds = _make_idx_seq<(NT > NF) ? NT - NF : 0>;
60 return _cast(v, d, is(), ds());
63 static constexpr
auto apply(data_param_t<TF, NF, VF> v, TT d) noexcept {
64 return apply(v,
fill < TT, (NT > NF) ? NT - NF : 0, VT > ::apply(d));
70 #endif // EAGINE_VECT_CAST_HPP