string::rfind() -- empty strings...

brent verner brent@rcfile.org
Fri Jun 23 13:19:00 GMT 2000


On 23 Jun 2000 at 09:34 (-0400), brent verner said:
| Following the recent bugfix in basic_string<>::find(..), there is
| a (similar) non-compliant behavior in rfind when the searched for
| string is an empty string. I deduce the following behavior would be
| correct based on the now-compliant behavior of find().
| 
| std::string a("str");
| std::string b;
| int pos;
|
| a.find(b,pos);
| //^^^^^^^^^^^ return pos for a.size() < pos => 0, npos otherwise

bzzt! wrong again! I should just quit :)

should have said (since rfind() returns highest position where
matched)...

a.rfind(b,pos);
// ^^^^^^^^^^^ return a.size() for pos < a.size() and pos >= 0
//             npos otherwise

Is this now correct? I think so. I'll have a patch shortly.

  Brent

-- 
now-whacking-head-repeatedly


More information about the Libstdc++ mailing list