template bug?

gedaiu via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 3 09:10:29 PST 2014


Hi,

Is this a bug in the compiler?


import std.stdio;
import std.typetuple;

class A {

	int foo() {
		return 0;
	}
}

class B : A {
	alias A.foo foo;

	override int foo() {
		return 1;
	}

}


template ItemProperty(item, string method) {
	static if(__traits(hasMember, item, method)) {
		static if(__traits(getProtection, ItemProperty!(item, 
method)).stringof[1..$-1] == "public") {
			alias ItemProperty = TypeTuple!(ItemProperty!(item, method));
		} else {
			alias ItemProperty = TypeTuple!();
		}

	} else {
		alias ItemProperty = TypeTuple!();
	}
}

void test()() {

	static if(ItemProperty!(B, "foo").length > 1) {
		writeln("found");
	} else {
		writeln("not found");
	}
}


void main()
{
	
	test;

	
}


More information about the Digitalmars-d-learn mailing list