Skip to content

Commit d6a0412

Browse files
authored
Simply when_all implementation and test (#647)
1 parent d610942 commit d6a0412

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

strings/base_coroutine_foundation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ WINRT_EXPORT namespace winrt
712712
template <typename... T>
713713
Windows::Foundation::IAsyncAction when_all(T... async)
714714
{
715-
((co_await async, void()), ...);
715+
(void(co_await async), ...);
716716
co_return;
717717
}
718718

test/test/when.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ using namespace concurrency;
55
using namespace winrt;
66
using namespace Windows::Foundation;
77

8-
struct CommaStruct
8+
struct CommaStruct : std::experimental::suspend_never
99
{
1010
// If the comma operator is invoked, we will get a build failure.
1111
CommaStruct operator,(CommaStruct) = delete;
12+
13+
// Awaiting the object just returns itself.
14+
auto await_resume() const { return *this; }
1215
};
1316

1417
task<void> ppl(bool& done)
@@ -56,7 +59,7 @@ TEST_CASE("when")
5659
when_all().get();
5760

5861
// Verify edge case of overloaded comma operator (shame on you).
59-
when_all(create_task([] { return CommaStruct{}; }), create_task([] { return CommaStruct{}; })).get();
62+
when_all(CommaStruct{}, CommaStruct{}).get();
6063
{
6164
handle first_event{ check_pointer(CreateEventW(nullptr, true, false, nullptr)) };
6265
handle second_event{ check_pointer(CreateEventW(nullptr, true, false, nullptr)) };

0 commit comments

Comments
 (0)