/*! @file Defines `boost::hana::insert_range`. @copyright Louis Dionne 2013-2016 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_INSERT_RANGE_HPP #define BOOST_HANA_INSERT_RANGE_HPP #include #include #include #include #include #include #include #include #include BOOST_HANA_NAMESPACE_BEGIN //! @cond template constexpr auto insert_range_t::operator()(Xs&& xs, N&& n, Elements&& elements) const { using S = typename hana::tag_of::type; using InsertRange = BOOST_HANA_DISPATCH_IF(insert_range_impl, hana::Sequence::value && hana::Foldable::value ); #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(hana::Sequence::value, "hana::insert_range(xs, n, elements) requires 'xs' to be a Sequence"); static_assert(hana::Foldable::value, "hana::insert_range(xs, n, elements) requires 'elements' to be a Foldable"); #endif return InsertRange::apply(static_cast(xs), static_cast(n), static_cast(elements)); } //! @endcond template struct insert_range_impl> { template static constexpr auto apply(Xs&& xs, N const& n, Elements&& e) { return hana::concat( hana::concat( hana::take_front(xs, n), hana::to(static_cast(e)) ), hana::drop_front(xs, n) ); } }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_INSERT_RANGE_HPP