mirror of
https://github.com/boostorg/hana.git
synced 2026-01-24 05:52:14 +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.
25 lines
527 B
C++
25 lines
527 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)
|
|
*/
|
|
|
|
#include <boost/hana/bool.hpp>
|
|
#include <boost/hana/fwd/foldable.hpp>
|
|
|
|
#include "benchmark.hpp"
|
|
|
|
<%= setup %>
|
|
|
|
template <int i> struct x { };
|
|
|
|
|
|
int main() {
|
|
auto pred = [](auto&& x) { return boost::hana::true_; };
|
|
auto foldable = <%= foldable %>;
|
|
|
|
boost::hana::benchmark::measure([=] {
|
|
boost::hana::count(foldable, pred);
|
|
});
|
|
}
|