| 1 | /*! |
| 2 | @file |
| 3 | Forward declares `boost::hana::zip`. |
| 4 | |
| 5 | Copyright Louis Dionne 2013-2022 |
| 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_HPP |
| 11 | #define BOOST_HANA_FWD_ZIP_HPP |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | #include <boost/hana/core/when.hpp> |
| 15 | |
| 16 | |
| 17 | namespace boost { namespace hana { |
| 18 | //! Zip one sequence or more. |
| 19 | //! @ingroup group-Sequence |
| 20 | //! |
| 21 | //! Given `n` sequences `s1, ..., sn`, `zip` produces a sequence whose |
| 22 | //! `i`-th element is a tuple of `(s1[i], ..., sn[i])`, where `sk[i]` |
| 23 | //! denotes the `i`-th element of the `k`-th sequence. In other words, |
| 24 | //! `zip` produces a sequence of the form |
| 25 | //! @code |
| 26 | //! [ |
| 27 | //! make_tuple(s1[0], ..., sn[0]), |
| 28 | //! make_tuple(s1[1], ..., sn[1]), |
| 29 | //! ... |
| 30 | //! make_tuple(s1[M], ..., sn[M]) |
| 31 | //! ] |
| 32 | //! @endcode |
| 33 | //! where `M` is the length of the sequences, which are all assumed to |
| 34 | //! have the same length. Assuming the sequences to all have the same size |
| 35 | //! allows the library to perform some optimizations. To zip sequences |
| 36 | //! that may have different lengths, `zip_shortest` should be used |
| 37 | //! instead. Also note that it is an error to provide no sequence at all, |
| 38 | //! i.e. `zip` expects at least one sequence. |
| 39 | //! |
| 40 | //! |
| 41 | //! Example |
| 42 | //! ------- |
| 43 | //! @include example/zip.cpp |
| 44 | #ifdef BOOST_HANA_DOXYGEN_INVOKED |
| 45 | constexpr auto zip = [](auto&& x1, ..., auto&& xn) { |
| 46 | return tag-dispatched; |
| 47 | }; |
| 48 | #else |
| 49 | template <typename S, typename = void> |
| 50 | struct zip_impl : zip_impl<S, when<true>> { }; |
| 51 | |
| 52 | struct zip_t { |
| 53 | template <typename Xs, typename ...Ys> |
| 54 | constexpr auto operator()(Xs&& xs, Ys&& ...ys) const; |
| 55 | }; |
| 56 | |
| 57 | BOOST_HANA_INLINE_VARIABLE constexpr zip_t zip{}; |
| 58 | #endif |
| 59 | }} // end namespace boost::hana |
| 60 | |
| 61 | #endif // !BOOST_HANA_FWD_ZIP_HPP |
| 62 | |