[PATCH] D40586: Implement p0457r2 - String Prefix and Suffix Checking
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 28 16:12:24 PST 2017
rsmith added inline comments.
================
Comment at: include/string:309
+ bool ends_with(charT c) const noexcept;
+ bool ends_with(const charT* s) const;
+
----------------
The indentation here seems off. Should these have a `// C++2a` comment?
================
Comment at: include/string:1249
+ { return ends_with(__self_view(__s)); }
+#endif
+
----------------
Indentation seems off here too.
================
Comment at: include/string_view:151
+ constexpr bool ends_with(charT c) const noexcept; // c++2a
+ constexpr bool ends_with(const charT* s) const; // c++2a
+
----------------
I think we usually capitalize the C in these comments.
================
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; }
+
----------------
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.
https://reviews.llvm.org/D40586
More information about the cfe-commits
mailing list