Debian Codegraph @

libstdc++-v3/testsuite/21_strings/headers/string/synopsis.cc

raw
1 // { dg-do compile }
2 // { dg-require-normal-namespace "" }
3
4 // Copyright (C) 2007-2025 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
20
21 #include <string>
22
23 #if __cplusplus >= 201103L
24 # define NOTHROW noexcept
25 #else
26 # define NOTHROW
27 #endif
28
29 #if __cplusplus >= 202002L
30 # define CONSTEXPR constexpr
31 #else
32 # define CONSTEXPR
33 #endif
34
35 namespace std {
36 // lib.char.traits, character traits:
37 template<class charT>
38 struct char_traits;
39 template <> struct char_traits<char>;
40 template <> struct char_traits<wchar_t>;
41
42 _GLIBCXX_BEGIN_NAMESPACE_CXX11
43 // lib.basic.string, basic_string:
44 template<class charT, class traits, class Allocator >
45 class basic_string;
46 _GLIBCXX_END_NAMESPACE_CXX11
47
48 template<class charT, class traits, class Allocator>
49 CONSTEXPR
50 basic_string<charT,traits,Allocator>
51 operator+(const basic_string<charT,traits,Allocator>& lhs,
52 const basic_string<charT,traits,Allocator>& rhs);
53 template<class charT, class traits, class Allocator>
54 CONSTEXPR
55 basic_string<charT,traits,Allocator>
56 operator+(const charT* lhs,
57 const basic_string<charT,traits,Allocator>& rhs);
58 template<class charT, class traits, class Allocator>
59 CONSTEXPR
60 basic_string<charT,traits,Allocator>
61 operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
62 template<class charT, class traits, class Allocator>
63 CONSTEXPR
64 basic_string<charT,traits,Allocator>
65 operator+(const basic_string<charT,traits,Allocator>& lhs,
66 const charT* rhs);
67 template<class charT, class traits, class Allocator>
68 CONSTEXPR
69 basic_string<charT,traits,Allocator>
70 operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs);
71
72 template<class charT, class traits, class Allocator>
73 CONSTEXPR
74 bool operator==(const basic_string<charT,traits,Allocator>& lhs,
75 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
76 template<class charT, class traits, class Allocator>
77 CONSTEXPR
78 bool operator==(const basic_string<charT,traits,Allocator>& lhs,
79 const charT* rhs);
80
81 #if __cpp_lib_three_way_comparison
82 template<class charT, class traits, class Allocator>
83 constexpr
84 bool operator<=>(const basic_string<charT,traits,Allocator>& lhs,
85 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
86 template<class charT, class traits, class Allocator>
87 constexpr
88 bool operator<=>(const basic_string<charT,traits,Allocator>& lhs,
89 const charT* rhs);
90 #else
91 template<class charT, class traits, class Allocator>
92 CONSTEXPR
93 bool operator==(const charT* lhs,
94 const basic_string<charT,traits,Allocator>& rhs);
95 template<class charT, class traits, class Allocator>
96 bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
97 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
98 template<class charT, class traits, class Allocator>
99 bool operator!=(const charT* lhs,
100 const basic_string<charT,traits,Allocator>& rhs);
101 template<class charT, class traits, class Allocator>
102 bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
103 const charT* rhs);
104
105 template<class charT, class traits, class Allocator>
106 bool operator< (const basic_string<charT,traits,Allocator>& lhs,
107 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
108 template<class charT, class traits, class Allocator>
109 bool operator< (const basic_string<charT,traits,Allocator>& lhs,
110 const charT* rhs);
111 template<class charT, class traits, class Allocator>
112 bool operator< (const charT* lhs,
113 const basic_string<charT,traits,Allocator>& rhs);
114 template<class charT, class traits, class Allocator>
115 bool operator> (const basic_string<charT,traits,Allocator>& lhs,
116 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
117 template<class charT, class traits, class Allocator>
118 bool operator> (const basic_string<charT,traits,Allocator>& lhs,
119 const charT* rhs);
120 template<class charT, class traits, class Allocator>
121 bool operator> (const charT* lhs,
122 const basic_string<charT,traits,Allocator>& rhs);
123
124 template<class charT, class traits, class Allocator>
125 bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
126 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
127 template<class charT, class traits, class Allocator>
128 bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
129 const charT* rhs);
130 template<class charT, class traits, class Allocator>
131 bool operator<=(const charT* lhs,
132 const basic_string<charT,traits,Allocator>& rhs);
133 template<class charT, class traits, class Allocator>
134 bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
135 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
136 template<class charT, class traits, class Allocator>
137 bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
138 const charT* rhs);
139 template<class charT, class traits, class Allocator>
140 bool operator>=(const charT* lhs,
141 const basic_string<charT,traits,Allocator>& rhs);
142 #endif
143
144 // lib.string.special:
145 template<class charT, class traits, class Allocator>
146 CONSTEXPR
147 void swap(basic_string<charT,traits,Allocator>& lhs,
148 basic_string<charT,traits,Allocator>& rhs)
149 #if __cplusplus >= 201103L
150 noexcept(noexcept(lhs.swap(rhs)))
151 #endif
152 ;
153
154 template<class charT, class traits, class Allocator>
155 basic_istream<charT,traits>&
156 operator>>(basic_istream<charT,traits>& is,
157 basic_string<charT,traits,Allocator>& str);
158 template<class charT, class traits, class Allocator>
159 basic_ostream<charT, traits>&
160 operator<<(basic_ostream<charT, traits>& os,
161 const basic_string<charT,traits,Allocator>& str);
162 template<class charT, class traits, class Allocator>
163 basic_istream<charT,traits>&
164 getline(basic_istream<charT,traits>& is,
165 basic_string<charT,traits,Allocator>& str,
166 charT delim);
167 template<class charT, class traits, class Allocator>
168 basic_istream<charT,traits>&
169 getline(basic_istream<charT,traits>& is,
170 basic_string<charT,traits,Allocator>& str);
171
172 typedef basic_string<char> string;
173 typedef basic_string<wchar_t> wstring;
174 }