What am I able to cast to ^Void?

But i even tried to write just a single string(text) in the memstream and it still does work, there im not longer in known addresssapce? :open_mouth:

var str := 'jdsghdfjhdujfdhf';
  
  d.Write(@str, sizeOf(str) * 1);

  d.Position := 0;

  var res : String;

  d.Read(@res, sizeOf(String)* 1);

  writeLn(res);

Is it able that you can fix this with generic T?

Meaning, that the memorystream is able to accept an: @generic_variable ?

Afaik that already works. Howver pair.item1 is a property. You can’t take the address of a property, you’d have to use a local. But once again, this is not going to work with any reference type. Ie strings classes, dynamic arrays

Unfortunately, it doesnt work, when i do it with generics:

i removed the tuple and wrote the Parameter directly and it still doesnt work, i get an error like that_

"Error (E406) No overloaded method “Write” with these parameters on type “MemoryStream”, best matching overload is “method Write(buf: ^Void; Count: Int32): Int32”

method TSample.Write(const bla: T);
begin
f_buffer.Write(@bla, sizeof(bla) * 1); // the error above
end;

Drop the “const”. you’re taking the address of something, which means it has to be writable.

1 Like

Thanks!! :slight_smile:

Did oversee this totally… ofc you are right ^^