none_of.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*!
  2. @file
  3. Defines `boost::hana::none_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_NONE_OF_HPP
  9. #define BOOST_HANA_NONE_OF_HPP
  10. #include <boost/hana/fwd/none_of.hpp>
  11. #include <boost/hana/any_of.hpp>
  12. #include <boost/hana/concept/searchable.hpp>
  13. #include <boost/hana/config.hpp>
  14. #include <boost/hana/core/dispatch.hpp>
  15. #include <boost/hana/not.hpp>
  16. BOOST_HANA_NAMESPACE_BEGIN
  17. //! @cond
  18. template <typename Xs, typename Pred>
  19. constexpr auto none_of_t::operator()(Xs&& xs, Pred&& pred) const {
  20. using S = typename hana::tag_of<Xs>::type;
  21. using NoneOf = BOOST_HANA_DISPATCH_IF(none_of_impl<S>,
  22. hana::Searchable<S>::value
  23. );
  24. #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
  25. static_assert(hana::Searchable<S>::value,
  26. "hana::none_of(xs, pred) requires 'xs' to be a Searchable");
  27. #endif
  28. return NoneOf::apply(static_cast<Xs&&>(xs), static_cast<Pred&&>(pred));
  29. }
  30. //! @endcond
  31. template <typename S, bool condition>
  32. struct none_of_impl<S, when<condition>> : default_ {
  33. template <typename Xs, typename Pred>
  34. static constexpr auto apply(Xs&& xs, Pred&& pred) {
  35. return hana::not_(hana::any_of(static_cast<Xs&&>(xs),
  36. static_cast<Pred&&>(pred)));
  37. }
  38. };
  39. BOOST_HANA_NAMESPACE_END
  40. #endif // !BOOST_HANA_NONE_OF_HPP