mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-29 15:24:51 +08:00
Make sure sizeof is truelly needed, thus improving SFINAE portability.
This commit is contained in:
parent
84cf6e42ca
commit
836fa25a82
@ -381,13 +381,13 @@ struct has_ReturnType
|
|||||||
enum { value = sizeof(testFunctor<T>(0)) == sizeof(meta_yes) };
|
enum { value = sizeof(testFunctor<T>(0)) == sizeof(meta_yes) };
|
||||||
};
|
};
|
||||||
|
|
||||||
template<int Val> struct integral_constant { static const int value = Val; };
|
template<int Size> struct meta_array { int a[Size]; };
|
||||||
template<typename T> const T& return_ref();
|
template<typename T> const T& return_ref();
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct has_nullary_operator
|
struct has_nullary_operator
|
||||||
{
|
{
|
||||||
template <typename C> static meta_yes testFunctor(C const *,integral_constant< sizeof(return_ref<C>()()) > * = 0);
|
template <typename C> static meta_yes testFunctor(C const *,meta_array< 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) };
|
||||||
@ -396,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 *,integral_constant< sizeof(return_ref<C>()(Index(0))) > * = 0);
|
template <typename C> static meta_yes testFunctor(C const *,meta_array< 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) };
|
||||||
@ -405,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 *,integral_constant< sizeof(return_ref<C>()(Index(0),Index(0))) > * = 0);
|
template <typename C> static meta_yes testFunctor(C const *,meta_array< 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