Re: [eigen] Strange operator behaviour

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




On Mon, Sep 22, 2014 at 1:33 PM, Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
On 19.09.2014 15:01, mwb@xxxxxxxxxxxx wrote:
Personally, I would prefer to make _expression_ ctors explicit, since the
current behavior is quite unintuitive and potentially dangerous, though
you probably get used to it.

I totally agree on making any constructor explicit when in:
  X x;  // some kind of _expression_ or scalar
  A a1(x);
  A a2; a2=x;
The last line is either not possible or leads to different behavior than the line before. In other words, only make it implicit if
  A a3=x;
has the same result as the a2 case.
I can't think of any case, where we would break intended behavior with changing that -- I guess it will rather make some show some unintended misuses visible.

I agree that usage will be a bit more painful, e.g.

  TransposeType transpose() const {
    return derived();
  }

and related, would need to be replaced by (the IMO easier to understand):

  TransposeType transpose() const {
    return TransposeType(derived());
  }

Actually, this would also motivate to consequently add typedefs for all return types.

alright, patch welcome then ;)

gael


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