Click here to Skip to main content
15,921,454 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: using swap to make assignment operator exception safe Pin
George_George8-Jan-08 3:18
George_George8-Jan-08 3:18 
GeneralRe: using swap to make assignment operator exception safe Pin
CPallini8-Jan-08 3:30
mveCPallini8-Jan-08 3:30 
GeneralRe: using swap to make assignment operator exception safe Pin
George_George8-Jan-08 3:33
George_George8-Jan-08 3:33 
GeneralYou're welcome Pin
CPallini8-Jan-08 3:36
mveCPallini8-Jan-08 3:36 
GeneralRe: using swap to make assignment operator exception safe Pin
toxcct8-Jan-08 2:03
toxcct8-Jan-08 2:03 
GeneralRe: using swap to make assignment operator exception safe Pin
CPallini8-Jan-08 2:12
mveCPallini8-Jan-08 2:12 
GeneralRe: using swap to make assignment operator exception safe Pin
toxcct8-Jan-08 2:17
toxcct8-Jan-08 2:17 
GeneralRe: using swap to make assignment operator exception safe Pin
CPallini8-Jan-08 2:29
mveCPallini8-Jan-08 2:29 
toxcct wrote:
that's how swap is normally designed.

The above I was suggesting: hence no need to create a temporary assignment before it.


toxcct wrote:
however, there's a lack in this design, because having a A::operator=() calling a A::swap() function, which itself calls A::operator=() 3 more times is recursive for sure, with no possibility to stop the loop.

so I think swap is not coded like this in B. Stroustrup's example...


I agree that there is recursion in the sample code (after all I was the first pointing out it...) and I was not suggesting to take that code as it stands, suppose, for instance, that method name was foo, instead of operator==.

BTW I think that swap should rely on the assignment operator and not the opposite (but I've not Stroustrup's example, that of course I suppose correct, at hand, I think George is not a diligent poster recently... Big Grin | :-D )

Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

[my articles]


GeneralRe: using swap to make assignment operator exception safe Pin
George_George8-Jan-08 3:15
George_George8-Jan-08 3:15 
GeneralRe: using swap to make assignment operator exception safe Pin
CPallini8-Jan-08 3:21
mveCPallini8-Jan-08 3:21 
GeneralRe: using swap to make assignment operator exception safe Pin
George_George8-Jan-08 3:27
George_George8-Jan-08 3:27 
GeneralRe: using swap to make assignment operator exception safe Pin
toxcct8-Jan-08 3:35
toxcct8-Jan-08 3:35 
GeneralRe: using swap to make assignment operator exception safe Pin
George_George8-Jan-08 3:40
George_George8-Jan-08 3:40 
JokeRe: using swap to make assignment operator exception safe Pin
CPallini8-Jan-08 3:54
mveCPallini8-Jan-08 3:54 
GeneralRe: using swap to make assignment operator exception safe Pin
George_George8-Jan-08 3:06
George_George8-Jan-08 3:06 
GeneralRe: using swap to make assignment operator exception safe Pin
George_George8-Jan-08 3:16
George_George8-Jan-08 3:16 
GeneralRe: using swap to make assignment operator exception safe Pin
George_George8-Jan-08 2:33
George_George8-Jan-08 2:33 
GeneralRe: using swap to make assignment operator exception safe Pin
George_George8-Jan-08 2:30
George_George8-Jan-08 2:30 
GeneralRe: using swap to make assignment operator exception safe Pin
toxcct8-Jan-08 2:37
toxcct8-Jan-08 2:37 
GeneralRe: using swap to make assignment operator exception safe Pin
George_George8-Jan-08 3:13
George_George8-Jan-08 3:13 
GeneralStrange error ! Pin
CrocodileBuck8-Jan-08 0:26
CrocodileBuck8-Jan-08 0:26 
GeneralRe: Strange error ! Pin
CPallini8-Jan-08 0:39
mveCPallini8-Jan-08 0:39 
GeneralRe: Strange error ! Pin
CrocodileBuck8-Jan-08 0:54
CrocodileBuck8-Jan-08 0:54 
GeneralYou're welcome Pin
CPallini8-Jan-08 1:50
mveCPallini8-Jan-08 1:50 
GeneralRe: Strange error ! Pin
Matthew Faithfull8-Jan-08 0:49
Matthew Faithfull8-Jan-08 0:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.