小编Ant*_*ton的帖子

为什么 gcc-10 没有看到与协程 ts 相关的关键字?

我已经在 ubuntu 20.04 上安装了 gcc-10 编译器。我需要测试协程ts的工作,所以我找到了一个使用协程的例子并尝试编译它。

例子:

#include <coroutine>
#include <iostream>

struct simple {
    static inline int x = 0;
    int id = 0;
    simple() : id{ x++ } { std::cout << id << " constructed\n"; }
    simple(simple&&) : id{ x++ } { std::cout << id << " move constructed\n"; }
    ~simple() { std::cout << id << " destructed\n"; }

    struct promise_type {
        simple get_return_object() { return {}; }
        void return_void() {}
        void unhandled_exception() { std::terminate(); }
        auto initial_suspend() noexcept …
Run Code Online (Sandbox Code Playgroud)

c++ gcc c++20 c++-coroutine gcc10

6
推荐指数
0
解决办法
639
查看次数

标签 统计

c++ ×1

c++-coroutine ×1

c++20 ×1

gcc ×1

gcc10 ×1