Thread View: comp.std.c++
1 messages
1 total messages
Started by Scott Bigham
Sun, 20 Aug 1995 02:48
Substring compare broken?
Author: 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. ]
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