diff --git a/std/typecons.d b/std/typecons.d index 6671f5e9d46..44b986ff759 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -2228,7 +2228,8 @@ Params: } /// Ditto - bool opEquals()(auto ref const(T) rhs) const + bool opEquals(U)(auto ref const(U) rhs) const + if (is(typeof(this.get == rhs))) { return _isNull ? false : rhs == _value; } @@ -2276,6 +2277,16 @@ Params: assert(a != Nullable!int(29)); } + // Issue 17482 + @system unittest + { + import std.variant : Variant; + Nullable!Variant a = Variant(12); + assert(a == 12); + Nullable!Variant e; + assert(e != 12); + } + template toString() { import std.format : FormatSpec, formatValue;