fix: direct-init const ref instead of list-init (#1175)

fixes: https://github.com/microsoft/GSL/issues/1162

gcc has a bug that generates a call to the copy constructor when list
initializing a const reference. This PR offers a workaround which is to
direct initialize the value.

see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117900
This commit is contained in:
Carson Radtke 2024-12-13 10:22:16 -06:00 committed by GitHub
parent aed09c41b6
commit 8a0e3d8a9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -117,7 +117,7 @@ public:
not_null(const not_null& other) = default;
not_null& operator=(const not_null& other) = default;
constexpr details::value_or_reference_return_t<T> get() const
noexcept(noexcept(details::value_or_reference_return_t<T>{std::declval<T&>()}))
noexcept(noexcept(details::value_or_reference_return_t<T>(std::declval<T&>())))
{
return ptr_;
}