@@ -21,23 +21,46 @@ struct rt_node {
21
21
rt_node const &) -> bool = default ;
22
22
};
23
23
24
- template <stdx::ct_string Name> struct ct_node : rt_node {
24
+ template <stdx::ct_string Type, stdx::ct_string Name, bool IsReference,
25
+ typename F, typename ... Ps>
26
+ struct ct_node : rt_node {
25
27
using is_node = void ;
28
+ using type_t =
29
+ decltype (stdx::ct_string_to_type<Type, sc::string_constant>());
30
+
26
31
using name_t =
27
32
decltype (stdx::ct_string_to_type<Name, sc::string_constant>());
33
+
34
+ constexpr static auto is_reference = IsReference;
35
+
36
+ constexpr ct_node ()
37
+ : rt_node{.run =
38
+ [] {
39
+ if ((Ps{}() and ...)) {
40
+ F{}();
41
+ }
42
+ },
43
+ .log_name =
44
+ [] {
45
+ // if ((Ps{}() and ...)) {
46
+ CIB_TRACE (" flow.{}({})" , type_t {}, name_t {});
47
+ // }
48
+ }} {}
49
+
50
+ constexpr auto operator +() const -> ct_node<Type, Name, false , F, Ps...> {
51
+ return {};
52
+ }
28
53
};
29
54
30
55
template <stdx::ct_string Name, stdx::ct_string Type>
31
- static void log_name_func () {
32
- CIB_TRACE (" flow.{}({})" ,
33
- stdx::ct_string_to_type<Type, sc::string_constant>(),
34
- stdx::ct_string_to_type<Name, sc::string_constant>());
35
- }
56
+ constexpr static auto log_name_func = [] {
57
+
58
+ };
36
59
37
60
namespace detail {
38
- template <stdx::ct_string Name , stdx::ct_string Type , typename F>
61
+ template <stdx::ct_string Type , stdx::ct_string Name , typename F>
39
62
[[nodiscard]] constexpr auto make_node () {
40
- return ct_node<Name>{{. run = F{}, . log_name = log_name_func< Name, Type>} };
63
+ return ct_node<Type, Name, true , F>{ };
41
64
}
42
65
43
66
constexpr auto empty_func = []() {};
@@ -46,7 +69,7 @@ constexpr auto empty_func = []() {};
46
69
template <stdx::ct_string Name, typename F>
47
70
requires (stdx::is_function_object_v<F> and std::is_empty_v<F>)
48
71
[[nodiscard]] constexpr auto action (F const &) {
49
- return detail::make_node<Name, " action" , F>();
72
+ return detail::make_node<" action" , Name , F>();
50
73
}
51
74
52
75
template <stdx::ct_string Name> [[nodiscard]] constexpr auto action () {
@@ -58,7 +81,7 @@ template <stdx::ct_string Name> [[nodiscard]] constexpr auto step() {
58
81
}
59
82
60
83
template <stdx::ct_string Name> [[nodiscard]] constexpr auto milestone () {
61
- return detail::make_node<Name, " milestone" , decltype (detail::empty_func)>();
84
+ return detail::make_node<" milestone" , Name , decltype (detail::empty_func)>();
62
85
}
63
86
64
87
inline namespace literals {
@@ -75,4 +98,12 @@ template <stdx::ct_string S>
75
98
return milestone<S>();
76
99
}
77
100
} // namespace literals
101
+
102
+ template <typename P, stdx::ct_string Type, stdx::ct_string Name,
103
+ bool IsReference, typename F, typename ... Ps>
104
+ constexpr auto
105
+ make_runtime_conditional (P, ct_node<Type, Name, IsReference, F, Ps...>) {
106
+ return ct_node<Type, Name, IsReference, F, P, Ps...>{};
107
+ }
108
+
78
109
} // namespace flow
0 commit comments