Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
coro/Generator: correct Generator alias of std::generator (#385)
* coro/Generator: correct Generator alias of std::generator before this change, the build fails, because `AlloAllocator` is not defined when the standard library provides `std::generator`, and the tree is built with C++23. in this change, we replace `AlloAllocator` with `Allocator`. and the tree builds fine. Signed-off-by: Kefu Chai <[email protected]> * coro/Generator: use <generator> only if __cpp_lib_generator std::generator is a feature provided by C++23, when the tree is built with C++20, even if `<generator>` header is available, we still don't have access to `std::generator`. and the compiler would fail to compile: ``` In file included from /home/kefu/dev/async_simple/async_simple/coro/test/GeneratorTest.cpp:29: /home/kefu/dev/async_simple/async_simple/coro/Generator.h:32:24: error: no template named 'generator' in namespace 'std'; did you mean 'generate'? 32 | using Generator = std::generator<Ref, V, Allocator>; | ~~~~~^~~~~~~~~ | generate /usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/stl_algo.h:4344:5: note: 'generate' declared here 4344 | generate(_ForwardIterator __first, _ForwardIterator __last, | ^ In file included from /home/kefu/dev/async_simple/async_simple/coro/test/GeneratorTest.cpp:29: /home/kefu/dev/async_simple/async_simple/coro/Generator.h:32:19: error: expected a type 32 | using Generator = std::generator<Ref, V, Allocator>; | ^ /home/kefu/dev/async_simple/async_simple/coro/Generator.h:32:24: error: expected ';' after alias declaration 32 | using Generator = std::generator<Ref, V, Allocator>; | ^ | ; ``` in this change, we guard the include with `__cpp_lib_generator`, to address the FTBFS. Signed-off-by: Kefu Chai <[email protected]> --------- Signed-off-by: Kefu Chai <[email protected]>
- Loading branch information