[libcxx-commits] [PATCH] D151260: [Demangle] avoid more std::string_view::substr

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 23 15:36:52 PDT 2023


philnik added inline comments.


================
Comment at: libcxxabi/src/demangle/StringViewExtras.h:25
+inline bool starts_with(std::string_view self, char C) noexcept {
   return !self.empty() && self.front() == C;
 }
----------------
MaskRay wrote:
> nickdesaulniers wrote:
> > nickdesaulniers wrote:
> > > `front` is not `noexcept`. Should I rewrite this to be `&*self == C`?
> > https://en.cppreference.com/w/cpp/string/basic_string_view/front
> Ah, `*self == C` looks good. It's a pity that `front` throws...
`front()` doesn't throw. All major implementation also mark it as `noexcept` as a conforming extension. It's just not required to be `noexcept` in case an implementation wants to throw in the UB case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151260/new/

https://reviews.llvm.org/D151260



More information about the libcxx-commits mailing list