So I have a function that expects a function pointer as an input and whose prototype goes something like this:
int function(int (*op)(int, int));
I was wondering if I can pass an operator in for that function pointer. Specifically this built in operator:
int operator|(int, int);
I've tried this:
function(&(operator|));
and got this kind of error:
error: no matching function for call to 'function(<unresolved overloaded function type>)'
I've tried this:
function(&(operator|(int, int)));
and got this kind of error:
error: expected primary-expression before 'int'
I've looked for this situation in documentation, but I get things about the "address of" operator (operator&) instead of things about the address of an operator....
Edit:
See previous question Calling primitive operator-functions explicitly in C++
The built-in operator | that takes two int
and returns an int
can not be accessed through the notation operator|
. For instance, the following does not compile
int a = operator|(2,3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With