Skip to content

Update usage of difference_type in span#769

Merged
JordanMaples merged 1 commit intomicrosoft:masterfrom
jack17529:patch-1
Aug 15, 2019
Merged

Update usage of difference_type in span#769
JordanMaples merged 1 commit intomicrosoft:masterfrom
jack17529:patch-1

Conversation

@jack17529
Copy link
Contributor

About my Issue - #765

About my Issue - microsoft#765
@reddwarf69
Copy link
Contributor

I have not looked at it in detail. I was just looking for an update on index_type, but I don't think this PR would be OK in the future since index_type and difference_type are different types (see https://en.cppreference.com/w/cpp/container/span or https://github.com/martinmoene/span-lite#select-index-type)

@jack17529
Copy link
Contributor Author

@reddwarf69 no, you have connected the wrong dots.
@annagrin can we please get this PR merged, one other PR by me is also remaining to get merged.

@annagrin
Copy link

@JordanMaples is this boiling down to gsl::span not following the standard? if yes, lets have a bigger PR making it so.

@JordanMaples
Copy link
Contributor

Maintainer's call: Looks good, thank you.

@JordanMaples JordanMaples merged commit b576cc6 into microsoft:master Aug 15, 2019
@reddwarf69
Copy link
Contributor

What have I got wrong here:

This constructor is going to be called by span::end(). span::end() is going to use span::size() as the "idx" parameter of this constructor. span::size() returns a span::index_type. After this PR "idx" is now of type span_iterator::difference_type.
As it is right now span_iterator::difference_type == span::index_type == "the type returned by span::size()" == "the type used by span::end()", no issues.

But whenever GSL's span is made to follow the standard somebody is going to create span::difference_type and will redefine span_iterator::difference_type as span::difference_type. Now if I have a span of size SIZE_MAX, and SIZE_MAX > PTRDIFF_MAX, span::end() is going to fail (and would have not before this PR).

?

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.

4 participants