none_of.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright Louis Dionne 2013-2017
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  4. #include <boost/hana/assert.hpp>
  5. #include <boost/hana/config.hpp>
  6. #include <boost/hana/ext/std/integral_constant.hpp>
  7. #include <boost/hana/integral_constant.hpp>
  8. #include <boost/hana/mod.hpp>
  9. #include <boost/hana/none_of.hpp>
  10. #include <boost/hana/not.hpp>
  11. #include <boost/hana/not_equal.hpp>
  12. #include <boost/hana/tuple.hpp>
  13. #include <boost/hana/type.hpp>
  14. #include <type_traits>
  15. namespace hana = boost::hana;
  16. using namespace hana::literals;
  17. BOOST_HANA_CONSTEXPR_LAMBDA auto is_odd = [](auto x) {
  18. return x % 2_c != 0_c;
  19. };
  20. int main() {
  21. BOOST_HANA_CONSTANT_CHECK(hana::none_of(hana::make_tuple(2_c, 4_c), is_odd));
  22. BOOST_HANA_CONSTEXPR_CHECK(!hana::none_of(hana::make_tuple(1, 2), is_odd));
  23. BOOST_HANA_CONSTANT_CHECK(
  24. !hana::none_of(hana::make_tuple(hana::type_c<void>, hana::type_c<char&>), hana::trait<std::is_void>)
  25. );
  26. BOOST_HANA_CONSTANT_CHECK(
  27. hana::none_of(hana::make_tuple(hana::type_c<void>, hana::type_c<char&>), hana::trait<std::is_integral>)
  28. );
  29. }