diff --git a/include/gsl.h b/include/gsl.h index 5ae4df6..7a66db2 100644 --- a/include/gsl.h +++ b/include/gsl.h @@ -111,7 +111,8 @@ class not_null { static_assert(std::is_assignable::value, "T cannot be assigned nullptr."); public: - not_null(T t) : ptr_(t) { ensure_invariant(); } + not_null(const T &t) : ptr_(t) { ensure_invariant(); } + not_null(T &&t) : ptr_(std::forward(t)) { ensure_invariant(); } not_null& operator=(const T& t) { ptr_ = t; ensure_invariant(); return *this; } not_null(const not_null &other) = default;