Skip to content

Conversation

@frederick-vs-ja
Copy link
Contributor

Currently, const_reference and const charT& are mixedly used in the return types of some functions in [strings] (same for non-const versions).

This PR consistently

  • spells the return types in the short aliased forms, as the shorter forms are clearer, and
  • aligns non-const and const overloads of basic_string::data, and
  • spells the shorter form for the type of basic_string_view::data_.

@eisenwave
Copy link
Member

We should better close this; it's not a good idea.

Note that https://eel.is/c++draft/sequence.reqmts#itemdecl:33 is worded to result in reference, and you're suggesting to make it inconsistent with the sequence container requirements by spelling it out as charT&.

@frederick-vs-ja
Copy link
Contributor Author

Note that https://eel.is/c++draft/sequence.reqmts#itemdecl:33 is worded to result in reference, and you're suggesting to make it inconsistent with the sequence container requirements by spelling it out as charT&.

Do you mean that we should change to spell (const_)reference as the return types of basic_string's front and back?

Moreover, I don't think consistency with "sequence container requirements" applies to basic_string_view.

@frederick-vs-ja frederick-vs-ja force-pushed the string-return-reference branch from 2c12baa to c7c19da Compare July 18, 2025 10:09
@eisenwave
Copy link
Member

Do you mean that we should change to spell (const_)reference as the return types of basic_string's front and back?

Yes, that seems better than changing it the other way around. That way it would be reference and const_reference everywhere.

Moreover, I don't think consistency with "sequence container requirements" applies to basic_string_view.

basic_string_view still implements the "string protocol", so it should be consistent with basic_string, which in turn, should be consistent with sequence container requirements.

@frederick-vs-ja
Copy link
Contributor Author

Do you mean that we should change to spell (const_)reference as the return types of basic_string's front and back?

Yes, that seems better than changing it the other way around. That way it would be reference and const_reference everywhere.

Moreover, I don't think consistency with "sequence container requirements" applies to basic_string_view.

basic_string_view still implements the "string protocol", so it should be consistent with basic_string, which in turn, should be consistent with sequence container requirements.

OK. I'll open another PR for spelling consistency and close this.

@frederick-vs-ja frederick-vs-ja deleted the string-return-reference branch July 20, 2025 09:49
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.

2 participants