#pragma once #include #include #include #include #define UNUSED(x) ((void)(x)) template using lambda_unique_ptr = std::unique_ptr>; std::string formatDuration(std::chrono::duration seconds); std::string formatTime(time_t time, const std::string& format); template void for_each_adjacent( iterator_type begin, iterator_type end, std::function>&)> f) { // Get the first n values iterator_type it = begin; using element_type = std::reference_wrapper; std::deque values; for (unsigned i = 0; i < n; ++i) { if (it == end) return; values.push_back(std::ref(*it)); if (i < n - 1) ++it; } for (; it != end; ++it) { f(values); values.pop_front(); values.push_back(*it); } } template void for_each_adjacent( iterator_type begin, iterator_type end, std::function f) { for_each_adjacent<2>(begin, end, [&](const std::deque>& args) { f(args[0], args[1]); }); } template void for_each_adjacent( iterator_type begin, iterator_type end, std::function f) { for_each_adjacent<3>(begin, end, [&](const std::deque>& args) { f(args[0], args[1], args[2]); }); }