Skip to content

Commit

Permalink
프로미스 모듈 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
iconstudio committed Jul 2, 2023
1 parent 5d973ca commit a19b04e
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Utility.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
<ClCompile Include="functional\LooseMonad.ixx" />
<ClCompile Include="functional\Monad.ixx" />
<ClCompile Include="functional\Option.ixx" />
<ClCompile Include="functional\Promise.ixx" />
<ClCompile Include="generic\Constraints.ixx" />
<ClCompile Include="generic\Traits.ixx" />
<ClCompile Include="main.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions src/Utility.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
<ClCompile Include="reflection\Unique.ixx">
<Filter>헤더 파일\Reflection</Filter>
</ClCompile>
<ClCompile Include="functional\Promise.ixx">
<Filter>헤더 파일\Functional</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Natvis Include="..\Utility.natvis" />
Expand Down
77 changes: 77 additions & 0 deletions src/functional/Promise.ixx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
export module Utility.Promise;
import Utility;
import Utility.Constraints;

export namespace util
{
template<typename Fn, typename U>
struct noexcept_t
{
template<typename... Args>
static consteval bool Eval() noexcept
{
if constexpr (!same_as<U, void>)
{
return nothrow_invocables<Fn>;
}
else
{
return nothrow_invocables<Fn, Args...>;
}
}

template<typename... Args>
requires (same_as<U, void>)
static constexpr auto Execute(Fn&& functor, [[maybe_unused]] Args...) noexcept(noexcept(forward<Fn>(functor)()))
{
return forward<Fn>(functor)();
}

template<typename... Args>
requires (!same_as<U, void>)
static constexpr auto Execute(Fn&& functor, Args&&... args) noexcept(noexcept(forward<Fn>(functor)(forward<Args>(args)...)))
{
return forward<Fn>(functor)(forward<Args>(args)...);
}
};

/// <summary>
///
/// </summary>
/// <typeparam name="T">Sucess</typeparam>
/// <typeparam name="E">Error</typeparam>
/// <typeparam name="C">Cause of Defer</typeparam>
template<movable T>
class Promise
{

};
}

#pragma warning(push, 1)
namespace test
{
#if false
void test_promise() noexcept
{
constexpr auto fnl0 = [](const int& v) -> int {
return 300;
};

constexpr auto fnr0 = [](int&&) -> int {
return 300;
};

Promise<int> vpromise0{};
const auto r0 = vpromise0 >> fnl0;
Promise<long long> vpromise1{};

constexpr Promise<int, void> cvpromise0{};

constexpr Promise<long long, void> cvpromise1{};

constexpr Proxy proxy0{};
}
#endif // false
}
#pragma warning(pop)

0 comments on commit a19b04e

Please sign in to comment.