Compare types with `static if` in template function.

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 29 15:40:07 PDT 2015


On 07/29/2015 11:54 AM, vladde wrote:
> 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/source/clayers.d
>

You seem to be using type names instead of member names:

             static if(is(typeof(c) == dchar) || is(typeof(c) == char))
             {
                 slots[xy.y][xy.x].character = c;
             }
             else if(is(typeof(c) == fg))
             {
                 slots[xy.y][xy.x].fg = c;

Should be

... color = c;

             }
             else if(is(typeof(c) == bg))
             {
                 slots[xy.y][xy.x].bg = c;

... background = c;

             }
             else if(is(typeof(c) == md))
             {
                 slots[xy.y][xy.x].md = c;

... mode = c;

             }

Ali



More information about the Digitalmars-d-learn mailing list