+ 1
Template specialisation error
I am trying to specialize a template for void, but I keep getting the error: template-id does not match any template declaration, how can I fix it? https://code.sololearn.com/c6fK2GLbOdLq/?ref=app
4 Antworten
+ 6
Due to the 'template<>' on line 45, the compiler thinks you are referring to a template function 'processOwnPointer'. Removing the 'template<>' fixes the problem and the compiler is able to identify the method.
https://code.sololearn.com/cmfI0LEOU8xu/?ref=app
The problem that now arises is that you have already specified
Widget<void>::processOwnPointer
as 'not deleted' on line 33. So now you can't assign it as deleted now.
You could remove the specialization of Widget<void> on line 27, which would fix this problem. But that would lead to another error when Widget<void> is instantiated on line 65, because you would be using 'new' with a 'void*'
https://code.sololearn.com/cIs1Ap5e2mL8/?ref=app
Only way to have no error is to assign Widget<void>::processOwnPointer as deleted inside the Widget<void> specialization
https://code.sololearn.com/cnh48CX7gPC0/?ref=app
+ 3
I can't click the link in your post. Is it a link to your code (because I don't recognize the URI)? If it is, can you post it in a comment since maybe it will be clickable from there, or post a different link to it?
+ 2
XXX Thank you! So that’s how it works for deleted functions in template specializations, Scott Meyers didn’t discuss that, so I was scratching my head for days on this. Thanks again!
0
XXX, yeah sorry about that! I just updated it