🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: A couple of questions about strings

#3761
From: J. Kanze
Date: Thu, 21 Mar 1996 19:13
37 lines
2427 bytes
In article <3150756f.168603020@sqarc.sq.com> willer@carolian.com (Steve
Willer) writes:

|> I'm probably beating a dead horse here, but I had a couple of
|> questions about the strings class (at least, the one in the April WP).
|> Specifically, there are two design decisions that I don't understand.

|> a) Why does basic_string::copy() not also copy an ending '\0'? If
|> there's some sort of good reason, why wasn't a function added that did
|> this (perhaps basic_string::copy_null() or something)? I must say, it
|> is very inconvenient to copy a string to a C-style array of chars with
|> the current string class.

Perhaps because it is so easy to write:

	dst[ s.copy( dst , sizeof( dst ) - 1 ) ] = '\0' ;

I'll admit that I don't particularly care for this style: too many side
effects in the indexing expression for readability.  But it does fit in
with the C/C++ tradition.

|> b) I don't see any reason why basic_string::copy() is not a const
|> function. Any particular reason for that one?

In my copy of the draft, it is const.
-- 
James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle --
                            -- Beratung in industrieller Datenverarbeitung
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]
Technical Details
Message-ID: <KANZE.96Mar21165742@gabi.gabi-soft.fr>
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern
References: <3150756f.168603020@sqarc.sq.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern
From: kanze@gabi-soft.fr (J. Kanze)
Newsgroups: comp.std.c++
Subject: Re: A couple of questions about strings
Date: 21 Mar 1996 11:13:00 PST
Organization: GABI Software, Sarl.
Approved: austern@isolde.mti.sgi.com
Message-ID: <KANZE.96Mar21165742@gabi.gabi-soft.fr>
References: <3150756f.168603020@sqarc.sq.com>
NNTP-Posting-Host: isolde.mti.sgi.com
X-Original-Date: 21 Mar 1996 15:57:42 GMT
In-Reply-To: willer@carolian.com's message of 20 Mar 1996 22:11:25 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMVGq40y4NqrwXLNJAQEJpgIAxV0mS0d+Fj1OP3l9HRb5aleAHP6GrxWh
 jjy1CG9MVuM7XD6+IGoyEciXgkzydOMKolXGiD7FSSR9I5b/r5TWcw==
 =k6i/
Originator: austern@isolde.mti.sgi.com