microsoft / GSL

Guidelines Support Library
Other
6.11k stars 736 forks source link

Remove useless `noexcept(false)` from `narrow` #1152

Open Mq-b opened 3 months ago

Mq-b commented 3 months ago

I thought this was some kind of code specification at first, but I searched the entire repository and only saw this one use of noexcept(false). I don't think that's necessary here, narrow is not a destructor.

If no exception specification is explicitly provided, the exception specification is considered to be one that would be used by the implicitly-declared destructor (see below). In most cases, this is noexcept(true). Thus a throwing destructor must be explicitly declared noexcept(false).

I looked at other gsl libraries and didn't see 'noexcept(false)' used either.

https://github.com/gsl-lite/gsl-lite/blob/bd9eb162d42d8ae6a7e86902ca7060247d71ac41/include/gsl/gsl-lite.hpp#L2532

frederick-vs-ja commented 3 months ago

No change requested - Instead of implicit or explicit noexcept(false), would it be better to use conditional noexcept here?

d-winsor commented 1 month ago

@Mq-b There appears to be problems with the checks running on older PRs. Can you please push an empty commit to retrigger tests.