diff options
| author | Marshall Clow <mclow.lists@gmail.com> | 2018-12-14 18:49:35 +0000 |
|---|---|---|
| committer | Marshall Clow <mclow.lists@gmail.com> | 2018-12-14 18:49:35 +0000 |
| commit | f60c63c090114a6b5f0ba0a7aacd67e6c92920e7 (patch) | |
| tree | 17e10b3f0bbd3a373498bbe621f9036bdd176e32 /libcxx/include/string | |
| parent | b7e2d6e4931b88fc5c84358a1fa7a9d3dffbecbc (diff) | |
| download | bcm5719-llvm-f60c63c090114a6b5f0ba0a7aacd67e6c92920e7.tar.gz bcm5719-llvm-f60c63c090114a6b5f0ba0a7aacd67e6c92920e7.zip | |
Implement P1209 - Adopt Consistent Container Erasure from Library Fundamentals 2 for C++20. Reviewed as https://reviews.llvm.org/D55532
llvm-svn: 349178
Diffstat (limited to 'libcxx/include/string')
| -rw-r--r-- | libcxx/include/string | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libcxx/include/string b/libcxx/include/string index 4dd6ddc4e92..fb838d1e5dd 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -437,6 +437,11 @@ template<class charT, class traits, class Allocator> basic_istream<charT, traits>& getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); +template<class charT, class traits, class Allocator, class U> +void erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20 +template<class charT, class traits, class Allocator, class Predicate> +void erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20 + typedef basic_string<char> string; typedef basic_string<wchar_t> wstring; typedef basic_string<char16_t> u16string; @@ -4276,6 +4281,18 @@ getline(basic_istream<_CharT, _Traits>&& __is, #endif // _LIBCPP_CXX03_LANG +#if _LIBCPP_STD_VER > 17 +template<class _CharT, class _Traits, class _Allocator, class _Up> +inline _LIBCPP_INLINE_VISIBILITY +void erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) +{ __str.erase(_VSTD::remove(__str.begin(), __str.end(), __v), __str.end()); } + +template<class _CharT, class _Traits, class _Allocator, class _Predicate> +inline _LIBCPP_INLINE_VISIBILITY +void erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) +{ __str.erase(_VSTD::remove_if(__str.begin(), __str.end(), __pred), __str.end()); } +#endif + #if _LIBCPP_DEBUG_LEVEL >= 2 template<class _CharT, class _Traits, class _Allocator> |

