template instance does not match template declaration

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 7 19:52:12 PST 2017


On Sunday, 8 January 2017 at 03:27:26 UTC, Fabrice Marie wrote:
> Hi,
>
> On my first attempt to create a templated class, I'm hitting an 
> issue that I can't seem to resolve.
>
> I've dustmite'd the code down to:
>
> class Cache(O, K, F)
> {
> }
>
>
> void main()
> {
> 	class BasicObject
> 	{
> 	}
>
> 	BasicObject lookupBasicObject() {
> 	}
>
>         Cache!(BasicObject, string, lookupBasicObject);
> }
>
>
> and I'm hitting the following error:
>
> cache.d(23): Error: template instance Cache!(BasicObject, 
> string, lookupBasicObject) does not match template declaration 
> Cache(O, K, F)
>
> Any help would be much appreciated in understanding what I am 
> doing wrong.
>
> Thanks.
>
> Take care,
> Fabrice.

By default template parameters are Types. lookupBasicObject is 
not.

change this `class Cache(O, K, F)` to `class Cache(O, K, alias F)`
and it should work.



More information about the Digitalmars-d-learn mailing list