Use std::index_sequence_for<Ts...> instead of std::make_index_sequence<sizeof...(Ts)>

This commit is contained in:
sha512sum 2024-02-28 21:01:46 +00:00
parent e6f988f320
commit 53ed6a22e9
4 changed files with 7 additions and 8 deletions

View file

@ -4,7 +4,7 @@
namespace utempl { namespace utempl {
template <std::size_t> template <std::size_t>
struct ConstexprString; struct ConstexprString;
}; } // namespace utempl
template <std::size_t Size> template <std::size_t Size>
struct fmt::formatter<utempl::ConstexprString<Size>> : public fmt::formatter<std::string_view> { struct fmt::formatter<utempl::ConstexprString<Size>> : public fmt::formatter<std::string_view> {
@ -37,7 +37,6 @@ struct ConstexprString {
inline constexpr ConstexprString() = default; inline constexpr ConstexprString() = default;
inline constexpr ConstexprString(const char (&data)[Size]) : data{} { inline constexpr ConstexprString(const char (&data)[Size]) : data{} {
std::ranges::copy_n(data, Size, this->data.begin()); std::ranges::copy_n(data, Size, this->data.begin());
}; };
inline constexpr ConstexprString(std::string data) : data{} { inline constexpr ConstexprString(std::string data) : data{} {
std::ranges::copy_n(data.begin(), Size, this->data.begin()); std::ranges::copy_n(data.begin(), Size, this->data.begin());

View file

@ -78,7 +78,7 @@ struct Menu {
return [&]<auto... Is>(std::index_sequence<Is...>){ return [&]<auto... Is>(std::index_sequence<Is...>){
constexpr auto list = ListFromTuple(storage); constexpr auto list = ListFromTuple(storage);
return GetMax(std::array{(std::remove_cvref_t<decltype(*std::declval<decltype(Get<Is>(list))>().need)>::kSize != 0 ? std::remove_cvref_t<decltype(*std::declval<decltype(Get<Is>(list))>().need)>::kSize : CountDigits(Is))...}); return GetMax(std::array{(std::remove_cvref_t<decltype(*std::declval<decltype(Get<Is>(list))>().need)>::kSize != 0 ? std::remove_cvref_t<decltype(*std::declval<decltype(Get<Is>(list))>().need)>::kSize : CountDigits(Is))...});
}(std::make_index_sequence<sizeof...(Fs)>()); }(std::index_sequence_for<Fs...>());
}; };
template <impl::CallbackMessage message, std::invocable F> template <impl::CallbackMessage message, std::invocable F>
constexpr auto With(F&& f) const { constexpr auto With(F&& f) const {
@ -129,7 +129,7 @@ struct Menu {
}; };
}; };
}(Wrapper<Is>{}), ...); }(Wrapper<Is>{}), ...);
}(std::make_index_sequence<sizeof...(Fs)>()); }(std::index_sequence_for<Fs...>());
}; };
}; };

View file

@ -71,7 +71,7 @@ struct Tuple : public impl::TupleHelper<std::index_sequence_for<Ts...>, Ts...> {
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::make_index_sequence<sizeof...(Ts)>(), std::make_index_sequence<sizeof...(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& {

View file

@ -52,7 +52,7 @@ template <typename... Ts>
consteval auto Reverse(TypeList<Ts...> list) { consteval auto Reverse(TypeList<Ts...> list) {
return [&]<auto... Is>(std::index_sequence<Is...>) -> TypeList<decltype(Get<sizeof...(Ts) - Is - 1>(list))...> { return [&]<auto... Is>(std::index_sequence<Is...>) -> TypeList<decltype(Get<sizeof...(Ts) - Is - 1>(list))...> {
return {}; return {};
}(std::make_index_sequence<sizeof...(Ts)>()); }(std::index_sequence_for<Ts...>());
}; };
template <typename... Ts> template <typename... Ts>