| 1 | /*! |
| 2 | @file |
| 3 | Forward declares `boost::hana::insert_range`. |
| 4 | |
| 5 | Copyright Louis Dionne 2013-2022 |
| 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_INSERT_RANGE_HPP |
| 11 | #define BOOST_HANA_FWD_INSERT_RANGE_HPP |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | #include <boost/hana/core/when.hpp> |
| 15 | |
| 16 | |
| 17 | namespace boost { namespace hana { |
| 18 | //! Insert several values at a given index in a sequence. |
| 19 | //! @ingroup group-Sequence |
| 20 | //! |
| 21 | //! Given a sequence, an index and any `Foldable` containing elements to |
| 22 | //! insert, `insert_range` inserts the elements in the `Foldable` at the |
| 23 | //! given index of the sequence. |
| 24 | //! |
| 25 | //! @param xs |
| 26 | //! The sequence in which values should be inserted. |
| 27 | //! |
| 28 | //! @param n |
| 29 | //! The index at which elements should be inserted. This must be a |
| 30 | //! non-negative `Constant` of an integral type, and it must also be |
| 31 | //! true that `n < length(xs)` if `xs` is a finite sequence. |
| 32 | //! |
| 33 | //! @param elements |
| 34 | //! A `Foldable` containing elements to insert in the sequence. |
| 35 | //! |
| 36 | //! |
| 37 | //! Example |
| 38 | //! ------- |
| 39 | //! @include example/insert_range.cpp |
| 40 | #ifdef BOOST_HANA_DOXYGEN_INVOKED |
| 41 | constexpr auto insert_range = [](auto&& xs, auto&& n, auto&& elements) { |
| 42 | return tag-dispatched; |
| 43 | }; |
| 44 | #else |
| 45 | template <typename S, typename = void> |
| 46 | struct insert_range_impl : insert_range_impl<S, when<true>> { }; |
| 47 | |
| 48 | struct insert_range_t { |
| 49 | template <typename Xs, typename N, typename Elements> |
| 50 | constexpr auto operator()(Xs&& xs, N&& n, Elements&& elements) const; |
| 51 | }; |
| 52 | |
| 53 | BOOST_HANA_INLINE_VARIABLE constexpr insert_range_t insert_range{}; |
| 54 | #endif |
| 55 | }} // end namespace boost::hana |
| 56 | |
| 57 | #endif // !BOOST_HANA_FWD_INSERT_RANGE_HPP |
| 58 | |