stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-466) basic_string<>::rfind() throws length_error(), but should return npos
Date Tue, 24 Jul 2007 00:27:31 GMT

    [ https://issues.apache.org/jira/browse/STDCXX-466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12514815
] 

Martin Sebor commented on STDCXX-466:
-------------------------------------

The rationale for this change from http://www.mail-archive.com/stdcxx-dev@incubator.apache.org/msg01251.html:

Consider these two examples:

    string s ("abc");
    s.find ("def", 0, 5);
    s.find ("def", 0, -1);

There is no way for us to detect that 5 is too large in the first call to find() so the the
function returns npos because
"def" is not found. But in the second example which is equally invalid we throw, even though
we could just as easily return npos. I think we might as well return npos is all such cases
for consistency. Doing so also simplifies the implementation.

> basic_string<>::rfind() throws length_error(), but should return npos
> ---------------------------------------------------------------------
>
>                 Key: STDCXX-466
>                 URL: https://issues.apache.org/jira/browse/STDCXX-466
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2
>         Environment: All
>            Reporter: Farid Zaripov
>            Assignee: Farid Zaripov
>
> The details are here: http://www.mail-archive.com/stdcxx-dev@incubator.apache.org/msg03795.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message