remove_at.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*!
  2. @file
  3. Forward declares `boost::hana::remove_at` and `boost::hana::remove_at_c`.
  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_REMOVE_AT_HPP
  9. #define BOOST_HANA_FWD_REMOVE_AT_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. #include <cstddef>
  13. BOOST_HANA_NAMESPACE_BEGIN
  14. //! Remove the element at a given index from a sequence.
  15. //! @ingroup group-Sequence
  16. //!
  17. //! `remove_at` returns a new sequence identical to the original, except
  18. //! that the element at the given index is removed. Specifically,
  19. //! `remove_at([x0, ..., xn-1, xn, xn+1, ..., xm], n)` is a new
  20. //! sequence equivalent to `[x0, ..., xn-1, xn+1, ..., xm]`.
  21. //!
  22. //! @note
  23. //! The behavior is undefined if the index is out of the bounds of the
  24. //! sequence.
  25. //!
  26. //!
  27. //! @param xs
  28. //! A sequence from which an element is to be removed.
  29. //!
  30. //! @param n
  31. //! An non-negative `IntegralConstant` representing the index of the
  32. //! element to be removed from the sequence. The behavior is undefined
  33. //! if that index is not in the bounds of the sequence.
  34. //!
  35. //!
  36. //! Example
  37. //! -------
  38. //! @include example/remove_at.cpp
  39. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  40. constexpr auto remove_at = [](auto&& xs, auto const& n) {
  41. return tag-dispatched;
  42. };
  43. #else
  44. template <typename S, typename = void>
  45. struct remove_at_impl : remove_at_impl<S, when<true>> { };
  46. struct remove_at_t {
  47. template <typename Xs, typename N>
  48. constexpr auto operator()(Xs&& xs, N const& n) const;
  49. };
  50. constexpr remove_at_t remove_at{};
  51. #endif
  52. //! Equivalent to `remove_at`; provided for convenience.
  53. //! @ingroup group-Sequence
  54. //!
  55. //!
  56. //! Example
  57. //! -------
  58. //! @include example/remove_at_c.cpp
  59. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  60. template <std::size_t n>
  61. constexpr auto remove_at_c = [](auto&& xs) {
  62. return hana::remove_at(forwarded(xs), hana::size_c<n>);
  63. };
  64. #else
  65. template <std::size_t n>
  66. struct remove_at_c_t;
  67. template <std::size_t n>
  68. constexpr remove_at_c_t<n> remove_at_c{};
  69. #endif
  70. BOOST_HANA_NAMESPACE_END
  71. #endif // !BOOST_HANA_FWD_REMOVE_AT_HPP