Skip to content

Commit e2883d9

Browse files
authored
Merge branch 'vibe' into claude/fix-pr-checks-7sDk2
2 parents 9e12a8a + 7cbefa5 commit e2883d9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cpp/include/mh/coroutine/generator.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,19 @@ namespace mh
160160
}
161161
detail::generator_hpp::iterator_end end() { return {}; }
162162

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+
163176
private:
164177
coroutine_type m_Handle;
165178
};

0 commit comments

Comments
 (0)