Even more scope for FormatSpec

This commit is contained in:
Walter Bright 2019-03-18 01:28:47 -07:00
parent 7a2bbdedab
commit bc3dd0afda
4 changed files with 12 additions and 11 deletions

View file

@ -1838,7 +1838,7 @@ 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, const ref FormatSpec!char fmt) const
void toString(scope void delegate(const(char)[]) sink, scope const ref FormatSpec!char fmt) const
{
sink("RedBlackTree(");
sink.formatValue(this[], fmt);

View file

@ -615,7 +615,7 @@ public:
{
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, scope const ref FormatSpec!char fmt)
{
sink.formatValue(get!real, fmt);
}

View file

@ -1231,7 +1231,7 @@ if (distinctFieldNames!(Specs))
}
/// ditto
void toString(DG, Char)(scope DG sink, const ref FormatSpec!Char fmt) const
void toString(DG, Char)(scope DG sink, scope const ref FormatSpec!Char fmt) const
{
import std.format : formatElement, formattedWrite, FormatException;
if (fmt.nested)
@ -1287,9 +1287,10 @@ if (distinctFieldNames!(Specs))
}
else
{
const spec = fmt.spec;
throw new FormatException(
"Expected '%s' or '%(...%)' or '%(...%|...%)' format specifier for type '" ~
Unqual!(typeof(this)).stringof ~ "', not '%" ~ fmt.spec ~ "'.");
Unqual!(typeof(this)).stringof ~ "', not '%" ~ spec ~ "'.");
}
}
@ -2780,7 +2781,7 @@ Params:
}
/// ditto
void toString(W)(ref W writer, const ref FormatSpec!char fmt)
void toString(W)(ref W writer, scope const ref FormatSpec!char fmt)
if (isOutputRange!(W, char))
{
import std.range.primitives : put;
@ -2792,7 +2793,7 @@ Params:
//@@@DEPRECATED_2.086@@@
deprecated("To be removed after 2.086. Please use the output range overload instead.")
void toString()(scope void delegate(const(char)[]) sink, const ref FormatSpec!char fmt)
void toString()(scope void delegate(const(char)[]) sink, scope const ref FormatSpec!char fmt)
{
if (isNull)
{
@ -2807,7 +2808,7 @@ Params:
// Issue 14940
//@@@DEPRECATED_2.086@@@
deprecated("To be removed after 2.086. Please use the output range overload instead.")
void toString()(scope void delegate(const(char)[]) @safe sink, const ref FormatSpec!char fmt)
void toString()(scope void delegate(const(char)[]) @safe sink, scope const ref FormatSpec!char fmt)
{
if (isNull)
{
@ -3513,7 +3514,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, const ref FormatSpec!char fmt)
void toString()(scope void delegate(const(char)[]) sink, scope const ref FormatSpec!char fmt)
{
if (isNull)
{
@ -3967,7 +3968,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, const ref FormatSpec!char fmt)
void toString()(scope void delegate(const(char)[]) sink, scope const ref FormatSpec!char fmt)
{
if (isNull)
{
@ -7357,7 +7358,7 @@ struct Typedef(T, T init = T.init, string cookie=null)
}
/// ditto
void toString(this T, W)(ref W writer, const ref FormatSpec!char fmt)
void toString(this T, W)(ref W writer, scope const ref FormatSpec!char fmt)
if (isOutputRange!(W, char))
{
formatValue(writer, Typedef_payload, fmt);

View file

@ -2453,7 +2453,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, const ref FormatSpec!char fmt) /* const */
void toString(Writer)(scope Writer sink, scope const ref FormatSpec!char fmt) /* const */
{
import std.format : formatValue;
auto range = byInterval;