mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
Preparation for signature erasure corrector
This commit is contained in:
parent
d116940005
commit
59a5b0266c
@ -703,7 +703,58 @@ void test_cross_forward()
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Corrects functionals with non expected signatures
|
||||||
|
/// to match the expected ones.
|
||||||
|
template<typename... _ATy>
|
||||||
|
struct partial_corrector
|
||||||
|
{
|
||||||
|
/// Corrector
|
||||||
|
template<typename _CTy>
|
||||||
|
static auto correct(_CTy&& functional)
|
||||||
|
-> typename std::enable_if<
|
||||||
|
!std::is_same<
|
||||||
|
fu::argument_type_of_t<
|
||||||
|
typename std::decay<_CTy>::type
|
||||||
|
>,
|
||||||
|
fu::identity<_ATy...>
|
||||||
|
>::value,
|
||||||
|
std::function<
|
||||||
|
fu::return_type_of_t<
|
||||||
|
typename std::decay<_CTy>::type
|
||||||
|
>(_ATy...)
|
||||||
|
>
|
||||||
|
>::type
|
||||||
|
{
|
||||||
|
// Make use of std::bind's signature erasure
|
||||||
|
return std::bind(std::forward<_CTy>(functional));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Route through
|
||||||
|
template<typename _CTy>
|
||||||
|
static auto correct(_CTy&& functional)
|
||||||
|
-> typename std::enable_if<
|
||||||
|
std::is_same<
|
||||||
|
fu::argument_type_of_t<
|
||||||
|
typename std::decay<_CTy>::type
|
||||||
|
>,
|
||||||
|
fu::identity<_ATy...>
|
||||||
|
>::value,
|
||||||
|
_CTy
|
||||||
|
>::type
|
||||||
|
{
|
||||||
|
return std::forward<_CTy>(functional);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void test_incubator()
|
void test_incubator()
|
||||||
{
|
{
|
||||||
test_cross_forward();
|
test_cross_forward();
|
||||||
|
|
||||||
|
std::function<void(int, float)> fn1 = partial_corrector<int, float>::correct([](int, float)
|
||||||
|
{
|
||||||
|
});
|
||||||
|
|
||||||
|
std::function<void(int, float)> fn2 = partial_corrector<int, float>::correct([]
|
||||||
|
{
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -463,7 +463,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Correct user given functionals through several stages into the form:
|
/// Correct user given functionals through several stages into the form:
|
||||||
/// Continuable<_CArgs...>(_FArgs
|
/// Continuable<_CArgs...>(_FArgs)
|
||||||
/// TODO Move this into an acceptor helper class.
|
/// TODO Move this into an acceptor helper class.
|
||||||
template<typename _CTy>
|
template<typename _CTy>
|
||||||
static inline auto correct(_CTy&& functional)
|
static inline auto correct(_CTy&& functional)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user