Skip to content

Commit a19b04e

Browse files
committed
프로미스 모듈 추가
1 parent 5d973ca commit a19b04e

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

src/Utility.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
<ClCompile Include="functional\LooseMonad.ixx" />
195195
<ClCompile Include="functional\Monad.ixx" />
196196
<ClCompile Include="functional\Option.ixx" />
197+
<ClCompile Include="functional\Promise.ixx" />
197198
<ClCompile Include="generic\Constraints.ixx" />
198199
<ClCompile Include="generic\Traits.ixx" />
199200
<ClCompile Include="main.cpp" />

src/Utility.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@
164164
<ClCompile Include="reflection\Unique.ixx">
165165
<Filter>헤더 파일\Reflection</Filter>
166166
</ClCompile>
167+
<ClCompile Include="functional\Promise.ixx">
168+
<Filter>헤더 파일\Functional</Filter>
169+
</ClCompile>
167170
</ItemGroup>
168171
<ItemGroup>
169172
<Natvis Include="..\Utility.natvis" />

src/functional/Promise.ixx

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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

Comments
 (0)