I'm looking for a function something like writeln or write, but instead of writing to stdout, it writes to a string and returns the string.

So i would like something like:

import std.stdio;
import std.conv;

string write_to_string(T...)(T values ) {
  string s;
  foreach ( value; values ) s ~= to!string( value );
  return s;
}

But because this is such a standard type of thing to do, i'd like to use whatever the standard function is for doing it, if there is one.

So . . . is there one? Like maybe some way to dress a string up as a file and pass it through the usual write/writeln apparatus? My only real requirement is that it be something really easy to do.

Thanks in advance for any pointers.

dan

Reply via email to