C++ Logo

std-proposals

Advanced search

Add first and last to the std::string_view

From: 康桓瑋 <hewillk_at_[hidden]>
Date: Fri, 22 Jan 2021 15:03:02 +0800
C++20 introduced the *std::span* which makes it easier to deal
with continuous rage. Especially the subview facilities: *first*, *last*
and *subspan*. I wonder if we can add *first* and *last* function to
*std::string_view*, then we can generate the *substr* more intuitively
and less fallible:

static_assert("hello world"sv.first(5) == "hello");


Thanks for your reply!

Received on 2021-01-22 01:03:15