From 84cf6e42ca8e3790ddfd0b1dab21adc7686b4d34 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 31 Aug 2016 23:04:14 +0200 Subject: minor tweaks in has_* helpers --- Eigen/src/Core/util/Meta.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'Eigen/src/Core/util/Meta.h') 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 { }; #endif +struct meta_yes { char a[1]; }; +struct meta_no { char a[2]; }; + // Check whether T::ReturnType does exist template struct has_ReturnType { - typedef char yes[1]; - typedef char no[2]; - - template static yes& testFunctor(typename C::ReturnType const *); - template static no& testFunctor(...); + template static meta_yes testFunctor(typename C::ReturnType const *); + template static meta_no testFunctor(...); - enum { value = sizeof(testFunctor(0)) == sizeof(yes) }; + enum { value = sizeof(testFunctor(0)) == sizeof(meta_yes) }; }; -template struct any_int {}; +template struct integral_constant { static const int value = Val; }; template const T& return_ref(); -struct meta_yes { char data[1]; }; -struct meta_no { char data[2]; }; - template struct has_nullary_operator { - template static meta_yes testFunctor(C const *,any_int< sizeof(return_ref()()) > * = 0); + template static meta_yes testFunctor(C const *,integral_constant< sizeof(return_ref()()) > * = 0); static meta_no testFunctor(...); enum { value = sizeof(testFunctor(static_cast(0))) == sizeof(meta_yes) }; @@ -399,7 +396,7 @@ struct has_nullary_operator template struct has_unary_operator { - template static meta_yes testFunctor(C const *,any_int< sizeof(return_ref()(Index(0))) > * = 0); + template static meta_yes testFunctor(C const *,integral_constant< sizeof(return_ref()(Index(0))) > * = 0); static meta_no testFunctor(...); enum { value = sizeof(testFunctor(static_cast(0))) == sizeof(meta_yes) }; @@ -408,7 +405,7 @@ struct has_unary_operator template struct has_binary_operator { - template static meta_yes testFunctor(C const *,any_int< sizeof(return_ref()(Index(0),Index(0))) > * = 0); + template static meta_yes testFunctor(C const *,integral_constant< sizeof(return_ref()(Index(0),Index(0))) > * = 0); static meta_no testFunctor(...); enum { value = sizeof(testFunctor(static_cast(0))) == sizeof(meta_yes) }; -- cgit v1.2.3