drop_while.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*!
  2. @file
  3. Forward declares `boost::hana::drop_while`.
  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_DROP_WHILE_HPP
  9. #define BOOST_HANA_FWD_DROP_WHILE_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Drop elements from an iterable up to, but excluding, the first
  14. //! element for which the `predicate` is not satisfied.
  15. //! @ingroup group-Iterable
  16. //!
  17. //! Specifically, `drop_while` returns an iterable containing all the
  18. //! elements of the original iterable except for those in the range
  19. //! delimited by [`head`, `e`), where `head` is the first element and
  20. //! `e` is the first element for which the `predicate` is not satisfied.
  21. //! If the iterable is not finite, the `predicate` has to return a false-
  22. //! valued `Logical` at a finite index for this method to return.
  23. //!
  24. //!
  25. //! @param iterable
  26. //! The iterable from which elements are dropped.
  27. //!
  28. //! @param predicate
  29. //! A function called as `predicate(x)`, where `x` is an element of the
  30. //! structure, and returning a `Logical` representing whether `x` should
  31. //! be dropped from the structure. In the current version of the library,
  32. //! `predicate` should return a compile-time `Logical`.
  33. //!
  34. //!
  35. //! Example
  36. //! -------
  37. //! @include example/drop_while.cpp
  38. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  39. constexpr auto drop_while = [](auto&& iterable, auto&& predicate) {
  40. return tag-dispatched;
  41. };
  42. #else
  43. template <typename It, typename = void>
  44. struct drop_while_impl : drop_while_impl<It, when<true>> { };
  45. struct drop_while_t {
  46. template <typename Xs, typename Pred>
  47. constexpr auto operator()(Xs&& xs, Pred&& pred) const;
  48. };
  49. constexpr drop_while_t drop_while{};
  50. #endif
  51. BOOST_HANA_NAMESPACE_END
  52. #endif // !BOOST_HANA_FWDDROP_WHILE_HPP