[PATCH] D40586: Implement p0457r2 - String Prefix and Suffix Checking

Marshall Clow via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 28 16:37:26 PST 2017


mclow.lists added inline comments.


================
Comment at: include/string:309
+	bool ends_with(charT c) const noexcept;
+	bool ends_with(const charT* s) const;
+
----------------
rsmith wrote:
> The indentation here seems off. Should these have a `// C++2a` comment?
I may have let a tab sneak in here. I'll be sure to de-tab before committing.


================
Comment at: include/string_view:577
+	bool starts_with(basic_string_view __s) const _NOEXCEPT
+	{ return size() >= __s.size() && compare(0, __s.size(), __s) == 0; }
+
----------------
rsmith wrote:
> Is this a conforming implementation? The `size()` check isn't part of the specification, and `compare` could run arbitrary user-supplied code, so the absence of a call to it seems observable.
> 
> Don't get me wrong: I think this check is the right thing to do, and it only makes a difference if `traits::compare` has observable side-effects. But we should file a bug against the standard to get this check added there.
The code as specified in the paper has a bug in it ;-)
I'll be filing an LWG issue once we have a draft standard with these bits in it.


https://reviews.llvm.org/D40586





More information about the cfe-commits mailing list