G
g18c
Hi, i am trying to overload a function with a number of specific
template functions without much sucess.
template<typename T> void TmplFunc(T& t)
{
}
template<typename T> void TmplFunc(list<T>& t)
{
list<T>::const_iterator fi = t.begin();
}
void main()
{
list<int> myList;
TmplFunc(myList);
}
On compilation i get an error saying none of the two overloads have a
best conversion. I appreciate for "void TmplFunc(T& t)" T could also be
a list... is there any way i can have the "void TmplFunc(list<T>& t)"
get called without resorting to calling the specific template with
"TmplFunc<list<int> >(myList)"? Or even better, i would like a template
function that can deal with any container object which has iterators!
Thanks in advance,
Chris
template functions without much sucess.
template<typename T> void TmplFunc(T& t)
{
}
template<typename T> void TmplFunc(list<T>& t)
{
list<T>::const_iterator fi = t.begin();
}
void main()
{
list<int> myList;
TmplFunc(myList);
}
On compilation i get an error saying none of the two overloads have a
best conversion. I appreciate for "void TmplFunc(T& t)" T could also be
a list... is there any way i can have the "void TmplFunc(list<T>& t)"
get called without resorting to calling the specific template with
"TmplFunc<list<int> >(myList)"? Or even better, i would like a template
function that can deal with any container object which has iterators!
Thanks in advance,
Chris