Member vs. non-member operator overload disambiguation

W

W Karas

Suppose an operator invocation matches a free-standing operator and a member operator of the class of the first argument equally well. Is this ambiguous? Or, does the Standard give member operators higher or lower precedence?

Related question: Does the Standard give higher or lower precedence to friend functions compared to non-friend functions?
 
V

Victor Bazarov

Suppose an operator invocation matches a free-standing operator and a
member operator of the class of the first argument equally well. Is
this ambiguous? Or, does the Standard give member operators higher
or lower precedence?

From what I could find, no preference is given. Ambiguous, most likely.
Related question: Does the Standard give higher or lower precedence
to friend functions compared to non-friend functions?

Same thing.

Why are you asking? Do you have a concrete code for which the behavior
of your compiler is suspect?

V
 
W

W Karas

From what I could find, no preference is given. Ambiguous, most likely.

Thanks, interesting.
Same thing.



Why are you asking? Do you have a concrete code for which the behavior

of your compiler is suspect?

Yes but it's proprietary. Someone gave it to me and said it was working, but I got compile errors.
 
V

Victor Bazarov

Yes but it's proprietary. Someone gave it to me and said it was
working, but I got compile errors.

Proprietary or not, you *could* rewrite the code and remove all
identifiable and copyright-protected features from it. If you are
interested in more details regarding the compiler behavior or whether
some particular code constructs are legal or not, we *need* to see the
code. Again, rewrite it, distill it, sterilize it. Leave only the
parts that give you the same error, then post it.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top