From dc291a16e43e803a126f8187b5eab1c7d4d5a6f0 Mon Sep 17 00:00:00 2001 From: Jack Stouffer Date: Thu, 4 Jan 2018 09:57:23 -0500 Subject: [PATCH] Changed all instances of FormatSpec to const ref --- std/bitmanip.d | 3 +-- std/complex.d | 3 +-- std/container/rbtree.d | 3 ++- std/typecons.d | 13 +++++++------ std/uni.d | 3 +-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/std/bitmanip.d b/std/bitmanip.d index 4a2ff47dee5..1062b32f9ea 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -2231,8 +2231,7 @@ public: * $(LI $(B %b) which prints the bits as 8-bit byte packets) * separated with an underscore. */ - void toString(scope void delegate(const(char)[]) sink, - FormatSpec!char fmt) const + void toString(scope void delegate(const(char)[]) sink, const ref FormatSpec!char fmt) const { switch (fmt.spec) { diff --git a/std/complex.d b/std/complex.d index 77638229220..bb2ab3855a1 100644 --- a/std/complex.d +++ b/std/complex.d @@ -146,8 +146,7 @@ if (isFloatingPoint!T) } /// ditto - void toString(Writer, Char)(scope Writer w, - FormatSpec!Char formatSpec) const + void toString(Writer, Char)(scope Writer w, const ref FormatSpec!Char formatSpec) const if (isOutputRange!(Writer, const(Char)[])) { import std.format : formatValue; diff --git a/std/container/rbtree.d b/std/container/rbtree.d index cde03eaaebf..5332788ea44 100644 --- a/std/container/rbtree.d +++ b/std/container/rbtree.d @@ -1712,7 +1712,8 @@ assert(equal(rbt[], [5])); */ static if (is(typeof((){FormatSpec!(char) fmt; formatValue((const(char)[]) {}, ConstRange.init, fmt);}))) { - void toString(scope void delegate(const(char)[]) sink, FormatSpec!char fmt) const { + void toString(scope void delegate(const(char)[]) sink, const ref FormatSpec!char fmt) const + { sink("RedBlackTree("); sink.formatValue(this[], fmt); sink(")"); diff --git a/std/typecons.d b/std/typecons.d index 97be02bfd34..620301b8df2 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -1189,11 +1189,12 @@ if (distinctFieldNames!(Specs)) */ void toString(DG)(scope DG sink) const { - toString(sink, FormatSpec!char()); + auto f = FormatSpec!char(); + toString(sink, f); } /// ditto - void toString(DG, Char)(scope DG sink, FormatSpec!Char fmt) const + void toString(DG, Char)(scope DG sink, const ref FormatSpec!Char fmt) const { import std.format : formatElement, formattedWrite, FormatException; if (fmt.nested) @@ -2443,7 +2444,7 @@ Params: { import std.format : FormatSpec, formatValue; // Needs to be a template because of DMD @@BUG@@ 13737. - void toString()(scope void delegate(const(char)[]) sink, FormatSpec!char fmt) + void toString()(scope void delegate(const(char)[]) sink, const ref FormatSpec!char fmt) { if (isNull) { @@ -2456,7 +2457,7 @@ Params: } // Issue 14940 - void toString()(scope void delegate(const(char)[]) @safe sink, FormatSpec!char fmt) + void toString()(scope void delegate(const(char)[]) @safe sink, const ref FormatSpec!char fmt) { if (isNull) { @@ -2996,7 +2997,7 @@ Params: { import std.format : FormatSpec, formatValue; // Needs to be a template because of DMD @@BUG@@ 13737. - void toString()(scope void delegate(const(char)[]) sink, FormatSpec!char fmt) + void toString()(scope void delegate(const(char)[]) sink, const ref FormatSpec!char fmt) { if (isNull) { @@ -3350,7 +3351,7 @@ Params: { import std.format : FormatSpec, formatValue; // Needs to be a template because of DMD @@BUG@@ 13737. - void toString()(scope void delegate(const(char)[]) sink, FormatSpec!char fmt) + void toString()(scope void delegate(const(char)[]) sink, const ref FormatSpec!char fmt) { if (isNull) { diff --git a/std/uni.d b/std/uni.d index 923e713cc91..58e17f31d51 100644 --- a/std/uni.d +++ b/std/uni.d @@ -2450,8 +2450,7 @@ public: * $(LI $(B %x) formats the intervals as a [low .. high$(RPAREN) range of lowercase hex characters) * $(LI $(B %X) formats the intervals as a [low .. high$(RPAREN) range of uppercase hex characters) */ - void toString(Writer)(scope Writer sink, - FormatSpec!char fmt) /* const */ + void toString(Writer)(scope Writer sink, const ref FormatSpec!char fmt) /* const */ { import std.format : formatValue; auto range = byInterval;