mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-29 15:24:51 +08:00
minor tweaks in has_* helpers
This commit is contained in:
parent
7ae819123c
commit
84cf6e42ca
@ -368,29 +368,26 @@ struct result_of<Func(ArgType0,ArgType1,ArgType2)> {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct meta_yes { char a[1]; };
|
||||||
|
struct meta_no { char a[2]; };
|
||||||
|
|
||||||
// Check whether T::ReturnType does exist
|
// Check whether T::ReturnType does exist
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct has_ReturnType
|
struct has_ReturnType
|
||||||
{
|
{
|
||||||
typedef char yes[1];
|
template <typename C> static meta_yes testFunctor(typename C::ReturnType const *);
|
||||||
typedef char no[2];
|
template <typename C> static meta_no testFunctor(...);
|
||||||
|
|
||||||
template <typename C> static yes& testFunctor(typename C::ReturnType const *);
|
enum { value = sizeof(testFunctor<T>(0)) == sizeof(meta_yes) };
|
||||||
template <typename C> static no& testFunctor(...);
|
|
||||||
|
|
||||||
enum { value = sizeof(testFunctor<T>(0)) == sizeof(yes) };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<int> struct any_int {};
|
template<int Val> struct integral_constant { static const int value = Val; };
|
||||||
template<typename T> const T& return_ref();
|
template<typename T> const T& return_ref();
|
||||||
|
|
||||||
struct meta_yes { char data[1]; };
|
|
||||||
struct meta_no { char data[2]; };
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct has_nullary_operator
|
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(...);
|
static meta_no testFunctor(...);
|
||||||
|
|
||||||
enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
|
enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
|
||||||
@ -399,7 +396,7 @@ struct has_nullary_operator
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
struct has_unary_operator
|
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(...);
|
static meta_no testFunctor(...);
|
||||||
|
|
||||||
enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
|
enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
|
||||||
@ -408,7 +405,7 @@ struct has_unary_operator
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
struct has_binary_operator
|
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(...);
|
static meta_no testFunctor(...);
|
||||||
|
|
||||||
enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
|
enum { value = sizeof(testFunctor(static_cast<T*>(0))) == sizeof(meta_yes) };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user