insert.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*!
  2. @file
  3. Forward declares `boost::hana::insert`.
  4. @copyright Louis Dionne 2013-2017
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_HANA_FWD_INSERT_HPP
  9. #define BOOST_HANA_FWD_INSERT_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. // Note: This function is documented per datatype/concept only.
  14. //! @cond
  15. template <typename T, typename = void>
  16. struct insert_impl : insert_impl<T, when<true>> { };
  17. //! @endcond
  18. struct insert_t {
  19. template <typename Set, typename ...Args>
  20. constexpr decltype(auto) operator()(Set&& set, Args&& ...args) const;
  21. };
  22. constexpr insert_t insert{};
  23. //! Insert a value at a given index in a sequence.
  24. //! @ingroup group-Sequence
  25. //!
  26. //! Given a sequence, an index and an element to insert, `insert` inserts
  27. //! the element at the given index.
  28. //!
  29. //! @param xs
  30. //! The sequence in which a value should be inserted.
  31. //!
  32. //! @param n
  33. //! The index at which an element should be inserted. This must be a
  34. //! non-negative `Constant` of an integral type, and it must also be
  35. //! true that `n < length(xs)` if `xs` is a finite sequence.
  36. //!
  37. //! @param element
  38. //! The element to insert in the sequence.
  39. //!
  40. //!
  41. //! Example
  42. //! -------
  43. //! @include example/insert.cpp
  44. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  45. constexpr auto insert = [](auto&& xs, auto&& n, auto&& element) {
  46. return tag-dispatched;
  47. };
  48. #endif
  49. BOOST_HANA_NAMESPACE_END
  50. #endif // !BOOST_HANA_FWD_INSERT_HPP