Consider the following code:
template < typename T >
struct A
{
struct B { };
};
template < typename T >
void f( typename A::B ) {
Following up on the question in the "Update", here is a situation in which the call to f
would be ambiguous (if it were allowed, that is):
// Definitions of generic "struct A", as well as "f()", are the same as above
// But additionally, consider a specialized "struct A", defined as follows:
template <>
struct A
{
typedef A::B B;
}
// Now consider the call to "f", similarly to before:
int main()
{
// Possibility 1 for argument to "f()"
// A::B x;
// Possibility 2 for argument to "f()": Use the specialized version of "struct A"
A::B x;
f(x); // which value to deduce for type T? Could be "int" or "double"
}
Notice the ambiguous pair of potential instantiated functions f
: Both f
and f
would result in a successfull call to f()
.