00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef EIGEN_RETURNBYVALUE_H
00012 #define EIGEN_RETURNBYVALUE_H
00013
00014 namespace Eigen {
00015
00021 namespace internal {
00022
00023 template<typename Derived>
00024 struct traits<ReturnByValue<Derived> >
00025 : public traits<typename traits<Derived>::ReturnType>
00026 {
00027 enum {
00028
00029
00030
00031 Flags = (traits<typename traits<Derived>::ReturnType>::Flags
00032 | EvalBeforeNestingBit) & ~DirectAccessBit
00033 };
00034 };
00035
00036
00037
00038
00039
00040
00041
00042 template<typename Derived,int n,typename PlainObject>
00043 struct nested<ReturnByValue<Derived>, n, PlainObject>
00044 {
00045 typedef typename traits<Derived>::ReturnType type;
00046 };
00047
00048 }
00049
00050 template<typename Derived> class ReturnByValue
00051 : public internal::dense_xpr_base< ReturnByValue<Derived> >::type
00052 {
00053 public:
00054 typedef typename internal::traits<Derived>::ReturnType ReturnType;
00055
00056 typedef typename internal::dense_xpr_base<ReturnByValue>::type Base;
00057 EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue)
00058
00059 template<typename Dest>
00060 inline void evalTo(Dest& dst) const
00061 { static_cast<const Derived*>(this)->evalTo(dst); }
00062 inline Index rows() const { return static_cast<const Derived*>(this)->rows(); }
00063 inline Index cols() const { return static_cast<const Derived*>(this)->cols(); }
00064
00065 #ifndef EIGEN_PARSED_BY_DOXYGEN
00066 #define Unusable YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT
00067 class Unusable{
00068 Unusable(const Unusable&) {}
00069 Unusable& operator=(const Unusable&) {return *this;}
00070 };
00071 const Unusable& coeff(Index) const { return *reinterpret_cast<const Unusable*>(this); }
00072 const Unusable& coeff(Index,Index) const { return *reinterpret_cast<const Unusable*>(this); }
00073 Unusable& coeffRef(Index) { return *reinterpret_cast<Unusable*>(this); }
00074 Unusable& coeffRef(Index,Index) { return *reinterpret_cast<Unusable*>(this); }
00075 #endif
00076 };
00077
00078 template<typename Derived>
00079 template<typename OtherDerived>
00080 Derived& DenseBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)
00081 {
00082 other.evalTo(derived());
00083 return derived();
00084 }
00085
00086 }
00087
00088 #endif // EIGEN_RETURNBYVALUE_H