find.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031
  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/equal.hpp>
  6. #include <boost/hana/find.hpp>
  7. #include <boost/hana/integral_constant.hpp>
  8. #include <boost/hana/map.hpp>
  9. #include <boost/hana/optional.hpp>
  10. #include <boost/hana/pair.hpp>
  11. #include <boost/hana/tuple.hpp>
  12. #include <boost/hana/type.hpp>
  13. namespace hana = boost::hana;
  14. BOOST_HANA_CONSTANT_CHECK(
  15. hana::find(hana::make_tuple(hana::int_c<1>, hana::type_c<int>, '3'), hana::type_c<int>) == hana::just(hana::type_c<int>)
  16. );
  17. BOOST_HANA_CONSTANT_CHECK(
  18. hana::find(hana::make_tuple(hana::int_c<1>, hana::type_c<int>, '3'), hana::type_c<void>) == hana::nothing
  19. );
  20. constexpr auto m = hana::make_map(
  21. hana::make_pair(hana::int_c<2>, 2),
  22. hana::make_pair(hana::type_c<float>, 3.3),
  23. hana::make_pair(hana::type_c<char>, hana::type_c<int>)
  24. );
  25. static_assert(hana::find(m, hana::type_c<float>) == hana::just(3.3), "");
  26. int main() { }