/*! @file Defines `boost::hana::remove_at` and `boost::hana::remove_at_c`. @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_REMOVE_AT_HPP #define BOOST_HANA_REMOVE_AT_HPP #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace hana { //! @cond template constexpr auto remove_at_t::operator()(Xs&& xs, N const& n) const { using S = typename hana::tag_of::type; using RemoveAt = BOOST_HANA_DISPATCH_IF(remove_at_impl, hana::Sequence::value && hana::IntegralConstant::value ); #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(hana::Sequence::value, "hana::remove_at(xs, n) requires 'xs' to be a Sequence"); static_assert(hana::IntegralConstant::value, "hana::remove_at(xs, n) requires 'n' to be an IntegralConstant"); #endif static_assert(N::value >= 0, "hana::remove_at(xs, n) requires 'n' to be non-negative"); return RemoveAt::apply(static_cast(xs), n); } //! @endcond template struct remove_at_impl> : default_ { template static constexpr auto remove_at_helper(Xs&& xs, std::index_sequence, std::index_sequence) { return hana::make( hana::at_c(static_cast(xs))..., hana::at_c(static_cast(xs))... ); } template static constexpr auto apply(Xs&& xs, N const&) { constexpr std::size_t n = N::value; constexpr std::size_t len = decltype(hana::length(xs))::value; static_assert(n < len, "hana::remove_at(xs, n) requires 'n' to be in the bounds of the sequence"); return remove_at_helper(static_cast(xs), std::make_index_sequence{}, std::make_index_sequence{}); } }; template struct remove_at_c_t { template constexpr decltype(auto) operator()(Xs&& xs) const { return hana::remove_at(static_cast(xs), hana::size_c); } }; }} // end namespace boost::hana #endif // !BOOST_HANA_REMOVE_AT_HPP