1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-02 22:36:00 +02:00

Fixed nullable null coalescing short circuiting

This commit is contained in:
Brian Fiete 2022-08-03 07:54:35 -07:00
parent 0bedd77f0a
commit e6352571c1
3 changed files with 34 additions and 30 deletions

View file

@ -420,31 +420,6 @@ namespace System
return Nullable<TResult>(lhs.mValue | rhs.mValue);
}
//
public static T operator??(Nullable<T> lhs, T rhs)
{
return (lhs.mHasValue) ? lhs.mValue : rhs;
}
public static TResult? operator??<TOther, TResult>(TOther lhs, Nullable<T> rhs) where TResult : operator TOther ?? T where TResult : struct
{
if (!rhs.mHasValue) return null;
return Nullable<TResult>(lhs ?? rhs.mValue);
}
public static TResult? operator??<TOther, TResult>(Nullable<T> lhs, TOther rhs) where TResult : operator T ?? TOther where TResult : struct
{
if (!lhs.mHasValue) return null;
return Nullable<TResult>(lhs.mValue ?? rhs);
}
public static TResult? operator??<TOther, TResult>(Nullable<T> lhs, Nullable<TOther> rhs) where TOther : struct where TResult : operator T ?? TOther where TResult : struct
{
if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null;
return Nullable<TResult>(lhs.mValue ?? rhs.mValue);
}
//
public static TResult? operator<< <TOther, TResult>(TOther lhs, Nullable<T> rhs) where TResult : operator TOther << T where TResult : struct