If I need to define a template foo with a template-template parameter, I usually do the following:
Please note that the template parameter of the template-template parameter is not specified, but we can assign a name to this parameter:
This does not seem useful at all, because I cannot cancel the INNER parameter in a function, the above code causes the following error:
error: "INNER" does not name type
It typename INNER me that typename INNER does not name a type, because the keyword typename exists to indicate a type. Anyway, this is easy to fix:
But in the end, the INNER parameter INNER not need a name after all:
And (of course, you already noticed before me) the name in the template-template parameter is ignored! It was ignored, because if it should not have a name clash with the second parameter of the foo template, right?
Another demonstration of ignoring the template parameter name:
Is the type named T used by the template-template parameter and the template-template itself at the same time? I donโt think that the name in the template is ignored by AFAIK.
So what is the question?
- Am I thinking right? Are parameter names of a named template template parameter template ignored?
- If I am mistaken, and I misunderstood all this, is there a use for the named parameters in the template-template parameters? Can you give some useful examples?
As for the useful examples on # 2, I mean something that could be achieved using the parameters of the named template of the template-template parameters.
c ++ templates template-templates
Paula_plus_plus
source share