https://issues.dlang.org/show_bug.cgi?id=20314
Issue ID: 20314
Summary: passing const variables to `only` forces const range
element type
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: minor
Priority: P1
Component: phobos
Assignee: [email protected]
Reporter: [email protected]
Consider this code:
import std;
void main()
{
const string s = "foo", t = "bar";
auto range = only(s, t);
[range].joiner(only(", ")).join.writeln;
}
Since `only` takes its parameters by `auto ref`, the fact that s and t are
`const string` forces `only` to have an `ElementType` of `const(string)`, which
then breaks `joiner`.
There's no reason for `only` to be `auto ref`, since it copies its parameters
anyways.
--