1 /*! 2 @file 3 Forward declares `boost::hana::remove_range` and `boost::hana::remove_range_c`. 4 5 @copyright Louis Dionne 2013-2017 6 Distributed under the Boost Software License, Version 1.0. 7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 8 */ 9 10 #ifndef BOOST_HANA_FWD_REMOVE_RANGE_HPP 11 #define BOOST_HANA_FWD_REMOVE_RANGE_HPP 12 13 #include <boost/hana/config.hpp> 14 #include <boost/hana/core/when.hpp> 15 16 #include <cstddef> 17 18 19 BOOST_HANA_NAMESPACE_BEGIN 20 //! Remove the elements inside a given range of indices from a sequence. 21 //! @ingroup group-Sequence 22 //! 23 //! `remove_range` returns a new sequence identical to the original, 24 //! except that elements at indices in the provided range are removed. 25 //! Specifically, `remove_range([x0, ..., xn], from, to)` is a new 26 //! sequence equivalent to `[x0, ..., x_from-1, x_to, ..., xn]`. 27 //! 28 //! 29 //! @note 30 //! The behavior is undefined if the range contains any index out of the 31 //! bounds of the sequence. 32 //! 33 //! 34 //! @param xs 35 //! A sequence from which elements are removed. 36 //! 37 //! @param [from, to) 38 //! An half-open interval of `IntegralConstant`s representing the indices 39 //! of the elements to be removed from the sequence. The `IntegralConstant`s 40 //! in the half-open interval must be non-negative and in the bounds of 41 //! the sequence. The half-open interval must also be valid, meaning that 42 //! `from <= to`. 43 //! 44 //! 45 //! Example 46 //! ------- 47 //! @include example/remove_range.cpp 48 #ifdef BOOST_HANA_DOXYGEN_INVOKED __anon83b838d60102(auto&& xs, auto const& from, auto const& to) 49 constexpr auto remove_range = [](auto&& xs, auto const& from, auto const& to) { 50 return tag-dispatched; 51 }; 52 #else 53 template <typename S, typename = void> 54 struct remove_range_impl : remove_range_impl<S, when<true>> { }; 55 56 struct remove_range_t { 57 template <typename Xs, typename From, typename To> 58 constexpr auto operator()(Xs&& xs, From const& from, To const& to) const; 59 }; 60 61 constexpr remove_range_t remove_range{}; 62 #endif 63 64 //! Equivalent to `remove_range`; provided for convenience. 65 //! @ingroup group-Sequence 66 //! 67 //! 68 //! Example 69 //! ------- 70 //! @include example/remove_range_c.cpp 71 #ifdef BOOST_HANA_DOXYGEN_INVOKED 72 template <std::size_t from, std::size_t to> __anon83b838d60202(auto&& xs) 73 constexpr auto remove_range_c = [](auto&& xs) { 74 return hana::remove_range(forwarded(xs), hana::size_c<from>, hana::size_c<to>); 75 }; 76 #else 77 template <std::size_t from, std::size_t to> 78 struct remove_range_c_t; 79 80 template <std::size_t from, std::size_t to> 81 constexpr remove_range_c_t<from, to> remove_range_c{}; 82 #endif 83 BOOST_HANA_NAMESPACE_END 84 85 #endif // !BOOST_HANA_FWD_REMOVE_RANGE_HPP 86