/*! @file Defines `boost::hana::concat`. @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_CONCAT_HPP #define BOOST_HANA_CONCAT_HPP #include #include #include #include #include #include #include #include #include #include #include BOOST_HANA_NAMESPACE_BEGIN //! @cond template constexpr auto concat_t::operator()(Xs&& xs, Ys&& ys) const { using M = typename hana::tag_of::type; using Concat = BOOST_HANA_DISPATCH_IF(concat_impl, hana::MonadPlus::value && std::is_same::type, M>::value ); #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(std::is_same::type, M>::value, "hana::concat(xs, ys) requires 'xs' and 'ys' to have the same tag"); static_assert(hana::MonadPlus::value, "hana::concat(xs, ys) requires 'xs' and 'ys' to be MonadPlus"); #endif return Concat::apply(static_cast(xs), static_cast(ys)); } //! @endcond template struct concat_impl> : default_ { template static constexpr auto apply(Args&& ...) = delete; }; template struct concat_impl::value>> { template static constexpr auto concat_helper(Xs&& xs, Ys&& ys, std::index_sequence, std::index_sequence) { return hana::make( hana::at_c(static_cast(xs))..., hana::at_c(static_cast(ys))... ); } template static constexpr auto apply(Xs&& xs, Ys&& ys) { constexpr std::size_t xi = decltype(hana::length(xs))::value; constexpr std::size_t yi = decltype(hana::length(ys))::value; return concat_helper(static_cast(xs), static_cast(ys), std::make_index_sequence{}, std::make_index_sequence{}); } }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_CONCAT_HPP