xref: /llvm-project/libcxx/include/__coroutine/coroutine_traits.h (revision 5aaefa510ef055e8f044ca89e352d4313f3aba49)
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_COROUTINE_TRAITS_H
10 #define _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
11 
12 #include <__config>
13 #include <type_traits>
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.traits]
25 // [coroutine.traits.primary]
26 //   The header <coroutine> defined the primary template coroutine_traits such that
27 // if ArgTypes is a parameter pack of types and if the qualified-id R::promise_type
28 // is valid and denotes a type ([temp.deduct]), then coroutine_traits<R, ArgTypes...>
29 // has the following publicly accessible memebr:
30 //
31 //    using promise_type = typename R::promise_type;
32 //
33 // Otherwise, coroutine_traits<R, ArgTypes...> has no members.
34 template <class _Tp, class = void>
35 struct __coroutine_traits_sfinae {};
36 
37 template <class _Tp>
38 struct __coroutine_traits_sfinae<
39     _Tp, typename __void_t<typename _Tp::promise_type>::type>
40 {
41   using promise_type = typename _Tp::promise_type;
42 };
43 
44 template <class _Ret, class... _Args>
45 struct coroutine_traits
46     : public __coroutine_traits_sfinae<_Ret>
47 {
48 };
49 
50 _LIBCPP_END_NAMESPACE_STD
51 
52 #endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
53 
54 #endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
55