Output Range Problem? How to make it work?
Paul Backus
snarwin at gmail.com
Mon Oct 11 16:04:06 UTC 2021
On Monday, 11 October 2021 at 15:57:00 UTC, apz28 wrote:
> The subject is why the call is not allowed (format is not
> mention in question). Below sample is a bit more clear
>
[...]
> ref Writer outFail(Writer, Char)(return ref Writer sink)
> if (isOutputRange!(Writer, Char) && isSomeChar!Char)
> {return sink;}
[...]
> foo.outFail(buffer); // NOT OK
The template parameter `Char` does not appear anywhere in the
function's parameter list, so the compiler cannot deduce it from
the function's arguments.
Here is a simpler example that demonstrates the same problem:
```d
Dest convert(Source, Dest)(Source source)
{
return cast(Dest) source;
}
void main()
{
double d = 123.456;
auto result = convert(d); // Source = double, Dest = ???
}
```
More information about the Digitalmars-d-learn
mailing list