1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

IOpSubtractable

The opposite of IOpAddable, useful for generic code.
This commit is contained in:
Damian Day 2020-03-20 22:01:18 +00:00
parent 96c53d4a9e
commit 9a8beec7d9
11 changed files with 63 additions and 8 deletions

View file

@ -43,6 +43,11 @@ namespace System
static Self operator+(Self lhs, Self rhs);
}
interface IOpSubtractable
{
static Self operator-(Self lhs, Self rhs);
}
interface IOpNegatable
{
static Self operator-(Self value);

View file

@ -2,7 +2,7 @@ using System;
namespace System
{
struct Int : int, IInteger, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable
struct Int : int, IInteger, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable
{
public enum ParseError
{
@ -21,6 +21,11 @@ namespace System
return (SelfBase)lhs + (SelfBase)rhs;
}
public static Self operator-(Self lhs, Self rhs)
{
return (SelfBase)lhs - (SelfBase)rhs;
}
public static Self operator-(Self value)
{
return (SelfBase)value;

View file

@ -1,6 +1,6 @@
namespace System
{
struct Int16 : int16, IInteger, ISigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable
struct Int16 : int16, IInteger, ISigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable
{
public const int32 MaxValue = 0x7FFF;
public const int32 MinValue = -0x8000;
@ -15,6 +15,11 @@ namespace System
return (SelfBase)lhs + (SelfBase)rhs;
}
public static Self operator-(Self lhs, Self rhs)
{
return (SelfBase)lhs - (SelfBase)rhs;
}
public static Self operator-(Self value)
{
return (SelfBase)value;

View file

@ -2,7 +2,7 @@ using System.Globalization;
namespace System
{
struct Int32 : int32, IInteger, ISigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable
struct Int32 : int32, IInteger, ISigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable
{
public enum ParseError
{
@ -24,6 +24,11 @@ namespace System
return (SelfBase)lhs + (SelfBase)rhs;
}
public static Self operator-(Self lhs, Self rhs)
{
return (SelfBase)lhs - (SelfBase)rhs;
}
public static Self operator-(Self value)
{
return (SelfBase)value;

View file

@ -25,6 +25,11 @@ namespace System
return (SelfBase)lhs + (SelfBase)rhs;
}
public static Self operator-(Self lhs, Self rhs)
{
return (SelfBase)lhs - (SelfBase)rhs;
}
public static Int64 operator-(Int64 value)
{
return -(SelfBase)value;

View file

@ -1,6 +1,6 @@
namespace System
{
struct Int8 : int8, IInteger, ISigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable
struct Int8 : int8, IInteger, ISigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable
{
public const int32 MaxValue = 0x7F;
public const int32 MinValue = -0x80;
@ -15,6 +15,11 @@ namespace System
return (SelfBase)lhs + (SelfBase)rhs;
}
public static Self operator-(Self lhs, Self rhs)
{
return (SelfBase)lhs - (SelfBase)rhs;
}
public static Self operator-(Self value)
{
return (SelfBase)value;

View file

@ -1,6 +1,6 @@
namespace System
{
struct UInt : uint, IInteger, IUnsigned, IHashable, IOpComparable, IFormattable, IIsNaN, IOpAddable
struct UInt : uint, IInteger, IUnsigned, IHashable, IOpComparable, IFormattable, IIsNaN, IOpAddable, IOpSubtractable
{
public enum ParseError
{
@ -27,6 +27,11 @@ namespace System
return (SelfBase)lhs + (SelfBase)rhs;
}
public static Self operator-(Self lhs, Self rhs)
{
return (SelfBase)lhs - (SelfBase)rhs;
}
public int GetHashCode()
{
return (int)this;

View file

@ -1,6 +1,6 @@
namespace System
{
struct UInt16 : uint16, IInteger, IUnsigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable
struct UInt16 : uint16, IInteger, IUnsigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable
{
public const uint16 MaxValue = (uint16)0xFFFF;
public const uint16 MinValue = 0;
@ -15,6 +15,11 @@ namespace System
return (SelfBase)lhs + (SelfBase)rhs;
}
public static Self operator-(Self lhs, Self rhs)
{
return (SelfBase)lhs - (SelfBase)rhs;
}
public static Self operator-(Self value)
{
return (SelfBase)value;

View file

@ -1,6 +1,6 @@
namespace System
{
struct UInt32 : uint32, IInteger, IUnsigned, IHashable, IOpComparable, IFormattable, IIsNaN, IOpAddable
struct UInt32 : uint32, IInteger, IUnsigned, IHashable, IOpComparable, IFormattable, IIsNaN, IOpAddable, IOpSubtractable
{
public enum ParseError
{
@ -22,6 +22,11 @@ namespace System
return (SelfBase)lhs + (SelfBase)rhs;
}
public static Self operator-(Self lhs, Self rhs)
{
return (SelfBase)lhs - (SelfBase)rhs;
}
public int GetHashCode()
{
return (int)this;

View file

@ -24,6 +24,11 @@ namespace System
return (SelfBase)lhs + (SelfBase)rhs;
}
public static Self operator-(Self lhs, Self rhs)
{
return (SelfBase)lhs - (SelfBase)rhs;
}
public int GetHashCode()
{
return (int)this;

View file

@ -1,6 +1,6 @@
namespace System
{
struct UInt8 : uint8, IInteger, IUnsigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable
struct UInt8 : uint8, IInteger, IUnsigned, IHashable, IFormattable, IOpComparable, IIsNaN, IOpNegatable, IOpAddable, IOpSubtractable
{
public const uint8 MaxValue = (uint8)0xFF;
public const uint8 MinValue = 0;
@ -15,6 +15,11 @@ namespace System
return (SelfBase)lhs + (SelfBase)rhs;
}
public static Self operator-(Self lhs, Self rhs)
{
return (SelfBase)lhs - (SelfBase)rhs;
}
public static Self operator-(Self value)
{
return (SelfBase)value;