Why is there a difference between the operator call and the corresponding member function call with Clang 17.0.1? Shouldn't they behave the same way?
#include <iostream>
struct A {
void operator()(int) { std::cout << "A...\n"; }
};
struct B {
void operator()(double) { std::cout << "B...\n"; }
};
template<typename... Ts> struct C : Ts... {};
int main() {
C<A, B> c;
c(1);
c.operator()(1);
}
The call
c(1);
works, but the call
c.operator()(1);
produces the error message
error: member 'operator()' found in multiple base classes of different types
The error message is clear. I was surprised that c(1)
doesn't produce this error.
The call
c(1);
works,
This seems to be a fixed clang 17.0.1 bug. Both calls are equivalent and produces the same error in the latest version of the clang etc.