Boost logo

Boost :

Subject: [boost] Suggestions for TMP/function introspection problem?
From: Hans Dembinski (hans.dembinski_at_[hidden])
Date: 2018-11-07 20:18:26


Hi all,

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...

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.

I cannot use boost::callable_traits, because an overloaded member function
cannot be fetched by name

using t = boost::callable_traits::args_t<decltype(&A::foo)>; // fails,
overload is ambiguous

Can't I match the member function with a template of the form
something(bool, Ts...) somehow?

Any ideas?

Best regards,
Hans


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk