
AMDG On 05/24/2011 04:39 PM, Giovanni Piero Deretta wrote:
On Mon, May 23, 2011 at 11:01 PM, Steven Watanabe <watanabesj@gmail.com> wrote:
struct callable1 { int operator()(int); };
struct callable2 : callable1 { double operator()(double); };
This can be solved by an "using callable1::operator();" . I just had to solve a very similar problem 20 minutes ago, but in my case all the elements in the inheritance chains only had operator() in need of un-hiding.
I guess the problem in your case is that in general your callable2 is not necessarily inheriting from something that is callable, that is, you are using operator() as the name but it could be anything.
Exactly.
A solution is adding every possible name (but with special arguments so that they won't actually partecipate in overload resolution) in the most base class and adding an "using <every possible name> at every level of the inheritance:
I've used this solution in the past. Now, I think it's better to detect the second and subsequent instances and add a using declaration. The advantage is that there are no extra overloads, so &any<...>::operator() is unambiguous if there's only a single overload.
Probably it will break in some cases I'm not foreseeing. Will definitely not work for user specified foo-able.
In Christ, Steven Watanabe