]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix warnings in Convert::to_pattern() 7797/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 11 Mar 2019 17:56:31 +0000 (18:56 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 11 Mar 2019 17:56:31 +0000 (18:56 +0100)
include/deal.II/base/patterns.h

index 3a8617fc91e00dd4ce9a28c3471f45f1061f3fa2..bbb5b50adf6c3a65502d6fca73263b2cb3d52ba0 100644 (file)
@@ -1493,22 +1493,38 @@ namespace Patterns
     struct Convert<T,
                    typename std::enable_if<std::is_arithmetic<T>::value>::type>
     {
-      static std::unique_ptr<Patterns::PatternBase>
-      to_pattern()
+      template <typename Dummy = T>
+      static
+        typename std::enable_if<std::is_same<Dummy, T>::value &&
+                                  std::is_same<T, bool>::value,
+                                std::unique_ptr<Patterns::PatternBase>>::type
+        to_pattern()
       {
-        if (std::is_same<T, bool>::value)
-          return std_cxx14::make_unique<Patterns::Bool>();
-        else if (std::is_integral<T>::value)
-          return std_cxx14::make_unique<Patterns::Integer>(
-            static_cast<int>(std::numeric_limits<T>::lowest()),
-            static_cast<int>(std::numeric_limits<T>::max()));
-        else if (std::is_floating_point<T>::value)
-          return std_cxx14::make_unique<Patterns::Double>(
-            std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
-
-        Assert(false, ExcNotImplemented());
-        // the following line should never be invoked
-        return nullptr;
+        return std_cxx14::make_unique<Patterns::Bool>();
+      }
+
+      template <typename Dummy = T>
+      static
+        typename std::enable_if<std::is_same<Dummy, T>::value &&
+                                  !std::is_same<T, bool>::value &&
+                                  std::is_integral<T>::value,
+                                std::unique_ptr<Patterns::PatternBase>>::type
+        to_pattern()
+      {
+        return std_cxx14::make_unique<Patterns::Integer>(
+          std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
+      }
+
+      template <typename Dummy = T>
+      static
+        typename std::enable_if<std::is_same<Dummy, T>::value &&
+                                  !std::is_same<T, bool>::value &&
+                                  std::is_floating_point<T>::value,
+                                std::unique_ptr<Patterns::PatternBase>>::type
+        to_pattern()
+      {
+        return std_cxx14::make_unique<Patterns::Double>(
+          std::numeric_limits<T>::lowest(), std::numeric_limits<T>::max());
       }
 
       static std::string

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.