30 template<
typename T, T... T_values>
31 using CVec =
Vec<T,
sizeof...(T_values), detail::CVec<T, T_values...>>;
35 template<
typename T, T... T_values>
36 [[nodiscard]]
constexpr auto integerSequenceToCVec(std::integer_sequence<T, T_values...>)
41 template<
typename T, T... T_values>
44 return std::integer_sequence<T, T_values...>{};
47 template<
typename Int, Int... Is1, Int... Is2>
48 [[nodiscard]]
constexpr auto combine(std::integer_sequence<Int, Is1...>, std::integer_sequence<Int, Is2...>)
50 return std::integer_sequence<Int, Is1..., Is2...>{};
53 template<
typename Last>
54 [[nodiscard]]
constexpr auto concatenate(Last last)
59 template<
typename First,
typename... Rest>
60 [[nodiscard]]
constexpr auto concatenate(First first, Rest... rest)
62 return combine(first, concatenate(rest...));
65 template<
bool pred,
typename T, T T_v>
66 using selectValue = std::conditional_t<pred, std::integer_sequence<T>, std::integer_sequence<T, T_v>>;
78 template<
typename T_UnaryOp,
typename T, T... T_values>
79 [[nodiscard]]
constexpr auto filterValues(T_UnaryOp
const op, std::integer_sequence<T, T_values...> _)
82 return concatenate(selectValue<op(T_values), T, T_values>{}...);
93 template<
typename T_Seq>
96 template<
typename T,
template<
typename, T...>
typename T_Seq, T... T_values>
97 struct Contains<T_Seq<T, T_values...>>
99 using argument_type = T;
101 constexpr bool operator()(T value)
const
103 return ((value == T_values) || ...);
112 template<
typename T, T... T_values>
113 struct Contains<
std::integer_sequence<T, T_values...>>
115 using argument_type = T;
117 constexpr bool operator()(T value)
const
119 return ((value == T_values) || ...);
134 template<
typename T, u
int32_t T_dim>
137 using IotaSeq = std::make_integer_sequence<T, T_dim>;
138 return detail::integerSequenceToCVec(IotaSeq{});
152 template<
typename T, u
int32_t T_dim, T T_val>
155 auto concatCVec = []<T... T_values>(
CVec<T, T_values...>) ->
auto {
return CVec<T, T_values..., T_val>{}; };
157 static_assert(T_dim > 0);
158 if constexpr(T_dim == 1)
171 using namespace detail;
172 constexpr auto rightSeq = toIntegerSequence(right);
174 return integerSequenceToCVec(
175 filterValues(detail::Contains<
ALPAKA_TYPEOF(rightSeq)>{}, toIntegerSequence(left)));
#define ALPAKA_TYPEOF(...)
Get the type of instance.
Concept to check if a type is a CVector.
Vec< T, sizeof...(T_values), detail::CVec< T, T_values... > > CVec
A vector with compile-time known values.
consteval auto fillCVec()
Create and return a CVector of some length, filled with the given value.
consteval auto iotaCVec()
Create and return a CVector of the given length with values 1, 2, ...
constexpr auto filter(concepts::CVector auto left, concepts::CVector auto right)
Filter the left vector with the right vector's values.