|
| 1 | +export module Utility.Promise; |
| 2 | +import Utility; |
| 3 | +import Utility.Constraints; |
| 4 | + |
| 5 | +export namespace util |
| 6 | +{ |
| 7 | + template<typename Fn, typename U> |
| 8 | + struct noexcept_t |
| 9 | + { |
| 10 | + template<typename... Args> |
| 11 | + static consteval bool Eval() noexcept |
| 12 | + { |
| 13 | + if constexpr (!same_as<U, void>) |
| 14 | + { |
| 15 | + return nothrow_invocables<Fn>; |
| 16 | + } |
| 17 | + else |
| 18 | + { |
| 19 | + return nothrow_invocables<Fn, Args...>; |
| 20 | + } |
| 21 | + } |
| 22 | + |
| 23 | + template<typename... Args> |
| 24 | + requires (same_as<U, void>) |
| 25 | + static constexpr auto Execute(Fn&& functor, [[maybe_unused]] Args...) noexcept(noexcept(forward<Fn>(functor)())) |
| 26 | + { |
| 27 | + return forward<Fn>(functor)(); |
| 28 | + } |
| 29 | + |
| 30 | + template<typename... Args> |
| 31 | + requires (!same_as<U, void>) |
| 32 | + static constexpr auto Execute(Fn&& functor, Args&&... args) noexcept(noexcept(forward<Fn>(functor)(forward<Args>(args)...))) |
| 33 | + { |
| 34 | + return forward<Fn>(functor)(forward<Args>(args)...); |
| 35 | + } |
| 36 | + }; |
| 37 | + |
| 38 | + /// <summary> |
| 39 | + /// |
| 40 | + /// </summary> |
| 41 | + /// <typeparam name="T">Sucess</typeparam> |
| 42 | + /// <typeparam name="E">Error</typeparam> |
| 43 | + /// <typeparam name="C">Cause of Defer</typeparam> |
| 44 | + template<movable T> |
| 45 | + class Promise |
| 46 | + { |
| 47 | + |
| 48 | + }; |
| 49 | +} |
| 50 | + |
| 51 | +#pragma warning(push, 1) |
| 52 | +namespace test |
| 53 | +{ |
| 54 | +#if false |
| 55 | + void test_promise() noexcept |
| 56 | + { |
| 57 | + constexpr auto fnl0 = [](const int& v) -> int { |
| 58 | + return 300; |
| 59 | + }; |
| 60 | + |
| 61 | + constexpr auto fnr0 = [](int&&) -> int { |
| 62 | + return 300; |
| 63 | + }; |
| 64 | + |
| 65 | + Promise<int> vpromise0{}; |
| 66 | + const auto r0 = vpromise0 >> fnl0; |
| 67 | + Promise<long long> vpromise1{}; |
| 68 | + |
| 69 | + constexpr Promise<int, void> cvpromise0{}; |
| 70 | + |
| 71 | + constexpr Promise<long long, void> cvpromise1{}; |
| 72 | + |
| 73 | + constexpr Proxy proxy0{}; |
| 74 | + } |
| 75 | +#endif // false |
| 76 | +} |
| 77 | +#pragma warning(pop) |
0 commit comments