From eaf430af9ace6911db1114248196e8da6e22d520 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 25 Jan 2002 12:16:56 +0000 Subject: [PATCH] Use the information provided by the numeric_limits class if available. git-svn-id: https://svn.dealii.org/trunk@5403 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/parameter_handler.h | 74 ++++++++++++++++--- 1 file changed, 64 insertions(+), 10 deletions(-) diff --git a/deal.II/base/include/base/parameter_handler.h b/deal.II/base/include/base/parameter_handler.h index 445eaaa9f8..36d7db7218 100644 --- a/deal.II/base/include/base/parameter_handler.h +++ b/deal.II/base/include/base/parameter_handler.h @@ -14,12 +14,6 @@ #define __deal2__parameter_handler_h -//TODO:[WB] (compiler) Use numeric_limits to designate the default values of bounds parameters -// of Patterns::Integer and Patterns::Double. This would then allow to use half-open -// intervals as well, among other advantages. - - - #include #include #include @@ -166,6 +160,36 @@ namespace Patterns class Integer : public PatternBase { public: + /** + * Minimal integer value. If + * the @p{numeric_limits} class + * is available, otherwise set + * it so that this class + * understands that all values + * are allowed. + */ + static const unsigned int min_int_value = +#ifdef HAVE_STD_NUMERIC_LIMITS + std::numeric_limits::min(); +#else + 1; +#endif + + /** + * Maximal integer value. If + * the @p{numeric_limits} class + * is available, otherwise set + * it so that this class + * understands that all values + * are allowed. + */ + static const unsigned int max_int_value = +#ifdef HAVE_STD_NUMERIC_LIMITS + std::numeric_limits::max(); +#else + 0; +#endif + /** * Constructor. Bounds can be * specified within which a @@ -178,8 +202,8 @@ namespace Patterns * such that no bounds are * enforced on parameters. */ - Integer (const int lower_bound = 1, - const int upper_bound = 0); + Integer (const int lower_bound = min_int_value, + const int upper_bound = max_int_value); /** * Return @p{true} if the @@ -276,6 +300,36 @@ namespace Patterns class Double : public PatternBase { public: + /** + * Minimal double value. If + * the @p{numeric_limits} class + * is available, otherwise set + * it so that this class + * understands that all values + * are allowed. + */ + static const unsigned int min_double_value = +#ifdef HAVE_STD_NUMERIC_LIMITS + std::numeric_limits::min(); +#else + 1; +#endif + + /** + * Maximal double value. If + * the @p{numeric_limits} class + * is available, otherwise set + * it so that this class + * understands that all values + * are allowed. + */ + static const unsigned int max_double_value = +#ifdef HAVE_STD_NUMERIC_LIMITS + std::numeric_limits::max(); +#else + 0; +#endif + /** * Constructor. Bounds can be * specified within which a @@ -288,8 +342,8 @@ namespace Patterns * such that no bounds are * enforced on parameters. */ - Double (const int lower_bound = 1, - const int upper_bound = 0); + Double (const int lower_bound = min_double_value, + const int upper_bound = max_double_value); /** * Return @p{true} if the -- 2.39.5