diff --git a/dev/functional/index_sequence_util.h b/dev/functional/index_sequence_util.h index 061627247..b13343663 100644 --- a/dev/functional/index_sequence_util.h +++ b/dev/functional/index_sequence_util.h @@ -3,9 +3,6 @@ #include // std::index_sequence, std::make_index_sequence #include "../functional/cxx_universal.h" -#ifdef SQLITE_ORM_RELAXED_CONSTEXPR_SUPPORTED -#include -#endif namespace sqlite_orm { namespace internal { @@ -17,37 +14,6 @@ namespace sqlite_orm { return I; } -#ifdef SQLITE_ORM_RELAXED_CONSTEXPR_SUPPORTED - /** - * Reorder the values of an index_sequence according to the positions from a second sequence. - */ - template - SQLITE_ORM_CONSTEVAL auto reorder_index_sequence(std::index_sequence, - std::index_sequence) { - constexpr std::array values{Value...}; - return std::index_sequence{}; - } - - template - SQLITE_ORM_CONSTEVAL std::index_sequence reorder_index_sequence(std::index_sequence, - std::index_sequence) { - return {}; - } - - inline SQLITE_ORM_CONSTEVAL std::index_sequence<> reorder_index_sequence(std::index_sequence<>, - std::index_sequence<>) { - return {}; - } - - /** - * Reverse the values of an index_sequence. - */ - template - SQLITE_ORM_CONSTEVAL auto reverse_index_sequence(std::index_sequence) { - return reorder_index_sequence(std::index_sequence{}, std::make_index_sequence{}); - } -#endif - template struct flatten_idxseq { using type = std::index_sequence<>; diff --git a/dev/tuple_helper/tuple_iteration.h b/dev/tuple_helper/tuple_iteration.h index cb37f7cbe..4d0a971fc 100644 --- a/dev/tuple_helper/tuple_iteration.h +++ b/dev/tuple_helper/tuple_iteration.h @@ -33,7 +33,9 @@ namespace sqlite_orm { template void iterate_tuple(const Tpl& tpl, std::index_sequence, L&& lambda) { if constexpr(reversed) { - iterate_tuple(tpl, reverse_index_sequence(std::index_sequence{}), std::forward(lambda)); + // nifty fold expression trick: make use of guaranteed right-to-left evaluation order when folding over operator= + int sink; + ((lambda(std::get(tpl)), sink) = ... = 0); } else { (lambda(std::get(tpl)), ...); } diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index 10e526f6b..4dcc1bcd8 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -1114,10 +1114,6 @@ namespace sqlite_orm { // #include "../functional/cxx_universal.h" -#ifdef SQLITE_ORM_RELAXED_CONSTEXPR_SUPPORTED -#include -#endif - namespace sqlite_orm { namespace internal { /** @@ -1128,37 +1124,6 @@ namespace sqlite_orm { return I; } -#ifdef SQLITE_ORM_RELAXED_CONSTEXPR_SUPPORTED - /** - * Reorder the values of an index_sequence according to the positions from a second sequence. - */ - template - SQLITE_ORM_CONSTEVAL auto reorder_index_sequence(std::index_sequence, - std::index_sequence) { - constexpr std::array values{Value...}; - return std::index_sequence{}; - } - - template - SQLITE_ORM_CONSTEVAL std::index_sequence reorder_index_sequence(std::index_sequence, - std::index_sequence) { - return {}; - } - - inline SQLITE_ORM_CONSTEVAL std::index_sequence<> reorder_index_sequence(std::index_sequence<>, - std::index_sequence<>) { - return {}; - } - - /** - * Reverse the values of an index_sequence. - */ - template - SQLITE_ORM_CONSTEVAL auto reverse_index_sequence(std::index_sequence) { - return reorder_index_sequence(std::index_sequence{}, std::make_index_sequence{}); - } -#endif - template struct flatten_idxseq { using type = std::index_sequence<>; @@ -9574,7 +9539,9 @@ namespace sqlite_orm { template void iterate_tuple(const Tpl& tpl, std::index_sequence, L&& lambda) { if constexpr(reversed) { - iterate_tuple(tpl, reverse_index_sequence(std::index_sequence{}), std::forward(lambda)); + // nifty fold expression trick: make use of guaranteed right-to-left evaluation order when folding over operator= + int sink; + ((lambda(std::get(tpl)), sink) = ... = 0); } else { (lambda(std::get(tpl)), ...); }