mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 09:16:46 +08:00
omg msvc...
This commit is contained in:
parent
a74e1e95b9
commit
566e8287f7
@ -38,22 +38,6 @@ namespace detail
|
|||||||
// ContinuableImpl Forward definition
|
// ContinuableImpl Forward definition
|
||||||
template<typename _STy, typename _CTy>
|
template<typename _STy, typename _CTy>
|
||||||
class _ContinuableImpl;
|
class _ContinuableImpl;
|
||||||
|
|
||||||
/// Corrects void return types from functional types which should be Continuable<DefaultContinuableState, Callback<>>
|
|
||||||
template<typename _RTy>
|
|
||||||
struct convert_void_to_continuable;
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct convert_void_to_continuable<void>
|
|
||||||
{
|
|
||||||
typedef _ContinuableImpl<DefaultContinuableState, Callback<>> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename _State, typename _CTy>
|
|
||||||
struct convert_void_to_continuable<_ContinuableImpl<_State, _CTy>>
|
|
||||||
{
|
|
||||||
typedef _ContinuableImpl<_State, _CTy> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename... _STy, typename... _ATy>
|
template<typename... _STy, typename... _ATy>
|
||||||
class _ContinuableImpl<ContinuableState<_STy...>, std::function<void(_ATy...)>>
|
class _ContinuableImpl<ContinuableState<_STy...>, std::function<void(_ATy...)>>
|
||||||
@ -119,18 +103,34 @@ namespace detail
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Corrects void return types from functional types which should be Continuable<DefaultContinuableState, Callback<>>
|
||||||
|
template<typename _RTy>
|
||||||
|
struct convert_void_to_continuable;
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct convert_void_to_continuable<void>
|
||||||
|
{
|
||||||
|
typedef _ContinuableImpl<DefaultContinuableState, Callback<>> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename _State, typename _CTy>
|
||||||
|
struct convert_void_to_continuable<_ContinuableImpl<_State, _CTy>>
|
||||||
|
{
|
||||||
|
typedef _ContinuableImpl<_State, _CTy> type;
|
||||||
|
};
|
||||||
|
|
||||||
template<typename _NextRTy, typename... _NextATy>
|
template<typename _NextRTy, typename... _NextATy>
|
||||||
struct unary_chainer;
|
struct unary_chainer;
|
||||||
|
|
||||||
|
// MSVC 12 has issues to detect the parameter pack otherwise.
|
||||||
template<typename _NextRTy, typename... _NextATy>
|
template<typename _NextRTy, typename... _NextATy>
|
||||||
struct unary_chainer<_NextRTy, fu::identity<_NextATy...>>
|
struct unary_chainer<_NextRTy, fu::identity<_NextATy...>>
|
||||||
{
|
{
|
||||||
template<typename _CTy>
|
template<typename _CTy>
|
||||||
static auto chain(_CTy&& /*functional*/, _ContinuableImpl&& /*me*/)
|
static auto chain(_CTy&& /*functional*//*, _MTy&& me*/)
|
||||||
-> typename convert_void_to_continuable<_NextRTy>::type
|
-> _ContinuableImpl<DefaultContinuableState, Callback<>> // typename convert_void_to_continuable<void>::type
|
||||||
{
|
{
|
||||||
return convert_void_to_continuable<_NextRTy>::type();
|
return _ContinuableImpl<DefaultContinuableState, Callback<>>();
|
||||||
// _ContinuableImpl<ContinuableState<_STy...>, Callback<_NextATy...>>();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -141,9 +141,11 @@ namespace detail
|
|||||||
|
|
||||||
template<typename _CTy>
|
template<typename _CTy>
|
||||||
auto then(_CTy&& functional)
|
auto then(_CTy&& functional)
|
||||||
-> decltype(unary_chainer_t<_CTy>::chain(std::declval<_CTy>(), std::declval<_ContinuableImpl&&>))
|
-> decltype(unary_chainer_t<_CTy>::chain(std::declval<_CTy>()
|
||||||
|
// std::declval<_ContinuableImpl<ContinuableState<_STy...>, std::function<void(_ATy...)>>>())
|
||||||
|
))
|
||||||
{
|
{
|
||||||
return unary_chainer_t<_CTy>::chain(std::forward<_CTy>(), std::move(*this));
|
return unary_chainer_t<_CTy>::chain(std::forward<_CTy>(functional)/*, std::move(*this)*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
5
test.cpp
5
test.cpp
@ -113,11 +113,6 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
typedef fu::requires_functional_constructible<std::function<void()>>::type test_assert1;
|
typedef fu::requires_functional_constructible<std::function<void()>>::type test_assert1;
|
||||||
// typedef fu::requires_functional_constructible<std::vector<int>>::type test_assert2;
|
// typedef fu::requires_functional_constructible<std::vector<int>>::type test_assert2;
|
||||||
|
|
||||||
detail::convert_void_to_continuable<void>::type* _test5 = nullptr;
|
|
||||||
_test5 = nullptr;
|
|
||||||
|
|
||||||
detail::convert_void_to_continuable<Continuable<Callback<SpellCastResult>>>::type* _test6 = nullptr;
|
|
||||||
_test6 = nullptr;
|
|
||||||
|
|
||||||
std::cout << "ok" << std::endl;
|
std::cout << "ok" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user