9
3

searchable.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/ext/boost/tuple.hpp>
  5. #include <boost/hana/bool.hpp>
  6. #include <boost/hana/tuple.hpp>
  7. #include <laws/base.hpp>
  8. #include <laws/searchable.hpp>
  9. #include <boost/tuple/tuple.hpp>
  10. namespace hana = boost::hana;
  11. template <int i>
  12. using eq = hana::test::ct_eq<i>;
  13. int main() {
  14. //////////////////////////////////////////////////////////////////////////
  15. // Setup for the laws below
  16. //////////////////////////////////////////////////////////////////////////
  17. auto eq_tuples = hana::make_tuple(
  18. ::boost::make_tuple()
  19. , ::boost::make_tuple(eq<0>{})
  20. , ::boost::make_tuple(eq<0>{}, eq<1>{})
  21. , ::boost::make_tuple(eq<0>{}, eq<1>{}, eq<2>{})
  22. );
  23. auto eq_tuple_keys = hana::make_tuple(
  24. eq<3>{}, eq<5>{}, eq<7>{}
  25. );
  26. //////////////////////////////////////////////////////////////////////////
  27. // Searchable
  28. //////////////////////////////////////////////////////////////////////////
  29. {
  30. hana::test::TestSearchable<hana::ext::boost::tuple_tag>{eq_tuples, eq_tuple_keys};
  31. auto bools = hana::make_tuple(
  32. ::boost::make_tuple(hana::true_c)
  33. , ::boost::make_tuple(hana::false_c)
  34. , ::boost::make_tuple(hana::true_c, hana::true_c)
  35. , ::boost::make_tuple(hana::true_c, hana::false_c)
  36. , ::boost::make_tuple(hana::false_c, hana::true_c)
  37. , ::boost::make_tuple(hana::false_c, hana::false_c)
  38. );
  39. hana::test::TestSearchable<hana::ext::boost::tuple_tag>{
  40. bools,
  41. hana::make_tuple(hana::true_c, hana::false_c)
  42. };
  43. }
  44. }