Original Post
I''m having a bit of trouble writing a templated function for my serialization, the vector one looks like
template < class Type, class Alloc >
inline CArchive & operator << (CArchive & Arc, std::list < Type, Alloc > & List)
{
int Size = List.size();
Arc << Size;
if(Arc.m_Mode & ArcStoring)
{
for(std::list < Type, Alloc >::iterator i = List.begin(); i != List.end(); ++i)
Arc << (*i);
}
else
{
List.clear();
Type temp;
for(int i = 0; i < Size; ++i)
{
Arc << temp;
List.push_back(temp);
}
}
return Arc;
}
this works great if Type isn''t a pointer. however, my operator << for pointers requires that it be null before passing it in (if its not, it assumes it points to something and calls a Release() function on it). so, basically I need to say Type temp = NULL, but only when its a pointer. I was thinking about some kind of specialization (I''m not sure how to do this though, I''m a template newbie), but I know MSVC6 has problems with template specialization. How do I solve this problem?