Static Foreach + Marking "compile time" variables

Chris Katko ckatko at gmail.com
Wed Mar 28 17:40:31 UTC 2018


On Wednesday, 28 March 2018 at 17:08:39 UTC, Chris Katko wrote:
> On Wednesday, 28 March 2018 at 15:49:39 UTC, Chris Katko wrote:
>> On Wednesday, 28 March 2018 at 15:46:42 UTC, Chris Katko wrote:
>>> [...]
>>
>> Whoops! Wrong error message. That's if I replace isa(pos) with 
>> IsIntegral.
>>
>> [...]
>
> Okay, the key appears to be here:
>
> funct2(123); //a function call
>
> void funct2(A...)(A a)
> 	{
> 	enum hasRotate = isIntegral!(a[0]); // NOPE!
>         }
>
> //E: template instance isIntegral!(_param_0) does not match 
> template declaration isIntegral(T)
>
> But if I do:
>
> funct2!(123); //note !
>
> I get
>
> //E: tuple A is used as a type


GOT IT!!

I needed typeof on the right side.

template isa(T){enum isa(U) = is(U == T); }

funct2(g.tile_bmp, pos(100,100), scale(2), rotate(0.0f));

void funct2(A...)(ALLEGRO_BITMAP *bit, A a)
	{
	enum hasPosition	= anySatisfy!(isa!(pos), typeof(a));
         }

Works!


More information about the Digitalmars-d-learn mailing list