xref: /llvm-project/libcxx/include/__coroutine/coroutine_traits.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_COROUTINE_TRAITS_H
102e6ae1d3SChuanqi Xu #define _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
112e6ae1d3SChuanqi Xu 
122e6ae1d3SChuanqi Xu #include <__config>
13fafed06bSNikolas Klauser #include <__type_traits/void_t.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.traits]
242e6ae1d3SChuanqi Xu // [coroutine.traits.primary]
252e6ae1d3SChuanqi Xu //   The header <coroutine> defined the primary template coroutine_traits such that
262e6ae1d3SChuanqi Xu // if ArgTypes is a parameter pack of types and if the qualified-id R::promise_type
272e6ae1d3SChuanqi Xu // is valid and denotes a type ([temp.deduct]), then coroutine_traits<R, ArgTypes...>
282e6ae1d3SChuanqi Xu // has the following publicly accessible memebr:
292e6ae1d3SChuanqi Xu //
302e6ae1d3SChuanqi Xu //    using promise_type = typename R::promise_type;
312e6ae1d3SChuanqi Xu //
322e6ae1d3SChuanqi Xu // Otherwise, coroutine_traits<R, ArgTypes...> has no members.
332e6ae1d3SChuanqi Xu template <class _Tp, class = void>
342e6ae1d3SChuanqi Xu struct __coroutine_traits_sfinae {};
352e6ae1d3SChuanqi Xu 
362e6ae1d3SChuanqi Xu template <class _Tp>
37*9783f28cSLouis Dionne struct __coroutine_traits_sfinae< _Tp, __void_t<typename _Tp::promise_type> > {
382e6ae1d3SChuanqi Xu   using promise_type = typename _Tp::promise_type;
392e6ae1d3SChuanqi Xu };
402e6ae1d3SChuanqi Xu 
412e6ae1d3SChuanqi Xu template <class _Ret, class... _Args>
42*9783f28cSLouis Dionne struct coroutine_traits : public __coroutine_traits_sfinae<_Ret> {};
432e6ae1d3SChuanqi Xu 
442e6ae1d3SChuanqi Xu _LIBCPP_END_NAMESPACE_STD
452e6ae1d3SChuanqi Xu 
464f15267dSNikolas Klauser #endif // __LIBCPP_STD_VER >= 20
472e6ae1d3SChuanqi Xu 
482e6ae1d3SChuanqi Xu #endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
49