summaryrefslogtreecommitdiff
path: root/src/util.hpp
blob: 4965ae7cef69710cd269638d21474895a95933ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include <command.h>
#include <tuple>

namespace WebStat {
	template<auto Deleter>
	using DeleteWith = decltype([](auto obj) {
		return Deleter(obj);
	});

	template<typename... T>
	auto
	visit(auto && visitor, const std::tuple<T...> & values)
	{
		std::apply(
				[&](auto &&... value) {
					(visitor(value), ...);
				},
				values);
	}

	template<typename... T>
	void
	bindMany(const DB::CommandPtr & cmd, unsigned int firstParam, T &&... param)
	{
		(cmd->bindParam(firstParam++, std::forward<T>(param)), ...);
	}
}