Skip to content

Commit a666113

Browse files
add times.hpp.
1 parent 211b62a commit a666113

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

times.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#pragma once
2+
3+
#include<utility>
4+
#include<cstddef>
5+
6+
namespace mlib
7+
{
8+
// this allows no recursion
9+
struct callable_wrapper
10+
{
11+
constexpr callable_wrapper() {}
12+
13+
constexpr auto operator()(auto callable, std::size_t index)
14+
{
15+
callable();
16+
}
17+
};
18+
19+
template<auto T>
20+
struct times
21+
{
22+
constexpr auto operator()(auto callable)
23+
{
24+
[&] <std::size_t... indexes>(std::index_sequence<indexes...>)
25+
{
26+
(callable_wrapper{}(callable, indexes), ...);
27+
}(std::make_index_sequence<T>{});
28+
}
29+
};
30+
} // namespace mlib

0 commit comments

Comments
 (0)