Re: Does std::map provides a copy assignment operator?



Hashim Saleem wrote:
"Stephen Howe" wrote:

So far Hashim, we have not seen any code of yours.


So, here it is just for you guys. Actually, I cant post the source code as the policy of my company where I am doing job. I ll try to explain what I am doing by posting the code chunks. Hope these chunks would be enough to clear my situation here. :)
[SNIP]
Does your default constructor set m_pCert to NULL? What happens if CERT_DupCertificate fails? And are you sure it is correctly implemented?


Also, have you come across this style of operator== implementation:

A& operator=(A a) //parameter passed by value to create copy
{
  a.swap(*this);
  return *this; //a's destructor frees old members.
}

All you need to do is implement a swap function, and no need to check for self-assignment. And it is exception-safe, unlike your version.

Tom
.