xxxxxxxxxx
struct S
{
int n;
void toString (Output) (ref Output output)
if (isOutputRange!(Output, char))
{
import std.format : formattedWrite;
output.formattedWrite!"%s"(2 * this.n);
}
}
void main ()
{
import std.range : empty, front, popFront, isOutputRange;
auto s = S(2);
char[] output;
static assert(isOutputRange!(typeof(output), char));
s.toString(output);
}