]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Use the information provided by the numeric_limits class if available.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 25 Jan 2002 12:16:56 +0000 (12:16 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 25 Jan 2002 12:16:56 +0000 (12:16 +0000)
git-svn-id: https://svn.dealii.org/trunk@5403 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/parameter_handler.h

index 445eaaa9f8f172da68a19940c65b484024cc67df..36d7db7218c60f2d2bab8df9441bf1139bd344c1 100644 (file)
 #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 <base/config.h>
 #include <map>
 #include <vector>
@@ -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<int>::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<int>::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<double>::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<double>::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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.