diff options
Diffstat (limited to 'src/boost/libs/hana/example/cppcon_2014/matrix/comparable.hpp')
-rw-r--r-- | src/boost/libs/hana/example/cppcon_2014/matrix/comparable.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/boost/libs/hana/example/cppcon_2014/matrix/comparable.hpp b/src/boost/libs/hana/example/cppcon_2014/matrix/comparable.hpp new file mode 100644 index 000000000..d84b0dac8 --- /dev/null +++ b/src/boost/libs/hana/example/cppcon_2014/matrix/comparable.hpp @@ -0,0 +1,33 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_COMPARABLE_HPP +#define BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_COMPARABLE_HPP + +#include "matrix.hpp" + +#include <boost/hana/all.hpp> +#include <boost/hana/bool.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/eval_if.hpp> +#include <boost/hana/zip_with.hpp> + + +namespace boost { namespace hana { + template <unsigned R1, unsigned C1, unsigned R2, unsigned C2> + struct equal_impl<cppcon::Matrix<R1, C1>, cppcon::Matrix<R2, C2>> { + template <typename M1, typename M2> + static constexpr auto apply(M1 const& m1, M2 const& m2) { + return eval_if(bool_c<R1 == R2 && C1 == C2>, + [&](auto _) { + return all(zip_with(_(equal), cppcon::rows(m1), + cppcon::rows(m2))); + }, + [] { return false_c; } + ); + } + }; +}} + +#endif // !BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_COMPARABLE_HPP |