Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / hana / fwd / insert_range.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::insert_range`.
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_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 BOOST_HANA_NAMESPACE_BEGIN
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     constexpr insert_range_t insert_range{};
54 #endif
55 BOOST_HANA_NAMESPACE_END
56
57 #endif // !BOOST_HANA_FWD_INSERT_RANGE_HPP