🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: no operator bool()?

#3690
From: Rich Paul
Date: Sat, 16 Mar 1996 07:38
44 lines
2287 bytes
Pablo Halpern wrote:
> 
> "Nathan Myers, http://www.cantrip.org/" <ncm@cantrip.org> wrote:
> 
> >Automatic conversions can be a problem in general, but the problems
> >with automatic conversions to a numeric type are ridiculous.
> >Compatibility with C has its downside.
> >
> >As a side note...  The problem with automatic conversions is not
> >only that the conversion may be called unexpectedly; the
> >possibility of the conversion affects overloading, so it may
> >force you to add "unnecessary" casts to guide the compiler to
> >the correct choice of function to call.
> 
> Sounds like another reason to permit the keyword "explicit" to apply to
> conversion operators. I really don't see why the committee is so
> resistant to this concept. I think the following would be a perfectly
> satisfactory usage:
> 
>    class istream : public ...
>    {
>      ...
>      explicit operator bool() const;
>      ...
>    };
> 
>    void f()
>    {
>      while (bool(cin))
>        // do something
>    }
> 
> Its clear. Its easy to remember. Its clean. Same would work for
> auto_ptr<>.
> 

I'd agree with that.  An explicit cast from a string to a <charT> * would be 
nice as well ... much cleaner than c_str() and data().
---
[ 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: <31498AE5.2CA3@trcinc.com>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <313ddfd9.16044605@sqarc.sq.com> <313E19BB.5AE2E407@cantrip.org> <31445809.5921189@news.ultranet.com>

Show Full Headers
Complete Article Headers
From: Rich Paul <rpaul@trcinc.com>
Message-ID: <31498AE5.2CA3@trcinc.com>
X-Original-Date: Fri, 15 Mar 1996 10:21:09 -0500
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 16 Mar 96 07:38:47 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Subject: Re: no operator bool()?
Organization: Technical Resource Connection
References: <313ddfd9.16044605@sqarc.sq.com> <313E19BB.5AE2E407@cantrip.org> <31445809.5921189@news.ultranet.com>
X-Mailer: Mozilla 2.0 (WinNT; I)
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMUpwEuEDnX0m9pzZAQEW7gF/R/UjJMwYU+6Q96HVT3rJxGJNPfhHRrWi
 32s8j2GHawiEOqdJT5bUFwEwap5ofpGJ
 =aLUA