On Jan 16, 2007, at 4:59 PM, Ronald Garcia wrote:
Hello Markus,
On Jan 16, 2007, at 9:06 AM, Markus Werle wrote:
IMHO the behaviour of operator= for multi_array is a little bit broken. A lot of preconditions required:
Indeed operator= for multi_array requires the sizes of the multi_arrays to match, hence the assertions. The multi_array type is not meant to automatically resize when assigned to. All resizing is intentionally meant to be explicit. For your application, you will need to resize your array prior to assignment.
This is awkward since it means that any class with a multi_array member cannot use the default operator= but needs to implement a special operator=. We just ran into a subtle bug with this because of the semantics of the valarray operator=, and I would strongly argue for an operator = that makes the semantics of A x = y; equivalent to A x; x = y; Matthias