How can I get the address of an overloaded statement defined as a friend in a class cube?
I tried the following
struct S {
friend bool operator==(S, S) { return true; }
};
int main() {
bool (*f)(S, S) = &operator==;
}
But gcc gives an error
test.cc: In function ‘int main()’:
test.cc:6:30: error: ‘operator==’ not defined
bool (*f)(S, S) = &operator==;
^
which can be fixed by declaring an operator in the (global) namespace:
bool operator==(S, S);
Is there a way to accept the address without reusing the operator?
source
share