Date
2012-08-05.16:44:00
Message id
5882

Content

Yesterday I noticed that the language we have in the FDIS about std::valarray move assignment is inconsistent with the resolution of LWG 675. Indeed, we guarantee constant complexity (vs linear complexity). We also want it to be noexcept, that is more subtle, but again it's at variance with all the containers.

Also, even if we suppose that LWG 675 applies only to the containers proper, I don't think the current "as if by calling resize(v.size())" is internally consistent with the noexcept requirement.

So, what do we really want for std::valarray? Shall we maybe just strike or fix the as-if, consider it some sort of pasto from the copy-assignment text, thus keep the noexcept and constant complexity requirements (essentially the whole operation would boild down to a swap of POD data members). Or LWG 675 should be explicitly extended to std::valarray too? In that case both noexcept and constant complexity would go, I think, and the operation would boil down to the moral equivalent of clear() (which doesn't really exist in this case) + swap?

Howard: I agree the current wording is incorrect. The complexity should be linear in size() (not v.size()) because the first thing this operator needs to do is resize(0) (or clear() as you put it).

I think we can keep the noexcept.

As for proper wording, here's a first suggestion:

Effects: *this obtains the value of v. The value of v after the assignment is not specified.

Complexity: linear.

See also reflector discussion starting with c++std-lib-30690.