Skip to content
Snippets Groups Projects
Commit 6ba07b81 authored by Max Kahnt's avatar Max Kahnt
Browse files

Replace trait enums by constexpr.

parent 25800577
Branches
No related tags found
No related merge requests found
...@@ -17,45 +17,45 @@ namespace Dune { ...@@ -17,45 +17,45 @@ namespace Dune {
template<class T> template<class T>
struct MatrixTraits struct MatrixTraits
{ {
enum { isMatrix=false }; constexpr static bool isMatrix = false;
enum { rows=-1}; constexpr static int rows = -1;
enum { cols=-1}; constexpr static int cols = -1;
}; };
template<class T, int n, int m> template<class T, int n, int m>
struct MatrixTraits<Dune::FieldMatrix<T,n,m> > struct MatrixTraits<Dune::FieldMatrix<T,n,m> >
{ {
enum { isMatrix=true }; constexpr static bool isMatrix = true;
enum { rows=n}; constexpr static int rows = n;
enum { cols=m}; constexpr static int cols = m;
}; };
template<class T, int n> template<class T, int n>
struct MatrixTraits<Dune::DiagonalMatrix<T,n> > struct MatrixTraits<Dune::DiagonalMatrix<T,n> >
{ {
enum { isMatrix=true }; constexpr static bool isMatrix = true;
enum { rows=n}; constexpr static int rows = n;
enum { cols=n}; constexpr static int cols = n;
}; };
template<class T, int n> template<class T, int n>
struct MatrixTraits<Dune::ScaledIdentityMatrix<T,n> > struct MatrixTraits<Dune::ScaledIdentityMatrix<T,n> >
{ {
enum { isMatrix=true }; constexpr static bool isMatrix = true;
enum { rows=n}; constexpr static int rows = n;
enum { cols=n}; constexpr static int cols = n;
}; };
template<class T> template<class T>
struct MatrixTraits<Dune::BCRSMatrix<T> > struct MatrixTraits<Dune::BCRSMatrix<T> >
{ {
enum { isMatrix=true }; constexpr static bool isMatrix = true;
}; };
template<class... T> template<class... T>
struct MatrixTraits<MultiTypeBlockMatrix<T...> > struct MatrixTraits<MultiTypeBlockMatrix<T...> >
{ {
enum { isMatrix=true }; constexpr static bool isMatrix = true;
}; };
} }
} }
......
...@@ -16,29 +16,27 @@ namespace MatrixVector { ...@@ -16,29 +16,27 @@ namespace MatrixVector {
*/ */
template <class T> template <class T>
struct ScalarTraits { struct ScalarTraits {
enum { constexpr static bool isScalar = Dune::IsNumber<T>::value;
isScalar = Dune::IsNumber<T>::value
};
}; };
template <class T> template <class T>
struct ScalarTraits<Dune::FieldVector<T, 1>> { struct ScalarTraits<Dune::FieldVector<T, 1>> {
enum { isScalar = true }; constexpr static bool isScalar = true;
}; };
template <class T> template <class T>
struct ScalarTraits<Dune::FieldMatrix<T, 1, 1>> { struct ScalarTraits<Dune::FieldMatrix<T, 1, 1>> {
enum { isScalar = true }; constexpr static bool isScalar = true;
}; };
template <class T> template <class T>
struct ScalarTraits<Dune::DiagonalMatrix<T, 1>> { struct ScalarTraits<Dune::DiagonalMatrix<T, 1>> {
enum { isScalar = true }; constexpr static bool isScalar = true;
}; };
template <class T> template <class T>
struct ScalarTraits<Dune::ScaledIdentityMatrix<T, 1>> { struct ScalarTraits<Dune::ScaledIdentityMatrix<T, 1>> {
enum { isScalar = true }; constexpr static bool isScalar = true;
}; };
} }
} }
......
...@@ -46,7 +46,8 @@ class SingleNonZeroColumnMatrix ...@@ -46,7 +46,8 @@ class SingleNonZeroColumnMatrix
}; };
public: public:
enum { rows = ROWS, cols = COLS}; constexpr static int rows = ROWS;
constexpr static int cols = COLS;
typedef RowProxy row_type; typedef RowProxy row_type;
typedef row_type const_row_reference; typedef row_type const_row_reference;
...@@ -117,12 +118,12 @@ namespace Arithmetic ...@@ -117,12 +118,12 @@ namespace Arithmetic
template<class K, int ROWS, int COLS> template<class K, int ROWS, int COLS>
struct MatrixTraits<SingleNonZeroColumnMatrix<K, ROWS, COLS> > struct MatrixTraits<SingleNonZeroColumnMatrix<K, ROWS, COLS> >
{ {
enum { isMatrix = true }; constexpr static bool isMatrix = true;
enum { isDense = false }; constexpr static bool isDense = false;
enum { sizeIsStatic = true }; //TODO only one of these should be used constexpr static bool sizeIsStatic = true; // TODO only one of these should be used
enum { hasStaticSize = true }; //TODO only one of these should be used constexpr static bool hasStaticSize = true; // TODO only one of these should be used
enum { rows = ROWS}; constexpr static int rows = ROWS;
enum { cols = COLS}; constexpr static int cols = COLS;
/* /*
typedef typename SingleNonZeroColumnMatrix<K, ROWS, COLS>::ConstColIterator ConstColIterator; typedef typename SingleNonZeroColumnMatrix<K, ROWS, COLS>::ConstColIterator ConstColIterator;
......
...@@ -54,7 +54,8 @@ protected: ...@@ -54,7 +54,8 @@ protected:
}; };
public: public:
enum { rows = ROWS, cols = COLS}; constexpr static int rows = ROWS;
constexpr static int cols = COLS;
typedef RowProxy row_type; typedef RowProxy row_type;
typedef row_type const_row_reference; typedef row_type const_row_reference;
...@@ -122,12 +123,12 @@ namespace Arithmetic ...@@ -122,12 +123,12 @@ namespace Arithmetic
template<class K, int ROWS, int COLS> template<class K, int ROWS, int COLS>
struct MatrixTraits<SingleNonZeroRowMatrix<K, ROWS, COLS> > struct MatrixTraits<SingleNonZeroRowMatrix<K, ROWS, COLS> >
{ {
enum { isMatrix = true }; constexpr static bool isMatrix = true;
enum { isDense = false }; constexpr static bool isDense = false;
enum { sizeIsStatic = true }; //TODO only one of these should be used constexpr static bool sizeIsStatic = true; // TODO only one of these should be used
enum { hasStaticSize = true }; //TODO only one of these should be used constexpr static bool hasStaticSize = true; // TODO only one of these should be used
enum { rows = ROWS}; constexpr static int rows = ROWS;
enum { cols = COLS}; constexpr static int cols = COLS;
}; };
} }
......
...@@ -31,7 +31,7 @@ struct CustomMultiTypeBlockMatrix : public Dune::MultiTypeBlockMatrix<Args...> { ...@@ -31,7 +31,7 @@ struct CustomMultiTypeBlockMatrix : public Dune::MultiTypeBlockMatrix<Args...> {
namespace Dune { namespace MatrixVector { namespace Dune { namespace MatrixVector {
template <class... Args> template <class... Args>
struct MatrixTraits<CustomMultiTypeBlockMatrix<Args...>> { struct MatrixTraits<CustomMultiTypeBlockMatrix<Args...>> {
enum { isMatrix = true }; constexpr static bool isMatrix = true;
}; };
}} }}
// inject vector identification trait for CustomMultiTypeBlockVector // inject vector identification trait for CustomMultiTypeBlockVector
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment