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]

std::max: if versus ?:


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?

The reason I am asking is that if I add ?: support for vector types (à la OpenCL), with "if" std::max will still fail on vectors, but with ?: it would suddenly become accepted.

(concept checking would still fail though, but that could be fixed or ignored)
(there would still be a bit of work to adapt the fold-const.c code to recognize this vec_cond_expr as a max_expr, as happens for regular cond_expr)


--
Marc Glisse


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