Article View: comp.std.c++
Article #1748Substring compare broken?
From: Scott Bigham
Date: Sun, 20 Aug 1995 02:48
Date: Sun, 20 Aug 1995 02:48
30 lines
1645 bytes
1645 bytes
I'm reading 21.1.1.9.8 [lib.string::compare] from the April 28 draft,
and it seems to require, counterintuitively, that the following program
print a nonzero value:
#include <string>
#include <iostream>
main() {
string fred("This is a test"), joe("his");
cout << fred.compare(joe, 1, 3);
return 0;
}
since fred.size() - 1 > joe.size() [as per Table 8]. This seems to
utterly vitiate the third parameter. I suspect (or at least I hope)
that Table 8 is only intended to apply when the third parameter equals
string::npos, or at least is greater than the lengths of the two
strings, but I can't find words to that effect in the section. Am I
missing something, or is this a genuine problem?
-sbigham
--
Scott Bigham | The opinions expressed above are
dsb@cs.duke.edu | (c) 1995 Hacker Ltd. and cannot be
http://www.cs.duke.edu/~dsb/ | copied or distributed without a
= PGP spoken here = | Darn Good Reason(tm).
---
[ 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:
<415mab$cck@duke.cs.duke.edu>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back Date: 20 Aug 95 02:48:59 GMT Approved: fjh@cs.mu.oz.au Return-Path: <daemon@ncar.UCAR.EDU> From: dsb@cs.duke.edu (Scott Bigham) Newsgroups: comp.std.c++ Subject: Substring compare broken? X-Original-Date: 19 Aug 1995 21:50:03 GMT Organization: n. Arrangement in an orderly or logical fashion. See "miracle". Message-ID: <415mab$cck@duke.cs.duke.edu>