🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3801

Re: no operator bool()?

#3801
From: Pablo Halpern
Date: Mon, 25 Mar 1996 18:19
38 lines
2186 bytes
"Paul D. DeRocco" <pderocco@ix.netcom.com> wrote:

>>      while (bool(cin))
>There's an awful lot of code out there that says "while (cin) ...", and 
>no one wants to rewrite it all just to coax it through the new compiler. 
>That's probably the reason.

Right, but that's not really my point. My point is that allowing the
keyword "explicit" for conversion operators would make a lot of sense.
If the committee ever did want to eliminate implicit conversion from
istream to bool, then they could simply make it explicit. Sure, people
would have to change their code, but at least the change would be
mnemonic and readable. More importantly would be the addition of 

   template <class T> class auto_ptr {
     ...
     explicit operator bool() const;
   };

This would be a clean syntax that would allow

   auto_ptr<foo> x;
   while (bool(x))
     ...

I shouldn't have confused the issue by using cin as my example.
-------------------------------------------------------------
Pablo Halpern                   phalpern@truffle.ultranet.com

I am self-employed. Therefore, my opinions *do* represent 
those of my employer.


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Technical Details
Message-ID: <3156d1c6.8268354@news.ultranet.com>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!usenet
References: <313ddfd9.16044605@sqarc.sq.com> <313E19BB.5AE2E407@cantrip.org> <31445809.5921189@news.ultranet.com> <31470097.36C0@ix.netcom.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!usenet
From: phalpern@truffle.ultranet.com (Pablo Halpern)
Newsgroups: comp.std.c++
Subject: Re: no operator bool()?
Date: 25 Mar 1996 18:19:27 GMT
Organization: UltraNet Communications, Inc.
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <3156d1c6.8268354@news.ultranet.com>
References: <313ddfd9.16044605@sqarc.sq.com> <313E19BB.5AE2E407@cantrip.org> <31445809.5921189@news.ultranet.com> <31470097.36C0@ix.netcom.com>
NNTP-Posting-Host: taumet.eng.sun.com
X-Nntp-Posting-Host: truffle.ultranet.com
X-Newsreader: Forte Agent .99d/16.182
Content-Length: 1127
X-Lines: 31