This commit is contained in:
Denis Blank 2015-06-22 03:21:47 +02:00 committed by Naios
parent f60d01c757
commit bed62d03d6

View File

@ -139,77 +139,6 @@ public:
}
}
/// Wrap void returning functionals to returns an empty continuable.
template <typename _CTy>
static auto remove_void_trait(_CTy&& functional)
-> typename std::enable_if<
std::is_void<
fu::return_type_of_t<
typename std::decay<_CTy>::type
>
>::value,
/*decltype(
detail::void_wrap_trait<
fu::return_type_of_t<
typename std::decay<_CTy>::type
>
>::wrap(std::declval<_CTy>())
)
*/
decltype(
detail::functional_corrector<_CTy>::correct(std::declval<_CTy>())
)
// std::function<Continuable<>()>
>::type
{
/*return detail::void_wrap_trait<
fu::return_type_of_t<
typename std::decay<_CTy>::type
>
>::wrap(std::forward<_CTy>(functional));*/
return detail::functional_corrector<_CTy>::correct(std::forward<_CTy>(functional));
}
/// Route continuable returning functionals through.
/*template <typename _CTy>
static auto remove_void_trait(_CTy&& functional)
-> typename std::enable_if<
!std::is_void<
fu::return_type_of_t<
typename std::decay<_CTy>::type
>
>::value,
_CTy>::type
{
return std::forward<_CTy>(functional);
}*/
/// Wrap continuables into the continuable returning functional type.
template<typename _CTy>
static auto box_continuable_trait(_CTy&& continuable)
-> typename std::enable_if<detail::is_continuable<typename std::decay<_CTy>::type>::value,
std::function<typename std::decay<_CTy>::type(_ATy...)>>::type
{
// Trick C++11 lambda capture rules for non copyable but moveable continuables.
std::shared_ptr<typename std::decay<_CTy>::type> shared_continuable =
std::make_shared<typename std::decay<_CTy>::type>(std::forward<_CTy>(continuable));
// Create a fake function which returns the value on invoke.
return [shared_continuable](_ATy...)
{
return std::move(*shared_continuable);
};
}
/// Route functionals through and forward to remove_void_trait
template<typename _CTy>
static auto box_continuable_trait(_CTy&& continuable)
-> typename std::enable_if<!detail::is_continuable<typename std::decay<_CTy>::type>::value,
typename std::decay<_CTy>::type>::type
{
return continuable;
}
public:
/// Deleted copy construct
Continuable(Continuable const&) = delete;
@ -398,9 +327,83 @@ inline auto make_continuable()
namespace detail
{
/// Wrap void returning functionals to returns an empty continuable.
template <typename _CTy>
static auto remove_void_trait(_CTy&& functional)
-> typename std::enable_if<
std::is_void<
fu::return_type_of_t<
typename std::decay<_CTy>::type
>
>::value,
/*decltype(
detail::void_wrap_trait<
fu::return_type_of_t<
typename std::decay<_CTy>::type
>
>::wrap(std::declval<_CTy>())
)
*/
decltype(
detail::functional_corrector<_CTy>::correct(std::declval<_CTy>())
)
// std::function<Continuable<>()>
>::type
{
/*return detail::void_wrap_trait<
fu::return_type_of_t<
typename std::decay<_CTy>::type
>
>::wrap(std::forward<_CTy>(functional));*/
return detail::functional_corrector<_CTy>::correct(std::forward<_CTy>(functional));
}
/// Route continuable returning functionals through.
/*template <typename _CTy>
static auto remove_void_trait(_CTy&& functional)
-> typename std::enable_if<
!std::is_void<
fu::return_type_of_t<
typename std::decay<_CTy>::type
>
>::value,
_CTy>::type
{
return std::forward<_CTy>(functional);
}*/
/// Wrap continuables into the continuable returning functional type.
template<typename _CTy>
auto box_continuable_trait(_CTy&& continuable)
-> typename std::enable_if<detail::is_continuable<typename std::decay<_CTy>::type>::value,
std::function<typename std::decay<_CTy>::type(_ATy...)>>::type
{
// Trick C++11 lambda capture rules for non copyable but moveable continuables.
std::shared_ptr<typename std::decay<_CTy>::type> shared_continuable =
std::make_shared<typename std::decay<_CTy>::type>(std::forward<_CTy>(continuable));
// Create a fake function which returns the value on invoke.
return [shared_continuable](_ATy...)
{
return std::move(*shared_continuable);
};
}
/// Route functionals through and forward to remove_void_trait
template<typename _CTy>
auto box_continuable_trait(_CTy&& continuable)
-> typename std::enable_if<!detail::is_continuable<typename std::decay<_CTy>::type>::value,
typename std::decay<_CTy>::type>::type
{
return continuable;
}
template <typename _CTy>
struct functional_corrector
{
typedef fu::return_type_of_t<_CTy> return_t;
typedef fu::argument_type_of_t<_CTy> arg_t;
static int correct(_CTy&&)
{
return 1;