L. Spiro posted this in another thread: http://www.artima.com/cppsource/bigtwo3.html
I find the concept fascinating, but I have a some questions about two of the RAII class member functions.
1.) What does the reset function do? What I see happening is it deleting the member pointer and then assigning the pointer passed into the function to the deleted pointer. How does that work? Is that legal C++?
2.) What purpose is there for the swap function? Apart from sorting pointers, is there any other reason for its existence?
Question about an example of The Rule of Two.
For implementing the copy and swap idiom for assignment? See the top reply to this question:
http://stackoverflow.com/questions/3279543/what-is-the-copy-and-swap-idiom
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement