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

[algorithms] Uniform notation of distance(first, last) to (last - first) #352

Merged
merged 1 commit into from Dec 18, 2015

Conversation

k-satoda
Copy link
Contributor

@k-satoda k-satoda commented Aug 2, 2014

As allowed in 25.1 [algorithms.general] p12, to express the same things
as same.

For is_permutation, it is really bad because last1 - first1 is used in the previous line.
Others are just for consistency.

As allowed in 25.1 [algorithms.general] p12, to express the same things
as same.
@Quuxplusone
Copy link
Contributor

No, this patch is incorrect. The concept of y - x is not defined for arbitrary ForwardIterators x and y; that's why the Standard uses distance(x,y) consistently instead. y - x is defined only for random access iterators.

In the one case you noted where last1 - first1 is used, that's in a case where the type of first1 and last1 is known to be a random access iterator.

@jwakely
Copy link
Member

jwakely commented Jan 7, 2015

@Quuxplusone see [algorithms.general//12

@Quuxplusone
Copy link
Contributor

@jwakely @k-satoda oops, my bad. LGTM then.
On the other hand, I idly wonder how much it would complicate or simplify the Standard to just delete [algorithms.general]/12, and then use distance(x,y) everywhere.

@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 14, 2015

I too have a large changeset ready in my private repository that makes [algorithms] more consistent. If there's interest, I can try and merge it with this one?

@jwakely
Copy link
Member

jwakely commented Dec 18, 2015

I agree this change is editorial, and is an improvement, so I'll merge it. @tkoeppe, if you still want to make further changes please make a separate pull request.

jwakely added a commit that referenced this pull request Dec 18, 2015
[algorithms] Uniform notation of distance(first, last) to (last - first)
@jwakely jwakely merged commit ea7969a into cplusplus:master Dec 18, 2015
@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 18, 2015

@jwakely: Since you asked for it: #588 :-)

@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 19, 2015

@jwakely: Here's the main change I've had around for a long time: #590

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

Successfully merging this pull request may close these issues.

None yet

4 participants