]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/zip.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / zip.hpp
1 /*!
2 @file
3 Defines `boost::hana::zip`.
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_ZIP_HPP
11 #define BOOST_HANA_ZIP_HPP
12
13 #include <boost/hana/fwd/zip.hpp>
14
15 #include <boost/hana/concept/sequence.hpp>
16 #include <boost/hana/config.hpp>
17 #include <boost/hana/core/dispatch.hpp>
18 #include <boost/hana/detail/fast_and.hpp>
19 #include <boost/hana/tuple.hpp>
20 #include <boost/hana/zip_with.hpp>
21
22
23 BOOST_HANA_NAMESPACE_BEGIN
24 //! @cond
25 template <typename Xs, typename ...Ys>
26 constexpr auto zip_t::operator()(Xs&& xs, Ys&& ...ys) const {
27 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
28 static_assert(detail::fast_and<
29 hana::Sequence<Xs>::value, hana::Sequence<Ys>::value...
30 >::value,
31 "hana::zip(xs, ys...) requires 'xs' and 'ys...' to be Sequences");
32 #endif
33
34 return zip_impl<typename hana::tag_of<Xs>::type>::apply(
35 static_cast<Xs&&>(xs),
36 static_cast<Ys&&>(ys)...
37 );
38 }
39 //! @endcond
40
41 template <typename S, bool condition>
42 struct zip_impl<S, when<condition>> : default_ {
43 template <typename ...Xs>
44 static constexpr decltype(auto) apply(Xs&& ...xs) {
45 return hana::zip_with(hana::make_tuple, static_cast<Xs&&>(xs)...);
46 }
47 };
48 BOOST_HANA_NAMESPACE_END
49
50 #endif // !BOOST_HANA_ZIP_HPP