From 3e421cc805f9e0776471f29087ed707b620a0a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20Gr=C3=A4ser?= <graeser@dune-project.org> Date: Thu, 10 Mar 2016 22:06:45 +0100 Subject: [PATCH] Add DefaultBitVector_t The type alias DefaultBitVector_t<T> provides a default choice for a bit vector that fits the structure of the vector type T. --- dune/solvers/common/CMakeLists.txt | 1 + dune/solvers/common/defaultbitvector.hh | 63 +++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 dune/solvers/common/defaultbitvector.hh diff --git a/dune/solvers/common/CMakeLists.txt b/dune/solvers/common/CMakeLists.txt index 07d57c75..37f71f6d 100644 --- a/dune/solvers/common/CMakeLists.txt +++ b/dune/solvers/common/CMakeLists.txt @@ -3,6 +3,7 @@ install(FILES arithmetic.hh boxconstraint.hh canignore.hh + defaultbitvector.hh genericvectortools.hh interval.hh numproc.hh diff --git a/dune/solvers/common/defaultbitvector.hh b/dune/solvers/common/defaultbitvector.hh new file mode 100644 index 00000000..32edd807 --- /dev/null +++ b/dune/solvers/common/defaultbitvector.hh @@ -0,0 +1,63 @@ +// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=8 sw=2 sts=2: +#ifndef DUNE_SOLVERS_COMMON_DEFAULTBITVECTOR_HH +#define DUNE_SOLVERS_COMMON_DEFAULTBITVECTOR_HH + +#include <dune/common/fvector.hh> + +#include <dune/istl/bvector.hh> + +namespace Dune { +namespace Solvers { + + +namespace Imp { + +template<class Vector> +struct DefaultBitVector +{ + using type = void; +}; + +template<class T, class A> +struct DefaultBitVector<BlockVector<T,A>> +{ + using type = typename std::vector<typename DefaultBitVector<T>::type>; +}; + +template<class T, class A> +struct DefaultBitVector<std::vector<T,A>> +{ + using type = typename std::vector<typename DefaultBitVector<T>::type>; +}; + +template<class T, int i, class A> +struct DefaultBitVector<BlockVector<FieldVector<T,i>, A>> +{ + using type = BitSetVector<i>; +}; + +} // end namespace Imp + + + +/** + * \brief Type alias for a bit vector that fits to T + * + * \tparam T A nested container type + * + * This alias provides a default choice of a bit vector + * that has the same nested structure as T. + */ +template<class T> +using DefaultBitVector_t = typename Imp::DefaultBitVector<T>::type; + + + +} // end namespace Solvers +} // end namespace Solvers + + + +#endif // DUNE_SOLVERS_COMMON_BITVECTOR_HH + -- GitLab