[libcxx-commits] [PATCH] D95251: Remove noexcept from basic_string::find and implementation functions.

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 22 17:15:09 PST 2021


zoecarver added a comment.

> It's probably a wide vs. narrow contract thing. The find overloads that take const char*, for example, have a precondition that the pointer is non-null. Under the so-called "Lakos rule" they would/could/should be "Throws: Nothing" but not noexcept.

Sure, that makes sense, and if the `find` function was entirely defined inside of the function (didn't make any calls to other functions), I think that would be OK. But, if I understand correctly (and that's a big if), then this doesn't have a narrow contract because a custom `traits::find` (depending on the wording of [char.traits.require]/1) could throw for any reason (it doesn't have a documented contract, it still might throw if the pointer is not-null).

So (again, if I understand correctly), I think all of these have a wide contract and should either be expected to throw or be marked noexcept.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95251



More information about the libcxx-commits mailing list