aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-01-24 21:44:18 -0500
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-01-24 21:44:18 -0500
commit6ae7d842a31e1e1937f88a1acf513c7bf51aee9c (patch)
treef797072c50f2814b953f6dfa3145511ed402cd61
parent858539a6af404d4e46a1524c356c985d14b8d169 (diff)
generate a compilation error when using ReturnByValue::coeff() or coeffRef(),
instead of doing an infinite recursion
-rw-r--r--Eigen/src/Core/ReturnByValue.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/Eigen/src/Core/ReturnByValue.h b/Eigen/src/Core/ReturnByValue.h
index 0199d3740..920269365 100644
--- a/Eigen/src/Core/ReturnByValue.h
+++ b/Eigen/src/Core/ReturnByValue.h
@@ -70,6 +70,18 @@ template<typename Derived> class ReturnByValue
{ static_cast<const Derived* const>(this)->evalTo(dst); }
inline int rows() const { return static_cast<const Derived* const>(this)->rows(); }
inline int cols() const { return static_cast<const Derived* const>(this)->cols(); }
+
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+#define Unusable YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT
+ class Unusable{
+ Unusable(const Unusable&) {}
+ Unusable& operator=(const Unusable&) {return *this;}
+ };
+ const Unusable& coeff(int) const { return *reinterpret_cast<const Unusable*>(this); }
+ const Unusable& coeff(int,int) const { return *reinterpret_cast<const Unusable*>(this); }
+ Unusable& coeffRef(int) { return *reinterpret_cast<Unusable*>(this); }
+ Unusable& coeffRef(int,int) { return *reinterpret_cast<Unusable*>(this); }
+#endif
};
template<typename Derived>