Tuple fixes

This commit is contained in:
sha512sum 2024-02-28 23:16:12 +00:00
parent 461a7ee3e0
commit 8dedf835b6
2 changed files with 13 additions and 6 deletions

View file

@ -64,17 +64,27 @@ struct Tuple : public impl::TupleHelper<std::index_sequence_for<Ts...>, Ts...> {
impl::TupleHelper<std::index_sequence_for<Ts...>, Ts...>(std::move(args)...) {};
inline constexpr Tuple(const Tuple&) = default;
inline constexpr Tuple(Tuple&&) = default;
inline constexpr bool operator==(const Tuple&) const = default;
template <typename... TTs>
inline constexpr bool operator==(const Tuple<TTs...>& other) const
requires (TypeList<Ts...>{} == TypeList<TTs...>{}) {
return [&]<auto... Is>(std::index_sequence<Is...>){
return ((Get<Is>(*this) == Get<Is>(other)) && ...);
}(std::index_sequence_for<TTs...>());
};
template <typename... TTs>
inline constexpr auto operator+(const Tuple<TTs...>& other) const -> Tuple<Ts..., TTs...> {
return [&]<auto... Is, auto... IIs>(std::index_sequence<Is...>, std::index_sequence<IIs...>) -> Tuple<Ts..., TTs...> {
return {Get<Is>(*this)..., Get<IIs>(other)...};
}(std::index_sequence_for<Ts...>(), std::index_sequence_for<TTs...>());
};
template <auto I>
inline constexpr auto operator[](Wrapper<I>) const -> const auto& {
return Get<I>(*this);
};
template <auto I>
inline constexpr auto operator[](Wrapper<I>) -> auto& {
return Get<I>(*this);
@ -86,7 +96,7 @@ template <typename T>
struct Process {
using type = decltype(Overloaded(
[]<typename TT>(TT&&) -> std::remove_cvref_t<TT> {},
[]<std::size_t N>(const char(&)[N]) -> const char(&)[N] {}
[]<std::size_t N>(const char(&)[N]) -> const char* {}
)(std::declval<T>()));
};

View file

@ -66,10 +66,7 @@ template <typename T>
inline constexpr std::size_t kTupleSize<T&> = kTupleSize<std::remove_reference_t<T>>;
template <typename T>
inline constexpr std::size_t kTupleSize<const T&> = kTupleSize<std::remove_cvref_t<T>>;
template <typename T>
inline constexpr std::size_t kTupleSize<const T&&> = kTupleSize<std::remove_cvref_t<T>>;
inline constexpr std::size_t kTupleSize<const T> = kTupleSize<std::remove_cv_t<T>>;
template <template <typename...> typename M, typename... Ts>
inline constexpr std::size_t kTupleSize<M<Ts...>> = sizeof...(Ts);