mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +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;
|
||||
};
|
||||
|
||||
template<typename Left, typename Right>
|
||||
struct concat_identities_as_pack;
|
||||
template<typename Tuple>
|
||||
struct identity_to_tuple;
|
||||
|
||||
template<typename... Left, typename... Right>
|
||||
struct concat_identities_as_pack<fu::identity<Left...>, fu::identity<Right...>>
|
||||
template<typename... Args>
|
||||
struct identity_to_tuple<fu::identity<Args...>>
|
||||
{
|
||||
typedef fu::identity<Left..., std::tuple<Right...>> type;
|
||||
typedef std::tuple<Args...> type;
|
||||
};
|
||||
|
||||
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
|
||||
template <typename... _ATy>
|
||||
struct functional_traits
|
||||
@ -434,30 +443,37 @@ namespace detail
|
||||
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;
|
||||
|
||||
template<size_t Count, typename... Args, typename... Pack>
|
||||
struct multiple_result_maker<Count, fu::identity<Args...>, fu::identity<Pack...>>
|
||||
template<size_t Position, typename... Args, typename... Pack>
|
||||
struct multiple_result_maker<Position, fu::identity<Args...>, fu::identity<Pack...>>
|
||||
{
|
||||
typedef fu::identity<Args...> arguments_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>
|
||||
struct multiple_result_maker<Count, Args, Pack, Next, Rest...>
|
||||
template<size_t Position, typename Args, typename Pack, typename Next, typename... Rest>
|
||||
struct multiple_result_maker<Position, Args, Pack, Next, Rest...>
|
||||
: public multiple_result_maker<
|
||||
Count + 1,
|
||||
Position + 1,
|
||||
typename concat_identities<
|
||||
Args,
|
||||
typename unary_chainer_t<Next, _ATy...>::callback_arguments_t
|
||||
>::type,
|
||||
typename concat_identities_as_pack <
|
||||
typename concat_identities <
|
||||
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,
|
||||
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;
|
||||
|
||||
// fu::identity<detail::functional_traits<>::position<1>> i;
|
||||
|
||||
std::tuple<int, std::vector<int>> tup;
|
||||
|
||||
std::cout << "ok" << std::endl;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user