Some help on Mixin Template at Class level.

Matthew Ong ongbp at yahoo.com
Sat May 21 01:54:54 PDT 2011


Hi,

As the documentation at D ONLY shows template at functions level and 
also ONLY the content of a class but without the definition of a class.
Could this code be working? Or did I miss out some syntax.

mixin template AType(alias T, U, alias V){
class T : ClassC { // Class level Template
private:
     U value;
public:
     this(){}
     void print(){}
         mixin V;
} // End Class
}

class ClassC {}

mixin template btype() {
     void someFunction() {}; // Content of a class.

}

mixin AType!("ClassB", string, btype);

void main() {
     ClassC r = new ClassB();
}


--------  Build Commands:  --------
-od"bin"
-of"bin\TestTemplate.exe"

-I"src"

"src\Sample.d"

src\Sample.d(20): Error: undefined identifier ClassB, did you mean class 
ClassC?
src\Sample.d(20): Error: ClassB is used as a type

Thanks very much for helping out.

-- 
Matthew Ong
email: ongbp at yahoo.com



More information about the Digitalmars-d-learn mailing list