Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do unsigned integral types satisfy RandomAccessIterable? #119

Open
ericniebler opened this issue Oct 7, 2017 · 0 comments
Open

Do unsigned integral types satisfy RandomAccessIterable? #119

ericniebler opened this issue Oct 7, 2017 · 0 comments

Comments

@ericniebler
Copy link
Collaborator

Required expression i += n where n is the (signed) difference type. To evaluate, n is first converted to unsigned ([conv.integral]):

If the destination type is unsigned, the resulting value is the least unsigned integer congruent to the source integer (modulo 2n where n is the number of bits used to represent the unsigned type). [ Note: In a two’s complement representation, this conversion is conceptual and there is no change in the bit pattern (if there is no truncation). —end note ]

Any sane semantics for RandomAccessIterable would give the result of i += n the same result as n applications of ++i (or of -n applications of --i if n is negative). I need to sit down and characterize the situations in which that is not true (if any).

Note that for a type like unsigned char, given the way difference_type_t is defined in the Ranges TS, the difference type will likely have more bits than unsigned char.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant