mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
fix requirement on not_null template
it should be comparable to nullptr, it does not have to be assignable
This commit is contained in:
parent
5cbde3008a
commit
423841e965
@ -69,7 +69,7 @@ template <class T>
|
|||||||
class not_null
|
class not_null
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static_assert(std::is_assignable<T&, std::nullptr_t>::value, "T cannot be assigned nullptr.");
|
static_assert(std::is_convertible<decltype(std::declval<T>() != nullptr), bool>::value, "T cannot be compared to nullptr.");
|
||||||
|
|
||||||
template <typename U, typename = std::enable_if_t<std::is_convertible<U, T>::value>>
|
template <typename U, typename = std::enable_if_t<std::is_convertible<U, T>::value>>
|
||||||
constexpr explicit not_null(U&& u) : ptr_(std::forward<U>(u))
|
constexpr explicit not_null(U&& u) : ptr_(std::forward<U>(u))
|
||||||
|
Loading…
Reference in New Issue
Block a user