Re: What is >?

Discussion in 'C++' started by Victor Bazarov, Mar 26, 2013.

  1. On 3/26/2013 10:37 AM, Blake McBride wrote:
    > I have an old editor written in C++ that I am trying to comple. It
    > gives me an error on an operator ">?". I searched everywhere in that
    > system and it is not defined anywhere. Couldn't find it in any C++ book
    > I had. Google can't search on symbols. I believe the left and right
    > arguments are int's. So it looks like this:
    > lbuf = lbuf >? x;
    > xda = 0 >? cda;
    > indent = indent >? 0;
    > This construct is used in several places. It don't think it is noise
    > becasue ">" is used elsewhere without "?".

    It was (is?) a gnu C (and probably C++) extension that acted (acts?)
    similarly to the ternary operator.

    a >? b --> (a > b ? a : b)

    a <? b --> (a < b ? a : b)


    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Mar 26, 2013
    1. Advertisements

  2. army1987

    army1987 Guest

    On Tue, 26 Mar 2013 09:48:46 -0500, Blake McBride wrote:

    > Thanks! Not being great at C++, can someone give me a definition of
    > that operator to do what is shown below?

    Please do not top-post.

    expr1 ? expr2 : expr3 returns expr2 if expr1 is true, and expr3
    otherwise. So

    >> a >? b --> (a > b ? a : b)

    returns a if a is greater than b, and b otherwise, i.e. the same as
    std::max(a,b); likewise

    >> a <? b --> (a < b ? a : b)

    returns the same as std::min(a,b).

    [ T H I S S P A C E I S F O R R E N T ]
    Troppo poca cultura ci rende ignoranti, troppa ci rende folli.
    -- fathermckenzie di it.cultura.linguistica.italiano
    army1987, Apr 2, 2013
    1. Advertisements

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.

Share This Page