diff --git a/dune/matrix-vector/vectortraits.hh b/dune/matrix-vector/vectortraits.hh new file mode 100644 index 0000000000000000000000000000000000000000..e505a7e59ea5228ada12e72625b2ce8018c15293 --- /dev/null +++ b/dune/matrix-vector/vectortraits.hh @@ -0,0 +1,33 @@ +#ifndef DUNE_MATRIX_VECTOR_VECTORTRAITS_HH +#define DUNE_MATRIX_VECTOR_VECTORTRAITS_HH + +#include <dune/common/fvector.hh> +#include <dune/istl/bvector.hh> +#include <dune/istl/multitypeblockvector.hh> + +namespace Dune { +namespace MatrixVector { + +/** \brief Class to identify vector types and extract information + * + * Specialize this class for all types that can be used like a vector. + */ +template <class T> +struct VectorTraits { + constexpr static bool isVector = false; +}; + +template <class K, int n> +struct VectorTraits<FieldVector<K, n>> { + constexpr static bool isVector = true; +}; + +template <class Block> +struct VectorTraits<BlockVector<Block>> { + constexpr static bool isVector = true; +}; + +} // end namespace MatrixVector +} // end namespace Dune + +#endif // DUNE_MATRIX_VECTOR_VECTORTRAITS_HH