-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstexpr_while.hpp
More file actions
36 lines (33 loc) · 827 Bytes
/
Copy pathconstexpr_while.hpp
File metadata and controls
36 lines (33 loc) · 827 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
#pragma once
#include<iostream>
namespace mlib
{
template<auto Value, auto Condition, auto ToDo, auto operation>
constexpr auto constexpr_while_helper()
{
if constexpr (Condition(Value))
{
ToDo();
constexpr_while_helper<operation(Value), Condition, ToDo, operation>();
}
else
{
// we end loop
}
}
template<auto Value, auto Condition, auto ToDo, auto operation>
struct constexpr_while
{
constexpr constexpr_while()
{
if constexpr (Condition(Value))
{
constexpr_while_helper<operation(Value), Condition, ToDo, operation>();
}
else
{
// we end the program.
}
}
};
} // namespace mlib