/*! @file Defines `boost::hana::zip_with`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_ZIP_WITH_HPP #define BOOST_HANA_ZIP_WITH_HPP #include #include #include #include #include #include #include #include #include #include BOOST_HANA_NAMESPACE_BEGIN //! @cond template constexpr auto zip_with_t::operator()(F&& f, Xs&& xs, Ys&& ...ys) const { #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(detail::fast_and< hana::Sequence::value, hana::Sequence::value... >::value, "hana::zip_with(f, xs, ys...) requires 'xs' and 'ys...' to be Sequences"); #endif return zip_with_impl::type>::apply( static_cast(f), static_cast(xs), static_cast(ys)... ); } //! @endcond template struct zip_with_impl::value>> { template static constexpr decltype(auto) transverse(F&& f, Xs&& ...xs) { return static_cast(f)(hana::at_c(static_cast(xs))...); } template static constexpr auto zip_helper(std::index_sequence, F&& f, Xs&& ...xs) { return hana::make(transverse(f, xs...)...); } template static constexpr auto apply(F&& f, X&& x, Xs&& ...xs) { constexpr std::size_t N = decltype(hana::length(x))::value; return zip_helper(std::make_index_sequence{}, static_cast(f), static_cast(x), static_cast(xs)...); } }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_ZIP_WITH_HPP