searchable.cpp 995 B

123456789101112131415161718192021222324252627
  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/all_of.hpp>
  5. #include <boost/hana/assert.hpp>
  6. #include <boost/hana/equal.hpp>
  7. #include <boost/hana/find_if.hpp>
  8. #include <boost/hana/integral_constant.hpp>
  9. #include <boost/hana/mod.hpp>
  10. #include <boost/hana/not_equal.hpp>
  11. #include <boost/hana/optional.hpp>
  12. namespace hana = boost::hana;
  13. auto odd = [](auto x) {
  14. return x % hana::int_c<2> != hana::int_c<0>;
  15. };
  16. BOOST_HANA_CONSTANT_CHECK(hana::find_if(hana::just(hana::int_c<3>), odd) == hana::just(hana::int_c<3>));
  17. BOOST_HANA_CONSTANT_CHECK(hana::find_if(hana::just(hana::int_c<2>), odd) == hana::nothing);
  18. BOOST_HANA_CONSTANT_CHECK(hana::find_if(hana::nothing, odd) == hana::nothing);
  19. BOOST_HANA_CONSTANT_CHECK(hana::all_of(hana::just(hana::int_c<3>), odd));
  20. BOOST_HANA_CONSTANT_CHECK(hana::all_of(hana::nothing, odd));
  21. int main() { }