ta**********@yahoo.com (Gina Yarmel) wrote in message
news:<e4**************************@posting.google. com>...
The foolowing error is mysterious to me. Isn't a typedef just a
synonym?
template<typename T>
typename T::me some_func(typename T::me A) {
return A;
}
template<typename T>
typename T::me other_func(T A) {
return A;
}
class some_class {
public:
typedef some_class me;
};
int main() {
some_class some_obj;
//ERROR:
//some_func(some_obj);
other_func(some_obj);
}
My VC6 fails with reasonable error: could not deduce template argument
for 'T'.
Typedef doesnt introduce a new type. But what you could do if you were
a c++ compiler? You have a template function call and you need to
identify the template argument in order to instantiate the function.
You are said: T::me is some_class, but nobody could tell you who is
mister T himself.
For example, we may have:
class some_class {
public:
typedef some_class me;
};
class other_class {
public:
typedef some_class me;
};
....
some_class some_obj;
some_func(some_obj); // ???? both some_class and other_class have
"me"
// of "some_class" type
For this reason you should explicitly tell the compiler which function
instance you want to use:
some_func<some_class> (some_obj); // OK!
[ See
http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]