diff --git a/dev/functional/index_sequence_util.h b/dev/functional/index_sequence_util.h index c0fec862..1e892cc4 100644 --- a/dev/functional/index_sequence_util.h +++ b/dev/functional/index_sequence_util.h @@ -1,61 +1,61 @@ -#pragma once - -#include // std::index_sequence - -namespace sqlite_orm { - namespace internal { -#if defined(SQLITE_ORM_PACK_INDEXING_SUPPORTED) - /** - * Get the index value of an `index_sequence` at a specific position. - */ - template - SQLITE_ORM_CONSTEVAL size_t index_sequence_value_at(std::index_sequence) { - return Idx...[Pos]; - } -#elif defined(SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED) - /** - * Get the index value of an `index_sequence` at a specific position. - */ - template - SQLITE_ORM_CONSTEVAL size_t index_sequence_value_at(std::index_sequence) { - static_assert(Pos < sizeof...(Idx)); -#ifdef SQLITE_ORM_CONSTEVAL_SUPPORTED - size_t result; -#else - size_t result = 0; -#endif - size_t i = 0; - // note: `(void)` cast silences warning 'expression result unused' - (void)((result = Idx, i++ == Pos) || ...); - return result; - } -#else - /** - * Get the index value of an `index_sequence` at a specific position. - * `Pos` must always be `0`. - */ - template - SQLITE_ORM_CONSTEVAL size_t index_sequence_value_at(std::index_sequence) { - static_assert(Pos == 0, ""); - return I; - } -#endif - - template - struct flatten_idxseq { - using type = std::index_sequence<>; - }; - - template - struct flatten_idxseq> { - using type = std::index_sequence; - }; - - template - struct flatten_idxseq, std::index_sequence, Seq...> - : flatten_idxseq, Seq...> {}; - - template - using flatten_idxseq_t = typename flatten_idxseq::type; - } -} +#pragma once + +#include // std::index_sequence + +namespace sqlite_orm { + namespace internal { +#if defined(SQLITE_ORM_PACK_INDEXING_SUPPORTED) + /** + * Get the index value of an `index_sequence` at a specific position. + */ + template + SQLITE_ORM_CONSTEVAL auto index_sequence_value_at(std::index_sequence) { + return Idx...[Pos]; + } +#elif defined(SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED) + /** + * Get the index value of an `index_sequence` at a specific position. + */ + template + SQLITE_ORM_CONSTEVAL size_t index_sequence_value_at(std::index_sequence) { + static_assert(Pos < sizeof...(Idx)); +#ifdef SQLITE_ORM_CONSTEVAL_SUPPORTED + size_t result; +#else + size_t result = 0; +#endif + size_t i = 0; + // note: `(void)` cast silences warning 'expression result unused' + (void)((result = Idx, i++ == Pos) || ...); + return result; + } +#else + /** + * Get the index value of an `index_sequence` at a specific position. + * `Pos` must always be `0`. + */ + template + SQLITE_ORM_CONSTEVAL size_t index_sequence_value_at(std::index_sequence) { + static_assert(Pos == 0, ""); + return I; + } +#endif + + template + struct flatten_idxseq { + using type = std::index_sequence<>; + }; + + template + struct flatten_idxseq> { + using type = std::index_sequence; + }; + + template + struct flatten_idxseq, std::index_sequence, Seq...> + : flatten_idxseq, Seq...> {}; + + template + using flatten_idxseq_t = typename flatten_idxseq::type; + } +} diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index ed5c2d8c..284f9e09 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -1371,7 +1371,7 @@ namespace sqlite_orm { * Get the index value of an `index_sequence` at a specific position. */ template - SQLITE_ORM_CONSTEVAL size_t index_sequence_value_at(std::index_sequence) { + SQLITE_ORM_CONSTEVAL auto index_sequence_value_at(std::index_sequence) { return Idx...[Pos]; } #elif defined(SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED)