This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: Deprecating min/max extension in C++


On Wed, 9 Mar 2005 18:48:06 +0100, Giovanni Bajo <rasky@develer.com> wrote:

> ... which do not handle promotions. So you do not consider useful to have a
> min/max operator with promotion (so that it would work exactly like any
> other operator) just because there is a cheap version without promotion. And
> my statement that min() and max() are not exact replacements still stands.

If you wish for a min/max with promotion, why not implement
alternative versions of those two template functions? With typeof
going into the standard and already being a available in gcc, it
should be easy to deduce the return type.

> for (int i=0;i<100;i++)
> {
>    float cur = Compute(i) * factor;
>     if (max_computed < cur)
>        max_computed = cur;
> }

for (int i=0;i<100;i++)
  max_computed = std::max(Compute(i) * factor, max_computed);

Rakshasa

-- 
http://libtorrent.rakshasa.no/ - BitTorrent library and client for *nix.


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