how to use stl in a MFc application?
ar didn't overload << and >> for vector ,list ,map,and so on, and these didn't inherit from Cobject, so no the virtual function Serialize, can't use the
CTypedPtrlist.serialize(ar) to write and read ,and so on,so we lost the ways of MFC's writing and read,if we use stl in a MFC application?
how can do this ?
I know MFC macro max,min need be hidden if use stl.
Re: how to use stl in a MFc application?
first of all, don't use MFC serialization, but if you are going to then just write some functions
Code:
template<typename T>
CArchive& STORE_VECTOR(CArchive& ar, const std::vector<T>& t_vector)
{
ar << to_store.size();
for(std::vector<T>::size_type i = 0; i < t_vector.size(); i++
ar << t_vector[i];
return ar;
}
template<typename T>
CArchive& LOAD_VECTOR(CArchive& ar, std::vector<T>& t_vector)
{
std::vector<T>::size_type size(0);
ar >> size;
t_vector.resize(size);
for(std::vector<T>::size_type i = 0; i < t_vector.size(); i++
ar >> t_vector[i];
return ar;
}
Re: how to use stl in a MFc application?
Quote:
Originally Posted by souldog
first of all, don't use MFC serialization, but if you are going to then just write some functions
Code:
template<typename T>
CArchive& STORE_VECTOR(CArchive& ar, const std::vector<T>& t_vector)
{
ar << to_store.size();
for(std::vector<T>::size_type i = 0; i < t_vector.size(); i++
ar << t_vector[i];
return ar;
}
template<typename T>
CArchive& LOAD_VECTOR(CArchive& ar, std::vector<T>& t_vector)
{
std::vector<T>::size_type size(0);
ar >> size;
t_vector.resize(size);
for(std::vector<T>::size_type i = 0; i < t_vector.size(); i++
ar >> t_vector[i];
return ar;
}
thanks!!
Re: how to use stl in a MFc application?
Quote:
Originally Posted by souldog
first of all, don't use MFC serialization
This means MFC serialization is a bad structure? So MFC lost many feathers.
How I understand this word?
Can tell me more about MFC's serialization, how to use it, when don't use it, why we don't use it? 3x!!