Insert placeholder declarations into winrt/base.h.

PiperOrigin-RevId: 495104919
This commit is contained in:
hai007
2022-12-13 13:09:29 -08:00
committed by Copybara-Service
parent db0aaf75d2
commit c5cb0e1d39
3 changed files with 70 additions and 0 deletions
@@ -0,0 +1,37 @@
*** third_party/nearby/internal/platform/implementation/windows/generated/winrt/base.h 2022-12-07 15:29:09.000000000 -0500
--- third_party/nearby/internal/platform/implementation/windows/generated/winrt/base-no-coroutines.h 2022-12-07 15:28:53.000000000 -0500
***************
*** 35,40 ****
--- 35,66 ----
#include <format>
#endif
+ #if defined(_LIBCPP_VERSION) && __cplusplus < 202002
+ // If the C++ standard is cxx17, coroutines are not available in libc++.
+ // To compile WinRT without coroutines, define some placeholder types.
+ // These placeholders should not be used. If they are used, they should fail.
+ template <typename T = void>
+ struct coroutine_handle {
+ coroutine_handle() { throw std::logic_error("Not implemented."); }
+ coroutine_handle(std::nullptr_t __h) {
+ throw std::logic_error("Not implemented.");
+ }
+ static coroutine_handle from_address(void*) {
+ throw std::logic_error("Not implemented.");
+ }
+ void operator()() const { throw std::logic_error("Not implemented."); }
+ void* address() const { throw std::logic_error("Not implemented."); }
+ };
+
+ class suspend_always {};
+ class suspend_never {};
+
+ template <typename _Result, typename...>
+ struct coroutine_traits;
+
+ } // namespace std::experimental
+ #endif
+
#ifdef __cpp_lib_coroutine
#include <coroutine>
@@ -0,0 +1,7 @@
#!/bin/bash
patch \
--forward \
-r - \
third_party/nearby/internal/platform/implementation/windows/generated/winrt/base.h \
third_party/nearby/internal/platform/implementation/windows/generated/base-no-coroutines.patch
@@ -35,6 +35,32 @@
#include <format>
#endif
#if defined(_LIBCPP_VERSION) && __cplusplus < 202002
// If the C++ standard is cxx17, coroutines are not available in libc++.
// To compile WinRT without coroutines, define some placeholder types.
// These placeholders should not be used. If they are used, they should fail.
template <typename T = void>
struct coroutine_handle {
coroutine_handle() { throw std::logic_error("Not implemented."); }
coroutine_handle(std::nullptr_t __h) {
throw std::logic_error("Not implemented.");
}
static coroutine_handle from_address(void*) {
throw std::logic_error("Not implemented.");
}
void operator()() const { throw std::logic_error("Not implemented."); }
void* address() const { throw std::logic_error("Not implemented."); }
};
class suspend_always {};
class suspend_never {};
template <typename _Result, typename...>
struct coroutine_traits;
} // namespace std::experimental
#endif
#ifdef __cpp_lib_coroutine
#include <coroutine>