On 24 Feb., 05:42, Peter Barker
I wonder if anyone can give me the rationale behind boost::multi_index's assignment operator having the following precondition: That meant to say boost::multi_array like the subject does!
I am not sure, but it seems that the idea was to avoid (surprise) reallocation by all means. If the LHS has to change size that means reallocation in the first place. Looking at the development history it seems that the author avoided reallocation by all means in the first versions of the library. Then he later added the .resize method (which does reallocation) but the assignment still follows the original prescription and that is why I believe. I might be wrong or there might be other reasons. I would like to know too, if that is the case. Note that, in multidimensional arrays, reallocation and/or copying is needed even if it shrinks in some directions (and not only at growing as one dimensional arrays) Regarding whether the current is the right design, I am not sure, on one hand it makes sense for a multidimensional arrays to forbid resize altogether, because in almost all cases, resize means reallocation and copying which has the order of cost of copy-constructing a new multiarray. On the other hand this restricted assignment doesn't follow the standard (expected) semantics. Regars, Alfredo