digitalmars.D - tupleof on arrays?
- Yang Bo (11/11) Oct 16 2007 I have some string generate from template, and I need to dump them to
- Yang Bo (9/22) Oct 16 2007 I forget the n.stringof, it should be:
- BCS (8/21) Oct 16 2007 no. What would it return? contents of the array? What would it do with a...
- Reiner Pope (6/19) Oct 16 2007 What's wrong with simply
I have some string generate from template, and I need to dump them to stack and modify it. So I write: template S(int n) { const char[] S = "n = " ~ n; } void f() { char[S!(123).length] s = [S!(0).tupleof]; s[0] = 'm'; } The problem is, there is not a 'tupleof' property on array. Should this feature be buildin ?
Oct 16 2007
Yang Bo дµÀ:I have some string generate from template, and I need to dump them to stack and modify it. So I write: template S(int n) { const char[] S = "n = " ~ n; } void f() { char[S!(123).length] s = [S!(0).tupleof]; s[0] = 'm'; } The problem is, there is not a 'tupleof' property on array. Should this feature be buildin ?I forget the n.stringof, it should be: template S(int n) { const char[] S = "n = " ~ n.stringof; } void f() { char[S!(123).length] s = [S!(0).tupleof]; s[0] = 'm'; }
Oct 16 2007
Reply to Yang,I have some string generate from template, and I need to dump them to stack and modify it. So I write: template S(int n) { const char[] S = "n = " ~ n; } void f() { char[S!(123).length] s = [S!(0).tupleof]; s[0] = 'm'; } The problem is, there is not a 'tupleof' property on array. Should this feature be buildin ?no. What would it return? contents of the array? What would it do with a non const? I think you can get the effect you want with a cast ot a slice or maybe both. also somthing along this line should work. template S(int n) { const char[4+n.stringof.length] S = "n = " ~ n.stringof; }
Oct 16 2007
Yang Bo wrote:I have some string generate from template, and I need to dump them to stack and modify it. So I write: template S(int n) { const char[] S = "n = " ~ n; } void f() { char[S!(123).length] s = [S!(0).tupleof]; s[0] = 'm'; } The problem is, there is not a 'tupleof' property on array. Should this feature be buildin ?What's wrong with simply void f() { char[S!(123).length] s = S!(0); s[0] = 'm'; }
Oct 16 2007