1 1.1 mrg // Components for manipulating sequences of characters -*- C++ -*- 2 1.1 mrg 3 1.1.1.12 mrg // Copyright (C) 1997-2024 Free Software Foundation, Inc. 4 1.1 mrg // 5 1.1 mrg // This file is part of the GNU ISO C++ Library. This library is free 6 1.1 mrg // software; you can redistribute it and/or modify it under the 7 1.1 mrg // terms of the GNU General Public License as published by the 8 1.1 mrg // Free Software Foundation; either version 3, or (at your option) 9 1.1 mrg // any later version. 10 1.1 mrg 11 1.1 mrg // This library is distributed in the hope that it will be useful, 12 1.1 mrg // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 1.1 mrg // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 1.1 mrg // GNU General Public License for more details. 15 1.1 mrg 16 1.1 mrg // Under Section 7 of GPL version 3, you are granted additional 17 1.1 mrg // permissions described in the GCC Runtime Library Exception, version 18 1.1 mrg // 3.1, as published by the Free Software Foundation. 19 1.1 mrg 20 1.1 mrg // You should have received a copy of the GNU General Public License and 21 1.1 mrg // a copy of the GCC Runtime Library Exception along with this program; 22 1.1 mrg // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23 1.1 mrg // <http://www.gnu.org/licenses/>. 24 1.1 mrg 25 1.1 mrg /** @file include/string 26 1.1 mrg * This is a Standard C++ Library header. 27 1.1 mrg */ 28 1.1 mrg 29 1.1 mrg // 30 1.1 mrg // ISO C++ 14882: 21 Strings library 31 1.1 mrg // 32 1.1 mrg 33 1.1 mrg #ifndef _GLIBCXX_STRING 34 1.1 mrg #define _GLIBCXX_STRING 1 35 1.1 mrg 36 1.1 mrg #pragma GCC system_header 37 1.1 mrg 38 1.1.1.12 mrg #include <bits/requires_hosted.h> // containers 39 1.1.1.12 mrg 40 1.1 mrg #include <bits/c++config.h> 41 1.1 mrg #include <bits/stringfwd.h> 42 1.1.1.12 mrg #include <bits/char_traits.h> 43 1.1 mrg #include <bits/allocator.h> 44 1.1 mrg #include <bits/cpp_type_traits.h> 45 1.1 mrg #include <bits/localefwd.h> // For operators >>, <<, and getline. 46 1.1 mrg #include <bits/ostream_insert.h> 47 1.1 mrg #include <bits/stl_iterator_base_funcs.h> 48 1.1 mrg #include <bits/stl_iterator.h> 49 1.1 mrg #include <bits/stl_function.h> // For less 50 1.1.1.5 mrg #include <ext/numeric_traits.h> 51 1.1.1.5 mrg #include <bits/stl_algobase.h> 52 1.1.1.11 mrg #include <bits/refwrap.h> 53 1.1.1.2 mrg #include <bits/range_access.h> 54 1.1 mrg #include <bits/basic_string.h> 55 1.1.1.5 mrg #include <bits/basic_string.tcc> 56 1.1 mrg 57 1.1.1.12 mrg #define __glibcxx_want_allocator_traits_is_always_equal 58 1.1.1.12 mrg #define __glibcxx_want_constexpr_char_traits 59 1.1.1.12 mrg #define __glibcxx_want_constexpr_string 60 1.1.1.12 mrg #define __glibcxx_want_erase_if 61 1.1.1.12 mrg #define __glibcxx_want_nonmember_container_access 62 1.1.1.12 mrg #define __glibcxx_want_string_resize_and_overwrite 63 1.1.1.12 mrg #define __glibcxx_want_string_udls 64 1.1.1.12 mrg #define __glibcxx_want_to_string 65 1.1.1.12 mrg #include <bits/version.h> 66 1.1.1.12 mrg 67 1.1.1.9 mrg #if __cplusplus >= 201703L && _GLIBCXX_USE_CXX11_ABI 68 1.1.1.12 mrg #include <bits/memory_resource.h> 69 1.1.1.9 mrg namespace std _GLIBCXX_VISIBILITY(default) 70 1.1.1.9 mrg { 71 1.1.1.9 mrg _GLIBCXX_BEGIN_NAMESPACE_VERSION 72 1.1.1.9 mrg namespace pmr { 73 1.1.1.9 mrg template<typename _CharT, typename _Traits = char_traits<_CharT>> 74 1.1.1.9 mrg using basic_string = std::basic_string<_CharT, _Traits, 75 1.1.1.9 mrg polymorphic_allocator<_CharT>>; 76 1.1.1.9 mrg using string = basic_string<char>; 77 1.1.1.9 mrg #ifdef _GLIBCXX_USE_CHAR8_T 78 1.1.1.9 mrg using u8string = basic_string<char8_t>; 79 1.1.1.9 mrg #endif 80 1.1.1.9 mrg using u16string = basic_string<char16_t>; 81 1.1.1.9 mrg using u32string = basic_string<char32_t>; 82 1.1.1.9 mrg using wstring = basic_string<wchar_t>; 83 1.1.1.9 mrg } // namespace pmr 84 1.1.1.9 mrg _GLIBCXX_END_NAMESPACE_VERSION 85 1.1.1.9 mrg } // namespace std 86 1.1.1.9 mrg #endif // C++17 87 1.1.1.9 mrg 88 1.1.1.12 mrg #ifdef __cpp_lib_erase_if // C++ >= 20 && HOSTED 89 1.1.1.9 mrg namespace std _GLIBCXX_VISIBILITY(default) 90 1.1.1.9 mrg { 91 1.1.1.9 mrg _GLIBCXX_BEGIN_NAMESPACE_VERSION 92 1.1.1.9 mrg 93 1.1.1.9 mrg template<typename _CharT, typename _Traits, typename _Alloc, 94 1.1.1.9 mrg typename _Predicate> 95 1.1.1.11 mrg _GLIBCXX20_CONSTEXPR 96 1.1.1.9 mrg inline typename basic_string<_CharT, _Traits, _Alloc>::size_type 97 1.1.1.9 mrg erase_if(basic_string<_CharT, _Traits, _Alloc>& __cont, _Predicate __pred) 98 1.1.1.9 mrg { 99 1.1.1.11 mrg using namespace __gnu_cxx; 100 1.1.1.9 mrg const auto __osz = __cont.size(); 101 1.1.1.11 mrg const auto __end = __cont.end(); 102 1.1.1.11 mrg auto __removed = std::__remove_if(__cont.begin(), __end, 103 1.1.1.11 mrg __ops::__pred_iter(std::ref(__pred))); 104 1.1.1.11 mrg __cont.erase(__removed, __end); 105 1.1.1.9 mrg return __osz - __cont.size(); 106 1.1.1.9 mrg } 107 1.1.1.9 mrg 108 1.1.1.9 mrg template<typename _CharT, typename _Traits, typename _Alloc, typename _Up> 109 1.1.1.11 mrg _GLIBCXX20_CONSTEXPR 110 1.1.1.9 mrg inline typename basic_string<_CharT, _Traits, _Alloc>::size_type 111 1.1.1.9 mrg erase(basic_string<_CharT, _Traits, _Alloc>& __cont, const _Up& __value) 112 1.1.1.9 mrg { 113 1.1.1.11 mrg using namespace __gnu_cxx; 114 1.1.1.9 mrg const auto __osz = __cont.size(); 115 1.1.1.11 mrg const auto __end = __cont.end(); 116 1.1.1.11 mrg auto __removed = std::__remove_if(__cont.begin(), __end, 117 1.1.1.11 mrg __ops::__iter_equals_val(__value)); 118 1.1.1.11 mrg __cont.erase(__removed, __end); 119 1.1.1.9 mrg return __osz - __cont.size(); 120 1.1.1.9 mrg } 121 1.1.1.9 mrg _GLIBCXX_END_NAMESPACE_VERSION 122 1.1.1.9 mrg } // namespace std 123 1.1.1.12 mrg #endif // __cpp_lib_erase_if 124 1.1.1.9 mrg 125 1.1 mrg #endif /* _GLIBCXX_STRING */ 126