@@ -232,7 +232,7 @@ struct OutBuffer
232232
233233 alias put = write; // transition to output range which uses put()
234234
235- extern (C++ ) void write(const (void )* data, size_t nbytes) pure nothrow @system
235+ extern (C++ ) void write(scope const (void )* data, size_t nbytes) pure nothrow @system
236236 {
237237 put(data[0 .. nbytes]);
238238 }
@@ -246,6 +246,23 @@ struct OutBuffer
246246 offset += buf.length;
247247 }
248248
249+ void write (scope string buf) pure nothrow @trusted // so write("hello") chooses this overload
250+ {
251+ if (doindent && ! notlinehead)
252+ indent();
253+ reserve (buf.length);
254+ memcpy(this .data.ptr + offset, buf.ptr, buf.length);
255+ offset += buf.length;
256+ }
257+
258+ extern (C++ ) void write(scope const (char )* s) pure nothrow @trusted
259+ {
260+ if (! s)
261+ return ;
262+ import core.stdc.string : strlen;
263+ put(s[0 .. strlen(s)]);
264+ }
265+
249266 /**
250267 * Writes a 16 bit value, no reserve check.
251268 */
@@ -286,10 +303,7 @@ struct OutBuffer
286303 // / Buffer will NOT be zero-terminated
287304 extern (C++ ) void writestring(const (char )* s) pure nothrow @system
288305 {
289- if (! s)
290- return ;
291- import core.stdc.string : strlen;
292- put(s[0 .. strlen(s)]);
306+ put(s);
293307 }
294308
295309 // / ditto
@@ -307,7 +321,7 @@ struct OutBuffer
307321 // / Buffer will NOT be zero-terminated, followed by newline
308322 void writestringln (const (char )[] s) pure nothrow @safe
309323 {
310- writestring (s);
324+ put (s);
311325 writenl();
312326 }
313327
0 commit comments