[Issue 12315] std.array.array at compile-time too
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 9 07:11:12 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12315
--- Comment #6 from bearophile_hugs at eml.cc 2014-03-09 07:11:11 PDT ---
(In reply to comment #5)
> There are also assumeSafeAppend, reserve/capacity, and so on. I don't know if
> they speedup the code at compile-time too.
It seems code like this doesn't yet work:
import std.traits: ForeachType;
import std.range: hasLength;
ForeachType!R[] myArray(R)(R r) {
if (__ctfe) {
typeof(return) result;
static if (hasLength!R)
result.reserve = r.length;
foreach (item; r)
result ~= r;
return result;
} else {
// ...
assert(0);
}
}
struct Foo1 {
int i;
}
struct Foo2 {
immutable int i;
}
void main() {
enum r1 = [Foo1(1)].myArray; // OK
enum r2 = [Foo2(1)].myArray; // OK
}
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list