This commit is contained in:
Hans Dembinski
2018-11-03 16:34:45 +01:00
parent 14c99de197
commit db88dd33e4
2 changed files with 13 additions and 15 deletions

View File

@@ -25,13 +25,10 @@ namespace histogram {
namespace detail {
template <typename... Ts, typename... Us>
constexpr bool axes_equal(const std::tuple<Ts...>&, const std::tuple<Us...>&) {
return false;
}
template <typename... Ts>
constexpr bool axes_equal(const std::tuple<Ts...>& t, const std::tuple<Ts...>& u) {
return t == u;
bool axes_equal(const std::tuple<Ts...>& t, const std::tuple<Us...>& u) {
return static_if<std::is_same<mp11::mp_list<Ts...>, mp11::mp_list<Us...>>>(
[](const auto& a, const auto& b) { return a == b; },
[](const auto&, const auto&) { return false; }, t, u);
}
template <typename... Ts, typename U>
@@ -374,15 +371,17 @@ void fill_impl(mp11::mp_int<-1>, S& storage, const A& axes,
}
template <typename L>
using weight_index = mp11::mp_if<
is_weight<mp11::mp_first<L>>, mp11::mp_int<0>,
mp11::mp_if<is_weight<mp_last<L>>, mp11::mp_int<(mp11::mp_size<L>::value - 1)>,
mp11::mp_int<-1>>>;
constexpr int weight_index() {
const int n = mp11::mp_size<L>::value - 1;
if (is_weight<mp11::mp_first<L>>::value) return 0;
if (is_weight<mp11::mp_at_c<L, n>>::value) return n;
return -1;
}
// generic entry point which analyses args and calls specific
template <typename S, typename T, typename... Us>
void fill_impl(S& s, const T& axes, const std::tuple<Us...>& args) {
fill_impl(weight_index<mp11::mp_list<Us...>>(), s, axes, args);
template <typename S, typename T, typename U>
void fill_impl(S& s, const T& axes, const U& args) {
fill_impl(mp11::mp_int<weight_index<unqual<U>>()>(), s, axes, args);
}
/* In all at_impl, we throw instead of asserting when an index is out of

View File

@@ -18,7 +18,6 @@ namespace histogram {
template <typename CharT, typename Traits, typename A, typename S>
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os,
const histogram<A, S>& h) {
using OS = std::basic_ostream<CharT, Traits>;
os << "histogram(";
h.for_each_axis([&](const auto& a) { os << "\n " << a << ","; });
os << (h.rank() ? "\n)" : ")");