40 template <
typename ResultT,
typename ...Ts>
41 struct unzip_types_aux;
43 template <
typename ResultT>
44 struct unzip_types_aux<ResultT>
49 template <
typename... ResultTs,
typename T,
typename... Ts>
50 struct unzip_types_aux<meta::pack<ResultTs...>, T, Ts...>
51 : unzip_types_aux<meta::pack<ResultTs...>,
52 meta::pack<T, meta::get_index_sequence<T> >,
56 template <
typename... ResultTs,
57 typename T, std::size_t... Indexes,
59 struct unzip_types_aux<meta::pack<ResultTs...>,
60 meta::pack<T, estd::index_sequence<Indexes...> >,
62 : unzip_types_aux<meta::pack<ResultTs...,
63 decltype(get<Indexes>(std::declval<T>()))...>,
67 template <
typename... ResultTs,
typename T,
typename... Ts>
68 struct unzip_types_aux<meta::pack<ResultTs...>,
69 meta::pack<T, meta::could_not_get_index_sequence>,
71 : unzip_types_aux<meta::pack<ResultTs..., T>, Ts...>
85 template <
typename... Ts>
86 struct unzip_types : unzip_types_aux<meta::pack<>, Ts...> {};
88 template <
typename... Ts>
89 using unzip_types_t =
typename unzip_types<estd::decay_t<Ts>... >::type;
95 template <
typename ReducingFnT,
typename StateT,
typename... InputTs>
98 template <
typename... Ts>
99 struct apply : std::result_of<ReducingFnT(StateT, Ts...)> {};
101 using type = meta::unpack_t<apply, unzip_types_t<InputTs...> >;
104 template <
typename ReducingFnT,
typename StateT,
typename... InputTs>
105 using unzip_result_t =
106 typename unzip_result<ReducingFnT, StateT, InputTs...>::type;
110 template <
typename ReducingFnT>
115 struct last_input_tag {};
117 template <
typename ResultT, std::size_t... Indexes,
118 typename StateT,
typename InputT,
typename... InputTs>
119 auto impl_apply(meta::pack<ResultT> r, estd::index_sequence<Indexes...>,
120 StateT&& s, InputT&& i, InputTs&& ...is)
124 std::forward<StateT>(s),
125 std::forward<InputTs>(is)...,
126 std::get<Indexes>(std::forward<InputT>(i))...);
129 template <
typename ResultT,
130 typename StateT,
typename InputT,
typename... InputTs>
131 auto impl_apply(meta::pack<ResultT> r, meta::could_not_get_index_sequence,
132 StateT&& s, InputT&& i, InputTs&& ...is)
136 std::forward<StateT>(s),
137 std::forward<InputTs>(is)...,
138 std::forward<InputT>(i));
141 template <
typename ResultT,
typename StateT,
typename InputT,
typename... InputTs>
142 auto impl(meta::pack<ResultT>, StateT&& s, InputT&&, InputTs&& ...is)
144 std::is_same<estd::decay_t<InputT>, last_input_tag>{},
147 return step(std::forward<StateT>(s),
148 std::forward<InputTs>(is)...);
151 template <
typename ResultT,
typename StateT,
typename InputT,
typename... InputTs>
152 auto impl(meta::pack<ResultT> r, StateT&& s, InputT&& i, InputTs&& ...is)
154 !std::is_same<estd::decay_t<InputT>, last_input_tag>{},
159 meta::get_index_sequence<InputT>{},
160 std::forward<StateT>(s),
161 std::forward<InputT>(i),
162 std::forward<InputTs>(is)...);
165 template <
typename StateT,
typename... InputTs>
166 auto operator() (StateT&& s, InputTs&& ...is)
167 -> unzip_result_t<ReducingFnT, StateT, InputTs...>
170 meta::pack<unzip_result_t<ReducingFnT, StateT, InputTs...> >{},
171 std::forward<StateT>(s),
172 std::forward<InputTs>(is)...,
181 using unzip_t = transducer_impl<detail::unzip_rf_gen>;
typename std::enable_if< X, T >::type enable_if_t
Similar to C++14 std::enable_if_t.
C++ amazing templates and reusable implementations awesomeness.