Skip to content

Commit d610942

Browse files
authored
Edge cases in when_all (#645)
1 parent dd4d45e commit d610942

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

strings/base_coroutine_foundation.h

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

718719
template <typename T, typename... Rest>

test/test/when.cpp

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

8+
struct CommaStruct
9+
{
10+
// If the comma operator is invoked, we will get a build failure.
11+
CommaStruct operator,(CommaStruct) = delete;
12+
};
13+
814
task<void> ppl(bool& done)
915
{
1016
co_await resume_background();
@@ -45,6 +51,12 @@ TEST_CASE("when")
4551
IAsyncAction result = when_any(done(), done());
4652
result.get();
4753
}
54+
55+
// Verify edge case of empty parameter list.
56+
when_all().get();
57+
58+
// Verify edge case of overloaded comma operator (shame on you).
59+
when_all(create_task([] { return CommaStruct{}; }), create_task([] { return CommaStruct{}; })).get();
4860
{
4961
handle first_event{ check_pointer(CreateEventW(nullptr, true, false, nullptr)) };
5062
handle second_event{ check_pointer(CreateEventW(nullptr, true, false, nullptr)) };

0 commit comments

Comments
 (0)