Created on 2014-06-14.00:00:00 last changed 127 months ago
Proposed resolution:
This wording is relative to N3936.
Change [alg.rotate] p2 as indicated:
-2- Returns: If middle == first, returns first. Otherwise, returns first + (last - middle).
[ 2014-06-16 Rapperswill ]
Closed as NAD.
When LWG 488 was resolved, the intention was to return "where the subrange [first, middle) starts after the rotate is performed". However, this wasn't achieved in one case.
When middle == last, rotate() does nothing and returns first. This is good. When middle == first, rotate() does nothing and returns last. This is bad. In addition to being inconsistent with the other do-nothing case, it prevents rotate() from providing the useful guarantee that LWG 488 wanted: when [first, last) is non-empty, rotate()'s return value should always be dereferenceable to get the originally-first element. Howard Hinnant: As the author of LWG 488 I can assure everyone that the edge cases the proposed resolution specifies were not specified by accident. rotate(i, i, j) should return j and rotate(i, j, j) should return i. Doing otherwise will break working code. These return values were motivated by the uses of rotate in the implementation of algorithms such as stable_partition and inplace_merge. The results of these edge cases were not chosen lightly. Also a good read: notes-on-programming-2006-10-13 Summary: NAD.History | |||
---|---|---|---|
Date | User | Action | Args |
2014-06-17 08:47:43 | admin | set | messages: + msg7061 |
2014-06-17 08:47:43 | admin | set | status: new -> nad |
2014-06-14 19:39:50 | admin | set | messages: + msg7041 |
2014-06-14 00:00:00 | admin | create |