microsoft / GSL

Guidelines Support Library
Other
6.11k stars 736 forks source link

Mark not_null constructors as noexcept when underlying type can be moved with no exception #1135

Closed mymedia2 closed 10 months ago

mymedia2 commented 12 months ago

This enables possible optimisations for trivial types. This also avoids a bug in std::variant::emplace from GNU's libstdc++. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106547

Closes: #1134

dmitrykobets-msft commented 11 months ago

Hi @mymedia2, with a quick inspection this looks reasonable, but I'll defer this for the next maintainers' sync. Thanks for the PR.

hsutter commented 10 months ago

Thanks!

beinhaerter commented 10 months ago

The changes only apply to not_null, they are not applied to strict_not_null. Is there any reason for that? Or was this only overseen/forgotten?