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

P1391R4 Range constructor for std::string_view #3454

Merged
merged 2 commits into from Nov 21, 2019
Merged

Conversation

zygoloid
Copy link
Member

@zygoloid zygoloid commented Nov 14, 2019

Renamed constructor parameters in description to match those in class
definition.

Fixes #3415.
Fixes cplusplus/nbballot#229
Partially addresses cplusplus/nbballot#268
Partially addresses cplusplus/nbballot#284
Fixes cplusplus/papers#184

@zygoloid zygoloid added this to the post-2019-11 milestone Nov 14, 2019
@jensmaurer jensmaurer added the changes requested Changes to the wording or approach have been requested and not yet applied. label Nov 14, 2019
@jensmaurer
Copy link
Member

Please add "fixes" to the commit for the NB comments linked in this pull request.

Copy link
Contributor

@JohelEGP JohelEGP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the similar changes to span in #3456.

source/strings.tex Outdated Show resolved Hide resolved
source/strings.tex Outdated Show resolved Hide resolved
source/strings.tex Outdated Show resolved Hide resolved
source/strings.tex Outdated Show resolved Hide resolved
source/strings.tex Outdated Show resolved Hide resolved
source/strings.tex Outdated Show resolved Hide resolved
@zygoloid zygoloid removed the changes requested Changes to the wording or approach have been requested and not yet applied. label Nov 16, 2019
Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

\pnum
\effects
Initializes \tcode{data_} with \tcode{to_address(begin)} and
initializes \tcode{size_} with \tcode{end - begin}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t is of type size_type, but end-begin is of type ptrdiff_t. The conversion will "just work" even for the overflow case, but it's a bit odd.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: end - begin has some signed-integer-like type (that isn't necessarily ptrdiff_t) but must be explicitly convertible to size_t per [iterator.concept.winc]/6. This needs to initialize size_ with static_cast<size_t>(end - begin).

As always, let-me-know-if-this-isn't-editorial-and-I'll-file-an-LWG-issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could simply say "direct-initializes size_t with end-begin", but that's a bit subtle.
@zygoloid , your call. (This also affects the similar text in the corresponding span changes.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my "bug" cry here was a bit of an overreaction - I (and apparently all of LWG) am still not used to non-integral difference types. Either "direct-initializes" or static_cast<size_t> would be great here, or we could clean it up post-merge via LWG issue. This certainly doesn't rise to the level of refusing to apply the proposal and sending it back to LWG, which "bug" would seem to imply.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that this is just one instance of a systemic problem in the library wording. This phrasing "initializes x with y" is common, but underspecified (and formally meaningless) -- the library wording either needs to say what kind of initialization is performed, or specify an initializer (not an expression) with which to initialize. We should ask LWG to think about this; for each "initializes x with y" utterance, the reader should know what kind of initialization we mean.

Looking at random through the library wording, the first case I found: [queue.cons]/1:

Effects: Initializes c with cont.

The meaning of this depends on whether this is direct- or copy-initialization. (It's obscure, but if T is not Cpp17CopyInsertable into the container, it could be the case that one form of initialization works and the other does not, or that they both work and do different things.)

Another random sample: [partial.sum]/2:

Effects: For a non-empty range, the function creates an accumulator acc whose type is InputIterator's value type, initializes it with *first, and assigns the result to *result.

Again the difference between direct- and copy-initialization is observable here.

Perhaps the library should have blanket wording that when it says "initializes", it means by direct- or copy-initialization, and that it's unspecified which one you get (or something like that) -- and someone should go through all the instances and check if any of them mean something else (I doubt this is the only case that does). I'm not convinced that this particular instance of the problem needs to be dealt with while applying the motions.

@CaseyCarter Can you file an LWG issue, please?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've mailed lwgchair to ask for an issue.

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Nov 19, 2019
Renamed constructor parameters in description to match those in class
definition.

Also fixes NB US 232 and partially fixes US 272 and DE 277 (C++20 CD).
…view.deduct]

Also replace commas with periods in lists of constraints.
@zygoloid zygoloid removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Nov 21, 2019
@zygoloid zygoloid merged commit d558fc9 into master Nov 21, 2019
@jensmaurer jensmaurer deleted the motions-2019-11-lwg-12 branch February 18, 2020 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants