Article View: comp.std.c++
Article #1786Re: Why no conversion of string to const char * in STD lib?
From: Herb Sutter
Date: Tue, 15 Aug 1995 03:04
Date: Tue, 15 Aug 1995 03:04
25 lines
1806 bytes
1806 bytes
In article <MATT.95Aug13161131@physics2.Berkeley.EDU>, rickh@csn.net (Rick Hollinbeck) wrote: >Don & (bashford@toad.scripps.edu) wrote: >: According to Plauger's book on the Draft Standard C++ library, >: there is no "operator const char *" for the string class. <snip> >: Is there any compelling reason for not having the conversion >: to const char* as part of the standard? > >>From what I understand, the const char* conversion operator would trigger >too many implicit type conversions in certain situations, leading to many >unpleasant surprises. the c_str() member is a way to control this. (See >Plauger's recent article in the C/C++ Users Journal which discusses this.) Implicit conversions are indeed the major bugaboo. See also Scott Meyers' article in the August CUJ. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Herb Sutter 2228 Urwin, Ste 102 voice (416) 618-0184 Connected Object Solutions Oakville ON Canada L6L 2T2 fax (905) 847-6019 --- [ 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:
<40oe0v$jgb@steel.interlog.com>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backReferences:
<BASHFORD.95Aug1200815@toad.scripps.edu> <MATT.95Aug13161131@physics2.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back Date: 15 Aug 95 03:04:31 GMT Approved: fjh@cs.mu.oz.au Return-Path: <daemon@ncar.UCAR.EDU> From: herbs@interlog.com (Herb Sutter) Newsgroups: comp.std.c++ Subject: Re: Why no conversion of string to const char * in STD lib? X-Original-Date: Mon, 14 Aug 95 21:13:20 GMT Organization: Daystar Software Systems Design Inc. Message-ID: <40oe0v$jgb@steel.interlog.com> References: <BASHFORD.95Aug1200815@toad.scripps.edu> <MATT.95Aug13161131@physics2.Berkeley.EDU> X-Newsreader: News Xpress Version 1.0 Beta #3