Article View: comp.std.c++
Article #1731Re: Why no conversion of string to const char * in STD lib?
From: David Vandevoorde
Date: Wed, 16 Aug 1995 18:53
Date: Wed, 16 Aug 1995 18:53
31 lines
2080 bytes
2080 bytes
>>>>> "OB" == Oren Ben-Kiki <oren@melissa.schema.co.il> writes: In article <MATT.95Aug16093212@physics2.Berkeley.EDU> oren@melissa.schema.co.il (Oren Ben-Kiki) writes: OB> Distribution: Rick Hollinbeck (rickh@csn.net) wrote: : Don & OB> (bashford@toad.scripps.edu) wrote: : : According to Plauger's book OB> on the Draft Standard C++ library, : : there is no "operator const OB> char *" for the string class. : : [snip] OB> : From what I understand, the const char* conversion operator OB> would trigger : too many implicit type conversions in certain OB> situations, leading to many : unpleasant surprises. the c_str() OB> member is a way to control this. (See : Plauger's recent article OB> in the C/C++ Users Journal which discusses this.) OB> But now that we have the 'explicit' keyword, shouldn't this OB> decision be reconsidered? This seems like just the situation for OB> which it was intended. The `explicit' keyword is currently only applicable to constructors, not conversion operators. Do you think: f(static_cast<char*>(s)) is more convenient than: f(s.c_str()) ? Daveed [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<VANDEVOD.95Aug16144504@avs.cs.rpi.edu>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<BASHFORD.95Aug1200815@toad.scripps.edu> <MATT.95Aug13161131@physics2.Berkeley.EDU> <MATT.95Aug16093212@physics2.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: vandevod@cs.rpi.edu (David Vandevoorde) Newsgroups: comp.std.c++ Subject: Re: Why no conversion of string to const char * in STD lib? Date: 16 Aug 1995 18:53:17 GMT Organization: RPI Computer Science Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <VANDEVOD.95Aug16144504@avs.cs.rpi.edu> References: <BASHFORD.95Aug1200815@toad.scripps.edu> <MATT.95Aug13161131@physics2.Berkeley.EDU> <MATT.95Aug16093212@physics2.Berkeley.EDU> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: avs.cs.rpi.edu In-Reply-To: oren@melissa.schema.co.il's message of 16 Aug 1995 16:32:12 GMT Content-Length: 1095 X-Lines: 27 Originator: clamage@taumet