On Fri, Jan 22, 2021 at 6:27 AM Nicholas Schwab via Std-Proposals <std-proposals@lists.isocpp.org> wrote:

for your specific example, the in my opinion best way would be

static_assert("hello world"sv.starts_with("hello"));

which is possible since C++20. But in general I agree, that it would be
nice to have these member functions. Specifically, I dislike calls to
string_view::substr with one argument (which is equivalent to your
proposed string_view::last):


This returns "_world"sv, but I do not find that obvious from the name

Absolutely. However, notice that `.substr(5)` isn't `.last(5)`; it's `.last_all_but(5)`.
The vocabulary terms for "first" and "last" here, since Ranges-v3, are actually "take" and "drop":
    assert("hello_world"sv.take(5) == "hello");
    assert("hello_world"sv.drop(5) == "_world");
    assert("hello_world"sv.drop_all_but(5) == "world");

The standard library was "poisoned" early on with APIs (like single-argument .substr(5)) that take integers to indicate either "start here" or "go until here" with no explanation. For example, it was recently brought to my attention that

    // https://godbolt.org/z/69xY4x
    assert(std::string("hello_world", 5) == "hello");
    assert(std::string("hello_world"s, 5) == "_world");