From -4461156351853133937
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,515fa24b8aaed57
X-Google-Attributes: gidf78e5,public
From: michaelt@asymetrix.com (Michael Taylor)
Subject: Re: Example in "The C++ Workbook" by Wiener and Pinson
Date: 1995/08/04
Message-ID: <3vtat5INNovr@hubble.asymetrix.com>#1/1
X-Deja-AN: 107568716
distribution: world
references: <3ujj8d$o4m@scapa.cs.ualberta.ca> <9520904.20199@mulga.cs.mu.OZ.AU>
organization: Asymetrix, Inc.
newsgroups: comp.std.c++

fenster@shadow.cs.columbia.edu (Sam Fenster) wrote:
>a2675528@athena.rrz.Uni-Koeln.DE (Paul Sponagl) writes:
>> or do like that
>>
>> 	inline template < class T > void swap(T& a, T& b)
>> 	{
>> 		a ^=b; b^=a;a ^=b;
>> 	}
>
>This sets `a' and `b' to zero if they refer to the same object.

Wrong!

Let a = 1001110
and b = 1001110

a ^= b; // -> a = 0
b ^= a; // -> b = 1001110
a ^= b; // -> a = 1001110


          Michael Taylor
	    michaelt@asymetrix.com



