From 63d197835262f26d1af825f7bb87050e76fcd04a Mon Sep 17 00:00:00 2001 From: klaus triendl Date: Wed, 8 Nov 2023 15:33:39 +0200 Subject: [PATCH] Updated tuple iteration for uninstantiated tuples with C++14 ... using pack expansion instead of unrolling --- dev/tuple_helper/tuple_iteration.h | 11 ++++------- include/sqlite_orm/sqlite_orm.h | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/dev/tuple_helper/tuple_iteration.h b/dev/tuple_helper/tuple_iteration.h index 7a73b6c6e..f519f08ff 100644 --- a/dev/tuple_helper/tuple_iteration.h +++ b/dev/tuple_helper/tuple_iteration.h @@ -76,13 +76,10 @@ namespace sqlite_orm { (lambda((std::tuple_element_t*)nullptr), ...); } #else - template - void iterate_tuple(std::index_sequence<>, L&& /*lambda*/) {} - - template - void iterate_tuple(std::index_sequence, L&& lambda) { - lambda((std::tuple_element_t*)nullptr); - iterate_tuple(std::index_sequence{}, std::forward(lambda)); + template + void iterate_tuple(std::index_sequence, L&& lambda) { + using Sink = int[sizeof...(Idx)]; + (void)Sink{(lambda((std::tuple_element_t*)nullptr), 0)...}; } #endif template diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index 9aeadb9cc..141d89d9c 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -7043,13 +7043,10 @@ namespace sqlite_orm { (lambda((std::tuple_element_t*)nullptr), ...); } #else - template - void iterate_tuple(std::index_sequence<>, L&& /*lambda*/) {} - - template - void iterate_tuple(std::index_sequence, L&& lambda) { - lambda((std::tuple_element_t*)nullptr); - iterate_tuple(std::index_sequence{}, std::forward(lambda)); + template + void iterate_tuple(std::index_sequence, L&& lambda) { + using Sink = int[sizeof...(Idx)]; + (void)Sink{(lambda((std::tuple_element_t*)nullptr), 0)...}; } #endif template