diff options
author | Gael Guennebaud <g.gael@free.fr> | 2010-06-25 13:20:34 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2010-06-25 13:20:34 +0200 |
commit | 75b6d2b2f84384457c1031d88fa606116d7016df (patch) | |
tree | 24635b10d77a1ab1cb54c48258daa737881e5715 | |
parent | 01553c419ebab54baa15a0921879dee8cff2d234 (diff) |
fix very annoying warning (gcc 4.3): type qualifiers ignored on function return type
-rw-r--r-- | Eigen/src/Core/DenseCoeffsBase.h | 7 | ||||
-rw-r--r-- | Eigen/src/Core/arch/SSE/PacketMath.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/util/Meta.h | 20 |
3 files changed, 29 insertions, 2 deletions
diff --git a/Eigen/src/Core/DenseCoeffsBase.h b/Eigen/src/Core/DenseCoeffsBase.h index 7d57d5abc..6802cea24 100644 --- a/Eigen/src/Core/DenseCoeffsBase.h +++ b/Eigen/src/Core/DenseCoeffsBase.h @@ -33,8 +33,11 @@ class DenseCoeffsBase : public EigenBase<Derived> typedef typename ei_traits<Derived>::Index Index; typedef typename ei_traits<Derived>::Scalar Scalar; typedef typename ei_packet_traits<Scalar>::type PacketScalar; - typedef typename ei_meta_if<ei_has_direct_access<Derived>::ret, const Scalar&, const Scalar>::ret CoeffReturnType; - typedef typename ei_makeconst<typename ei_packet_traits<Scalar>::type>::type PacketReturnType; + typedef typename ei_meta_if<ei_has_direct_access<Derived>::ret, + const Scalar&, + typename ei_meta_if<ei_is_arithmetic<Scalar>::ret, Scalar, const Scalar>::ret + >::ret CoeffReturnType; + typedef typename ei_makeconst_return_type<typename ei_packet_traits<Scalar>::type>::type PacketReturnType; typedef EigenBase<Derived> Base; using Base::rows; diff --git a/Eigen/src/Core/arch/SSE/PacketMath.h b/Eigen/src/Core/arch/SSE/PacketMath.h index 754379891..29375bdae 100644 --- a/Eigen/src/Core/arch/SSE/PacketMath.h +++ b/Eigen/src/Core/arch/SSE/PacketMath.h @@ -33,6 +33,10 @@ typedef __m128 Packet4f; typedef __m128i Packet4i; typedef __m128d Packet2d; +template<> struct ei_is_arithmetic<__m128> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<__m128i> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<__m128d> { enum { ret = true }; }; + #define ei_vec4f_swizzle1(v,p,q,r,s) \ (_mm_castsi128_ps(_mm_shuffle_epi32( _mm_castps_si128(v), ((s)<<6|(r)<<4|(q)<<2|(p))))) diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 318664869..481b0ceb2 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -64,6 +64,21 @@ template<typename T> struct ei_cleantype<T&> { typedef typename ei_cleant template<typename T> struct ei_cleantype<const T*> { typedef typename ei_cleantype<T>::type type; }; template<typename T> struct ei_cleantype<T*> { typedef typename ei_cleantype<T>::type type; }; +template<typename T> struct ei_is_arithmetic { enum { ret = false }; }; +template<> struct ei_is_arithmetic<float> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<double> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<long double> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<bool> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<char> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<signed char> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<unsigned char> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<signed short> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<unsigned short>{ enum { ret = true }; }; +template<> struct ei_is_arithmetic<signed int> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<unsigned int> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<signed long> { enum { ret = true }; }; +template<> struct ei_is_arithmetic<unsigned long> { enum { ret = true }; }; + template<typename T> struct ei_makeconst { typedef const T type; }; template<typename T> struct ei_makeconst<const T> { typedef const T type; }; template<typename T> struct ei_makeconst<T&> { typedef const T& type; }; @@ -71,6 +86,11 @@ template<typename T> struct ei_makeconst<const T&> { typedef const T& type; }; template<typename T> struct ei_makeconst<T*> { typedef const T* type; }; template<typename T> struct ei_makeconst<const T*> { typedef const T* type; }; +template<typename T> struct ei_makeconst_return_type +{ + typedef typename ei_meta_if<ei_is_arithmetic<T>::ret, T, typename ei_makeconst<T>::type>::ret type; +}; + /** \internal Allows to enable/disable an overload * according to a compile time condition. */ |