1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H 10 #define __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H 11 12 #include <__config> 13 #include <__coroutine/coroutine_handle.h> 14 15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 16 # pragma GCC system_header 17 # pragma clang include_instead(<coroutine>) 18 #endif 19 20 #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) 21 22 _LIBCPP_BEGIN_NAMESPACE_STD 23 24 // [coroutine.trivial.awaitables] 25 struct suspend_never { 26 _LIBCPP_HIDE_FROM_ABI 27 constexpr bool await_ready() const noexcept { return true; } 28 _LIBCPP_HIDE_FROM_ABI 29 constexpr void await_suspend(coroutine_handle<>) const noexcept {} 30 _LIBCPP_HIDE_FROM_ABI 31 constexpr void await_resume() const noexcept {} 32 }; 33 34 struct suspend_always { 35 _LIBCPP_HIDE_FROM_ABI 36 constexpr bool await_ready() const noexcept { return false; } 37 _LIBCPP_HIDE_FROM_ABI 38 constexpr void await_suspend(coroutine_handle<>) const noexcept {} 39 _LIBCPP_HIDE_FROM_ABI 40 constexpr void await_resume() const noexcept {} 41 }; 42 43 _LIBCPP_END_NAMESPACE_STD 44 45 #endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) 46 47 #endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H 48