Skip to content

Commit

Permalink
Fix experimental::coro compatibility with Apple clang 15.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskohlhoff committed Jun 26, 2024
1 parent 33a37e1 commit cad203d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ struct coro_promise_allocator
allocator_type get_allocator() const {return alloc_;}

template <typename... Args>
void* operator new(const std::size_t size, Args & ... args)
void* operator new(std::size_t size, Args & ... args)
{
return allocate_coroutine(size,
get_variadic<variadic_first<std::allocator_arg_t,
std::decay_t<Args>...>() + 1u>(args...));
}

void operator delete(void* raw, const std::size_t size)
void operator delete(void* raw, std::size_t size)
{
deallocate_coroutine<allocator_type>(raw, size);
}
Expand Down
4 changes: 2 additions & 2 deletions asio/include/asio/experimental/detail/partial_promise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ template <typename Allocator>
struct partial_promise_base
{
template <typename Executor, typename Token, typename... Args>
void* operator new(const std::size_t size, Executor&, Token& tk, Args&...)
void* operator new(std::size_t size, Executor&, Token& tk, Args&...)
{
return allocate_coroutine<Allocator>(size, get_associated_allocator(tk));
}

void operator delete(void* raw, const std::size_t size)
void operator delete(void* raw, std::size_t size)
{
deallocate_coroutine<Allocator>(raw, size);
}
Expand Down
5 changes: 4 additions & 1 deletion asio/src/tests/unit/experimental/coro/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ asio::experimental::coro<int> throwing_generator(

int i = 0;
while (i < 3)
co_yield last = ++i;
{
last = ++i;
co_yield last;
}

throw std::runtime_error("throwing-generator");
}
Expand Down
5 changes: 4 additions & 1 deletion asio/src/tests/unit/experimental/coro/simple_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ asio::experimental::coro<int> generator_impl(

int i = 0;
while (true)
co_yield last = ++i;
{
last = ++i;
co_yield last;
}
}

asio::awaitable<void> generator_test()
Expand Down

0 comments on commit cad203d

Please sign in to comment.