/// \file // Range v3 library // // Copyright Eric Niebler 2013-present // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/ericniebler/range-v3 // #ifndef RANGES_V3_VIEW_ZIP_HPP #define RANGES_V3_VIEW_ZIP_HPP #include #include #include #include #include #include #include #include #include #include RANGES_DISABLE_WARNINGS namespace ranges { /// \cond namespace detail { struct indirect_zip_fn_ { // tuple value template [[noreturn]] auto operator()(copy_tag, Its...) const -> CPP_ret(std::tuple...>)( // requires and_v...> && (sizeof...(Its) != 2)) { RANGES_EXPECT(false); } // tuple reference template auto operator()(Its const &... its) const noexcept(meta::and_c(*its))...>::value) -> CPP_ret(common_tuple...>)( // requires and_v...> && (sizeof...(Its) != 2)) { return common_tuple...>{*its...}; } // tuple rvalue reference template auto operator()(move_tag, Its const &... its) const noexcept(meta::and_c(iter_move(its)))...>::value) -> CPP_ret(common_tuple...>)( // requires and_v...> && (sizeof...(Its) != 2)) { return common_tuple...>{iter_move(its)...}; } // pair value template [[noreturn]] auto operator()(copy_tag, It1, It2) const -> CPP_ret(std::pair, iter_value_t>)( // requires readable && readable) { RANGES_EXPECT(false); } // pair reference template auto operator()(It1 const & it1, It2 const & it2) const noexcept( noexcept(iter_reference_t(*it1)) && noexcept(iter_reference_t(*it2))) -> CPP_ret(common_pair, iter_reference_t>)( // requires readable && readable) { return {*it1, *it2}; } // pair rvalue reference template auto operator()(move_tag, It1 const & it1, It2 const & it2) const noexcept(noexcept(iter_rvalue_reference_t(iter_move(it1))) && noexcept(iter_rvalue_reference_t(iter_move(it2)))) -> CPP_ret(common_pair, iter_rvalue_reference_t>)( // requires readable && readable) { return {iter_move(it1), iter_move(it2)}; } }; } // namespace detail /// \endcond /// \addtogroup group-views /// @{ template struct zip_view : iter_zip_with_view { CPP_assert(sizeof...(Rngs) != 0); zip_view() = default; explicit zip_view(Rngs... rngs) : iter_zip_with_view{ detail::indirect_zip_fn_{}, std::move(rngs)...} {} }; #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17 template zip_view(Rng &&...)->zip_view...>; #endif namespace views { struct zip_fn { template auto operator()(Rngs &&... rngs) const -> CPP_ret( zip_view...>)( // requires and_v...> && and_v...> && (sizeof...(Rngs) != 0)) { return zip_view...>{all(static_cast(rngs))...}; } constexpr empty_view> operator()() const noexcept { return {}; } }; /// \relates zip_fn /// \ingroup group-views RANGES_INLINE_VARIABLE(zip_fn, zip) } // namespace views /// @} } // namespace ranges RANGES_RE_ENABLE_WARNINGS #include RANGES_SATISFY_BOOST_RANGE(::ranges::zip_view) #endif