How does memcpy work in 0.6.0 ?
Before, I wrote a helper function for string vector in 0.5.0 and
memcpy
was working fine, now I am unable to do so in 0.6.0, this is code snippet:
I have noticed, that a concept of address space is introduced, but I am not able to find solid examples to learn from. Need some help8 Replies
This seems to work, doesn't look idiomatic in anyway though.
Thanks a lot for replying @sora , could you explain, why are we doing this line:
Its an underscored method but I think you want
._as_ptr()
.
Picking apart an
AnyPointer
and cast it to DTypePointer
. Mojo pointers are confusing, i don't fully understand what i'm doing.
I think you should go with @Michael K 's answer as that looks less hacky.What is Anypointer? Is it an abstract class for pointers or where can i learn more about it ?
It's also not documented.
No problem, Thanks for helping out @sora, @Michael K . The solution worked, will explore further. 👍
Also if you just want the underlying data in a pointer and dont need the original String, you can use
str._steal_ptr()
. No memcpy needed.