Article View: comp.std.c++
Article #3054Re: STL still in standard
From: Cay S. Horstmann
Date: Sun, 21 Jan 1996 23:03
Date: Sun, 21 Jan 1996 23:03
49 lines
3042 bytes
3042 bytes
James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> wrote: >Safer implementations are possible; Cay Horstman, I think, has already >made one available. Indeed. It works nicely as a debugging tool, and is 100% compatible with plain STL. Think of it as an "assert" for STL. It is available from http://www.mathcs.sjsu.edu/faculty/horstman/safestl.html. A number of people at NYU have ported it to g++. If there is interest, I'll find out how far they got. >Exception safe implementations are also possible. >(It is also an open question how far one wants to go here. I would >accept, for example, that an exception from the comparison function >when inserting into a map results in undefined behavior; if comparison >can throw an exception, an STL map is perhaps not the appropriate >container.) I am not sure exceptions are the way to go--the great value of a standard is that it is, well, standard. STL may not be the greatest library on the planet, but it is certainly good enough, and it is standard. I don't like the idea of tinkering with the interface by adding exceptions. My model here is the C string.h library. Consider strncpy. Could you imagine a dumber function? If either of the arguments is null, it dumps core. 99% of strncpy uses in my programs are of the form strncpy(buffer, s, sizeof(buffer)); buffer[sizeof(buffer) - 1] = 0; Sure, in 1% of the cases, I am glad it doesn't add the terminating 0, but in 99% of the cases I hate it. But did I go out and write my own superior replacement of strncpy? I did for a while and all of my team members protested. They didn't want to learn my pet library. So I am back to strncpy. Like Bjarne Stroustrup wrote, library design is language design. Same with STL. I'd rather not figure out subtle differences between customized STL versions, especially with something as subtle as exception specifications. If it is a good idea for STL to throw exceptions when the user inserts something stupid, then let's lobby to make that a part of the standard. Otherwise put the test in the user code, not into a custom STL. Cay horstman@cs.sjsu.edu --- [ 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:
<4du1v6$h74@jupiter.SJSU.EDU>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backReferences:
<4dd7on$djk@rc1.vub.ac.be> <4dgrb4$a2e@engnews1.Eng.Sun.COM> <9601171106.AA12639@lts.sel.alcatel.de>Show Full Headers
Complete Article Headers
From: horstman@jupiter.SJSU.EDU (Cay S. Horstmann) Message-ID: <4du1v6$h74@jupiter.SJSU.EDU> X-Original-Date: Sun, 21 Jan 1996 18:43:05 GMT Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back Date: 21 Jan 96 23:03:54 GMT Approved: fjh@cs.mu.oz.au Newsgroups: comp.std.c++ Subject: Re: STL still in standard Organization: San Jose State University - Math/CS Dept References: <4dd7on$djk@rc1.vub.ac.be> <4dgrb4$a2e@engnews1.Eng.Sun.COM> <9601171106.AA12639@lts.sel.alcatel.de> X-Newsreader: Forte Free Agent 1.0.82 X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMQLGbeEDnX0m9pzZAQE6ywF5ASnscOoUT0cNxP/UsNOXl3sJYkrRO5Yh 2SlUghuT6j8tS1PWZrZbeN0ZoZKJ3ZQ6 =XoYK