Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 530 Bytes

README.md

File metadata and controls

29 lines (24 loc) · 530 Bytes

CXX Generator

Naive CXX17 generator implementation with std::thread<>

Usage

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

int main() {
  generator::Generate<int, int, int>
      s([](gen::Ctx<int, int> &_) -> int {
    const auto a = _.yield(0);
    const auto b = _.yield(a);
    const auto c = _.yield(b);
    const auto d = _.yield(c);
    return d;
  });
  int i = 1;
  while (!s.done()) {
    std::cout << s.resume(i++) << std::endl;
  }
}

Yields 0 2 3 4 5