[Boost-bugs] [Boost C++ Libraries] #9518: string_ref::rfind return value offset

Subject: [Boost-bugs] [Boost C++ Libraries] #9518: string_ref::rfind return value offset
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-12-23 00:50:37

#9518: string_ref::rfind return value offset
 Reporter: Peter A. Bigot <pab@…> | Owner: no-maintainer
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: utility
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
 The value returned from basic_string_ref::rfind() is calculated based on
 the where the end of the target string was found, but is not adjusted for
 the length of that string.

 E.g, given
     const char pstr[] = "abcdabc\0abcd";
     string_view sv(pstr, sizeof(pstr)-1);
     const char * pabc = "abc";
     string_view svabc(pabc);

     string_ref::size_type rv = sv.rfind(svabc);

 ``rv`` will have the value 10 (referencing the last 'c') instead of 8
 (referencing the 'a' that starts the match).

Ticket URL: <https://svn.boost.org/trac/boost/ticket/9518>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC