aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/util/Meta.h
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-02-19 11:59:52 -0800
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-02-19 11:59:52 -0800
commit92ceb02c6dd4b2fc375d6c355e0450d705390ca0 (patch)
tree5913c328561b17db3f7c7bc8ea8d31b9a7e048ed /Eigen/src/Core/util/Meta.h
parent110fb90250292d16ac6aadbf7bc0332e89827b99 (diff)
parent829dddd0fdb1bfd4942ff35fe7dfd4ccdeddc97e (diff)
Pulle latest updates from trunk
Diffstat (limited to 'Eigen/src/Core/util/Meta.h')
-rw-r--r--Eigen/src/Core/util/Meta.h40
1 files changed, 34 insertions, 6 deletions
diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h
index f3bafd5af..674cd8f97 100644
--- a/Eigen/src/Core/util/Meta.h
+++ b/Eigen/src/Core/util/Meta.h
@@ -165,6 +165,7 @@ template<typename T> struct result_of {};
struct has_none {int a[1];};
struct has_std_result_type {int a[2];};
struct has_tr1_result {int a[3];};
+struct has_cxx_eleven_result {int a[4];};
template<typename Func, typename ArgType, int SizeOf=sizeof(has_none)>
struct unary_result_of_select {typedef ArgType type;};
@@ -175,13 +176,22 @@ struct unary_result_of_select<Func, ArgType, sizeof(has_std_result_type)> {typed
template<typename Func, typename ArgType>
struct unary_result_of_select<Func, ArgType, sizeof(has_tr1_result)> {typedef typename Func::template result<Func(ArgType)>::type type;};
+#ifdef EIGEN_HAS_STD_RESULT_OF
+template<typename Func, typename ArgType>
+struct unary_result_of_select<Func, ArgType, sizeof(has_cxx_eleven_result)> {typedef typename std::result_of<Func(ArgType)>::type type;};
+#endif
+
template<typename Func, typename ArgType>
struct result_of<Func(ArgType)> {
template<typename T>
- static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
+ static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
+ template<typename T>
+ static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType)>::type const * = 0);
+#ifdef EIGEN_HAS_STD_RESULT_OF
template<typename T>
- static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType)>::type const * = 0);
- static has_none testFunctor(...);
+ static has_cxx_eleven_result testFunctor(T const *, typename std::result_of<T(ArgType)>::type const * = 0);
+#endif
+ static has_none testFunctor(...);
// note that the following indirection is needed for gcc-3.3
enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};
@@ -199,13 +209,23 @@ template<typename Func, typename ArgType0, typename ArgType1>
struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_tr1_result)>
{typedef typename Func::template result<Func(ArgType0,ArgType1)>::type type;};
+#ifdef EIGEN_HAS_STD_RESULT_OF
+template<typename Func, typename ArgType0, typename ArgType1>
+struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_cxx_eleven_result)>
+{typedef typename std::result_of<Func(ArgType0, ArgType1)>::type type;};
+#endif
+
template<typename Func, typename ArgType0, typename ArgType1>
struct result_of<Func(ArgType0,ArgType1)> {
template<typename T>
- static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
+ static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
+ template<typename T>
+ static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1)>::type const * = 0);
+#ifdef EIGEN_HAS_STD_RESULT_OF
template<typename T>
- static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1)>::type const * = 0);
- static has_none testFunctor(...);
+ static has_cxx_eleven_result testFunctor(T const *, typename std::result_of<T(ArgType0, ArgType1)>::type const * = 0);
+#endif
+ static has_none testFunctor(...);
// note that the following indirection is needed for gcc-3.3
enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};
@@ -284,6 +304,14 @@ template<typename T> EIGEN_DEVICE_FUNC void swap(T &a, T &b) { T tmp = b; b =
template<typename T> EIGEN_STRONG_INLINE void swap(T &a, T &b) { std::swap(a,b); }
#endif
+// Integer division with rounding up.
+// T is assumed to be an integer type with a>=0, and b>0
+template<typename T>
+T div_ceil(const T &a, const T &b)
+{
+ return (a+b-1) / b;
+}
+
} // end namespace numext
} // end namespace Eigen