M
Modular4mo ago
Anthony

UnsafePointer[T].initialize_pointee_copy error

Hi, I try to store multiple values in memory initialize by an UnsafePointer[T], like the official documentation states but I've got the error "invalid call to 'initialize_pointee_copy': argument #0 cannot be converted from 'UnsafePointer[T, 0]' to 'UnsafePointer[T, 0]'" The code is: struct Array[T: AnyTrivialRegType]: var data: UnsafePointer[T] var size: Int fn init(inout self, *elements: T): self.size = len(elements) self.data = UnsafePointer[T].alloc(self.size) for offset in range(self.size): initialize_pointee_copy(self.data + offset, elements[offset]) fn del(owned self): self.data.free() fn getitem(self, i: Int) raises -> T: if i < self.size: return self.data[i] else: raise Error("Out of bounds") I am using the latest version of mojo. What am I doing wrong? Thank you for any help, Anthony
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server