diff options
-rw-r--r-- | Eigen/src/Core/util/Meta.h | 12 | ||||
-rw-r--r-- | test/meta.cpp | 24 |
2 files changed, 24 insertions, 12 deletions
diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 28d7189b5..0cf0ccc04 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -59,16 +59,11 @@ template <class T> struct remove_const<const T> { typedef T type; }; template <class T> struct remove_const<const T[]> { typedef T type[]; }; template <class T, unsigned int Size> struct remove_const<const T[Size]> { typedef T type[Size]; }; -template<typename T> struct remove_const_on_value_type { typedef T type; }; -template<typename T> struct remove_const_on_value_type<const T> { typedef T type; }; -template<typename T> struct remove_const_on_value_type<T const &> { typedef T & type; }; -template<typename T> struct remove_const_on_value_type<T const *> { typedef T * type; }; - template<typename T> struct remove_all { typedef T type; }; template<typename T> struct remove_all<const T> { typedef typename remove_all<T>::type type; }; -template<typename T> struct remove_all<const T&> { typedef typename remove_all<T>::type type; }; +template<typename T> struct remove_all<T const&> { typedef typename remove_all<T>::type type; }; template<typename T> struct remove_all<T&> { typedef typename remove_all<T>::type type; }; -template<typename T> struct remove_all<const T*> { typedef typename remove_all<T>::type type; }; +template<typename T> struct remove_all<T const*> { typedef typename remove_all<T>::type type; }; template<typename T> struct remove_all<T*> { typedef typename remove_all<T>::type type; }; template<typename T> struct is_arithmetic { enum { value = false }; }; @@ -94,7 +89,8 @@ template <class T> struct add_const<T&> { typedef T& type; }; template<typename T> struct add_const_on_value_type { typedef const T type; }; template<typename T> struct add_const_on_value_type<T&> { typedef T const& type; }; template<typename T> struct add_const_on_value_type<T*> { typedef T const* type; }; -template<typename T> struct add_const_on_value_type<T* const> { typedef const T* const type; }; +template<typename T> struct add_const_on_value_type<T* const> { typedef T const* const type; }; +template<typename T> struct add_const_on_value_type<T const* const> { typedef T const* const type; }; template<typename T> struct makeconst_return_type { diff --git a/test/meta.cpp b/test/meta.cpp index 2c3c2985a..e8c95920b 100644 --- a/test/meta.cpp +++ b/test/meta.cpp @@ -43,11 +43,27 @@ void test_meta() VERIFY(( internal::is_same<float,internal::remove_all<float* const *&>::type >::value)); VERIFY(( internal::is_same<float,internal::remove_all<float* const>::type >::value)); - VERIFY(( internal::is_same<float*,internal::remove_const_on_value_type<const float*>::type >::value)); - VERIFY(( internal::is_same<float&,internal::remove_const_on_value_type<const float&>::type >::value)); - VERIFY(( internal::is_same<float&,internal::remove_const_on_value_type<ConstFloatRef>::type >::value)); + // test add_const + VERIFY(( internal::is_same< internal::add_const<float>::type, const float >::value)); + VERIFY(( internal::is_same< internal::add_const<float*>::type, float* const>::value)); + VERIFY(( internal::is_same< internal::add_const<float const*>::type, float const* const>::value)); + VERIFY(( internal::is_same< internal::add_const<float&>::type, float& >::value)); + + // test remove_const + VERIFY(( internal::is_same< internal::remove_const<float const* const>::type, float const* >::value)); + VERIFY(( internal::is_same< internal::remove_const<float const*>::type, float const* >::value)); + VERIFY(( internal::is_same< internal::remove_const<float* const>::type, float* >::value)); + + // test add_const_on_value_type + VERIFY(( internal::is_same< internal::add_const_on_value_type<float&>::type, float const& >::value)); + VERIFY(( internal::is_same< internal::add_const_on_value_type<float*>::type, float const* >::value)); + + VERIFY(( internal::is_same< internal::add_const_on_value_type<float>::type, const float >::value)); + VERIFY(( internal::is_same< internal::add_const_on_value_type<const float>::type, const float >::value)); + + VERIFY(( internal::is_same< internal::add_const_on_value_type<const float* const>::type, const float* const>::value)); + VERIFY(( internal::is_same< internal::add_const_on_value_type<float* const>::type, const float* const>::value)); - VERIFY(( internal::is_same<float&,internal::remove_const_on_value_type<float&>::type >::value)); VERIFY(( internal::is_same<float,internal::remove_reference<float&>::type >::value)); VERIFY(( internal::is_same<const float,internal::remove_reference<const float&>::type >::value)); VERIFY(( internal::is_same<float,internal::remove_pointer<float*>::type >::value)); |