//********************************************************
// The following code example is taken from the book
//  C++23 - The Complete Guide
//  by Nicolai M. Josuttis (www.josuttis.com)
//  https://www.cppstd23.com
//
// The code is licensed under a
//  Creative Commons Attribution 4.0 International License
//  https://creativecommons.org/licenses/by/4.0/
//********************************************************


#include <iostream>
#include "fibo1.hpp"

int main()
{
  // initialize the coroutine:
  auto coro = fibonacci();

  // start the coroutine:
  auto pos = coro.begin();

  // while we are not at the end of the coroutine, print the yielded value and resume the coroutine:
  while (pos != coro.end()) {    // while suspended with a yielded value
    std::cout << *pos << ' ';    // print the value from co_yield
    ++pos;                       // RESUME the coroutine
  }
  std::cout << '\n';
}

