458. 24.1.5 contains unintended limitation for operator-

Section: 24.3.5.7 [random.access.iterators] Status: NAD Submitter: Daniel Frey Opened: 2004-02-27 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [random.access.iterators].

View all issues with NAD status.

Discussion:

In 24.1.5 [lib.random.access.iterators], table 76 the operational semantics for the expression "r -= n" are defined as "return r += -n". This means, that the expression -n must be valid, which is not the case for unsigned types.

[ Sydney: Possibly not a real problem, since difference type is required to be a signed integer type. However, the wording in the standard may be less clear than we would like. ]

[ Post Summit Alisdair adds: ]

This issue refers to a requirements table we have removed.

The issue might now relate to 24.3.5.7 [random.access.iterators] p5. However, the rationale in the issue already recognises that the difference_type must be signed, so this really looks NAD.

[ Batavia (2009-05): ]

We agree with Alisdair's observations.

Move to NAD.

[ 2009-07 Frankfurt: ]

Need to look at again without concepts.

There was a question about this phrase in the discussion: "the expression -n must be valid, which is not the case for unsigned types." If n is an object of the iterator difference_type (eg ptrdiff_t), then it is never unsigned.

[ 2009-10 Santa Cruz: ]

The group reviewed the wording in the draft and agreed that n is of difference type, the difference type is signed, and the current wording is correct. Moved to NAD.

Proposed resolution:

To remove this limitation, I suggest to change the operational semantics for this column to:

    { Distance m = n;
      if (m >= 0)
        while (m--) --r;
      else
        while (m++) ++r;
      return r; }