Namespaces
Variants
Views
Actions

Talk:cpp/string/basic string view/starts with

From cppreference.com
< Talk:cpp‎ | string/basic string view
Revision as of 12:51, 10 May 2024 by Space Mission (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Is the description of the first overload correct? "Effectively returns basic_string_view(data(), std::min(size(), x.size())) == sv."

First, note that x.size() is probably supposed to be sv.size().

Assuming that's correct, and sv.size() > size(), the result is true if the first size() characters of sv match those in data(). Is that really correct? The effect is to implicitly swap the order of *this and sv in the test (IOW, *this is considered the prefix to check for in sv, which just seems wrong.) RobStewart (talk) 11:31, 10 May 2024 (PDT)

Oh, duh. The temporary string_view is shorter, so the two won't be equal. Anyway, x.size() should probably be sv.size()! RobStewart (talk) 11:56, 10 May 2024 (PDT)

 Fixed: xsv, as per draft. x was from <string_view>. Thanks, @RobStewart.) --Space Mission (talk) 13:51, 10 May 2024 (PDT)