Mercurial > hg > octave-lyh
diff src/pr-output.cc @ 6120:ba9db42a1fe0
[project @ 2006-10-28 02:45:48 by jwe]
author | jwe |
---|---|
date | Sat, 28 Oct 2006 02:45:48 +0000 |
parents | c68896f193e3 |
children | 14992092ab06 |
line wrap: on
line diff
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -2205,19 +2205,41 @@ } } +// FIXME -- all this mess with abs is an attempt to avoid seeing +// +// warning: comparison of unsigned expression < 0 is always false +// +// from GCC. Isn't there a better way + template <class T> /* static */ inline T abs (T x) { - return x; + return x < 0 ? -x : x; } -#define INSTANTIATE_ABS(T) template /* static */ inline T abs (T x) - -INSTANTIATE_ABS (unsigned int); -INSTANTIATE_ABS (unsigned short); -INSTANTIATE_ABS (unsigned long); -INSTANTIATE_ABS (unsigned long long); +#define INSTANTIATE_ABS(T) \ + template /* static */ inline T abs (T) + +INSTANTIATE_ABS(signed char); +INSTANTIATE_ABS(short); +INSTANTIATE_ABS(int); +INSTANTIATE_ABS(long); +INSTANTIATE_ABS(long long); + +#define SPECIALIZE_UABS(T) \ + template <> \ + /* static */ inline unsigned T \ + abs (unsigned T x) \ + { \ + return x; \ + } + +SPECIALIZE_UABS(char) +SPECIALIZE_UABS(short) +SPECIALIZE_UABS(int) +SPECIALIZE_UABS(long) +SPECIALIZE_UABS(long long) template <class T> void