Transferring 32 bits

Paul Backus snarwin at gmail.com
Thu Aug 25 14:17:16 UTC 2022


On Thursday, 25 August 2022 at 12:40:57 UTC, Adam D Ruppe wrote:
> What you want to do instead is either `.idup` the bytes or make 
> your toString do a `void delegate(in char[]) sink` and you pass 
> the bytes to the sink casting to char[].

Rather than using a delegate sink, I believe the current 
recommended approach [1] is to make toString a template that 
accepts an output range:

     import std.range;

     void toString(Sink)(ref Sink sink)
     if (isOutputRange!(Sink, char))
     {
         put(sink, cast(char[]) bytes);
     }

[1] https://dlang.org/phobos/std_format_write.html


More information about the Digitalmars-d mailing list