618. valarray::cshift() effects on empty array

Section: 29.6.2.8 [valarray.members] Status: CD1 Submitter: Gabriel Dos Reis Opened: 2007-01-10 Last modified: 2016-01-28

Priority: Not Prioritized

View all issues with CD1 status.

Discussion:

I would respectfully request an issue be opened with the intention to clarify the wording for size() == 0 for cshift.

Proposed resolution:

Change 29.6.2.8 [valarray.members], paragraph 10:

valarray<T> cshift(int n) const;

This function returns an object of class valarray<T>, of length size(), each of whose elements I is (*this)[(I + n ) % size()]. Thus, if element zero is taken as the leftmost element, a positive value of n shifts the elements circularly left n places. that is a circular shift of *this. If element zero is taken as the leftmost element, a non-negative value of n shifts the elements circularly left n places and a negative value of n shifts the elements circularly right -n places.

Rationale:

We do not believe that there is any real ambiguity about what happens when size() == 0, but we do believe that spelling this out as a C++ expression causes more trouble that it solves. The expression is certainly wrong when n < 0, since the sign of % with negative arguments is implementation defined.

[ Kona (2007) Changed proposed wording, added rationale and set to Review. ]