front doesn't compile for arrays of immutable data
Roman D. Boiko
rb at d-coding.com
Mon Jun 25 07:23:24 PDT 2012
import std.range;
struct Element {
//immutable // uncomment to break compilation
int _i;
this(int i) { _i = i; }
}
void main() {
auto arr = [Element.init];
arr.front;
}
Declaring _i immutable yields the following compilation error:
/usr/include/x86_64-linux-gnu/dmd/phobos/std/array.d(460): Error:
a[0LU] isn't mutable
sample.d(11): Error: template instance std.array.front!(Element)
error instantiating
Is this a bug, or I misunderstand something?
More information about the Digitalmars-d-learn
mailing list