From fe92bad20ff986889803f17bfd13c2ad9616c609 Mon Sep 17 00:00:00 2001 From: Koby Kahane Date: Tue, 13 Oct 2020 09:53:29 +0300 Subject: [PATCH] Define co_await operators for C++20 coroutines as well (#764) --- strings/base_coroutine_foundation.h | 2 +- strings/base_coroutine_system.h | 2 +- strings/base_coroutine_system_winui.h | 2 +- strings/base_coroutine_threadpool.h | 2 +- strings/base_coroutine_ui_core.h | 2 +- strings/base_deferral.h | 2 +- strings/base_macros.h | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/strings/base_coroutine_foundation.h b/strings/base_coroutine_foundation.h index 5ebe8c617..a3cf5b780 100644 --- a/strings/base_coroutine_foundation.h +++ b/strings/base_coroutine_foundation.h @@ -223,7 +223,7 @@ namespace winrt::impl } } -#ifdef __cpp_coroutines +#ifdef WINRT_IMPL_COROUTINES WINRT_EXPORT namespace winrt::Windows::Foundation { inline impl::await_adapter operator co_await(IAsyncAction const& async) diff --git a/strings/base_coroutine_system.h b/strings/base_coroutine_system.h index 3d97437cf..b893bd1b5 100644 --- a/strings/base_coroutine_system.h +++ b/strings/base_coroutine_system.h @@ -41,7 +41,7 @@ WINRT_EXPORT namespace winrt return awaitable{ dispatcher, priority }; }; -#ifdef __cpp_coroutines +#ifdef WINRT_IMPL_COROUTINES inline auto operator co_await(Windows::System::DispatcherQueue const& dispatcher) { return resume_foreground(dispatcher); diff --git a/strings/base_coroutine_system_winui.h b/strings/base_coroutine_system_winui.h index f3d91407f..ecb3cf766 100644 --- a/strings/base_coroutine_system_winui.h +++ b/strings/base_coroutine_system_winui.h @@ -41,7 +41,7 @@ WINRT_EXPORT namespace winrt return awaitable{ dispatcher, priority }; }; -#ifdef __cpp_coroutines +#ifdef WINRT_IMPL_COROUTINES inline auto operator co_await(Microsoft::System::DispatcherQueue const& dispatcher) { return resume_foreground(dispatcher); diff --git a/strings/base_coroutine_threadpool.h b/strings/base_coroutine_threadpool.h index b810b56d5..fded22c85 100644 --- a/strings/base_coroutine_threadpool.h +++ b/strings/base_coroutine_threadpool.h @@ -442,7 +442,7 @@ WINRT_EXPORT namespace winrt return awaitable{ duration }; } -#ifdef __cpp_coroutines +#ifdef WINRT_IMPL_COROUTINES inline auto operator co_await(Windows::Foundation::TimeSpan duration) { return resume_after(duration); diff --git a/strings/base_coroutine_ui_core.h b/strings/base_coroutine_ui_core.h index 2d4e24f83..dab34c8de 100644 --- a/strings/base_coroutine_ui_core.h +++ b/strings/base_coroutine_ui_core.h @@ -39,7 +39,7 @@ WINRT_EXPORT namespace winrt return awaitable{ dispatcher, priority }; }; -#ifdef __cpp_coroutines +#ifdef WINRT_IMPL_COROUTINES inline auto operator co_await(Windows::UI::Core::CoreDispatcher const& dispatcher) { return resume_foreground(dispatcher); diff --git a/strings/base_deferral.h b/strings/base_deferral.h index e0d568f03..ceab1cd4b 100644 --- a/strings/base_deferral.h +++ b/strings/base_deferral.h @@ -1,7 +1,7 @@ WINRT_EXPORT namespace winrt { -#ifdef __cpp_coroutines +#ifdef WINRT_IMPL_COROUTINES template struct deferrable_event_args { diff --git a/strings/base_macros.h b/strings/base_macros.h index 0eea5c3c9..37fcc1a88 100644 --- a/strings/base_macros.h +++ b/strings/base_macros.h @@ -27,8 +27,8 @@ // Note: this is a workaround for a false-positive warning produced by the Visual C++ 16.3 compiler. #pragma warning(disable : 4268) -#if defined(_RESUMABLE_FUNCTIONS_SUPPORTED) && !defined(__cpp_coroutines) -#define __cpp_coroutines +#if defined(__cpp_lib_coroutine) || defined(__cpp_coroutines) || defined(_RESUMABLE_FUNCTIONS_SUPPORTED) +#define WINRT_IMPL_COROUTINES #endif #ifndef WINRT_EXPORT