www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Problems with templates and arrays of strings

I'm experimenting with some simple template magic. I have a template
that adds another string to the end of a string:

template foo(char[] s) {
	static const char[] foo = s ~ "foo";
}

I have a list of strings. I need a template that concatenates the 'foo'
to every string in the list. After that, I need to convert that list
into an array of strings. An alternative would to handle them as an
array of strings all the way. All of that must happen on compile time.
Example:

template fooall(???) {
	// should use foo somehow
}

static const char[][] abc = toArray!(fooall!(fooall!("template", "magic")));

// or

static const char[][] abc = fooall!(fooall!(["template", "magic"]));

writefln(abc);

=> ["templatefoofoo", "magicfoofoo"]


Is it possible to do this yet? I haven't had any luck yet.
Feb 15 2007