Thread View: comp.std.c++
2 messages
2 total messages
Started by Steve Willer
Wed, 20 Mar 1996 22:11
A couple of questions about strings
Author: Steve Willer
Date: Wed, 20 Mar 1996 22:11
Date: Wed, 20 Mar 1996 22:11
20 lines
1515 bytes
1515 bytes
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. b) I don't see any reason why basic_string::copy() is not a const function. Any particular reason for that one? [ 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 ]
Re: A couple of questions about strings
Author: J. Kanze
Date: Thu, 21 Mar 1996 19:13
Date: Thu, 21 Mar 1996 19:13
37 lines
2427 bytes
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
]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads