We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9e12a8a + 7cbefa5 commit e2883d9Copy full SHA for e2883d9
1 file changed
cpp/include/mh/coroutine/generator.hpp
@@ -160,6 +160,19 @@ namespace mh
160
}
161
detail::generator_hpp::iterator_end end() { return {}; }
162
163
+ // Count elements (consumes the generator, only available on rvalues)
164
+ size_t count() && {
165
+ size_t n = 0;
166
+ for ([[maybe_unused]] auto&& _ : *this) ++n;
167
+ return n;
168
+ }
169
+
170
+ // Check if generator is empty (consumes at most one element, only available on rvalues)
171
+ bool empty() && {
172
+ for ([[maybe_unused]] auto&& _ : *this) return false;
173
+ return true;
174
175
176
private:
177
coroutine_type m_Handle;
178
};
0 commit comments