//********************************************************
// 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 <print>
#include <vector>
#include <generator>

std::generator<int&> genMod(auto& coll)
{
  for (int& elem : coll) {
    std::println("\tSUSPEND with {}", elem);    
    co_yield elem;
    std::println("\t RESUME with {}", elem);
  }
}

int main() 
{
  std::vector<int> vec{0, 8, 15};
  std::println("vec: {}", vec);

  for (auto& val : genMod(vec)) {
    std::println(" main(): MODIFY {}", val);
    ++val;
  }
  std::println("vec: {}", vec);
}

