Skip to content

Conversation

@kennykerr
Copy link
Collaborator

@kennykerr kennykerr commented Oct 26, 2020

Fixes #566

Looks like Clang defines __cpp_coroutines but not __cpp_lib_coroutine as it should. Anyway, this fix should tide us over until Clang offers full coroutine support. This change just ifdefs away the mentions of operator co_await if WINRT_IMPL_COROUTINES is not defined.

Also, silenced a few more warnings about dependent template names.

@kennykerr kennykerr requested a review from oldnewthing October 26, 2020 18:57
@kennykerr kennykerr changed the title Clang optional coroutine support Clang conformance Oct 26, 2020
template <typename> static constexpr bool find_co_await_free(...) { return false; }

#ifdef WINRT_IMPL_COROUTINES
template <typename U, typename = decltype(std::declval<U>().await_ready())> static constexpr bool find_awaitable_member(int) { return true; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one doesn't mention operator co_await and could stay in its original location, I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just cleaner to group the trues and falses together.

template <typename T>
decltype(auto) get_awaiter(T&& value) noexcept
{
#ifdef WINRT_IMPL_COROUTINES
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need this #ifdef any more. has_co_await_member and has_co_await_free will always be false if WINRT_IMPL_COROUTINES is not defined, so we fall through to the last case, which requires the type to be its own awaiter (and if we move the find_awaitable_member outside the #ifdef it will work), it will look for an await_ready which is fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, Clang currently looks inside the if constexpr regardless and fails to compile.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah, forgot about that. Even though it's if constexpr'd out, it still has to compile.

@kennykerr kennykerr merged commit 22f3b70 into master Oct 26, 2020
@kennykerr kennykerr deleted the clang branch October 26, 2020 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot use clang-tidy in combination with winrt/base.h

3 participants