]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/cppcon_2014/matrix/comparable.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / example / cppcon_2014 / matrix / comparable.hpp
1 // Copyright Louis Dionne 2013-2016
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
5 #ifndef BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_COMPARABLE_HPP
6 #define BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_COMPARABLE_HPP
7
8 #include "matrix.hpp"
9
10 #include <boost/hana/all.hpp>
11 #include <boost/hana/bool.hpp>
12 #include <boost/hana/equal.hpp>
13 #include <boost/hana/eval_if.hpp>
14 #include <boost/hana/zip_with.hpp>
15
16
17 namespace boost { namespace hana {
18 template <unsigned R1, unsigned C1, unsigned R2, unsigned C2>
19 struct equal_impl<cppcon::Matrix<R1, C1>, cppcon::Matrix<R2, C2>> {
20 template <typename M1, typename M2>
21 static constexpr auto apply(M1 const& m1, M2 const& m2) {
22 return eval_if(bool_c<R1 == R2 && C1 == C2>,
23 [&](auto _) {
24 return all(zip_with(_(equal), cppcon::rows(m1),
25 cppcon::rows(m2)));
26 },
27 [] { return false_c; }
28 );
29 }
30 };
31 }}
32
33 #endif // !BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_COMPARABLE_HPP