Thanks to visit codestin.com
Credit goes to github.com

Skip to content

trunk doesn't work with std::generator #4053

@hewillk

Description

@hewillk
#include <fmt/ranges.h>
#include <sstream>
#include <generator>

std::generator<std::string&> istream_gen() {
  auto words = std::istringstream{"today is yesterday's tomorrow"};
  std::string word;
  while (words >> word)
    co_yield word;
}

int main() {
  fmt::print("{}\n", istream_gen());
}

https://godbolt.org/z/s7sGrGvzd

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions