cannot implicitly convert char[] to string

2015-08-15 Thread vladde via Digitalmars-d-learn
I made a PR to phobos where I modified `std.format.format`. https://github.com/D-Programming-Language/phobos/pull/3528 However the auto builder fails, with the error message: runnable/test23.d(1219): Error: cannot implicitly convert expression (format("s = %s", s)) of type char[] to string Th

Re: Compare types with `static if` in template function.

2015-07-29 Thread vladde via Digitalmars-d-learn
On Wednesday, 29 July 2015 at 18:14:11 UTC, Ali Çehreli wrote: else if(is(typeof(c) == fg)) { // slots[xy.y][xy.x].fg = C; } The error occurs when the commented line is run. The full code can be viewed at https://github.com/vladdeSV/clayers/blob/change-slot

Re: Compare types with `static if` in template function.

2015-07-29 Thread vladde via Digitalmars-d-learn
On Wednesday, 29 July 2015 at 18:04:48 UTC, vladde wrote: Apparently, if I only check for a character the code compiles without the need of static if. if(is(typeof(c) == dchar) || is(typeof(c) == char)){ slots[xy.y][xy.x].character = c; } //Compiles and works as expected And changing all if

Re: Compare types with `static if` in template function.

2015-07-29 Thread vladde via Digitalmars-d-learn
On Wednesday, 29 July 2015 at 17:52:45 UTC, Ali Çehreli wrote: On 07/29/2015 10:48 AM, vladde wrote: > static if(is(typeof(c) == dchar) || is(typeof(c) == char)) > { > slots[xy.y][xy.x].character = c; > } > else if(is(typeof(c) == fg)) I don't kn

Compare types with `static if` in template function.

2015-07-29 Thread vladde via Digitalmars-d-learn
I want to have a template function where I can throw in some stuff in the parameters, then run foreach+static ifs and check what type the current is. From my project clayers[1], I've taken out some parts. (Note the current code does not compile.) This is what I have so far: struct XY {size_t

Re: Multi-dimensional fixed arrays

2015-06-30 Thread vladde via Digitalmars-d-learn
Oh, seems I should learn to refresh the page :)

Re: Multi-dimensional fixed arrays

2015-06-30 Thread vladde via Digitalmars-d-learn
I am pretty surprised, as the following code gives errors. void main(){ int [1][2] foo; foo[0][0] = 1; foo[0][1] = 2; foo[1][0] = 3; foo[1][1] = 4; } Those errors are: app.d(5): Error: array index 1 is out of bounds foo[0][0 .. 1] app.d(7): Error: array index 1 is out of bound