]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/21_strings/headers/string/synopsis.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 21_strings / headers / string / synopsis.cc
CommitLineData
a024740d 1// { dg-do compile }
8468bfe8 2// { dg-require-normal-namespace "" }
a024740d 3
83ffe9cd 4// Copyright (C) 2007-2023 Free Software Foundation, Inc.
a024740d
BK
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
748086b7 9// Free Software Foundation; either version 3, or (at your option)
a024740d
BK
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
748086b7
JJ
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
a024740d
BK
20
21#include <string>
22
13feb023
JW
23#if __cplusplus >= 201103L
24# define NOTHROW noexcept
25#else
26# define NOTHROW
27#endif
28
73e4d9f1
JW
29#if __cplusplus >= 202002L
30# define CONSTEXPR constexpr
31#else
32# define CONSTEXPR
33#endif
34
a024740d
BK
35namespace 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
34a2b755 42_GLIBCXX_BEGIN_NAMESPACE_CXX11
a024740d
BK
43 // lib.basic.string, basic_string:
44 template<class charT, class traits, class Allocator >
45 class basic_string;
34a2b755 46_GLIBCXX_END_NAMESPACE_CXX11
a024740d
BK
47
48 template<class charT, class traits, class Allocator>
73e4d9f1 49 CONSTEXPR
a024740d
BK
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>
73e4d9f1 54 CONSTEXPR
a024740d
BK
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>
73e4d9f1 59 CONSTEXPR
a024740d
BK
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>
73e4d9f1 63 CONSTEXPR
a024740d
BK
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>
73e4d9f1 68 CONSTEXPR
a024740d
BK
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>
73e4d9f1 73 CONSTEXPR
a024740d 74 bool operator==(const basic_string<charT,traits,Allocator>& lhs,
13feb023 75 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
a024740d 76 template<class charT, class traits, class Allocator>
73e4d9f1 77 CONSTEXPR
a024740d
BK
78 bool operator==(const basic_string<charT,traits,Allocator>& lhs,
79 const charT* rhs);
73e4d9f1
JW
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);
a024740d
BK
95 template<class charT, class traits, class Allocator>
96 bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
13feb023 97 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
a024740d
BK
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,
13feb023 107 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
a024740d
BK
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,
13feb023 116 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
a024740d
BK
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,
13feb023 126 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
a024740d
BK
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,
13feb023 135 const basic_string<charT,traits,Allocator>& rhs) NOTHROW;
a024740d
BK
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);
73e4d9f1 142#endif
a024740d
BK
143
144 // lib.string.special:
145 template<class charT, class traits, class Allocator>
73e4d9f1 146 CONSTEXPR
a024740d 147 void swap(basic_string<charT,traits,Allocator>& lhs,
13feb023
JW
148 basic_string<charT,traits,Allocator>& rhs)
149#if __cplusplus >= 201103L
150 noexcept(noexcept(lhs.swap(rhs)))
151#endif
152 ;
a024740d
BK
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}