MCPcopy Create free account
hub / github.com/Codesire-Deng/co_context / nested_sequences_example

Function nested_sequences_example

test/generator_test.cpp:45–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43// the current generator's elements.
44
45co_context::generator<uint64_t, uint64_t> nested_sequences_example() {
46 std::printf("yielding elements_of std::array\n");
47#if defined(__GNUC__) && !defined(__clang__)
48 co_yield co_context::ranges::elements_of(
49 std::array<const uint64_t, 5>{2, 4, 6, 8, 10}, {}
50 );
51#else
52 co_yield co_context::ranges::elements_of{
53 std::array<const uint64_t, 5>{2, 4, 6, 8, 10}
54 };
55#endif
56 std::printf("yielding elements_of nested co_context::generator\n");
57 co_yield co_context::ranges::elements_of{fib(10)};
58
59 std::printf("yielding elements_of other kind of generator\n");
60 co_yield co_context::ranges::elements_of{other_generator(5, 8)};
61}
62
63//////////////////////////////////////
64// Following examples show difference between:

Callers 1

mainFunction · 0.85

Calls 3

elements_ofClass · 0.85
fibFunction · 0.85
other_generatorFunction · 0.85

Tested by

no test coverage detected