[Issue 9074] Can't use range functions with Appender
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Apr 24 13:56:30 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=9074
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |monarchdodra at gmail.com
--- Comment #2 from monarchdodra at gmail.com ---
(In reply to Andrej Mitrovic from comment #1)
> Different error now:
>
> -----
> C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\conv.d(3873): Error: static
> assert "immutable(char) cannot be emplaced from a string."
> C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\array.d(2522):
> instantiated from here: emplaceRef!string
> test.d(9): instantiated from here: put!(Take!(Repeat!string))
> -----
>
> Anyone has ideas how to fix this (or if it should be fixed?).
Yeah, use the "actual" std.range.put:
//----
void main()
{
// Error: casting string to char is deprecated
// Error: static assert "Cannot put a dchar into a Appender!(string)"
Appender!string x;
put(x, repeat(" ", 4));
// Error: casting string to dchar is deprecated
Appender!dstring y;
put(y, repeat(" ").take(4));
}
//----
This is why you should "never" use put "UFCS-style".
Always "put(a, b)".
Now, when all that is said and done, there's still an internal error, so it
needs fixing.
I don't think "Appender" should be able to handle this "natively" though. It
should have given a "no matching function" error.
--
More information about the Digitalmars-d-bugs
mailing list