Re: [eigen] Return type of eval() for non-plain-object should not be const qualified

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]



Hi,

IIRC, the rationale was to prevent calling non-const methods on temporary objects, like:

 (....).eval().normalize()

At that time, C++11 did not existed, but nowadays, we could reconsider this choice to favor move assignment.

Gael. 

On Sun, Jul 23, 2017 at 10:03 AM, Yuanchen Zhu <yuanchen.zhu@xxxxxxxxx> wrote:
Hi all, 

I want to check with the list if this is as intended (and I'm missing some big picture) or a bug:

Currently T::eval() either returns a const reference if T is a plain object, which is fine, or a const object if T is an _expression_. I think evaluating an _expression_ should return just an object, not a const qualified object. This enables move assignment optimization that takes the result from evaluation, and return it directly, without creating a temporary copy.

The relevant line is:

 typedef typename internal::add_const_on_value_type<typename internal::eval<Derived>::type>::type EvalReturnType;

in DenseBase.h




Thanks,
Yuanchen




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/