I get the following compiler¹ message
main.cpp: In instantiation of ‘void fkt(Foo) [with Foo = int]’:
main.cpp:5:7: required from here
The bi
main.cpp: In instantiation of ‘void fkt(Foo) [with Foo = int]’:
main.cpp:5:7: required from here
main.cpp:2:6: warning: unused parameter ‘f’ [-Wunused-parameter]
This is all one warning. You are getting a 3 line warning about an unused parameter. The first two lines are the compiler attempting to help you identify the cause of the warning. Here's an English translation:
In the instantiation of
fkt
with template argumentFoo
asint
which was required by line 5 column 7, you have an unused parameter calledf
.
fkt
is a function template. Templates have to be instantiated with the given template arguments. For example, if you use fkt
, the fkt
function template is instantiated with Foo
as int
. If you use fkt
, the fkt
function template is instantiated with Foo
as float
.
In particular, this first line of this message is telling you that the warning occurs inside fkt
which was instantiated with Foo
as int
. The second line of the warning tells you that instantiation occurred on line 5. That corresponds to this line:
fkt(1);
This is instantiating fkt
with Foo
as int
because the template argument Foo
is being deduced from the type of the argument you're giving. Since you're passing 1
, Foo
is deduced to be int
.