23 template<
typename type_t>
29 enumerable_generator get_return_object() {
return enumerable_generator {std::coroutine_handle<promise_type>::from_promise(*
this)};}
31 std::suspend_always initial_suspend()
noexcept {
return {};}
32 std::suspend_always final_suspend()
noexcept {
return {};}
33 void return_void()
noexcept {}
34 void unhandled_exception() {std::terminate();}
36 std::suspend_always yield_value(type_t value)
noexcept {
37 current_value = std::move(value);
42 enumerable_generator(
const enumerable_generator&
other) =
delete;
43 enumerable_generator& operator =(
const enumerable_generator&
other) =
delete;
44 enumerable_generator(enumerable_generator&&
other) noexcept : handle_(std::exchange(
other.handle_, {})) {}
46 handle_ = std::exchange(
other.handle_, {});
49 ~enumerable_generator()
override {
if (handle_) handle_.destroy();}
53 explicit generator_enumerator(std::coroutine_handle<promise_type> handle) : handle_(handle) {}
54 const type_t& current()
const override {
return handle_.promise().current_value;}
55 bool move_next()
override {
56 if (!handle_ || handle_.done())
return false;
58 return !handle_.done();
63 std::coroutine_handle<promise_type> handle_;
72 mutable std::coroutine_handle<promise_type> handle_;
Represents an enumerable enumerable_generator.
Definition enumerable_generator.hpp:24
xtd::collections::generic::enumerator< type_t > get_enumerator() const override
Returns an enumerator that iterates through a collection.
Definition enumerable_generator.hpp:51
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
Supports a simple iteration over a generic collection.
Definition ienumerator.hpp:58
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
Contains xtd::collections::generic::ienumerable <type_t> interface.
Contains xtd::collections::generic::ienumerator <type_t> interface.
@ not_supported
The method or operation is not supported.
Definition exception_case.hpp:77
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
@ other
The operating system is other.
Definition platform_id.hpp:60
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Definition enumerable_generator.hpp:26
Supports a simple iteration over a generic collection.
Definition enumerator.hpp:38
Contains xtd::helpers::throw_helper class.