insert_range.hpp 1.7 KB

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