template evaluation

Alex sascha.orlov at gmail.com
Sat Apr 14 10:53:41 UTC 2018


Ok, trying to reduce my example a little bit, I arrived at this:

´´´
void main(){}

struct D
{
	size_t dummy;
	auto static s = S!D.init;
}

struct S(alias container = null)
{
	pragma(msg, container);
	
	static if(__traits(compiles, __traits(allMembers, container)))
	{
		static foreach(m; __traits(allMembers, container))
		{
			pragma(msg, m);
			
			pragma(msg, is(typeof(__traits(getMember, container, m))));
                         /*
                         for D.dummy this yields "true"
                         for D.s this yields "false"
                         */
		}
	}
}
´´´

What I clearly have, is a circular reference, now I'm aware of 
this.

So, am I trying something illegal? It seems, I can't get the type 
of the according member of the template parameter, even then (or 
should I say "especially because") the analyzing type has the 
same type.
But if this would be the only member, which I can't get the type 
of, the information would be enough, to ensure what I want. Is it 
like this?


More information about the Digitalmars-d-learn mailing list