How to check if an array is a manifest constant?
simendsjo
simen.endsjo at pandavre.com
Mon Apr 4 01:16:50 PDT 2011
But there is a difference in how they behave, and I have no way of checking this behavior.
Consider the following little snippet:
void f(int[] a) {
a[0] = -1;
}
void main() {
int[] a = [1,2,3];
static assert(is(typeof(a) == int[]));
f(a);
assert(a[0] == -1); // a passed by reference, a[0] changed
enum b = [1,2,3];
static assert(is(typeof(b) == int[])); // a regular int[] you say?
f(b);
assert(b[0] == -1); // b passed by value, b[0] unchanged
}
More information about the Digitalmars-d-learn
mailing list