summaryrefslogtreecommitdiff
path: root/libdbpp/selectcommandUtil.impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'libdbpp/selectcommandUtil.impl.h')
-rw-r--r--libdbpp/selectcommandUtil.impl.h18
1 files changed, 6 insertions, 12 deletions
diff --git a/libdbpp/selectcommandUtil.impl.h b/libdbpp/selectcommandUtil.impl.h
index 9ef901e..cd64e7e 100644
--- a/libdbpp/selectcommandUtil.impl.h
+++ b/libdbpp/selectcommandUtil.impl.h
@@ -6,19 +6,13 @@
/// @cond
namespace DB {
- template<typename Fields, typename Func, unsigned int field, typename... Fn, typename... Args>
+ template<typename... Fn, std::size_t... I>
inline void
- forEachField(DB::SelectCommand * sel, const Func & func, Args &&... args)
+ forEachField(DB::SelectCommand * sel [[maybe_unused]], auto && func, std::index_sequence<I...>)
{
- if constexpr (field >= std::tuple_size<Fields>::value) {
- (void)sel;
- func(std::forward<Args>(args)...);
- }
- else {
- typename std::tuple_element<field, Fields>::type a;
- (*sel)[field] >> a;
- forEachField<Fields, Func, field + 1, Fn...>(sel, func, args..., a);
- }
+ std::tuple<Fn...> values;
+ (((*sel)[I] >> std::get<I>(values)), ...);
+ std::apply(func, values);
}
template<typename... Fn, typename Func>
@@ -26,7 +20,7 @@ namespace DB {
SelectCommand::forEachRow(const Func & func)
{
while (fetch()) {
- forEachField<std::tuple<Fn...>, Func, 0>(this, func);
+ forEachField<Fn...>(this, func, std::make_index_sequence<sizeof...(Fn)> {});
}
}