From bba5c02d17e55c5838c4135be096ed71f89bee33 Mon Sep 17 00:00:00 2001 From: Rene Milk <rene.milk@uni-muenster.de> Date: Tue, 21 Jul 2015 16:03:29 +0200 Subject: [PATCH] [common] is_vector<std::complex<T>> is now false closes #63 --- dune/stuff/common/float_cmp_internal.hh | 4 ++-- dune/stuff/common/string_internal.hh | 4 ++-- dune/stuff/common/vector.hh | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dune/stuff/common/float_cmp_internal.hh b/dune/stuff/common/float_cmp_internal.hh index c9f4e003b..e178a2dec 100644 --- a/dune/stuff/common/float_cmp_internal.hh +++ b/dune/stuff/common/float_cmp_internal.hh @@ -62,7 +62,7 @@ typename std::enable_if<is_complex<T>::value, bool>::type float_cmp_eq(const T& template <class XType, class YType, class TolType> -typename std::enable_if<!is_complex<XType>::value && is_vector<XType>::value && is_vector<YType>::value +typename std::enable_if<is_vector<XType>::value && is_vector<YType>::value && std::is_same<typename VectorAbstraction<XType>::S, TolType>::value && std::is_same<typename VectorAbstraction<YType>::S, TolType>::value, bool>::type @@ -93,7 +93,7 @@ typename std::enable_if<is_complex<T>::value, bool>::type dune_float_cmp_eq(cons } template <Dune::FloatCmp::CmpStyle style, class XType, class YType, class EpsType> -typename std::enable_if<!is_complex<XType>::value && is_vector<XType>::value && is_vector<YType>::value +typename std::enable_if<is_vector<XType>::value && is_vector<YType>::value && std::is_same<typename VectorAbstraction<XType>::S, EpsType>::value && std::is_same<typename VectorAbstraction<YType>::S, EpsType>::value, bool>::type diff --git a/dune/stuff/common/string_internal.hh b/dune/stuff/common/string_internal.hh index 8a216e80b..f2e847e14 100644 --- a/dune/stuff/common/string_internal.hh +++ b/dune/stuff/common/string_internal.hh @@ -139,7 +139,7 @@ DUNE_STUFF_COMMON_STRING_GENERATE_HELPER(long double, ld) #undef DUNE_STUFF_COMMON_STRING_GENERATE_HELPER -// variant for everything that is not a matrix or a vector +// variant for everything that is not a matrix or a vector or complex value template <class T> static inline typename std::enable_if<!is_vector<T>::value && !is_matrix<T>::value && !is_complex<T>::value, T>::type from_string(std::string ss, const size_t UNUSED_UNLESS_DEBUG(rows) = 0, const size_t UNUSED_UNLESS_DEBUG(cols) = 0) @@ -172,7 +172,7 @@ from_string(std::string ss, const size_t /*size*/ = 0, const size_t /*cols*/ = 0 } template <class VectorType> -static inline typename std::enable_if<is_vector<VectorType>::value && !is_complex<VectorType>::value, VectorType>::type +static inline typename std::enable_if<is_vector<VectorType>::value, VectorType>::type from_string(std::string ss, const size_t size, const size_t UNUSED_UNLESS_DEBUG(cols) = 0) { auto vector_str = ss; diff --git a/dune/stuff/common/vector.hh b/dune/stuff/common/vector.hh index 128b3efbf..5ffbf045e 100644 --- a/dune/stuff/common/vector.hh +++ b/dune/stuff/common/vector.hh @@ -158,7 +158,7 @@ struct VectorAbstraction<std::complex<T>> typedef ScalarType S; typedef RealType R; - static const bool is_vector = true; + static const bool is_vector = false; static const bool has_static_size = true; @@ -180,7 +180,7 @@ struct VectorAbstraction<std::complex<T>> }; template <class VectorType> -typename std::enable_if<is_vector<VectorType>::value && !is_complex<VectorType>::value, VectorType>::type +typename std::enable_if<is_vector<VectorType>::value, VectorType>::type create(const size_t sz, const typename VectorAbstraction<VectorType>::S& val = typename VectorAbstraction<VectorType>::S(0)) { @@ -188,8 +188,8 @@ create(const size_t sz, } template <class T, class SR> -typename std::enable_if<is_vector<T>::value && is_complex<T>::value, T>::type -create(const size_t /*sz*/, const SR& val = typename VectorAbstraction<T>::R(0)) +typename std::enable_if<is_complex<T>::value, T>::type create(const size_t /*sz*/, + const SR& val = typename VectorAbstraction<T>::R(0)) { return VectorAbstraction<T>::create(0, val); } -- GitLab