mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 17:26:47 +08:00
Add position to partial results
This commit is contained in:
parent
541d3e5def
commit
99fbb8d71f
@ -303,13 +303,13 @@ namespace detail
|
|||||||
typedef fu::identity<Left..., Right...> type;
|
typedef fu::identity<Left..., Right...> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Left, typename Right>
|
template<typename Tuple>
|
||||||
struct concat_identities_as_pack;
|
struct identity_to_tuple;
|
||||||
|
|
||||||
template<typename... Left, typename... Right>
|
template<typename... Args>
|
||||||
struct concat_identities_as_pack<fu::identity<Left...>, fu::identity<Right...>>
|
struct identity_to_tuple<fu::identity<Args...>>
|
||||||
{
|
{
|
||||||
typedef fu::identity<Left..., std::tuple<Right...>> type;
|
typedef std::tuple<Args...> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename... _CTy>
|
template<typename... _CTy>
|
||||||
@ -339,6 +339,15 @@ namespace detail
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Position wrapper class to pass ints as type
|
||||||
|
template<size_t Position, typename Tuple>
|
||||||
|
struct partial_result
|
||||||
|
{
|
||||||
|
static size_t const position = Count;
|
||||||
|
|
||||||
|
typedef Tuple tuple;
|
||||||
|
};
|
||||||
|
|
||||||
/// Continuable processing detail implementation
|
/// Continuable processing detail implementation
|
||||||
template <typename... _ATy>
|
template <typename... _ATy>
|
||||||
struct functional_traits
|
struct functional_traits
|
||||||
@ -434,30 +443,37 @@ namespace detail
|
|||||||
return remove_void_trait(box_continuable_trait(std::forward<_CTy>(functional)));
|
return remove_void_trait(box_continuable_trait(std::forward<_CTy>(functional)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t Count, typename Args, typename Pack, typename... Rest>
|
template<size_t Position, typename Args, typename Pack, typename... Rest>
|
||||||
struct multiple_result_maker;
|
struct multiple_result_maker;
|
||||||
|
|
||||||
template<size_t Count, typename... Args, typename... Pack>
|
template<size_t Position, typename... Args, typename... Pack>
|
||||||
struct multiple_result_maker<Count, fu::identity<Args...>, fu::identity<Pack...>>
|
struct multiple_result_maker<Position, fu::identity<Args...>, fu::identity<Pack...>>
|
||||||
{
|
{
|
||||||
typedef fu::identity<Args...> arguments_t;
|
typedef fu::identity<Args...> arguments_t;
|
||||||
|
|
||||||
typedef fu::identity<Pack...> arguments_storage_t;
|
typedef fu::identity<Pack...> arguments_storage_t;
|
||||||
|
|
||||||
static size_t const size = Count;
|
static size_t const size = Position;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<size_t Count, typename Args, typename Pack, typename Next, typename... Rest>
|
template<size_t Position, typename Args, typename Pack, typename Next, typename... Rest>
|
||||||
struct multiple_result_maker<Count, Args, Pack, Next, Rest...>
|
struct multiple_result_maker<Position, Args, Pack, Next, Rest...>
|
||||||
: public multiple_result_maker<
|
: public multiple_result_maker<
|
||||||
Count + 1,
|
Position + 1,
|
||||||
typename concat_identities<
|
typename concat_identities<
|
||||||
Args,
|
Args,
|
||||||
typename unary_chainer_t<Next, _ATy...>::callback_arguments_t
|
typename unary_chainer_t<Next, _ATy...>::callback_arguments_t
|
||||||
>::type,
|
>::type,
|
||||||
typename concat_identities_as_pack <
|
typename concat_identities <
|
||||||
Pack,
|
Pack,
|
||||||
typename unary_chainer_t<Next, _ATy...>::callback_arguments_t
|
fu::identity<
|
||||||
|
partial_result<
|
||||||
|
Position,
|
||||||
|
typename identity_to_tuple<
|
||||||
|
typename unary_chainer_t<Next, _ATy...>::callback_arguments_t
|
||||||
|
>::type
|
||||||
|
>
|
||||||
|
>
|
||||||
>::type,
|
>::type,
|
||||||
Rest...
|
Rest...
|
||||||
> { };
|
> { };
|
||||||
|
|||||||
2
test.cpp
2
test.cpp
@ -252,6 +252,8 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
|
|
||||||
detail::concat_identities<fu::identity<int, bool, char>, fu::identity<float, double>>::type myt;
|
detail::concat_identities<fu::identity<int, bool, char>, fu::identity<float, double>>::type myt;
|
||||||
|
|
||||||
|
// fu::identity<detail::functional_traits<>::position<1>> i;
|
||||||
|
|
||||||
std::tuple<int, std::vector<int>> tup;
|
std::tuple<int, std::vector<int>> tup;
|
||||||
|
|
||||||
std::cout << "ok" << std::endl;
|
std::cout << "ok" << std::endl;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user