]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/std/string
tree-object-size: Drop unused pdecl and poff arguments
[thirdparty/gcc.git] / libstdc++-v3 / include / std / string
CommitLineData
54c1bf78 1// Components for manipulating sequences of characters -*- C++ -*-
de96ac46 2
99dee823 3// Copyright (C) 1997-2021 Free Software Foundation, Inc.
de96ac46
BK
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
de96ac46
BK
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
748086b7
JJ
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
de96ac46 19
748086b7
JJ
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
de96ac46 24
143c27b0
BK
25/** @file include/string
26 * This is a Standard C++ Library header.
27 */
28
54c1bf78
BK
29//
30// ISO C++ 14882: 21 Strings library
31//
32
1143680e
SE
33#ifndef _GLIBCXX_STRING
34#define _GLIBCXX_STRING 1
54c1bf78
BK
35
36#pragma GCC system_header
37
38#include <bits/c++config.h>
39#include <bits/stringfwd.h>
f56fe8ff
PC
40#include <bits/char_traits.h> // NB: In turn includes stl_algobase.h
41#include <bits/allocator.h>
c0736a9d 42#include <bits/cpp_type_traits.h>
11202768
PC
43#include <bits/localefwd.h> // For operators >>, <<, and getline.
44#include <bits/ostream_insert.h>
c2ba9709
JS
45#include <bits/stl_iterator_base_types.h>
46#include <bits/stl_iterator_base_funcs.h>
54c1bf78 47#include <bits/stl_iterator.h>
11202768 48#include <bits/stl_function.h> // For less
33ac58d5
JW
49#include <ext/numeric_traits.h>
50#include <bits/stl_algobase.h>
acf3a21c 51#include <bits/refwrap.h>
f67a9881 52#include <bits/range_access.h>
ee3ee948 53#include <bits/basic_string.h>
33ac58d5 54#include <bits/basic_string.tcc>
54c1bf78 55
1bc7a28f 56#if __cplusplus >= 201703L && _GLIBCXX_USE_CXX11_ABI
1fc9d0b0
JW
57namespace std _GLIBCXX_VISIBILITY(default)
58{
59_GLIBCXX_BEGIN_NAMESPACE_VERSION
60 namespace pmr {
61 template<typename _Tp> class polymorphic_allocator;
62 template<typename _CharT, typename _Traits = char_traits<_CharT>>
63 using basic_string = std::basic_string<_CharT, _Traits,
64 polymorphic_allocator<_CharT>>;
65 using string = basic_string<char>;
c124af93
TH
66#ifdef _GLIBCXX_USE_CHAR8_T
67 using u8string = basic_string<char8_t>;
68#endif
1fc9d0b0
JW
69 using u16string = basic_string<char16_t>;
70 using u32string = basic_string<char32_t>;
71#ifdef _GLIBCXX_USE_WCHAR_T
72 using wstring = basic_string<wchar_t>;
73#endif
74 } // namespace pmr
0cb78ef4
JW
75
76 template<typename _Str>
77 struct __hash_string_base
78 : public __hash_base<size_t, _Str>
79 {
80 size_t
81 operator()(const _Str& __s) const noexcept
82 { return hash<basic_string_view<typename _Str::value_type>>{}(__s); }
83 };
84
85 template<>
86 struct hash<pmr::string>
87 : public __hash_string_base<pmr::string>
88 { };
89#ifdef _GLIBCXX_USE_CHAR8_T
90 template<>
91 struct hash<pmr::u8string>
92 : public __hash_string_base<pmr::u8string>
93 { };
94#endif
95 template<>
96 struct hash<pmr::u16string>
97 : public __hash_string_base<pmr::u16string>
98 { };
99 template<>
100 struct hash<pmr::u32string>
101 : public __hash_string_base<pmr::u32string>
102 { };
103#ifdef _GLIBCXX_USE_WCHAR_T
104 template<>
105 struct hash<pmr::wstring>
106 : public __hash_string_base<pmr::wstring>
107 { };
108#endif
109
1fc9d0b0
JW
110_GLIBCXX_END_NAMESPACE_VERSION
111} // namespace std
112#endif // C++17
113
188588e4
ESR
114#if __cplusplus > 201703L
115namespace std _GLIBCXX_VISIBILITY(default)
116{
117_GLIBCXX_BEGIN_NAMESPACE_VERSION
45a8d80f 118
55b00d14 119#define __cpp_lib_erase_if 202002L
45a8d80f 120
188588e4
ESR
121 template<typename _CharT, typename _Traits, typename _Alloc,
122 typename _Predicate>
0b44b4b8 123 inline typename basic_string<_CharT, _Traits, _Alloc>::size_type
188588e4
ESR
124 erase_if(basic_string<_CharT, _Traits, _Alloc>& __cont, _Predicate __pred)
125 {
acf3a21c
JW
126 using namespace __gnu_cxx;
127 using _It = typename basic_string<_CharT, _Traits, _Alloc>::iterator;
0b44b4b8 128 const auto __osz = __cont.size();
acf3a21c
JW
129 _It __removed(std::__remove_if(std::__niter_base(__cont.begin()),
130 std::__niter_base(__cont.end()),
131 __ops::__pred_iter(std::ref(__pred))));
132 __cont.erase(__removed, __cont.end());
0b44b4b8 133 return __osz - __cont.size();
188588e4
ESR
134 }
135
136 template<typename _CharT, typename _Traits, typename _Alloc, typename _Up>
0b44b4b8 137 inline typename basic_string<_CharT, _Traits, _Alloc>::size_type
188588e4
ESR
138 erase(basic_string<_CharT, _Traits, _Alloc>& __cont, const _Up& __value)
139 {
acf3a21c
JW
140 using namespace __gnu_cxx;
141 using _It = typename basic_string<_CharT, _Traits, _Alloc>::iterator;
0b44b4b8 142 const auto __osz = __cont.size();
acf3a21c
JW
143 _It __removed(std::__remove_if(std::__niter_base(__cont.begin()),
144 std::__niter_base(__cont.end()),
145 __ops::__iter_equals_val(__value)));
146 __cont.erase(__removed, __cont.end());
0b44b4b8 147 return __osz - __cont.size();
188588e4
ESR
148 }
149_GLIBCXX_END_NAMESPACE_VERSION
150} // namespace std
151#endif // C++20
152
1143680e 153#endif /* _GLIBCXX_STRING */