any_of.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*!
  2. @file
  3. Forward declares `boost::hana::any_of`.
  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_ANY_OF_HPP
  9. #define BOOST_HANA_FWD_ANY_OF_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Returns whether any key of the structure satisfies the `predicate`.
  14. //! @ingroup group-Searchable
  15. //!
  16. //! If the structure is not finite, `predicate` has to be satisfied
  17. //! after looking at a finite number of keys for this method to finish.
  18. //!
  19. //!
  20. //! @param xs
  21. //! The structure to search.
  22. //!
  23. //! @param predicate
  24. //! A function called as `predicate(k)`, where `k` is a key of the
  25. //! structure, and returning a `Logical`.
  26. //!
  27. //!
  28. //! Example
  29. //! -------
  30. //! @include example/any_of.cpp
  31. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  32. constexpr auto any_of = [](auto&& xs, auto&& predicate) {
  33. return tag-dispatched;
  34. };
  35. #else
  36. template <typename S, typename = void>
  37. struct any_of_impl : any_of_impl<S, when<true>> { };
  38. struct any_of_t {
  39. template <typename Xs, typename Pred>
  40. constexpr auto operator()(Xs&& xs, Pred&& pred) const;
  41. };
  42. constexpr any_of_t any_of{};
  43. #endif
  44. BOOST_HANA_NAMESPACE_END
  45. #endif // !BOOST_HANA_FWD_ANY_OF_HPP