Article View: comp.std.c++
Article #2419Re: Inconsistent use of default arguments in string class?
From: Bob Manson
Date: Fri, 03 Nov 1995 19:12
Date: Fri, 03 Nov 1995 19:12
31 lines
2210 bytes
2210 bytes
In article <HARALD.95Nov1105205@moon.bion.kth.se>, Harald Winroth <harald@bion.kth.se> wrote: >I have a question regarding the proposed string class. In the April WP [...text deleted] >would append "123" to str. Is that interpretation correct? If so, I think It is that way in Plauger's "The Draft Standard C++ Library", and I'm pretty sure it's one of the things that didn't change in the April draft. Speaking as someone that's written an implementation of (and uses pretty heavily) this string class interface, it hasn't been an issue at all. I think it's because that all of the functions that take char* work in a similar fashion, and it's simple enough (and perhaps a bit more obvious code-wise) to add the offset to the char* pointer if that's what is desired. (Admittedly it seemed a little disturbing when I was initially implementing it, but it just hasn't been a problem in actual use.) But I would like to argue for removing the position offset from append/assign/insert etc. The same thing can be accomplished with using substr(), and for a reasonably efficient implementation there would only be a little extra overhead--not to mention that it makes the resulting code more readable. The reasoning for the current design may have been that since the offset case is efficient for char*, it should be equally efficient for instances of string as well. Bob --- [ 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:
<47dgb5$1bb@charm.magnus.acs.ohio-state.edu>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<HARALD.95Nov1105205@moon.bion.kth.se>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 03 Nov 95 19:12:04 GMT Approved: fjh@cs.mu.oz.au From: manson@magnus.acs.ohio-state.edu (Bob Manson) Newsgroups: comp.std.c++ Subject: Re: Inconsistent use of default arguments in string class? X-Original-Date: 3 Nov 1995 16:34:45 GMT Organization: The Ohio State University Message-ID: <47dgb5$1bb@charm.magnus.acs.ohio-state.edu> References: <HARALD.95Nov1105205@moon.bion.kth.se> X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMJppqeEDnX0m9pzZAQEeywGAgvGdmGuebj6FccOL6Yazc46NxIwWPicx GFvmpD6c6AeKhfQVF37fnQKG1GxyWBwe =oVzZ