Templated class requires values even though having default value

tcak tcak at gmail.com
Sun May 9 10:53:49 UTC 2021


	public class OpenCLKernel(size_t dim = 1) if( (dim >= 1) && (dim 
<= 3) )
	{
		public this( OpenCLProgram program, in string kernelName )
		{
			// ...
		}
	}

I have a class definition as above. When I want to create an 
instance as below,

	OpenCLKernel k = new OpenCLKernel( program, "kernelName" );

compiler tells me,

	/test2.d(168): Error: template class `OpenCLKernel(ulong dim = 
1) if (dim >= 1 && (dim <= 3))` is used as a type without 
instantiation; to instantiate it use `OpenCLKernel!(arguments)`


The "dim" template parameter has a default value of 1 already. 
Why does it still force me to give a value?

(DMD64 D Compiler v2.096.0)


More information about the Digitalmars-d-learn mailing list