Re: Does std::map provides a copy assignment operator?
- From: Tom Widmer <tom_usenet@xxxxxxxxxxx>
- Date: Mon, 18 Apr 2005 15:40:39 +0100
Hashim Saleem wrote:
[SNIP]"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. :)
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 .
- Follow-Ups:
- Re: Does std::map provides a copy assignment operator?
- From: Hashim Saleem
- Re: Does std::map provides a copy assignment operator?
- References:
- Does std::map provides a copy assignment operator?
- From: Hashim Saleem
- Re: Does std::map provides a copy assignment operator?
- From: Stephen Howe
- Re: Does std::map provides a copy assignment operator?
- From: Hashim Saleem
- Does std::map provides a copy assignment operator?
- Prev by Date: Re: Does std::map provides a copy assignment operator?
- Next by Date: Re: Does std::map provides a copy assignment operator?
- Previous by thread: Re: Does std::map provides a copy assignment operator?
- Next by thread: Re: Does std::map provides a copy assignment operator?
- Index(es):
Relevant Pages
|