This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
std::max: if versus ?:
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 20 Sep 2012 13:55:49 +0200 (CEST)
- Subject: std::max: if versus ?:
- Reply-to: libstdc++ at gcc dot gnu dot org
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