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-170) std::string::replace (iterator, iterator, InputIterator, InputIterator) inserting self incorrect
Date Thu, 27 Apr 2006 00:02:03 GMT
    [ http://issues.apache.org/jira/browse/STDCXX-170?page=comments#action_12376612 ] 

Martin Sebor commented on STDCXX-170:
-------------------------------------

And another version of the same to show that there is an unbounded set of specializations
of the replace() member function template whose arguments may reference elements in *this.

#include <cassert>
#include <string>

int main ()
{
    std::string s ("abc");

    typedef const unsigned char UChar;
    s.replace (s.begin (), s.begin (), (UChar*)&s [1], (UChar*)&s [2]);

    assert ("babc" == s);    
}


> std::string::replace (iterator, iterator, InputIterator, InputIterator) inserting self
incorrect
> ------------------------------------------------------------------------------------------------
>
>          Key: STDCXX-170
>          URL: http://issues.apache.org/jira/browse/STDCXX-170
>      Project: C++ Standard Library
>         Type: Bug

>   Components: 21. Strings
>     Versions: 4.1.3
>  Environment: all
>     Reporter: Anton Pevtsov
>     Priority: Minor

>
> This test fails:
> #include <iostream>
> #include <string>
> static const char* test = "babc";
> int main (void)
> {
>     std::string s ("abc");
>     s.replace (s.begin (), s.begin (), s.begin () + 1, s.begin () + 2);
>     std::cout << "Expected " << test << " and got " << s <<
'\n';
>     return 0;
> }
> The output is "Expected babc and got aabc".
> See details here:
> http://mail-archives.apache.org/mod_mbox/incubator-stdcxx-dev/200604.mbox/%3c44337C76.4020909@roguewave.com%3e

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message