From kde-devel Sun May 29 15:25:50 2005 From: Nicos Gollan Date: Sun, 29 May 2005 15:25:50 +0000 To: kde-devel Subject: Re: Use true/false or TRUE/FALSE in KDE C++ programs? Message-Id: <200505291725.54771.gtdev () spearhead ! de> X-MARC-Message: https://marc.info/?l=kde-devel&m=111738038911259 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============0281099159==" --===============0281099159== Content-Type: multipart/signed; boundary="nextPart15740721.mEMfZcRY52"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart15740721.mEMfZcRY52 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Sunday May 29 2005 16:02, Richard Dale wrote: > On Sunday 29 May 2005 16:48, Andr=E9 W=F6bbeking wrote: > > On Sunday 29 May 2005 15:36, Richard Dale wrote: > > > I hate code which type puns ints into booleans such as: > > > > > > if !strcmp("mything", "myotherthing') { > > > ..other difficult to read crap code > > > } > > > > this is a bad example as strcmp() returns a tristate: less, equal or > > greater but I know what you mean. > > Well, it's a good example because it's so bad.. :) You could write a very short, trivial wrapper to map strcmp's output to an= =20 enumeration, so that it better suits your needs. However, with the string=20 class in standard C++, you don't need that stuff anyway in most cases. You= =20 can just write it straightforward, thanks to overloaded operators: #include #include using namespace std; int main( void ) { string a( "Hello, world!" ); if( a =3D=3D "Hello, world!" ) cout << "pass." << endl; exit(0); } =2D-=20 Got Backup? Jabber: Shadowdancer at jabber.fsinf.de --nextPart15740721.mEMfZcRY52 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQBCmd8C9vaiE9zi/vERArjoAKC7JOO7UPrnoDnQwK6AAvAiTMT2AACdGue+ uatI2Hmc8v1H29kHXPwPo5E= =DRrv -----END PGP SIGNATURE----- --nextPart15740721.mEMfZcRY52-- --===============0281099159== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << --===============0281099159==--