c++-coroutine Questions

2

Solved

VS2019 latest c++ compiler. Error is :"a coroutine's promise must declare either 'return_value' or 'return_void'" Example pulled from David Mazièreshttps://www.scs.stanford.edu/~dm/blog/c...
Greenhead asked 28/4, 2021 at 18:59

1

I have installed gcc-10 compiler on my ubuntu 20.04. I needed to test the work of coroutine ts, so I found an example using coroutines and tried to compile it. exemple: #include <coroutine> #...
Alkyd asked 27/11, 2020 at 15:45

2

The GCC C++ compiler (any many other C++ compilers as well) provide nonstandard extentions such as alloca() for stack based allocation variable length arrays, as they are part of the C standard C...
Acrobatic asked 17/5, 2021 at 19:47

1

I'm fairly new to C++ coroutines. When my app shuts down, I'd like to be able to give any outstanding co-routines a hint that I'd prefer they finished early. One solution/idea I came up with was to...
Pumpernickel asked 2/2, 2021 at 22:17

2

Solved

With the new C++ coroutines, is it possible to define a coroutine class that I can use to yield from functions without returning a value? Or does yield always have to return something? I'm just int...
Beaston asked 3/8, 2018 at 22:54

0

I'm performing some experimentation on C++20 having in mind their potential usage in embedded application. However I noticed that both GCC and Clang generates frames that are bigger than the ones t...
Meingoldas asked 28/2, 2024 at 0:54

2

Solved

In Rust, asynchronous functions do not require allocating on the heap. Function async returns a compiler-generated structure on which you call a compiler generated poll method. The design of async ...
Sachiko asked 31/1, 2024 at 8:45

2

Solved

I am working with C++20 coroutines, specifically simple generators, but I have observed similar results with coroutines replacing state machines based on boost::msm. Actually my goal is to provide ...
Merwin asked 10/1, 2024 at 14:44

3

Solved

I have a specific use case: In my library, concurrencpp, I want to implement the function make_exceptional_lazy_result which is basically like the C# method Task.FromException. Inside the implement...
Braun asked 20/10, 2023 at 9:29

1

Solved

When using C++20 coroutines with Boost.Asio it is possible to make an operation awaitable with either boost::asio::use_awaitable or boost::asio::deferred as in the following examples. std::size_t n...
Craigcraighead asked 24/8, 2023 at 9:26

1

I was tracking down a bug in gcc and encountered a situation for which I don't know what the acceptable behavior(s) are. Suppose we have, somewhere within a coroutine, a line such as: Pair{.x{}, .y...
Cuisine asked 27/12, 2021 at 17:5

1

Solved

Preamble This is a description of what I am trying to do with the code, skip to the next section to see the actual issue. I want to use coroutines in an embedded system, where I can't afford too ma...
Inflexed asked 9/6, 2023 at 15:23

2

Solved

From the well-known C++ coroutine library (search "Don't allow any use of co_await inside the generator coroutine." in the source file generator.hpp), and from my own experiments, I know ...
Crossways asked 30/12, 2021 at 18:53

4

This question is not about coroutines in C++20 but coroutines in general. I'm learning C++20 coroutines these days. I've learnt about stackful and stackless coroutines from Coroutines Introduction....
Julieannjulien asked 18/7, 2020 at 11:5

1

Solved

I want to warp a typical C callback API that generates multiple int values into an iterable in the fashion of std::generator<int> (see p2502r1). API looks like: typedef void (*Callback)(int);...
Oneida asked 2/9, 2022 at 11:4

2

Solved

Since the std::generator is making it into CPP23, I am playing around with MSVC's incomplete version. However, I notice that it seems lose exactly one yield when used with std::views::take. Here is...
Aneroidograph asked 2/8, 2022 at 11:48

1

It's common knowledge that returning a pointer to a stack variable is generally a bad idea: int* foo() { int i = 0; return &i; } int main() { int* p = foo(); } In the example above, my und...
Courante asked 11/6, 2022 at 9:34

4

Solved

In the following example, NRVO (Named Return Value Optimization) applies as per this article: std::string f1() { std::string str; return str; // NVRO applies here! } However, consider: task&...
Flamen asked 18/5, 2020 at 13:5

1

The first restriction on coroutines specified in cpp reference page is that coroutines cannot use variadic arguments. But when I try to use a coroutine that accepts varidaic arguments in its parame...
Rumanian asked 30/4, 2022 at 10:59

1

Solved

I have read this question and tried to replicate the answer with the following code: #include <iostream> #include <syncstream> #include <thread> #include <coroutine> #includ...
Kellen asked 24/4, 2022 at 9:16

2

Solved

I'd like to make a function with both sync and coroutine version, without using template specialization, i.e. with an if constexpr. This is the function I wrote: template <Async _a> AsyncResu...
Shag asked 11/3, 2022 at 2:55

2

Solved

I am exploring and trying to learn C++ Coroutines (added in C++20). An SDK I am using has asynchronous API calls which all take a callback, the callbacks are invoked on some background thread manag...
Wallford asked 8/10, 2020 at 21:7

4

Solved

As a novice C++ programmer who is very new to the concept of coroutines, I am trying to study and utilize the feature. Although there is explanation of coroutine here: What is a coroutine? I ...
Sophy asked 17/2, 2022 at 6:6

0

In C++ coroutines, awaiters-types (i. e. argument-types of co_await and return types of initial_suspend/final_suspend) require the three methods await_ready(), await_suspend(std::coroutine_handle&l...
Sceptre asked 6/2, 2022 at 13:33

1

Solved

I am writing a C++ coroutine for a UWP control using C++/WinRT: winrt::fire_and_forget MyControl::DoSomething() { if (/* some condition */) { // Why does this work?! return; } co_await winrt...
Choriocarcinoma asked 20/1, 2022 at 19:57

© 2022 - 2025 — McMap. All rights reserved.