Skip to content

Conversation

@MirzakDD
Copy link

Implements C++20 string methods starts_with() and ends_with() with three
overloads each:

  • bool starts_with(view_type sv) const EA_NOEXCEPT;
  • bool starts_with(value_type c) const EA_NOEXCEPT;
  • bool starts_with(const value_type* p) const;

And corresponding ends_with() methods.

Includes comprehensive unit tests covering all overloads and edge cases.

https://en.cppreference.com/w/cpp/string/basic_string/starts_with https://en.cppreference.com/w/cpp/string/basic_string/ends_with

…tring

Changes:
- Added 3 overloads of starts_with():
  - bool starts_with(view_type sv) const EA_NOEXCEPT
  - bool starts_with(value_type c) const EA_NOEXCEPT
  - bool starts_with(const value_type* p) const EA_NOEXCEPT

- Added 3 overloads of ends_with():
  - bool ends_with(view_type sv) const EA_NOEXCEPT
  - bool ends_with(value_type c) const EA_NOEXCEPT
  - bool ends_with(const value_type* p) const EA_NOEXCEPT

- Added comprehensive unit tests covering all overloads and edge cases

Testing:
All existing tests pass. New tests cover:
- view_type, C-string, and character overloads
- Empty strings and empty prefix/suffix
- Full string match
- Oversized prefix/suffix (returns false)
- SSO and heap strings

Compatibility:
- Methods are marked EA_NOEXCEPT as per C++20 standard
- Implementation uses existing EASTL internal methods
- No breaking changes to existing API

https://en.cppreference.com/w/cpp/string/basic_string/starts_with
https://en.cppreference.com/w/cpp/string/basic_string/ends_with
@MirzakDD MirzakDD changed the title Adds C++20-compliant starts_with() and ends_with() methods to basic_s… basic_string::starts_with() / basic_string::ends_with() Jan 11, 2026
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.

1 participant