diff options
author | HampusM <hampus@hampusmat.com> | 2022-06-11 23:06:04 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-12 12:56:52 +0200 |
commit | 10afd2aa0a35b45300cfb60bea656edf08c2b78c (patch) | |
tree | ded190e7e1243894848c5d823fe27e03c3ef16bf | |
parent | 7a191f97ce0c222566973f9e18b43036844ecf3c (diff) |
refactor: make tuple indices gcc compatible
-rw-r--r-- | include/yacppdic/detail/internal/tuple_indices.hpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/include/yacppdic/detail/internal/tuple_indices.hpp b/include/yacppdic/detail/internal/tuple_indices.hpp index 3a367b6..f2308e6 100644 --- a/include/yacppdic/detail/internal/tuple_indices.hpp +++ b/include/yacppdic/detail/internal/tuple_indices.hpp @@ -11,29 +11,27 @@ class TupleIndices }; template <typename IdxType, IdxType... Values> -class IntegerSequence +class TupleIndicesIntSequence { public: - template < - template <typename OIdxType, OIdxType...> - typename ToIndexSeq, - typename ToIndexType> - using Convert = ToIndexSeq<ToIndexType, Values...>; - template <std::size_t Sp> using ToTupleIndices = TupleIndices<(Values + Sp)...>; }; -template <std::size_t SizeOne, std::size_t SizeTwo> -using MakeIndices = - typename __make_integer_seq<IntegerSequence, std::size_t, SizeOne - SizeTwo>:: - template ToTupleIndices<SizeTwo>; - -template <std::size_t SizeOne, std::size_t SizeTwo = 0> -requires(SizeTwo <= SizeOne) class MakeTupleIndices +template <std::size_t EndIndex, std::size_t StartIndex> +using MakeIndices = typename +#if __has_builtin(__make_integer_seq) + __make_integer_seq<TupleIndicesIntSequence, std::size_t, EndIndex - StartIndex> +#else + TupleIndicesIntSequence<std::size_t, __integer_pack(EndIndex - StartIndex)...> +#endif + ::template ToTupleIndices<StartIndex>; + +template <std::size_t EndIndex, std::size_t StartIndex = 0> +requires(StartIndex <= EndIndex) class MakeTupleIndices { public: - using type = MakeIndices<SizeOne, SizeTwo>; + using type = MakeIndices<EndIndex, StartIndex>; }; } // namespace yacppdic::internal |