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
00029 namespace Eigen {
00030
00036 namespace internal {
00037
00038 template<typename Derived>
00039 struct traits<ReturnByValue<Derived> >
00040 : public traits<typename traits<Derived>::ReturnType>
00041 {
00042 enum {
00043
00044
00045
00046 Flags = (traits<typename traits<Derived>::ReturnType>::Flags
00047 | EvalBeforeNestingBit) & ~DirectAccessBit
00048 };
00049 };
00050
00051
00052
00053
00054
00055
00056
00057 template<typename Derived,int n,typename PlainObject>
00058 struct nested<ReturnByValue<Derived>, n, PlainObject>
00059 {
00060 typedef typename traits<Derived>::ReturnType type;
00061 };
00062
00063 }
00064
00065 template<typename Derived> class ReturnByValue
00066 : public internal::dense_xpr_base< ReturnByValue<Derived> >::type
00067 {
00068 public:
00069 typedef typename internal::traits<Derived>::ReturnType ReturnType;
00070
00071 typedef typename internal::dense_xpr_base<ReturnByValue>::type Base;
00072 EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue)
00073
00074 template<typename Dest>
00075 inline void evalTo(Dest& dst) const
00076 { static_cast<const Derived*>(this)->evalTo(dst); }
00077 inline Index rows() const { return static_cast<const Derived*>(this)->rows(); }
00078 inline Index cols() const { return static_cast<const Derived*>(this)->cols(); }
00079
00080 #ifndef EIGEN_PARSED_BY_DOXYGEN
00081 #define Unusable YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT
00082 class Unusable{
00083 Unusable(const Unusable&) {}
00084 Unusable& operator=(const Unusable&) {return *this;}
00085 };
00086 const Unusable& coeff(Index) const { return *reinterpret_cast<const Unusable*>(this); }
00087 const Unusable& coeff(Index,Index) const { return *reinterpret_cast<const Unusable*>(this); }
00088 Unusable& coeffRef(Index) { return *reinterpret_cast<Unusable*>(this); }
00089 Unusable& coeffRef(Index,Index) { return *reinterpret_cast<Unusable*>(this); }
00090 #endif
00091 };
00092
00093 template<typename Derived>
00094 template<typename OtherDerived>
00095 Derived& DenseBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)
00096 {
00097 other.evalTo(derived());
00098 return derived();
00099 }
00100
00101 }
00102
00103 #endif // EIGEN_RETURNBYVALUE_H