Example: Assuming f to be a template function, having two arguments:
f (1, 2) In this call, does the template function assume that its arguments are int, or short, or anything else?
EDIT 1:
The template function declaration:
template <typename dataTypeA, typename dataTypeB> dataTypeB functionX (dataTypeA argA, dataTypeB argB)
As @David already said, as far as your question is concerned, there’s no such thing as “making assumptions”. The literals simply have types, which are the types that a function template may use for type deduction. Remember that conversions considered as part of the template matching, though!
So, let’s say you have this function template:
Then if you call
foo(1, 2), this will be called withT = int.If you say
foo(1u, 2u), the deduction isT = unsigned int.If you say anything mixed like
foo(1u, 2), there is no preferred match and the compiler will report an error.Since there is no
shortliteral in C or C++, if you want to explicitly call the functionfoo<short>, you can either say so, or create temporary explicitshortarguments:Update: In light of your edit, note that since you’re only matching one argument per template parameter, you won’t have any trouble with ambiguous matching.