summaryrefslogtreecommitdiff
path: root/src/util.hpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-08-24 12:00:10 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2025-08-25 16:02:46 +0100
commit7301fe6484dc1b1d652425ad005ccfd214002a87 (patch)
treef12bf0ce0ed7adc3f0aea06cf85858aef8c1fdcb /src/util.hpp
parente30cbf9fef8922abef4cc44ad8628d4eef5d28a9 (diff)
downloadwebstat-7301fe6484dc1b1d652425ad005ccfd214002a87.tar.bz2
webstat-7301fe6484dc1b1d652425ad005ccfd214002a87.tar.xz
webstat-7301fe6484dc1b1d652425ad005ccfd214002a87.zip
Merge storeEntities into a single thing
Add visitSum for tuples and makes storeEntities into a single lambda.
Diffstat (limited to 'src/util.hpp')
-rw-r--r--src/util.hpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util.hpp b/src/util.hpp
new file mode 100644
index 0000000..0ed260c
--- /dev/null
+++ b/src/util.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <tuple>
+
+namespace WebStat {
+ template<typename... T>
+ auto
+ visitSum(auto && visitor, const std::tuple<T...> & values)
+ {
+ return std::apply(
+ [&](auto &&... value) {
+ return (visitor(value) + ...);
+ },
+ values);
+ }
+}