This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std::max: if versus ?:


On 09/20/2012 01:55 PM, Marc Glisse wrote:
Hello,

I noticed that std::max is implemented as:

      //return  __a < __b ? __b : __a;
      if (__a < __b)
        return __b;
      return __a;

Notice how it doesn't use the ?: code but the "if" version instead. Looking at the history, this seems to come from SGI. Does someone know why it was done this way?
I'm going to tell you something very vague and non technical, but in the past, outside std::max, I had quite often to use the above instead of a conditional operator as a second thought, when (maybe on a less common target) a test "unexpectedly" failed with a conversion error. Does that help you figuring out the technical details of the issue?

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]