I'm trying to write an UDT with a numeric member, which can be constructed from all FB datatypes and can be casted to all datatypes. But in this constellation, the compiler returns the error "Ambigious call to overloaded function" (datatype).constructor() in Return z (from any of the operators). In the smallest version possible, the code looks like:
Code: Select all
type murks
s as integer
Declare Constructor()
Declare Constructor (ByRef a As Byte)
Declare Constructor (ByRef a As Integer)
declare operator cast() as byte
end type
Constructor murks()
This.s = 0
end Constructor
constructor murks(byref a as byte)
this.s = a
End constructor
constructor murks(byref a as integer)
this.s = a
End constructor
Operator + (ByRef x As murks, byref y as murks) As murks
dim as murks z
z.s = x.s + y.s
Return z
End Operator
Operator murks.Cast() as byte
Return Cast(byte,this.s)
End Operator
Regards,
Stephan
PS: If this issue is solved, the 128-bit datatype for 64-bit looks pretty good. The muliplication alone is 70x faster than the bigint implemenation.