Comment #1 by ellery-newcomer — 2011-08-11T18:37:07Z
Created attachment 1016
dmd doesn't like Format
Comment #2 by hsteoh — 2013-07-01T12:27:28Z
Now that std.format is CTFE-able, std.metastrings has been deprecated. Maybe this bug can be closed?
Comment #3 by ellery-newcomer — 2013-07-01T17:12:25Z
Depends on whether you consider it a dmd issue or a phobos issue.
I just took a second look at this and.. you get a recursion depth of exactly 500 for templates. I don't recall this restriction being documented anywhere, so if it isn't, it should be, and after that maybe take up the question of whether it is an acceptable restriction (with ctfe maybe it is now).
import std.string;
enum s = "abcdefghijklmorpshtn";
static assert(s.length == 20);
enum t = s ~ s;
static assert(t.length == 40);
enum u = t ~ t;
static assert(u.length == 80);
enum v = u ~ u;
static assert(v.length == 160);
enum w = v ~ v;
static assert(w.length == 320);
enum x = w ~ v ~ s;
static assert(x.length == 500);
/*
// ok!
enum x = w ~ v ~ s[1..$];
static assert(x.length == 499);
*/
template iter(string s, T) {
static if(s.length == 0) {
enum iter = "";
}else{
enum iter = toUpper(s[0..1]) ~ iter!(s[1..$], T);
}
}
pragma(msg, iter!(x, int));
void main() {}
Comment #4 by hsteoh — 2014-08-18T21:12:10Z
std.metastrings has been deprecated and removed, so this bug will never be "fixed". Use std.format instead (it is now supported in CTFE).