forked from boostorg/static_string
Implement erase_if function and related tests
This commit is contained in:
committed by
Krystian Stasiowski
parent
59c4c556bb
commit
3a1efd2078
@ -5614,6 +5614,31 @@ operator+(
|
||||
std::size_t(0), +lhs);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// erase_if
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<
|
||||
std::size_t N, typename CharT,
|
||||
typename Traits, typename UnaryPredicate>
|
||||
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
||||
typename
|
||||
basic_static_string<N, CharT, Traits>::size_type
|
||||
erase_if(
|
||||
basic_static_string<N, CharT, Traits>& str,
|
||||
UnaryPredicate pred)
|
||||
{
|
||||
auto first = str.begin();
|
||||
for (auto it = first; it != str.end(); ++it)
|
||||
if (!pred(*it))
|
||||
*first++ = std::move(*it);
|
||||
const auto count = str.end() - first;
|
||||
str.erase(first, str.end());
|
||||
return count;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// swap
|
||||
|
Reference in New Issue
Block a user