Comment #0 by Jesse.K.Phillips+D — 2010-11-01T16:26:02Z
The code below fails to compile because a Class with InputRange primitives sanctifies two std.format.formatValue functions. On is for printing Classes and the other for printing an InputRange. This is not an issue when using std.string.format (Since it doesn't use formatValue).
C:\opt\dmd\windows\bin\..\..\src\phobos\std\format.d(1455): Error: template std.
format.formatValue(Writer,T,Char) if (is(const(T) == const(void[]))) formatValue
(Writer,T,Char) if (is(const(T) == const(void[]))) matches more than one templat
e declaration, C:\opt\dmd\windows\bin\..\..\src\phobos\std\format.d(1126):format
Value(Writer,T,Char) if (isInputRange!(T) && !isSomeChar!(ElementType!(T))) and
C:\opt\dmd\windows\bin\..\..\src\phobos\std\format.d(1297):formatValue(Writer,T,
Char) if (is(T == class))
import std.stdio;
import std.string;
class Range {
bool empty() { return true; }
int front() { return 1; }
void popFront() { }
}
void main() {
writefln("%s", new Range());
writeln(new Range());
writeln(format("%s", new Range()));
}