C++23已完成,C++26来了( 三 )


无堆叠:
auto data = https://www.isolves.com/it/cxkf/yy/C/2023-02-21/co_await socket.receive();process(data);co_await socket.send(data);co_return; // requires function to return a special data type
堆叠:
auto data = https://www.isolves.com/it/cxkf/yy/C/2023-02-21/socket.receive();process(data);socket.send(data);
P0876已被纳入核心亚组 。经过讨论,决定禁止在执行线程之间迁移此类协程 。禁止的主要原因是编译器优化了对TLS的访问并缓存了TLS变量的值:
thread_local int i = 0;++i;foo(); // Stackful coroutines can switch execution threadsassert(i > 0); // The compiler saved the address in a register; we’re working with the TLS of another thread摘要
就这么定了!C++23已经被正式发送到更高的ISO权威机构,并将很快作为一个完整的标准发布 。
与此同时,C++26的开发正如火如荼,在执行器、网络化、模式匹配、静态反射等方面都有着令人兴奋的前景 。




推荐阅读