Skip to content

Commit

Permalink
Updated tuple iteration for uninstantiated tuples with C++14
Browse files Browse the repository at this point in the history
... using pack expansion instead of unrolling
  • Loading branch information
trueqbit committed Nov 8, 2023
1 parent 45db8d8 commit 63d1978
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
11 changes: 4 additions & 7 deletions dev/tuple_helper/tuple_iteration.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,10 @@ namespace sqlite_orm {
(lambda((std::tuple_element_t<Idx, Tpl>*)nullptr), ...);
}
#else
template<class Tpl, class L>
void iterate_tuple(std::index_sequence<>, L&& /*lambda*/) {}

template<class Tpl, size_t I, size_t... Idx, class L>
void iterate_tuple(std::index_sequence<I, Idx...>, L&& lambda) {
lambda((std::tuple_element_t<I, Tpl>*)nullptr);
iterate_tuple<Tpl>(std::index_sequence<Idx...>{}, std::forward<L>(lambda));
template<class Tpl, size_t... Idx, class L>
void iterate_tuple(std::index_sequence<Idx...>, L&& lambda) {
using Sink = int[sizeof...(Idx)];
(void)Sink{(lambda((std::tuple_element_t<Idx, Tpl>*)nullptr), 0)...};
}
#endif
template<class Tpl, class L>
Expand Down
11 changes: 4 additions & 7 deletions include/sqlite_orm/sqlite_orm.h
Original file line number Diff line number Diff line change
Expand Up @@ -7043,13 +7043,10 @@ namespace sqlite_orm {
(lambda((std::tuple_element_t<Idx, Tpl>*)nullptr), ...);
}
#else
template<class Tpl, class L>
void iterate_tuple(std::index_sequence<>, L&& /*lambda*/) {}

template<class Tpl, size_t I, size_t... Idx, class L>
void iterate_tuple(std::index_sequence<I, Idx...>, L&& lambda) {
lambda((std::tuple_element_t<I, Tpl>*)nullptr);
iterate_tuple<Tpl>(std::index_sequence<Idx...>{}, std::forward<L>(lambda));
template<class Tpl, size_t... Idx, class L>
void iterate_tuple(std::index_sequence<Idx...>, L&& lambda) {
using Sink = int[sizeof...(Idx)];
(void)Sink{(lambda((std::tuple_element_t<Idx, Tpl>*)nullptr), 0)...};
}
#endif
template<class Tpl, class L>
Expand Down

0 comments on commit 63d1978

Please sign in to comment.