xref: /llvm-project/libcxx/include/__coroutine/trivial_awaitables.h (revision 9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7)
12e6ae1d3SChuanqi Xu //===----------------------------------------------------------------------===//
22e6ae1d3SChuanqi Xu //
32e6ae1d3SChuanqi Xu // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42e6ae1d3SChuanqi Xu // See https://llvm.org/LICENSE.txt for license information.
52e6ae1d3SChuanqi Xu // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
62e6ae1d3SChuanqi Xu //
72e6ae1d3SChuanqi Xu //===----------------------------------------------------------------------===//
82e6ae1d3SChuanqi Xu 
92e6ae1d3SChuanqi Xu #ifndef __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H
102e6ae1d3SChuanqi Xu #define __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H
112e6ae1d3SChuanqi Xu 
122e6ae1d3SChuanqi Xu #include <__config>
132e6ae1d3SChuanqi Xu #include <__coroutine/coroutine_handle.h>
142e6ae1d3SChuanqi Xu 
152e6ae1d3SChuanqi Xu #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
162e6ae1d3SChuanqi Xu #  pragma GCC system_header
172e6ae1d3SChuanqi Xu #endif
182e6ae1d3SChuanqi Xu 
194f15267dSNikolas Klauser #if _LIBCPP_STD_VER >= 20
202e6ae1d3SChuanqi Xu 
212e6ae1d3SChuanqi Xu _LIBCPP_BEGIN_NAMESPACE_STD
222e6ae1d3SChuanqi Xu 
232e6ae1d3SChuanqi Xu // [coroutine.trivial.awaitables]
242e6ae1d3SChuanqi Xu struct suspend_never {
await_readysuspend_never25*9783f28cSLouis Dionne   _LIBCPP_HIDE_FROM_ABI constexpr bool await_ready() const noexcept { return true; }
await_suspendsuspend_never26*9783f28cSLouis Dionne   _LIBCPP_HIDE_FROM_ABI constexpr void await_suspend(coroutine_handle<>) const noexcept {}
await_resumesuspend_never27*9783f28cSLouis Dionne   _LIBCPP_HIDE_FROM_ABI constexpr void await_resume() const noexcept {}
282e6ae1d3SChuanqi Xu };
292e6ae1d3SChuanqi Xu 
302e6ae1d3SChuanqi Xu struct suspend_always {
await_readysuspend_always31*9783f28cSLouis Dionne   _LIBCPP_HIDE_FROM_ABI constexpr bool await_ready() const noexcept { return false; }
await_suspendsuspend_always32*9783f28cSLouis Dionne   _LIBCPP_HIDE_FROM_ABI constexpr void await_suspend(coroutine_handle<>) const noexcept {}
await_resumesuspend_always33*9783f28cSLouis Dionne   _LIBCPP_HIDE_FROM_ABI constexpr void await_resume() const noexcept {}
342e6ae1d3SChuanqi Xu };
352e6ae1d3SChuanqi Xu 
362e6ae1d3SChuanqi Xu _LIBCPP_END_NAMESPACE_STD
372e6ae1d3SChuanqi Xu 
384f15267dSNikolas Klauser #endif // __LIBCPP_STD_VER >= 20
392e6ae1d3SChuanqi Xu 
402e6ae1d3SChuanqi Xu #endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H
41