//******************************************************** // The following code example is taken from the book // C++23 - The Complete Guide // by Nicolai M. Josuttis (www.josuttis.com) // http://www.cppstd23.com // // The code is licensed under a // Creative Commons Attribution 4.0 International License // http://creativecommons.org/licenses/by/4.0/ //******************************************************** #include #include #include "fibo5.hpp" std::generator testFibonacci() { // yield the first 10 Fibonacci numbers: co_yield std::ranges::elements_of(fibonacci(10)); co_yield 9999; // yield 9999 as separator // yield the last two of the first 10 Fibonacci numbers again: co_yield std::ranges::elements_of(fibonacci(10) | std::views::drop(8)); co_yield 9999; // yield 9999 as separator // yield the first Fibonacci number: co_yield std::ranges::elements_of(fibonacci(1)); }