tB has some support for generics in sub/function and classes, but doesn't support them with delegates yet. Or whatever the heck that 2nd argument at the Filter callsite.
I started seeing how close I could get and I'll come back to it later, for now here's some generics examples working right now.
Code:Module testmod Private Sub testc() Dim names As List(Of String) = New List(Of String)(Array("John", "Smith", "Kane", "Tessa", "Yoland", "Royce", "Samuel")) Dim s As String = names(0) Debug.Print s End Sub End Module [COMCreatable(False)] Class List(Of T) Private src() As T Private c As Long Sub New(p() As T) For i As Long = 0 To UBound(p) ReDim Preserve src(c) src(c) = p(i) c += 1 Next End Sub [DefaultMember] Function GetAt(ByVal idx As Long) As T Return src(idx) End Function Public Property Get Count() As Long Return c End Property End ClassCode:Public Function GetMem(Of T)(ByVal ptr As LongPtr) As T vbaCopyBytes(LenB(Of T), VarPtr(GetMem), ptr) End Function Public Function DCast(Of T, T2)(ByVal v As T2) As T If LenB(Of T2) >= LenB(Of T) Then vbaCopyBytes(LenB(Of T), VarPtr(DCast), VarPtr(v)) Else vbaCopyBytes(LenB(Of T2), VarPtr(DCast), VarPtr(v)) End If End Function




Reply With Quote
