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)
5 #ifndef BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_MONOID_HPP
6 #define BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_MONOID_HPP
10 #include <boost/hana/integral_constant.hpp>
11 #include <boost/hana/concept/sequence.hpp>
12 #include <boost/hana/concept/monoid.hpp>
13 #include <boost/hana/range.hpp>
16 namespace boost { namespace hana {
17 template <unsigned R, unsigned C>
18 struct plus_impl<cppcon::Matrix<R, C>, cppcon::Matrix<R, C>> {
19 template <typename M1, typename M2>
20 static constexpr decltype(auto) apply(M1&& m1, M2&& m2) {
21 return element_wise(plus)(
28 template <unsigned R, unsigned C>
29 struct zero_impl<cppcon::Matrix<R, C>> {
30 static constexpr decltype(auto) apply() {
31 auto zeros = replicate(int_<0>, int_<C>);
32 return unpack(replicate(zeros, int_<R>), cppcon::matrix);
37 #endif // !BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_MONOID_HPP