Hi Steven,
On 7. Nov 2018, at 21:38, Steven Watanabe via Boost
wrote: On 11/07/2018 01:18 PM, Hans Dembinski via Boost wrote:
I am trying to figure out how to solve an introspection problem since a few days, and I am not making progress. I could use some help, it is for boost.histogram. Maybe what I want is not possible...
I don't know what you need this for, but I would recommend reconsidering why you need this in the first place.
It is for generic support of arbitrary accumulators per bin. Normally, a histogram gets some values equal to the number of axes, finds a corresponding bin and increments a counter for that bin. More generally, one can replace the counter by an accumulator that can accept an arbitrary number of values (the standard histogram is then the special case where the accumulator accepts zero arguments). Extra arguments passed to the histogram are forwarded to the accumulator. For example, an accumulator could compute a mean for values which end up in the same bin. This is what people in high energy physics call a "profile".
// bin in 'x', compute a mean of 'y' for each bin in 'x'
auto h = make_histogram_with(std::vector
Here is my problem. I have some classes A, B, ... which have some overloaded methods, let's call them `foo`.
struct A { void foo(int, char); void foo(bool, int, char); };
struct B { void foo(double); void foo(bool, double); };
I need a way to detect how many arguments the shorter methods has. If the shorter method is foo(Ts...), the longer method is always (bool, Ts...). This is guaranteed. I do not know what Ts... is, it can be anything.
What if Ts... has a bool as the first item?
This case can never happen. bool was a placeholder for the special weight_type. It never makes sense to pass two weight_type's to an accumulator.
Can't I match the member function with a template of the form something(bool, Ts...) somehow?
Like this?
template
constexpr int arity_impl(R (C::*)(bool, T...)) { return sizeof...(T); } template<int N> struct int_ {};
struct Tester { void fun(double); void fun(bool, double); };
int main() { int_
x; }
Yes, great, thanks. Hans