-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1,添加 is_awaiter_v 模板用于 await_transform 模板参数判断 2,增加 local_storage_t 的用法,例如: auto y = co_await ucoro::local_storage_t<std::string>(); 通过 ucoro::local_storage_t 模板类型返回它本身的类型,这样就不必自己做 std::any_cast 了 3,添加对 is_awaiter_v 模板的测试用例。
- Loading branch information
Showing
4 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
add_executable(test3 test.cpp) | ||
target_link_libraries(test3 ucoro) | ||
|
||
add_test(NAME test3 COMMAND test3) | ||
set_target_properties(test3 PROPERTIES FOLDER "ucoro_tests") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <iostream> | ||
#include "ucoro/awaitable.hpp" | ||
|
||
|
||
int main(int argc, char **argv) | ||
{ | ||
using CallbackAwaiterType0 = CallbackAwaiter<void, decltype([](auto h) {}) >; | ||
using ExecutorAwaiterType0 = ExecutorAwaiter<void, decltype([](auto h) {}) > ; | ||
|
||
using CallbackAwaiterType1 = CallbackAwaiter<int, decltype([](auto h) {}) > ; | ||
using ExecutorAwaiterType1 = ExecutorAwaiter<int, decltype([](auto h) {}) > ; | ||
|
||
static_assert(ucoro::detail::is_awaiter_v < CallbackAwaiterType0 >, "not a coroutine"); | ||
static_assert(ucoro::detail::is_awaiter_v < ExecutorAwaiterType0 >, "not a coroutine"); | ||
|
||
static_assert(ucoro::detail::is_awaiter_v < CallbackAwaiterType1 >, "not a coroutine"); | ||
static_assert(ucoro::detail::is_awaiter_v < ExecutorAwaiterType1 >, "not a coroutine"); | ||
|
||
static_assert(ucoro::detail::is_awaiter_v < ucoro::awaitable<void> >, "not a coroutine"); | ||
static_assert(ucoro::detail::is_awaiter_v < ucoro::awaitable<int> >, "not a coroutine"); | ||
|
||
static_assert(!ucoro::detail::is_awaiter_v < int >, "not a coroutine"); | ||
|
||
return 0; | ||
} |