From 6ba07b8148f4af3d005319df3904d9f395e00c00 Mon Sep 17 00:00:00 2001
From: Max Kahnt <max.kahnt@fu-berlin.de>
Date: Sat, 30 Sep 2017 15:33:52 +0200
Subject: [PATCH] Replace trait enums by constexpr.

---
 dune/matrix-vector/matrixtraits.hh            | 28 +++++++++----------
 dune/matrix-vector/scalartraits.hh            | 12 ++++----
 .../singlenonzerocolumnmatrix.hh              | 15 +++++-----
 dune/matrix-vector/singlenonzerorowmatrix.hh  | 15 +++++-----
 dune/matrix-vector/test/resizetest.cc         |  2 +-
 5 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/dune/matrix-vector/matrixtraits.hh b/dune/matrix-vector/matrixtraits.hh
index 5b673ed..73c3c0d 100644
--- a/dune/matrix-vector/matrixtraits.hh
+++ b/dune/matrix-vector/matrixtraits.hh
@@ -17,45 +17,45 @@ namespace Dune {
     template<class T>
     struct MatrixTraits
     {
-        enum { isMatrix=false };
-        enum { rows=-1};
-        enum { cols=-1};
+      constexpr static bool isMatrix = false;
+      constexpr static int rows = -1;
+      constexpr static int cols = -1;
     };
 
     template<class T, int n, int m>
     struct MatrixTraits<Dune::FieldMatrix<T,n,m> >
     {
-        enum { isMatrix=true };
-        enum { rows=n};
-        enum { cols=m};
+      constexpr static bool isMatrix = true;
+      constexpr static int rows = n;
+      constexpr static int cols = m;
     };
 
     template<class T, int n>
     struct MatrixTraits<Dune::DiagonalMatrix<T,n> >
     {
-        enum { isMatrix=true };
-        enum { rows=n};
-        enum { cols=n};
+      constexpr static bool isMatrix = true;
+      constexpr static int rows = n;
+      constexpr static int cols = n;
     };
 
     template<class T, int n>
     struct MatrixTraits<Dune::ScaledIdentityMatrix<T,n> >
     {
-        enum { isMatrix=true };
-        enum { rows=n};
-        enum { cols=n};
+      constexpr static bool isMatrix = true;
+      constexpr static int rows = n;
+      constexpr static int cols = n;
     };
 
     template<class T>
     struct MatrixTraits<Dune::BCRSMatrix<T> >
     {
-        enum { isMatrix=true };
+      constexpr static bool isMatrix = true;
     };
 
     template<class... T>
     struct MatrixTraits<MultiTypeBlockMatrix<T...> >
     {
-        enum { isMatrix=true };
+      constexpr static bool isMatrix = true;
     };
   }
 }
diff --git a/dune/matrix-vector/scalartraits.hh b/dune/matrix-vector/scalartraits.hh
index 0894730..66b47c3 100644
--- a/dune/matrix-vector/scalartraits.hh
+++ b/dune/matrix-vector/scalartraits.hh
@@ -16,29 +16,27 @@ namespace MatrixVector {
    */
   template <class T>
   struct ScalarTraits {
-    enum {
-      isScalar = Dune::IsNumber<T>::value
-    };
+    constexpr static bool isScalar = Dune::IsNumber<T>::value;
   };
 
   template <class T>
   struct ScalarTraits<Dune::FieldVector<T, 1>> {
-    enum { isScalar = true };
+    constexpr static bool isScalar = true;
   };
 
   template <class T>
   struct ScalarTraits<Dune::FieldMatrix<T, 1, 1>> {
-    enum { isScalar = true };
+    constexpr static bool isScalar = true;
   };
 
   template <class T>
   struct ScalarTraits<Dune::DiagonalMatrix<T, 1>> {
-    enum { isScalar = true };
+    constexpr static bool isScalar = true;
   };
 
   template <class T>
   struct ScalarTraits<Dune::ScaledIdentityMatrix<T, 1>> {
-    enum { isScalar = true };
+    constexpr static bool isScalar = true;
   };
 }
 }
diff --git a/dune/matrix-vector/singlenonzerocolumnmatrix.hh b/dune/matrix-vector/singlenonzerocolumnmatrix.hh
index 4225019..6b515d4 100644
--- a/dune/matrix-vector/singlenonzerocolumnmatrix.hh
+++ b/dune/matrix-vector/singlenonzerocolumnmatrix.hh
@@ -46,7 +46,8 @@ class SingleNonZeroColumnMatrix
     };
 
 public:
-    enum { rows = ROWS, cols = COLS};
+    constexpr static int rows = ROWS;
+    constexpr static int cols = COLS;
 
     typedef RowProxy row_type;
     typedef row_type const_row_reference;
@@ -117,12 +118,12 @@ namespace Arithmetic
     template<class K, int ROWS, int COLS>
     struct MatrixTraits<SingleNonZeroColumnMatrix<K, ROWS, COLS> >
     {
-        enum { isMatrix = true };
-        enum { isDense = false };
-        enum { sizeIsStatic = true };  //TODO only one of these should be used
-        enum { hasStaticSize = true }; //TODO only one of these should be used
-        enum { rows = ROWS};
-        enum { cols = COLS};
+        constexpr static bool isMatrix = true;
+        constexpr static bool isDense = false;
+        constexpr static bool sizeIsStatic = true;  // TODO only one of these should be used
+        constexpr static bool hasStaticSize = true; // TODO only one of these should be used
+        constexpr static int rows = ROWS;
+        constexpr static int cols = COLS;
         /*
         typedef typename SingleNonZeroColumnMatrix<K, ROWS, COLS>::ConstColIterator ConstColIterator;
 
diff --git a/dune/matrix-vector/singlenonzerorowmatrix.hh b/dune/matrix-vector/singlenonzerorowmatrix.hh
index 5de2968..f88b769 100644
--- a/dune/matrix-vector/singlenonzerorowmatrix.hh
+++ b/dune/matrix-vector/singlenonzerorowmatrix.hh
@@ -54,7 +54,8 @@ protected:
     };
 
 public:
-    enum { rows = ROWS, cols = COLS};
+    constexpr static int rows = ROWS;
+    constexpr static int cols = COLS;
 
     typedef RowProxy row_type;
     typedef row_type const_row_reference;
@@ -122,12 +123,12 @@ namespace Arithmetic
     template<class K, int ROWS, int COLS>
     struct MatrixTraits<SingleNonZeroRowMatrix<K, ROWS, COLS> >
     {
-        enum { isMatrix = true };
-        enum { isDense = false };
-        enum { sizeIsStatic = true };  //TODO only one of these should be used
-        enum { hasStaticSize = true }; //TODO only one of these should be used
-        enum { rows = ROWS};
-        enum { cols = COLS};
+        constexpr static bool isMatrix = true;
+        constexpr static bool isDense = false;
+        constexpr static bool sizeIsStatic = true;  // TODO only one of these should be used
+        constexpr static bool hasStaticSize = true; // TODO only one of these should be used
+        constexpr static int rows = ROWS;
+        constexpr static int cols = COLS;
     };
 }
 
diff --git a/dune/matrix-vector/test/resizetest.cc b/dune/matrix-vector/test/resizetest.cc
index e3e80f9..59bfc29 100644
--- a/dune/matrix-vector/test/resizetest.cc
+++ b/dune/matrix-vector/test/resizetest.cc
@@ -31,7 +31,7 @@ struct CustomMultiTypeBlockMatrix : public Dune::MultiTypeBlockMatrix<Args...> {
 namespace Dune { namespace MatrixVector {
   template <class... Args>
   struct MatrixTraits<CustomMultiTypeBlockMatrix<Args...>> {
-    enum { isMatrix = true };
+    constexpr static bool isMatrix = true;
   };
 }}
 // inject vector identification trait for CustomMultiTypeBlockVector
-- 
GitLab