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