From 393a53a030a0e8fa4edafdde89cc7bec06f947be Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Tue, 7 Apr 2020 12:24:17 +0200
Subject: [PATCH] [io] Replace ifElse by if constexpr

---
 dune/istl/io.hh | 59 ++++++++++++++++++++++++-------------------------
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/dune/istl/io.hh b/dune/istl/io.hh
index a1d63018..eba142e0 100644
--- a/dune/istl/io.hh
+++ b/dune/istl/io.hh
@@ -50,28 +50,29 @@ namespace Dune {
   void recursive_printvector (std::ostream& s, const V& v, std::string rowtext,
                               int& counter, int columns, int width)
   {
-    Hybrid::ifElse(IsNumber<V>(),
-      [&](auto id) {
-        // Print one number
-        if (counter%columns==0)
-        {
-          s << rowtext; // start a new row
-          s << " ";     // space in front of each entry
-          s.width(4);   // set width for counter
-          s << counter; // number of first entry in a line
-        }
-        s << " ";         // space in front of each entry
-        s.width(width);   // set width for each entry anew
-        s << v;        // yeah, the number !
-        counter++;        // increment the counter
-        if (counter%columns==0)
-          s << std::endl; // start a new line
-      },
-      [&](auto id) {
-        // Recursively print a vector
-        for (const auto& entry : id(v))
-          recursive_printvector(s,id(entry),rowtext,counter,columns,width);
-      });
+    if constexpr (IsNumber<V>())
+    {
+      // Print one number
+      if (counter%columns==0)
+      {
+        s << rowtext; // start a new row
+        s << " ";     // space in front of each entry
+        s.width(4);   // set width for counter
+        s << counter; // number of first entry in a line
+      }
+      s << " ";         // space in front of each entry
+      s.width(width);   // set width for each entry anew
+      s << v;        // yeah, the number !
+      counter++;        // increment the counter
+      if (counter%columns==0)
+        s << std::endl; // start a new line
+    }
+    else
+    {
+      // Recursively print a vector
+      for (const auto& entry : v)
+        recursive_printvector(s,entry,rowtext,counter,columns,width);
+    }
   }
 
 
@@ -465,14 +466,12 @@ namespace Dune {
   template<class V>
   void writeVectorToMatlabHelper (const V& v, std::ostream& stream)
   {
-    Hybrid::ifElse(IsNumber<V>(),
-      [&](auto id) {
-        stream << id(v) << std::endl;
-      },
-      [&](auto id) {
-        for (const auto& entry : id(v))
-          writeVectorToMatlabHelper(entry, stream);
-      });
+    if constexpr (IsNumber<V>()) {
+      stream << v << std::endl;
+    } else {
+      for (const auto& entry : v)
+        writeVectorToMatlabHelper(entry, stream);
+    }
   }
 
   /**
-- 
GitLab