C
cindypwl
I was looking at some code in the MS NG, and I saw this code listed.
template <class T>class List{};
template<class T>
bool MySortFunc(List<T>& list){return true;}
template <class T>struct SORT{typedef bool (*FnPtr)(List<T>& list);};
int main(){
List<int> MyList;
List<long> MyList2;
SORT<int>::FnPtr Sort = &MySortFunc; //***No template type!!!!!!!
Sort(MyList);
I would think that the function pointer assignment would not compile
with out using the templae type.
SORT<int>::FnPtr Sort = &MySortFunc<int>;
But I was able to compile this with out the type on both VC++ and
Comeau.
So is this code legal, or are the compilers wrong to compile it
successfully?
template <class T>class List{};
template<class T>
bool MySortFunc(List<T>& list){return true;}
template <class T>struct SORT{typedef bool (*FnPtr)(List<T>& list);};
int main(){
List<int> MyList;
List<long> MyList2;
SORT<int>::FnPtr Sort = &MySortFunc; //***No template type!!!!!!!
Sort(MyList);
I would think that the function pointer assignment would not compile
with out using the templae type.
SORT<int>::FnPtr Sort = &MySortFunc<int>;
But I was able to compile this with out the type on both VC++ and
Comeau.
So is this code legal, or are the compilers wrong to compile it
successfully?