Compare types with `static if` in template function.

Vladde Nordholm via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 30 06:14:18 PDT 2015


On Wednesday, 29 July 2015 at 22:40:08 UTC, Ali Çehreli wrote:
> 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

Thank you! This was a mistake on my end. Really glad you spotted 
it, saved me quite some headaches!


More information about the Digitalmars-d-learn mailing list