1
0
forked from boostorg/core

Add sv_find_last_of_test

This commit is contained in:
Peter Dimov
2021-10-09 02:32:00 +03:00
parent 8ec0e7f68a
commit fe9c0164c0
3 changed files with 522 additions and 4 deletions

View File

@@ -513,16 +513,23 @@ public:
BOOST_CXX14_CONSTEXPR size_type find_last_of( basic_string_view str, size_type pos = npos ) const BOOST_NOEXCEPT
{
if( pos > size() )
if( size() == 0 )
{
pos = size();
return npos;
}
for( std::size_t i = pos; i > 0; --i )
if( pos > size() - 1 )
{
if( str.contains( p_[ i - 1 ] ) ) return i - 1;
pos = size() - 1;
}
do
{
if( str.contains( p_[ pos ] ) ) return pos;
--pos;
}
while( pos != npos );
return npos;
}