Tuple fixes
This commit is contained in:
parent
461a7ee3e0
commit
8dedf835b6
2 changed files with 13 additions and 6 deletions
|
@ -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)...) {};
|
impl::TupleHelper<std::index_sequence_for<Ts...>, Ts...>(std::move(args)...) {};
|
||||||
inline constexpr Tuple(const Tuple&) = default;
|
inline constexpr Tuple(const Tuple&) = default;
|
||||||
inline constexpr Tuple(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>
|
template <typename... TTs>
|
||||||
inline constexpr auto operator+(const Tuple<TTs...>& other) const -> Tuple<Ts..., 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 [&]<auto... Is, auto... IIs>(std::index_sequence<Is...>, std::index_sequence<IIs...>) -> Tuple<Ts..., TTs...> {
|
||||||
return {Get<Is>(*this)..., Get<IIs>(other)...};
|
return {Get<Is>(*this)..., Get<IIs>(other)...};
|
||||||
}(std::index_sequence_for<Ts...>(), std::index_sequence_for<TTs...>());
|
}(std::index_sequence_for<Ts...>(), std::index_sequence_for<TTs...>());
|
||||||
};
|
};
|
||||||
|
|
||||||
template <auto I>
|
template <auto I>
|
||||||
inline constexpr auto operator[](Wrapper<I>) const -> const auto& {
|
inline constexpr auto operator[](Wrapper<I>) const -> const auto& {
|
||||||
return Get<I>(*this);
|
return Get<I>(*this);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <auto I>
|
template <auto I>
|
||||||
inline constexpr auto operator[](Wrapper<I>) -> auto& {
|
inline constexpr auto operator[](Wrapper<I>) -> auto& {
|
||||||
return Get<I>(*this);
|
return Get<I>(*this);
|
||||||
|
@ -86,7 +96,7 @@ template <typename T>
|
||||||
struct Process {
|
struct Process {
|
||||||
using type = decltype(Overloaded(
|
using type = decltype(Overloaded(
|
||||||
[]<typename TT>(TT&&) -> std::remove_cvref_t<TT> {},
|
[]<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>()));
|
)(std::declval<T>()));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -66,10 +66,7 @@ template <typename T>
|
||||||
inline constexpr std::size_t kTupleSize<T&> = kTupleSize<std::remove_reference_t<T>>;
|
inline constexpr std::size_t kTupleSize<T&> = kTupleSize<std::remove_reference_t<T>>;
|
||||||
|
|
||||||
template <typename 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 <typename T>
|
|
||||||
inline constexpr std::size_t kTupleSize<const T&&> = kTupleSize<std::remove_cvref_t<T>>;
|
|
||||||
|
|
||||||
template <template <typename...> typename M, typename... Ts>
|
template <template <typename...> typename M, typename... Ts>
|
||||||
inline constexpr std::size_t kTupleSize<M<Ts...>> = sizeof...(Ts);
|
inline constexpr std::size_t kTupleSize<M<Ts...>> = sizeof...(Ts);
|
||||||
|
|
Loading…
Reference in a new issue