Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-concurrency
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-concurrency
Commits
e72659cd
Commit
e72659cd
authored
Mar 28, 2024
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add AwaitResult metafunction
parent
76287636
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
1 deletion
+26
-1
rt/include/typon/meta.hpp
rt/include/typon/meta.hpp
+26
-1
No files found.
rt/include/typon/meta.hpp
View file @
e72659cd
...
@@ -21,13 +21,19 @@ namespace typon::meta
...
@@ -21,13 +21,19 @@ namespace typon::meta
};
};
/* inspired by and simplified from
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1288r0.pdf
*/
template
<
typename
T
>
template
<
typename
T
>
concept
Awaitable
=
Awaiter
<
std
::
remove_cvref_t
<
T
>>
||
requires
(
T
&&
a
)
concept
HasCoAwait
=
requires
(
T
&&
a
)
{
{
// simplified
// simplified
std
::
forward
<
T
>
(
a
).
operator
co_await
();
std
::
forward
<
T
>
(
a
).
operator
co_await
();
};
};
template
<
typename
T
>
concept
Awaitable
=
Awaiter
<
T
>
||
HasCoAwait
<
T
>
;
template
<
typename
T
>
template
<
typename
T
>
requires
(
!
Awaitable
<
T
>
)
requires
(
!
Awaitable
<
T
>
)
...
@@ -46,6 +52,25 @@ namespace typon::meta
...
@@ -46,6 +52,25 @@ namespace typon::meta
}
}
};
};
template
<
typename
T
>
struct
AwaitResult_t
{
using
type
=
T
;
};
template
<
typename
T
>
using
AwaitResult
=
typename
AwaitResult_t
<
T
>::
type
;
template
<
Awaiter
T
>
struct
AwaitResult_t
<
T
>
{
using
type
=
decltype
(
std
::
declval
<
T
>
().
await_resume
());
};
template
<
HasCoAwait
T
>
struct
AwaitResult_t
<
T
>
{
using
type
=
AwaitResult
<
decltype
(
std
::
declval
<
T
>
().
operator
co_await
())
>
;
};
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment