Mercurial > hg > octave-avbm
changeset 14810:d40349493d87
provide template version of octave_NA
* lo-ieee.h (octave_numeric_limits): New template for NA value.
Provide specializations for double and float.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Jun 2012 16:53:48 -0400 |
parents | 2e2a336c6b48 |
children | 52cb71787cd1 |
files | liboctave/lo-ieee.h |
diffstat | 1 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/lo-ieee.h +++ b/liboctave/lo-ieee.h @@ -118,4 +118,26 @@ #define lo_ieee_signbit(x) (sizeof (x) == sizeof (float) ? \ __lo_ieee_float_signbit (x) : __lo_ieee_signbit (x)) +#ifdef __cplusplus + +template <typename T> +struct octave_numeric_limits +{ + static T NA (void) { return static_cast<T> (0); } +}; + +template <> +struct octave_numeric_limits<double> +{ + static double NA (void) { return octave_NA; } +}; + +template <> +struct octave_numeric_limits<float> +{ + static float NA (void) { return octave_Float_NA; } +}; + #endif + +#endif