sv_find_last_not_of_test

This commit is contained in:
Peter Dimov
2021-10-09 03:33:10 +03:00
parent ab3950fdfb
commit a51364c5d3
3 changed files with 596 additions and 8 deletions
+22 -8
View File
@@ -584,31 +584,45 @@ public:
BOOST_CXX14_CONSTEXPR size_type find_last_not_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;
}
BOOST_CXX14_CONSTEXPR size_type find_last_not_of( Ch c, 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( p_[ i - 1 ] != c ) return i - 1;
pos = size() - 1;
}
do
{
if( p_[ pos ] != c ) return pos;
--pos;
}
while( pos != npos );
return npos;
}