[libcxx-commits] [libcxx] [libc++] Document the strengthened noexcept convention (PR #203869)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 24 05:34:55 PDT 2026
philnik777 wrote:
> > FWIW I do think that having a rationale would make this net-positive. I'd be perfectly happy with having short-hands for common stuff like `Throws: Nothing`, e.g. as `noexcept // strengthened(throws nothing)`, and having longer explanations for why we think e.g. conditional noexcepts are a good idea in some places. That would provide substantial value IMO, since it tells me the intention/rationale of the author.
>
> I think I like the explanations. But IIUC in most cases of strengthening (~99.5% in MSVC STL for now), the comments will say `// strengthened(throws nothing)`, and I don't think it will be helpful to say `(throws nothing)`.
First, how did you get that number? Second, why is it not helpful? It tells you how the author got to the conclusion that the extended `noexcept` is correct. If it's in fact not (i.e. the standard doesn't say `Throws: nothing`), it tells you that something probably went wrong. You don't have to guess what the reasoning was anymore. I'm fine with something shorter, but I do think an explicit mention of the motivation would be helpful, even if it's mostly the same. I'd also be happy with e.g. `// nothrow-strengthened` as long as it's documented what it means.
I'd also like to note that the very examples in this PR aren't of the `Throws: nothing` variety, so I do wonder whether there will be that few strengthened `noexcept` where `Throws: nothing` doesn't apply.
https://github.com/llvm/llvm-project/pull/203869
More information about the libcxx-commits
mailing list