-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperation_stack.hpp
More file actions
39 lines (32 loc) · 833 Bytes
/
Copy pathoperation_stack.hpp
File metadata and controls
39 lines (32 loc) · 833 Bytes
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
30
31
32
33
34
35
36
37
38
39
#pragma once
#include<utility>
#include<cstddef>
#include<iostream>
#include"constant_parameter.hpp"
namespace mlib
{
struct run_all_t {};
static constexpr auto run_all = run_all_t{};
template<auto callable, auto... operations>
constexpr auto for_each_pack()
{
[&] <std::size_t... indexes>(std::index_sequence<indexes...>)
{
(callable(operations), ...);
}(std::make_index_sequence<sizeof...(operations)>{});
}
template<auto... operations>
struct operation_stack
{
template<auto T>
constexpr auto enque(mlib::constexpr_parameter<T>)
{
return operation_stack<operations, T>{};
}
template<auto type>
constexpr auto run()
{
for_each_pack < [](auto& x) {x(); }, operations... > ();
};
};
} // namespace mlib