Compare AliasSeq isn't working

Chris Katko ckatko at gmail.com
Wed Mar 28 06:11:01 UTC 2018


I'm trying this idea for an API style it's... not quite working. 
The part I'm failing at currently is actually classifying types 
passed in.

I want this to occur at compile time.

void funct(A...)(A a)
	{
	static if (a.length)
		{
		writeln(a[0]); //first is "pos(100,100)"
		static if(
			is(a[0] == pos) //<---never matches
			)
			{
			writeln(a[0].x); //works, as "pos.x"
			writeln(a[0].y);
			}
		
                 static if (a.length > 1)
                      funct(a[1 .. $]);
		}
	}

struct pos { float x, y; }
struct scale { float f; }
struct rotate { float a; }

void test_inst()
	{
	funct(pos(100,100), scale(2), rotate(0.0f));
	}


I've tried all kinds of variations of test conditions. I've tried 
wrapping the right side in an AliasSeq. I've tried quotation 
marks. I've tried other stuff. I can't find any applicable posts 
or examples online.

All I want to do is (at this point anyway):

   - Pass a variable number of arguments (works), match them 
(FAIL), and read their interal values. (works)

At compile time.

Thanks.


More information about the Digitalmars-d-learn mailing list