diff options
author | Gael Guennebaud <g.gael@free.fr> | 2016-08-31 23:04:14 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2016-08-31 23:04:14 +0200 |
commit | 84cf6e42ca8e3790ddfd0b1dab21adc7686b4d34 (patch) | |
tree | 1517d07b379d11354bcd56360c4faecf0df323dd /Eigen/src | |
parent | 7ae819123c38b2397bbb0922f5d16e53e4fac42c (diff) |
minor tweaks in has_* helpers
Diffstat (limited to 'Eigen/src')
-rwxr-xr-x | Eigen/src/Core/util/Meta.h | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index e69c78db2..96563962e 100755 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -368,29 +368,26 @@ struct result_of<Func(ArgType0,ArgType1,ArgType2)> { }; #endif +struct meta_yes { char a[1]; }; +struct meta_no { char a[2]; }; + // Check whether T::ReturnType does exist template <typename T> struct has_ReturnType { - typedef char yes[1]; - typedef char no[2]; - - template <typename C> static yes& testFunctor(typename C::ReturnType const *); - template <typename C> static no& testFunctor(...); + template <typename C> static meta_yes testFunctor(typename C::ReturnType const *); + template <typename C> static meta_no testFunctor(...); - enum { value = sizeof(testFunctor<T>(0)) == sizeof(yes) }; + enum { value = sizeof(testFunctor<T>(0)) == sizeof(meta_yes) }; }; -template<int> struct any_int {}; +template<int Val> struct integral_constant { static const int value = Val; }; template<typename T> const T& return_ref(); -struct meta_yes { char data[1]; }; -struct meta_no { char data[2]; }; - template <typename T> struct has_nullary_operator { - template <typename C> static meta_yes testFunctor(C const *,any_int< sizeof(return_ref<C>()()) > * = 0); + template <typename C> static meta_yes testFunctor(C const *,integral_constant< sizeof(return_ref<C>()()) > * = 0); static meta_no testFunctor(...); enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) }; @@ -399,7 +396,7 @@ struct has_nullary_operator template <typename T> struct has_unary_operator { - template <typename C> static meta_yes testFunctor(C const *,any_int< sizeof(return_ref<C>()(Index(0))) > * = 0); + template <typename C> static meta_yes testFunctor(C const *,integral_constant< sizeof(return_ref<C>()(Index(0))) > * = 0); static meta_no testFunctor(...); enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) }; @@ -408,7 +405,7 @@ struct has_unary_operator template <typename T> struct has_binary_operator { - template <typename C> static meta_yes testFunctor(C const *,any_int< sizeof(return_ref<C>()(Index(0),Index(0))) > * = 0); + template <typename C> static meta_yes testFunctor(C const *,integral_constant< sizeof(return_ref<C>()(Index(0),Index(0))) > * = 0); static meta_no testFunctor(...); enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) }; |