Problems with templates and arrays of strings

Jari-Matti Mäkelä jmjmak at
Thu Feb 15 07:24:27 PST 2007

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.

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

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

// or

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


=> ["templatefoofoo", "magicfoofoo"]

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

More information about the Digitalmars-d-learn mailing list