Member vs. non-member operator overload disambiguation

Discussion in 'C++' started by W Karas, Nov 29, 2012.

  1. W Karas

    W Karas Guest

    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?
    W Karas, Nov 29, 2012
    #1
    1. Advertising

  2. On 11/29/2012 5:33 PM, W Karas wrote:
    > 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
    --
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Nov 29, 2012
    #2
    1. Advertising

  3. W Karas

    W Karas Guest

    On Thursday, November 29, 2012 6:45:25 PM UTC-5, Victor Bazarov wrote:
    > On 11/29/2012 5:33 PM, W Karas wrote:
    >
    > > 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.


    Thanks, interesting.

    > > 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?


    Yes but it's proprietary. Someone gave it to me and said it was working, but I got compile errors.
    W Karas, Nov 30, 2012
    #3
  4. On 11/30/2012 1:19 PM, W Karas wrote:
    > On Thursday, November 29, 2012 6:45:25 PM UTC-5, Victor Bazarov wrote:
    >> On 11/29/2012 5:33 PM, W Karas wrote:
    >>
    >>> 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?

    >>
    >> 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.
    >


    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
    --
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Nov 30, 2012
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piotre Ugrumov
    Replies:
    3
    Views:
    362
    Nick Hounsome
    Jan 25, 2004
  2. Xenos
    Replies:
    2
    Views:
    683
    Dave Moore
    Apr 29, 2004
  3. John Collins

    Template disambiguation

    John Collins, Dec 28, 2004, in forum: C++
    Replies:
    1
    Views:
    457
    Victor Bazarov
    Dec 29, 2004
  4. =?windows-1250?Q?Petr_Jake=9A?=
    Replies:
    11
    Views:
    1,509
  5. Ying-Chieh Liao

    function overload (not operator overload)

    Ying-Chieh Liao, Oct 11, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    241
    Sherm Pendley
    Oct 11, 2004
Loading...

Share This Page