Closed VoidPhantom closed 1 year ago
Hi @VoidPhantom, thanks for investigating this. As far as I can tell, the reason why the not_null type doesn't have a defaulted move constructor and instead relies on a templated alternative (which is not noexcept & has a non-trivial implementation) is that it performs a nullcheck upon construction from a moved-from not_null instance. This problem should be resolved in tandem with a larger design change for gsl::not_null
, for which I've created issue https://github.com/microsoft/GSL/issues/1051.
The
gsl::not_null
class template has:This makes it trivially copyable. However, move construction of an object of this class invokes a non-trivial, non-noexcept constructor template (
include/gsl/pointers
, line 90). This is unusual and unexpected; in fact, this triggers a bug in libstdc++’s implementation ofstd::variant
. This could be fixed by adding explicitly defaulted move constructor and move assignment operator.