comparable.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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. #ifndef BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_COMPARABLE_HPP
  5. #define BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_COMPARABLE_HPP
  6. #include "matrix.hpp"
  7. #include <boost/hana/all.hpp>
  8. #include <boost/hana/bool.hpp>
  9. #include <boost/hana/equal.hpp>
  10. #include <boost/hana/eval_if.hpp>
  11. #include <boost/hana/zip_with.hpp>
  12. namespace boost { namespace hana {
  13. template <unsigned R1, unsigned C1, unsigned R2, unsigned C2>
  14. struct equal_impl<cppcon::Matrix<R1, C1>, cppcon::Matrix<R2, C2>> {
  15. template <typename M1, typename M2>
  16. static constexpr auto apply(M1 const& m1, M2 const& m2) {
  17. return eval_if(bool_c<R1 == R2 && C1 == C2>,
  18. [&](auto _) {
  19. return all(zip_with(_(equal), cppcon::rows(m1),
  20. cppcon::rows(m2)));
  21. },
  22. [] { return false_c; }
  23. );
  24. }
  25. };
  26. }}
  27. #endif // !BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_COMPARABLE_HPP