T
Travis Vitek
Can someone explain why the compiler is unable to deduce T when
invoking the function template `f' in the example below? Is there some
way to get the compiler to see `f' without having to explicitly
specify the template argument type?
template <class T>
struct A {
enum B {
};
};
template <class T>
void f(typename A<T>::B a)
{
}
int main ()
{
A<int>::B a0 = A<int>::B();
f(a0); // don't want to explicitly specify f<int>(a0) here
}
I have been able to move the definition of `f' into A to get the
results I want, but I'd like to declare/define the function outside of
A if possible. Is there something wrong with my declaration of `f', or
is there some other way to do what I want?
Travis
invoking the function template `f' in the example below? Is there some
way to get the compiler to see `f' without having to explicitly
specify the template argument type?
template <class T>
struct A {
enum B {
};
};
template <class T>
void f(typename A<T>::B a)
{
}
int main ()
{
A<int>::B a0 = A<int>::B();
f(a0); // don't want to explicitly specify f<int>(a0) here
}
I have been able to move the definition of `f' into A to get the
results I want, but I'd like to declare/define the function outside of
A if possible. Is there something wrong with my declaration of `f', or
is there some other way to do what I want?
Travis