1
1
#include " compiler.hpp"
2
- #include " ordered_set .hpp"
2
+ #include " ../tuple .hpp"
3
3
4
- #include < tuple>
5
4
#include < type_traits>
6
5
7
6
@@ -55,7 +54,7 @@ namespace cib::detail {
55
54
};
56
55
57
56
/* *
58
- * fold_right a ordered_set of elements.
57
+ * fold_right a tuple of elements.
59
58
*
60
59
* Fold operations are sometimes called accumulate or reduce in other
61
60
* languages or libraries.
@@ -66,7 +65,7 @@ namespace cib::detail {
66
65
* A callable that takes the current element being processed
67
66
* and the current state, and returns the state to be used
68
67
* to process the next element. Called for each element in
69
- * the ordered_set .
68
+ * the tuple .
70
69
*
71
70
* @return
72
71
* The final state of all of the operations.
@@ -76,7 +75,7 @@ namespace cib::detail {
76
75
typename InitType,
77
76
typename CallableType>
78
77
[[nodiscard]] CIB_CONSTEXPR inline static auto fold_right (
79
- std::tuple <ElementTypes...> const & elements,
78
+ tuple_impl <ElementTypes...> const & elements,
80
79
InitType const & initial_state,
81
80
CallableType const & operation
82
81
) {
@@ -85,37 +84,6 @@ namespace cib::detail {
85
84
}, elements);
86
85
}
87
86
88
- /* *
89
- * fold_right a ordered_set of elements.
90
- *
91
- * Fold operations are sometimes called accumulate or reduce in other
92
- * languages or libraries.
93
- *
94
- * https://en.wikipedia.org/wiki/Fold_%28higher-order_function%29
95
- *
96
- * @param operation
97
- * A callable that takes the current element being processed
98
- * and the current state, and returns the state to be used
99
- * to process the next element. Called for each element in
100
- * the ordered_set.
101
- *
102
- * @return
103
- * The final state of all of the operations.
104
- */
105
- template <
106
- typename ... ElementTypes,
107
- typename InitType,
108
- typename CallableType>
109
- [[nodiscard]] CIB_CONSTEXPR inline static auto fold_right (
110
- ordered_set<ElementTypes...> const & elements,
111
- InitType const & initial_state,
112
- CallableType const & operation
113
- ) {
114
- return apply ([&](auto const & ... element_pack){
115
- return (fold_helper{element_pack, operation} + ... + initial_state);
116
- }, elements);
117
- }
118
-
119
87
/* *
120
88
* Perform an operation on each element of an integral sequence.
121
89
*
@@ -153,7 +121,7 @@ namespace cib::detail {
153
121
}
154
122
155
123
/* *
156
- * Perform an operation on each element of a ordered_set .
124
+ * Perform an operation on each element of a tuple .
157
125
*
158
126
* @param operation
159
127
* The operation to perform. Must be a callable that accepts a single parameter.
@@ -162,31 +130,13 @@ namespace cib::detail {
162
130
typename ... ElementTypes,
163
131
typename CallableType>
164
132
CIB_CONSTEXPR inline void for_each (
165
- std::tuple <ElementTypes...> const & elements,
133
+ tuple_impl <ElementTypes...> const & elements,
166
134
CallableType const & operation
167
135
) {
168
136
apply ([&](auto const & ... element_pack){
169
137
(operation (element_pack) , ...);
170
138
}, elements);
171
139
}
172
-
173
- /* *
174
- * Perform an operation on each element of a ordered_set.
175
- *
176
- * @param operation
177
- * The operation to perform. Must be a callable that accepts a single parameter.
178
- */
179
- template <
180
- typename ... ElementTypes,
181
- typename CallableType>
182
- CIB_CONSTEXPR inline void for_each (
183
- ordered_set<ElementTypes...> const & elements,
184
- CallableType const & operation
185
- ) {
186
- apply ([&](auto const & ... element_pack){
187
- (operation (element_pack) , ...);
188
- }, elements);
189
- }
190
140
}
191
141
192
142
0 commit comments