I was under the impression that the function template "template <typename T> void example(T one, T two)" would be called by "example<int,int>(1,3)" |
This is almost correct.
Your example,
template <typename T> void example(T one, T two);
should be called as in the following:
example<int>(1, 3)
Note that you only have one template parameter, T, in your function definition. Even though you *use* T twice in the function prototype, there is only one template variable, which is why you only need to type example<int>, rather than example<int, int>.
If you wanted two template variables, you could make your function prototype look like this:
template <typename T1, typename T2> void example(T1 one, T2 two);
which could be called like this:
example<int, int>(1, 3);
As an extra note, either of those example functions could be called simply with
example(1, 3);
In this particular case, C++ is smart enough to figure out that the arguments you are giving the example function are
ints, so you can omit the template arguments. As soon as you have any ambiguity this will no longer work though.