Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / hana / fwd / zip_with.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::zip_with`.
4
5 @copyright Louis Dionne 2013-2017
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8  */
9
10 #ifndef BOOST_HANA_FWD_ZIP_WITH_HPP
11 #define BOOST_HANA_FWD_ZIP_WITH_HPP
12
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
15
16
17 BOOST_HANA_NAMESPACE_BEGIN
18     //! Zip one sequence or more with a given function.
19     //! @ingroup group-Sequence
20     //!
21     //! Given a `n`-ary function `f` and `n` sequences `s1, ..., sn`,
22     //! `zip_with` produces a sequence whose `i`-th element is
23     //! `f(s1[i], ..., sn[i])`, where `sk[i]` denotes the `i`-th element of
24     //! the `k`-th sequence. In other words, `zip_with` produces a sequence
25     //! of the form
26     //! @code
27     //!     [
28     //!         f(s1[0], ..., sn[0]),
29     //!         f(s1[1], ..., sn[1]),
30     //!         ...
31     //!         f(s1[M], ..., sn[M])
32     //!     ]
33     //! @endcode
34     //! where `M` is the length of the sequences, which are all assumed to
35     //! have the same length. Assuming the sequences to all have the same size
36     //! allows the library to perform some optimizations. To zip sequences
37     //! that may have different lengths, `zip_shortest_with` should be used
38     //! instead. Also note that it is an error to provide no sequence at all,
39     //! i.e. `zip_with` expects at least one sequence.
40     //!
41     //!
42     //! Example
43     //! -------
44     //! @include example/zip_with.cpp
45 #ifdef BOOST_HANA_DOXYGEN_INVOKED
46     constexpr auto zip_with = [](auto&& f, auto&& x1, ..., auto&& xn) {
47         return tag-dispatched;
48     };
49 #else
50     template <typename S, typename = void>
51     struct zip_with_impl : zip_with_impl<S, when<true>> { };
52
53     struct zip_with_t {
54         template <typename F, typename Xs, typename ...Ys>
55         constexpr auto operator()(F&& f, Xs&& xs, Ys&& ...ys) const;
56     };
57
58     constexpr zip_with_t zip_with{};
59 #endif
60 BOOST_HANA_NAMESPACE_END
61
62 #endif // !BOOST_HANA_FWD_ZIP_WITH_HPP