mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
generate a compilation error when using ReturnByValue::coeff() or coeffRef(),
instead of doing an infinite recursion
This commit is contained in:
parent
858539a6af
commit
6ae7d842a3
@ -70,6 +70,18 @@ template<typename Derived> class ReturnByValue
|
|||||||
{ static_cast<const Derived* const>(this)->evalTo(dst); }
|
{ static_cast<const Derived* const>(this)->evalTo(dst); }
|
||||||
inline int rows() const { return static_cast<const Derived* const>(this)->rows(); }
|
inline int rows() const { return static_cast<const Derived* const>(this)->rows(); }
|
||||||
inline int cols() const { return static_cast<const Derived* const>(this)->cols(); }
|
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>
|
template<typename Derived>
|
||||||
|
Loading…
Reference in New Issue
Block a user