@@ -5,6 +5,24 @@ public unsafe struct pointer
5
5
6
6
public nint Address ;
7
7
8
+ #region Operators
9
+ public static pointer operator + ( pointer a , pointer b ) => new ( a . Address + b . Address ) ;
10
+ public static pointer operator - ( pointer a , pointer b ) => new ( a . Address - b . Address ) ;
11
+ public static pointer operator ++ ( pointer self ) => self . Address ++ ;
12
+ public static pointer operator -- ( pointer self ) => self . Address -- ;
13
+ public static pointer operator * ( pointer a , pointer b ) => new ( a . Address * b . Address ) ;
14
+ public static pointer operator / ( pointer a , pointer b ) => new ( a . Address / b . Address ) ;
15
+ public static pointer operator % ( pointer a , pointer b ) => new ( a . Address % b . Address ) ;
16
+ public static pointer operator & ( pointer a , pointer b ) => new ( a . Address & b . Address ) ;
17
+ public static pointer operator ^ ( pointer a , pointer b ) => new ( a . Address ^ b . Address ) ;
18
+ public static pointer operator | ( pointer a , pointer b ) => new ( a . Address | b . Address ) ;
19
+ #endregion
20
+
21
+ #region Object
22
+ public override string ToString ( ) => $ "0x{ Address : X} ";
23
+ #endregion
24
+
25
+ #region Implicits
8
26
public static implicit operator pointer ( nint address ) => new ( address ) ;
9
27
public static implicit operator pointer ( void * pointer ) => new ( ( nint ) pointer ) ;
10
28
public static implicit operator pointer ( void * * pointer ) => new ( ( nint ) pointer ) ;
@@ -29,6 +47,5 @@ public unsafe struct pointer
29
47
public static implicit operator nuint * ( pointer pointer ) => ( nuint * ) pointer . Address ;
30
48
31
49
public static implicit operator delegate * unmanaged< void > ( pointer pointer ) => ( delegate * unmanaged< void > ) pointer ;
32
-
33
- public override string ToString ( ) => $ "0x{ Address : X} ";
50
+ #endregion
34
51
}
0 commit comments