]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/fwd/zip_shortest.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / fwd / zip_shortest.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::zip_shortest`.
4
5 @copyright Louis Dionne 2013-2016
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_SHORTEST_HPP
11 #define BOOST_HANA_FWD_ZIP_SHORTEST_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.
19 //! @ingroup group-Sequence
20 //!
21 //! Given `n` sequences `s1, ..., sn`, `zip_shortest` produces a sequence
22 //! whose `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_shortest` 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 shortest sequence. Hence, the returned
34 //! sequence stops when the shortest input sequence is exhausted. If you
35 //! know that all the sequences you are about to zip have the same length,
36 //! you should use `zip` instead, since it can be more optimized. Also
37 //! note that it is an error to provide no sequence at all, i.e.
38 //! `zip_shortest` expects at least one sequence.
39 //!
40 //!
41 //! Example
42 //! -------
43 //! @include example/zip_shortest.cpp
44 #ifdef BOOST_HANA_DOXYGEN_INVOKED
45 constexpr auto zip_shortest = [](auto&& x1, ..., auto&& xn) {
46 return tag-dispatched;
47 };
48 #else
49 template <typename S, typename = void>
50 struct zip_shortest_impl : zip_shortest_impl<S, when<true>> { };
51
52 struct zip_shortest_t {
53 template <typename Xs, typename ...Ys>
54 constexpr auto operator()(Xs&& xs, Ys&& ...ys) const;
55 };
56
57 constexpr zip_shortest_t zip_shortest{};
58 #endif
59 BOOST_HANA_NAMESPACE_END
60
61 #endif // !BOOST_HANA_FWD_ZIP_SHORTEST_HPP