Skip to content

Commit f48d7a6

Browse files
authored
make progress_token::operator() const so it can be captured by lambdas (#673)
1 parent f67e55a commit f48d7a6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

strings/base_coroutine_foundation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ namespace winrt::impl
305305
return *this;
306306
}
307307

308-
void operator()(Progress const& result)
308+
void operator()(Progress const& result) const
309309
{
310310
m_promise->set_progress(result);
311311
}

test/test/async_progress.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ namespace
1919
IAsyncOperationWithProgress<int, int> Operation(HANDLE event)
2020
{
2121
co_await resume_on_signal(event);
22-
auto progress = co_await get_progress_token();
23-
progress(123);
22+
23+
// Invoke from a lambda to ensure that operator() is const.
24+
[progress = co_await get_progress_token()]()
25+
{
26+
progress(123);
27+
}();
2428
co_return 1;
2529
}
2630

0 commit comments

Comments
 (0)