@@ -3814,13 +3814,16 @@ struct Nullable(T)
38143814 assert (e != 12 );
38153815 }
38163816
3817- size_t toHash () const @safe nothrow
3817+ static if ( ! isAggregateType ! T || hasMember ! (T, " toHash " ))
38183818 {
3819- static if (__traits(compiles, .hashOf(_value.payload)))
3820- return _isNull ? 0 : .hashOf(_value.payload);
3821- else
3822- // Workaround for when .hashOf is not both @safe and nothrow.
3823- return _isNull ? 0 : typeid (T).getHash(&_value.payload);
3819+ size_t toHash () const @safe nothrow
3820+ {
3821+ static if (__traits(compiles, .hashOf(_value.payload)))
3822+ return _isNull ? 0 : .hashOf(_value.payload);
3823+ else
3824+ // Workaround for when .hashOf is not both @safe and nothrow.
3825+ return _isNull ? 0 : typeid (T).getHash(&_value.payload);
3826+ }
38243827 }
38253828
38263829 /**
@@ -4826,6 +4829,18 @@ auto nullable(T)(T t)
48264829 auto result = cast (immutable (Nullable! (int * ))) a;
48274830}
48284831
4832+ // https://github.com/dlang/phobos/issues/10758
4833+ @safe unittest
4834+ {
4835+ struct F
4836+ {
4837+ bool opEquals (ref const F rhs) const { return true ; }
4838+ }
4839+
4840+ static assert (! __traits(compiles, bool [F]));
4841+ static assert (! __traits(compiles, bool [Nullable! F]));
4842+ }
4843+
48294844/**
48304845Just like `Nullable!T`, except that the null state is defined as a
48314846particular value. For example, $(D Nullable!(uint, uint.max)) is an
0 commit comments