32 #include <type_traits>
39 template<
typename T1,
typename T2,
template<
typename U>
class Container,
typename F>
40 auto ZipWith (
const Container<T1>& c1,
const Container<T2>& c2, F f) -> Container<typename std::result_of<F (T1, T2)>::type>
42 Container<typename std::result_of<F (T1, T2)>::type> result;
44 auto i1 = std::begin (c1), e1 = std::end (c1);
45 auto i2 = std::begin (c2), e2 = std::end (c2);
46 for ( ; i1 != e1 && i2 != e2; ++i1, ++i2)
47 result.push_back (f (*i1, *i2));
51 template<
typename T1,
typename T2,
52 template<
typename U>
class Container,
53 template<
typename U1,
typename U2>
class Pair = QPair>
54 auto Zip (
const Container<T1>& c1,
const Container<T2>& c2) -> Container<Pair<T1, T2>>
57 [] (
const T1& t1,
const T2& t2) -> Pair<T1, T2>
58 {
return { t1, t2}; });
61 template<
typename T,
template<
typename U>
class Container,
typename F>
62 auto Map (
const Container<T>& c, F f) -> Container<decltype (f (T ()))>
64 Container<decltype (f (T ()))> result;
66 result.push_back (f (t));
auto ZipWith(const Container< T1 > &c1, const Container< T2 > &c2, F f) -> Container< typename std::result_of< F(T1, T2)>::type >
auto Zip(const Container< T1 > &c1, const Container< T2 > &c2) -> Container< Pair< T1, T2 >>
auto Map(const Container< T > &c, F f) -> Container< decltype(f(T()))>