Checking, whether or not a given string starts with a given prefix (or ends with a given suffix) is a common task.
This proposal adds two member functions
to class templates
Implemented in standard libraries of many other programming languages as a member of string/string-like classes. For example:
Implemented in some C++ libraries:
Used in various codebases
Name | starts_with | ends_with |
---|---|---|
Qt | 1193 | 953 | Webkit | 304 | 142 |
LLVM | 113 | 38 |
Alan was concerned about "findXXX" and starts_with/end_with functions, and suggested that they be free functions.
Sam said that he was in favor of having starts_with/end_with as member functions.
Dietmar suggested that starts_with/end_with should be in a separate proposal, and are independent of string_view. He also said that we are not designing a new interface here, we need to be more or less compatible with std::string.