Bug 23707 – File.rawRead/rawWrite should support reading/writing individual values

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-02-15T03:22:54Z
Last change time
2024-12-01T16:41:06Z
Assigned to
No Owner
Creator
Steven Schveighoffer
Moved to GitHub: phobos#9855 →

Comments

Comment #0 by schveiguy — 2023-02-15T03:22:54Z
Sometimes, you just want to read a byte (or write one). Doing so with rawRead or rawWrite is awkward, because first you have to declare a buffer, then use the buffer, then convert to the place where you actually want to use it. A 3-statement process is pretty inconvenient. However, what if rawRead/rawWrite could have overloads that deal with one item: ```d T rawRead(T)() if (!isArray!T) {...} void rawWrite(T)(in T item) if (!isArray!T) {...} ``` Or stdio could provide wrappers that do this, they don't have to be overloads. Just some way to do in one line what it currently takes 3 lines to do.
Comment #1 by robert.schadek — 2024-12-01T16:41:06Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9855 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB