TIP: Click on subject to list as thread! ANSI
echo: nthelp
to: Geo
from: Paul Ranson
date: 2004-11-21 23:13:04
subject: Re: C++ for beginners?

From: "Paul Ranson" 

IIRC the '^' operator is 'xor'. I suspect it boils down to,

x = x ^ y ;
y = y ^ x ;
x = x ^ y ;

therefore it resolves to y = y ^ x ^ y ; or x and x = x ^ y ^ y ^ x ^ y ;
or y. Probably not going to work for strings or floats. And I suspect real
computers and real compilers will run a conventional swap at least as fast.

BTW STL includes 'swap' as a template, use it...

Paul

"Geo"  wrote in message
news:41a10f7e$2{at}w3.nls.net...
> "Tony Williams"  wrote in message
> news:41a10437$1{at}w3.nls.net...
>
>>      x ^= y ^= x ^= y;
>
>
>> There, that's much harder to understand 
>
> Ok now explain what ^= does.
>
> Geo.
>
>

--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)
SEEN-BY: 633/267 270 5030/786
@PATH: 379/45 1 396/45 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.