On Friday, 6 November 2015 at 22:55:15 UTC, Alex wrote:
Ok... the question is not silly any more...
without 'immutable' it works. So, what am I missing?
sorry, again a forum bug that stripped my answer:
sort() fails because in the template constraint
`hasAssignableElements` fails.
hasAssignableElements fails because of this you cannot assign
another value to a ku because the immutable member is already
defined.
---
template hasAssignableElements(R)
{
enum bool hasAssignableElements = isInputRange!R && is(typeof(
(inout int = 0)
{
R r = R.init;
r.front = r.front;
static if (isBidirectionalRange!R) r.back = r.front;
static if (isRandomAccessRange!R) r[0] = r.front;
}));
}
---
more especially this is 'r.front = r.front;' that doesn't pass:
---
import std.range;
struct ku
{
immutable int id;
}
void main()
{
ku[] tt;
tt.front = tt.front;
}
---
so yeah, it cant work if id is immutable.