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

[basic.string.general] Fix basic_string::npos #4862

Merged
merged 1 commit into from Sep 9, 2021

Conversation

jensmaurer
Copy link
Member

@jensmaurer jensmaurer commented Sep 3, 2021

Use constexpr and an explicit conversion to size_type,
for consistency with basic_string_view.

Requested by http://lists.isocpp.org/lib-ext/2021/09/19813.php

@jensmaurer
Copy link
Member Author

@jwakely , please have a look. Is the proposed change editorial from an LWG perspective?

Copy link
Member

@jwakely jwakely left a comment

Choose a reason for hiding this comment

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

Yes, I think this has no normative impact and qualifies as editorial.

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 9, 2021

@jensmaurer: could you please make the commit description more specific (not just "fix" in the opening line, but actually hint at what changed)? Also feel free to add some background from the discussion to the second paragraph, e.g. that this was omitted by accident. It's not just "for consistency", but it's really fixing some accidental omission, if I understand correctly? Then feel free to commit.

Use constexpr and an explicit conversion to size_type,
for consistency with basic_string_view.
@jensmaurer
Copy link
Member Author

@tkoeppe, I'm sorry, but this is in fact just for consistency with string_view. "const" vs. "constexpr" doesn't matter in this particular case (static class member of integral type).

I've slightly amended the commit description to avoid "fix".

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 9, 2021

Yes, it's for consistency abstractly, but as I understand, this change should have been made by some previous paper, where it was forgotten? That's the kind of background that would be nice to know (if true).

@tkoeppe tkoeppe merged commit 598d39c into cplusplus:main Sep 9, 2021
@jensmaurer
Copy link
Member Author

jensmaurer commented Sep 9, 2021

@tkoeppe: No. basic_string is ages old, then came along basic_string_view, which used all the new stuff such as "constexpr". Nobody ever thought about upgrading basic_string to follow stylistically, although presentation consistency between basic_string and basic_string_view would be nice. This pull request does it.

@jensmaurer jensmaurer deleted the c47 branch September 9, 2021 16:18
@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 9, 2021

OK, thanks. I thought the reflector discussion suggested that this was an oversight in http://wg21.link/P0980R1, but that might not actually have been true.

@jensmaurer
Copy link
Member Author

Well, that paper did add "constexpr" to basic_string member functions, which is a feature add-on. I'm hard pressed viewing "constexpr" on npos as in-scope of that paper; "constexpr" on a member function is quite different from constexpr on a static variable that was already usable in constant expressions.

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 9, 2021

Yeah, I was thinking that, too -- this is ultimately really nobody's fault.

frederick-vs-ja added a commit to frederick-vs-ja/draft that referenced this pull request Jan 12, 2024
frederick-vs-ja added a commit to frederick-vs-ja/draft that referenced this pull request Jan 12, 2024
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