]>
Commit | Line | Data |
---|---|---|
1 | /*! | |
2 | @file | |
3 | Forward declares `boost::hana::insert`. | |
4 | ||
5 | @copyright Louis Dionne 2013-2016 | |
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_HPP | |
11 | #define BOOST_HANA_FWD_INSERT_HPP | |
12 | ||
13 | #include <boost/hana/config.hpp> | |
14 | #include <boost/hana/core/when.hpp> | |
15 | ||
16 | ||
17 | BOOST_HANA_NAMESPACE_BEGIN | |
18 | // Note: This function is documented per datatype/concept only. | |
19 | //! @cond | |
20 | template <typename T, typename = void> | |
21 | struct insert_impl : insert_impl<T, when<true>> { }; | |
22 | //! @endcond | |
23 | ||
24 | struct insert_t { | |
25 | template <typename Set, typename ...Args> | |
26 | constexpr decltype(auto) operator()(Set&& set, Args&& ...args) const; | |
27 | }; | |
28 | ||
29 | constexpr insert_t insert{}; | |
30 | ||
31 | ||
32 | //! Insert a value at a given index in a sequence. | |
33 | //! @ingroup group-Sequence | |
34 | //! | |
35 | //! Given a sequence, an index and an element to insert, `insert` inserts | |
36 | //! the element at the given index. | |
37 | //! | |
38 | //! @param xs | |
39 | //! The sequence in which a value should be inserted. | |
40 | //! | |
41 | //! @param n | |
42 | //! The index at which an element should be inserted. This must be a | |
43 | //! non-negative `Constant` of an integral type, and it must also be | |
44 | //! true that `n < length(xs)` if `xs` is a finite sequence. | |
45 | //! | |
46 | //! @param element | |
47 | //! The element to insert in the sequence. | |
48 | //! | |
49 | //! | |
50 | //! Example | |
51 | //! ------- | |
52 | //! @include example/insert.cpp | |
53 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
54 | constexpr auto insert = [](auto&& xs, auto&& n, auto&& element) { | |
55 | return tag-dispatched; | |
56 | }; | |
57 | #endif | |
58 | BOOST_HANA_NAMESPACE_END | |
59 | ||
60 | #endif // !BOOST_HANA_FWD_INSERT_HPP |