Re: [eigen] a few updates...

[ Thread Index | Date Index | More Archives ]

On 22.12.2010 19:33, Benoit Jacob wrote:
> 2010/12/22 Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx>:
>> Another possibility would be:
>> c) Pass argument to swap() by value if it is a Map/Block-expression.
> I tried that, using a enable-if trick to select abstract expressions
> vs. plain objects.
> The problem is that that doesn't solve the problem at all. By passing
> the expression by value, we completely forget its constness, so we
> can't prevent doing
>   const Expression xpr;
>   foo.swap(xpr);

Well that's again all about bug54. Having, e.g., a `const ColXpr` does
not prevent modifying its data -- the constness must be encoded directly
in the type (as it is in `Map<const T>`). Otherwise you can do:

  const MatrixXd m;
  MatrixXd::RowXpr r(m.row(0));
  // modify r ...
Which is still a bug in the latest available tip. I think as long as
there are const_casts used somewhere in the code it is quite likely that
Bug 54 is not completely fixed ...

Back to the swap-problem I can suggest another possibility:
d) Mark most methods of Map<T> and Block<T> as const (everything that
does not alter the Map or Block itself). Then have three possible
parameters for swap:
Matrix<...> &
const Block<T> &
const Map<T> &

where the latter two could be combined as soon as
direct-access-unification is done.


Dipl.-Inf. Christoph Hertzberg
Cartesium 0.051
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: (+49) 421-218-64252

Mail converted by MHonArc 2.6.19+