53 static_assert((std::is_trivially_copyable_v<Components> && ...));
57 using size_type = size_t;
59 [[nodiscard]]
consteval static size_t size()
noexcept {
return sizeof...(Components); }
62 static constexpr void forEachComponent(F&& func)
noexcept {
63 meta::unrollType<Components...>(func);
66 [[nodiscard]]
constexpr std::string toString()
const noexcept {
68 forEachComponent([&]<
typename axis_type,
size_t iter> {
69 res = fmt::format(
"{}{}", res,
static_cast<T const*
>(
this)->
template get<axis_type, iter>());
70 res += ((iter < size() - 1) ?
", " :
")");
75 [[nodiscard]]
constexpr bool operator==(T
const& b)
const noexcept {
77 forEachComponent([&]<
typename axis_type,
size_t iter> {
79 && (b.template get<axis_type, iter>() ==
static_cast<T const*
>(
this)->
template get<axis_type, iter>());
84 [[nodiscard]]
constexpr bool operator!=(T
const& b)
const noexcept {
85 return !(
static_cast<bool>((
static_cast<T const*
>(
this))->operator==(b)));
88 [[nodiscard]]
constexpr first_type& operator[](
size_t index)
noexcept
89 requires(traits::is_all_same_v<first_type, Components...>)
91 return ::ll::meta::visitIndex<size()>(index, [&]<
size_t I>() -> first_type& {
92 return static_cast<T*
>(
this)->
template get<first_type, I>();
96 [[nodiscard]]
constexpr first_type
const& operator[](
size_t index)
const noexcept
97 requires(traits::is_all_same_v<first_type, Components...>)
99 return ::ll::meta::visitIndex<size()>(index, [&]<
size_t I>() -> first_type
const& {
100 return static_cast<T*
>(
this)->
template get<first_type, I>();
104 [[nodiscard]]
constexpr size_t hash()
const noexcept {
106 forEachComponent([&]<
typename axis_type,
size_t iter> {
108 hash_utils::hashCombine(
static_cast<T const*
>(
this)->
template get<axis_type, iter>().hash(), res);
110 hash_utils::hashCombine(
111 std::hash<axis_type>()(
static_cast<T const*
>(
this)->
template get<axis_type, iter>()),
119 template <ll::concepts::IsVectorBase V>
120 [[nodiscard]]
constexpr V as()
const noexcept
121 requires(V::size() == size() && std::convertible_to<T, V>)
123 return static_cast<V
>(*this);
126 [[nodiscard]]
constexpr class boolN<sizeof...(Components)> eq(T const& b)
const noexcept
127 requires(
sizeof...(Components) >= 2 &&
sizeof...(Components) <= 4)
129 boolN<
sizeof...(Components)> res =
true;
130 forEachComponent([&]<
typename axis_type,
size_t iter> {
132 (b.template get<axis_type, iter>() ==
static_cast<T const*
>(
this)->
template get<axis_type, iter>());
137 [[nodiscard]]
constexpr class boolN<sizeof...(Components)> ne(T const& b)
const noexcept
138 requires(
sizeof...(Components) >= 2 &&
sizeof...(Components) <= 4)
140 boolN<
sizeof...(Components)> res =
true;
141 forEachComponent([&]<
typename axis_type,
size_t iter> {
143 (b.template get<axis_type, iter>() !=
static_cast<T const*
>(
this)->
template get<axis_type, iter>());