mirror of
https://github.com/boostorg/hana.git
synced 2026-02-01 20:42:13 +00:00
This essentially undo parts of307d3d0. While it seemed a like good idea to over-modularize type classes to reduce header dependencies, I think it was a mistake. What307d3d0did was basically split each of the components of a type class into a single header (typeclass/operators.hpp, typeclass/mcd_1.hpp, typeclass/mcd_2.hpp, ...). At first, it resolved many weird header dependency glitches. However, it also made everything more complex; creating even easy type classes was sometimes much longer than it should have been, and using type classes was tricky because you had to know exactly what to include. It also went against the idea of implicit type class instances being provided whenever that's possible, which I think is a nice feature of the library. Being dissatisfied with this, I opted for a simpler header organization with a fwd/ directory that contains forward declaration headers, and everything else in the same directory. A possible objection to this change would be that you are now forced to include sometimes more than what you strictly need when e.g. defining an instance or using only some instance(s) of a data type. My answer to this is that Hana is a really small library and the parsing is not going to have a huge impact on overall compilation time. My bet is that the time that will be saved by programmers with a simple header hierarchy outweights the parsing time by far.
32 lines
1006 B
C++
32 lines
1006 B
C++
/*
|
|
@copyright Louis Dionne 2014
|
|
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/bool.hpp>
|
|
#include <boost/hana/comparable.hpp>
|
|
#include <boost/hana/foldable.hpp>
|
|
#include <boost/hana/list.hpp>
|
|
|
|
|
|
namespace boost { namespace hana {
|
|
template <unsigned R1, unsigned C1, unsigned R2, unsigned C2>
|
|
struct Comparable::instance<cppcon::Matrix<R1, C1>, cppcon::Matrix<R2, C2>>
|
|
: Comparable::equal_mcd
|
|
{
|
|
template <typename M1, typename M2>
|
|
static constexpr auto equal_impl(M1 const& m1, M2 const& m2) {
|
|
return bool_<R1 == R2 && C1 == C2> &&
|
|
all_of(zip_with(equal, cppcon::rows(m1), cppcon::rows(m2)));
|
|
}
|
|
};
|
|
}}
|
|
|
|
#endif // !BOOST_HANA_EXAMPLE_CPPCON_2014_MATRIX_COMPARABLE_HPP
|