mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Reworked binary operators and transformability
This commit is contained in:
parent
230b71cecb
commit
b49e513494
5 changed files with 45 additions and 64 deletions
|
@ -52,7 +52,8 @@ namespace Tests
|
|||
static
|
||||
{
|
||||
public static int CompareIt<T>(this T self, T other)
|
||||
where bool: operator T < T
|
||||
where bool : operator T < T
|
||||
where bool : operator T > T
|
||||
{
|
||||
if(self < other)
|
||||
return -1;
|
||||
|
|
|
@ -30,6 +30,12 @@ namespace Tests
|
|||
newVal.mA = val.mA + 1;
|
||||
return newVal;
|
||||
}
|
||||
|
||||
[Commutable]
|
||||
public static bool operator<(StructA lhs, StructB rhs)
|
||||
{
|
||||
return lhs.mA < rhs.mB;
|
||||
}
|
||||
}
|
||||
|
||||
struct StructB
|
||||
|
@ -226,6 +232,12 @@ namespace Tests
|
|||
StructB sb1;
|
||||
sb1.mB = 12;
|
||||
|
||||
Test.Assert(sa1 < sb0);
|
||||
Test.Assert(!(sa1 >= sb0));
|
||||
|
||||
Test.Assert(sb0 > sa1);
|
||||
Test.Assert(!(sb0 <= sa1));
|
||||
|
||||
StructA sa3 = sa0 + sb0;
|
||||
Test.Assert(sa3.mA == 1012);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue