Tempated class instantiation

grauzone none at example.net
Wed Dec 16 11:22:08 PST 2009


Mike L. wrote:
> I'm making a class template that only works with strings, so I thought it'd be good to instantiate each template with char, wchar, and dchar right in the template's module so that when it's compiled it'll be part of the .obj file and won't have to compile it for every other project that uses it. However, I get an error reproducible with this:
> 
> module test;
> 
> class A(T)
> {
> 	version(broken)
> 	{
> 		class B
> 		{
> 			T blah() { return t; }
> 		}
> 	}
> 	
> 	T t;
> }
> 
> mixin A!(int);
> 
> int main()
> {
> 	A!(int) a = new A!(int)();
> 	return 0;
> }
> 
> If what I want to do makes sense, how should I be doing it?

AFAIK it works if you do

alias B!(int) Something;

If you want to get the above code to work, use template A(T) instead of 
class A(T) + mixin.


More information about the Digitalmars-d-learn mailing list