any_of.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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/any_of.hpp>
  5. #include <boost/hana/assert.hpp>
  6. #include <boost/hana/concept/struct.hpp>
  7. #include <boost/hana/equal.hpp>
  8. #include <boost/hana/integral_constant.hpp>
  9. #include <boost/hana/not.hpp>
  10. #include "minimal_struct.hpp"
  11. namespace hana = boost::hana;
  12. template <int i = 0>
  13. struct undefined { };
  14. int main() {
  15. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of(
  16. obj(),
  17. undefined<>{}
  18. )));
  19. BOOST_HANA_CONSTANT_CHECK(hana::any_of(
  20. obj(undefined<0>{}),
  21. hana::equal.to(hana::int_c<0>)
  22. ));
  23. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of(
  24. obj(undefined<0>{}),
  25. hana::equal.to(hana::int_c<1>)
  26. )));
  27. BOOST_HANA_CONSTANT_CHECK(hana::any_of(
  28. obj(undefined<0>{}, undefined<1>{}),
  29. hana::equal.to(hana::int_c<0>)
  30. ));
  31. BOOST_HANA_CONSTANT_CHECK(hana::any_of(
  32. obj(undefined<0>{}, undefined<1>{}),
  33. hana::equal.to(hana::int_c<1>)
  34. ));
  35. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of(
  36. obj(undefined<0>{}, undefined<1>{}),
  37. hana::equal.to(hana::int_c<2>)
  38. )));
  39. }