MCPcopy Create free account
hub / github.com/3rdparty/libprocess / ControlFlow

Class ControlFlow

include/process/loop.hpp:163–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161// the functions `Continue()` and `Break(...)`).
162template <typename T>
163class ControlFlow
164{
165public:
166 using ValueType = T;
167
168 enum class Statement
169 {
170 CONTINUE,
171 BREAK
172 };
173
174 class Continue
175 {
176 public:
177 Continue() = default;
178
179 template <typename U>
180 operator ControlFlow<U>() const
181 {
182 return ControlFlow<U>(ControlFlow<U>::Statement::CONTINUE, None());
183 }
184 };
185
186 class Break
187 {
188 public:
189 Break(T t) : t(std::move(t)) {}
190
191 template <typename U>
192 operator ControlFlow<U>() const &
193 {
194 return ControlFlow<U>(ControlFlow<U>::Statement::BREAK, t);
195 }
196
197 template <typename U>
198 operator ControlFlow<U>() &&
199 {
200 return ControlFlow<U>(ControlFlow<U>::Statement::BREAK, std::move(t));
201 }
202
203 private:
204 T t;
205 };
206
207 ControlFlow(Statement s, Option<T> t) : s(s), t(std::move(t)) {}
208
209 Statement statement() const { return s; }
210
211 T& value() & { return t.get(); }
212 const T& value() const & { return t.get(); }
213 T&& value() && { return t.get(); }
214 const T&& value() const && { return t.get(); }
215
216private:
217 Statement s;
218 Option<T> t;
219};
220

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected