williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 1997-1999
|
williamr@2
|
3 |
* Silicon Graphics Computer Systems, Inc.
|
williamr@2
|
4 |
*
|
williamr@2
|
5 |
* Copyright (c) 1999
|
williamr@2
|
6 |
* Boris Fomitchev
|
williamr@2
|
7 |
*
|
williamr@2
|
8 |
* This material is provided "as is", with absolutely no warranty expressed
|
williamr@2
|
9 |
* or implied. Any use is at your own risk.
|
williamr@2
|
10 |
*
|
williamr@2
|
11 |
* Permission to use or copy this software for any purpose is hereby granted
|
williamr@2
|
12 |
* without fee, provided the above notices are retained on all copies.
|
williamr@2
|
13 |
* Permission to modify the code and to distribute modified code is granted,
|
williamr@2
|
14 |
* provided the above notices are retained, and a notice that the code was
|
williamr@2
|
15 |
* modified is included with the above copyright notice.
|
williamr@2
|
16 |
*
|
williamr@2
|
17 |
*/
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#ifndef _STLP_DBG_STRING_H
|
williamr@2
|
20 |
#define _STLP_DBG_STRING_H
|
williamr@2
|
21 |
|
williamr@2
|
22 |
#include <stl/debug/_iterator.h>
|
williamr@2
|
23 |
|
williamr@2
|
24 |
# define _STLP_DBG_STRING_BASE _Nondebug_string <_CharT, _Traits, _Alloc>
|
williamr@2
|
25 |
|
williamr@2
|
26 |
_STLP_BEGIN_NAMESPACE
|
williamr@2
|
27 |
|
williamr@2
|
28 |
# ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
|
williamr@2
|
29 |
template <class _CharT,class _Traits, class _Alloc>
|
williamr@2
|
30 |
inline _CharT*
|
williamr@2
|
31 |
value_type(const _DBG_iter_base< _STLP_DBG_STRING_BASE >&) {
|
williamr@2
|
32 |
return (_CharT*)0;
|
williamr@2
|
33 |
}
|
williamr@2
|
34 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
35 |
inline random_access_iterator_tag
|
williamr@2
|
36 |
iterator_category(const _DBG_iter_base< _STLP_DBG_STRING_BASE >&) {
|
williamr@2
|
37 |
return random_access_iterator_tag();
|
williamr@2
|
38 |
}
|
williamr@2
|
39 |
# endif
|
williamr@2
|
40 |
|
williamr@2
|
41 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
42 |
class basic_string : public _STLP_DBG_STRING_BASE {
|
williamr@2
|
43 |
private:
|
williamr@2
|
44 |
typedef _STLP_DBG_STRING_BASE _Base;
|
williamr@2
|
45 |
typedef basic_string<_CharT, _Traits, _Alloc> _Self;
|
williamr@2
|
46 |
protected:
|
williamr@2
|
47 |
mutable __owned_list _M_iter_list;
|
williamr@2
|
48 |
public:
|
williamr@2
|
49 |
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
williamr@2
|
50 |
typedef _DBG_iter<_Base, _Nonconst_traits<value_type> > iterator;
|
williamr@2
|
51 |
typedef _DBG_iter<_Base, _Const_traits<value_type> > const_iterator;
|
williamr@2
|
52 |
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
|
williamr@2
|
53 |
# ifdef _STLP_USE_NATIVE_STRING
|
williamr@2
|
54 |
// this typedef is being used for conversions
|
williamr@2
|
55 |
typedef _STLP_VENDOR_STD::basic_string<_CharT,_Traits,
|
williamr@2
|
56 |
_STLP_VENDOR_STD::allocator<_CharT> > __std_string;
|
williamr@2
|
57 |
# endif
|
williamr@2
|
58 |
public: // Constructor, destructor, assignment.
|
williamr@2
|
59 |
typedef typename _Base::_Reserve_t _Reserve_t;
|
williamr@2
|
60 |
|
williamr@2
|
61 |
const _Base* _Get_base() const { return (const _Base*)this; }
|
williamr@2
|
62 |
_Base* _Get_base() { return (_Base*)this; }
|
williamr@2
|
63 |
|
williamr@2
|
64 |
basic_string() :_STLP_DBG_STRING_BASE(), _M_iter_list(_Get_base()) {}
|
williamr@2
|
65 |
|
williamr@2
|
66 |
explicit basic_string(const allocator_type& __a):
|
williamr@2
|
67 |
_STLP_DBG_STRING_BASE(__a), _M_iter_list(_Get_base()) {}
|
williamr@2
|
68 |
|
williamr@2
|
69 |
basic_string(_Reserve_t __r, size_t __n,
|
williamr@2
|
70 |
const allocator_type& __a = allocator_type())
|
williamr@2
|
71 |
: _STLP_DBG_STRING_BASE(__r, __n, __a), _M_iter_list(_Get_base()) {}
|
williamr@2
|
72 |
|
williamr@2
|
73 |
basic_string(const _Self& __s):
|
williamr@2
|
74 |
_STLP_DBG_STRING_BASE(__s), _M_iter_list(_Get_base()) {}
|
williamr@2
|
75 |
|
williamr@2
|
76 |
basic_string(const _Self& __s, size_type __pos, size_type __n = _Base::npos,
|
williamr@2
|
77 |
const allocator_type& __a = allocator_type()):
|
williamr@2
|
78 |
_STLP_DBG_STRING_BASE(__s, __pos, __n, __a), _M_iter_list(_Get_base()) {}
|
williamr@2
|
79 |
|
williamr@2
|
80 |
basic_string(const _CharT* __s, size_type __n,
|
williamr@2
|
81 |
const allocator_type& __a = allocator_type()):
|
williamr@2
|
82 |
_STLP_DBG_STRING_BASE(__s, __n, __a), _M_iter_list(_Get_base()) {}
|
williamr@2
|
83 |
|
williamr@2
|
84 |
basic_string(const _CharT* __s,
|
williamr@2
|
85 |
const allocator_type& __a = allocator_type()):
|
williamr@2
|
86 |
_STLP_DBG_STRING_BASE(__s, __a), _M_iter_list(_Get_base()) {}
|
williamr@2
|
87 |
|
williamr@2
|
88 |
basic_string(size_type __n, _CharT __c,
|
williamr@2
|
89 |
const allocator_type& __a = allocator_type()):
|
williamr@2
|
90 |
_STLP_DBG_STRING_BASE(__n, __c, __a), _M_iter_list(_Get_base()) {}
|
williamr@2
|
91 |
|
williamr@2
|
92 |
#if defined (_STLP_MEMBER_TEMPLATES) && !(defined(__MRC__)||(defined(__SC__) && !defined(__DMC__)))
|
williamr@2
|
93 |
# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
|
williamr@2
|
94 |
template <class _InputIterator>
|
williamr@2
|
95 |
basic_string(_InputIterator __f, _InputIterator __l):
|
williamr@2
|
96 |
_STLP_DBG_STRING_BASE(__f, __l), _M_iter_list(_Get_base()) {}
|
williamr@2
|
97 |
# endif
|
williamr@2
|
98 |
template <class _InputIterator>
|
williamr@2
|
99 |
basic_string(_InputIterator __f, _InputIterator __l,
|
williamr@2
|
100 |
const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL):
|
williamr@2
|
101 |
_STLP_DBG_STRING_BASE(__f, __l, __a), _M_iter_list(_Get_base()) {}
|
williamr@2
|
102 |
#else /* _STLP_MEMBER_TEMPLATES */
|
williamr@2
|
103 |
basic_string(const_iterator __f, const_iterator __l,
|
williamr@2
|
104 |
const allocator_type & __a = allocator_type()):
|
williamr@2
|
105 |
_STLP_DBG_STRING_BASE(__f._M_iterator, __l._M_iterator, __a),
|
williamr@2
|
106 |
_M_iter_list(_Get_base()) {}
|
williamr@2
|
107 |
|
williamr@2
|
108 |
basic_string(const _CharT* __f, const _CharT* __l,
|
williamr@2
|
109 |
const allocator_type& __a = allocator_type()):
|
williamr@2
|
110 |
_STLP_DBG_STRING_BASE(__f, __l, __a), _M_iter_list(_Get_base()) {}
|
williamr@2
|
111 |
#endif
|
williamr@2
|
112 |
|
williamr@2
|
113 |
# ifdef _STLP_USE_NATIVE_STRING
|
williamr@2
|
114 |
// these conversion operations still needed for
|
williamr@2
|
115 |
// strstream, etc.
|
williamr@2
|
116 |
basic_string (const __std_string& __x)
|
williamr@2
|
117 |
: _STLP_DBG_STRING_BASE(__x.begin(), __x.end()), _M_iter_list(_Get_base()) {}
|
williamr@2
|
118 |
operator __std_string() const { return __std_string(this->data()); }
|
williamr@2
|
119 |
# endif
|
williamr@2
|
120 |
|
williamr@2
|
121 |
// constructor from non-debug version
|
williamr@2
|
122 |
basic_string (const _Base& __x)
|
williamr@2
|
123 |
: _STLP_DBG_STRING_BASE(__x), _M_iter_list(_Get_base()) {}
|
williamr@2
|
124 |
|
williamr@2
|
125 |
_Self& operator=(const _Self& __s) {
|
williamr@2
|
126 |
_Base::operator=(__s);
|
williamr@2
|
127 |
return *this;
|
williamr@2
|
128 |
}
|
williamr@2
|
129 |
|
williamr@2
|
130 |
_Self& operator=(const _CharT* __s) {
|
williamr@2
|
131 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
132 |
_Base::operator=(__s);
|
williamr@2
|
133 |
return *this;
|
williamr@2
|
134 |
}
|
williamr@2
|
135 |
|
williamr@2
|
136 |
_Self& operator=(_CharT __c) {
|
williamr@2
|
137 |
_Base::operator=(__c);
|
williamr@2
|
138 |
return *this;
|
williamr@2
|
139 |
}
|
williamr@2
|
140 |
|
williamr@2
|
141 |
public: // Iterators.
|
williamr@2
|
142 |
|
williamr@2
|
143 |
iterator begin() { return iterator(&_M_iter_list, this->_M_start); }
|
williamr@2
|
144 |
const_iterator begin() const { return const_iterator(&_M_iter_list,this->_M_start); }
|
williamr@2
|
145 |
iterator end() { return iterator(&_M_iter_list,this->_M_finish); }
|
williamr@2
|
146 |
const_iterator end() const { return const_iterator(&_M_iter_list,this->_M_finish); }
|
williamr@2
|
147 |
void _M_deallocate_block() {
|
williamr@2
|
148 |
_M_iter_list._Invalidate_all();
|
williamr@2
|
149 |
_Base::_M_deallocate_block();
|
williamr@2
|
150 |
}
|
williamr@2
|
151 |
|
williamr@2
|
152 |
reverse_iterator rbegin()
|
williamr@2
|
153 |
{ return reverse_iterator(iterator(&_M_iter_list,this->_M_finish)); }
|
williamr@2
|
154 |
reverse_iterator rend()
|
williamr@2
|
155 |
{ return reverse_iterator(iterator(&_M_iter_list,this->_M_start)); }
|
williamr@2
|
156 |
const_reverse_iterator rbegin() const
|
williamr@2
|
157 |
{ return const_reverse_iterator(const_iterator(&_M_iter_list,this->_M_finish)); }
|
williamr@2
|
158 |
const_reverse_iterator rend() const
|
williamr@2
|
159 |
{ return const_reverse_iterator(const_iterator(&_M_iter_list,this->_M_start)); }
|
williamr@2
|
160 |
|
williamr@2
|
161 |
public: // Size, capacity, etc.
|
williamr@2
|
162 |
|
williamr@2
|
163 |
void resize(size_type __n, _CharT __c) {
|
williamr@2
|
164 |
_Base::resize(__n, __c);
|
williamr@2
|
165 |
}
|
williamr@2
|
166 |
void resize(size_type __n) { resize(__n, this->_M_null()); }
|
williamr@2
|
167 |
|
williamr@2
|
168 |
void reserve(size_type __s= 0) {
|
williamr@2
|
169 |
_Base::reserve(__s);
|
williamr@2
|
170 |
}
|
williamr@2
|
171 |
|
williamr@2
|
172 |
void clear() {
|
williamr@2
|
173 |
_M_iter_list._Invalidate_all();
|
williamr@2
|
174 |
_Base::clear();
|
williamr@2
|
175 |
}
|
williamr@2
|
176 |
|
williamr@2
|
177 |
public: // Element access.
|
williamr@2
|
178 |
|
williamr@2
|
179 |
const_reference operator[](size_type __n) const
|
williamr@2
|
180 |
{ return *(begin() + __n); }
|
williamr@2
|
181 |
reference operator[](size_type __n)
|
williamr@2
|
182 |
{ return *(begin() + __n); }
|
williamr@2
|
183 |
|
williamr@2
|
184 |
const_reference at(size_type __n) const {
|
williamr@2
|
185 |
if (__n >= this->size())
|
williamr@2
|
186 |
this->_M_throw_out_of_range();
|
williamr@2
|
187 |
return *(begin() + __n);
|
williamr@2
|
188 |
}
|
williamr@2
|
189 |
|
williamr@2
|
190 |
reference at(size_type __n) {
|
williamr@2
|
191 |
if (__n >= this->size())
|
williamr@2
|
192 |
this->_M_throw_out_of_range();
|
williamr@2
|
193 |
return *(begin() + __n);
|
williamr@2
|
194 |
}
|
williamr@2
|
195 |
|
williamr@2
|
196 |
public: // Append, operator+=, push_back.
|
williamr@2
|
197 |
|
williamr@2
|
198 |
_Self& operator+=(const _Self& __s) { return append(__s); }
|
williamr@2
|
199 |
_Self& operator+=(const _CharT* __s) { _STLP_FIX_LITERAL_BUG(__s) return append(__s); }
|
williamr@2
|
200 |
_Self& operator+=(_CharT __c) { push_back(__c); return *this; }
|
williamr@2
|
201 |
|
williamr@2
|
202 |
_Self& append(const _Self& __s) { return append(__s._M_start, __s._M_finish); }
|
williamr@2
|
203 |
|
williamr@2
|
204 |
_Self& append(const _Self& __s,
|
williamr@2
|
205 |
size_type __pos, size_type __n)
|
williamr@2
|
206 |
{
|
williamr@2
|
207 |
_Base::append(__s, __pos, __n);
|
williamr@2
|
208 |
return *this;
|
williamr@2
|
209 |
}
|
williamr@2
|
210 |
|
williamr@2
|
211 |
_Self& append(const _CharT* __s, size_type __n)
|
williamr@2
|
212 |
{ _STLP_FIX_LITERAL_BUG(__s) return append(__s, __s+__n); }
|
williamr@2
|
213 |
|
williamr@2
|
214 |
_Self& append(const _CharT* __s)
|
williamr@2
|
215 |
{ _STLP_FIX_LITERAL_BUG(__s) return append(__s, __s + _Traits::length(__s)); }
|
williamr@2
|
216 |
|
williamr@2
|
217 |
_Self& append(size_type __n, _CharT __c){
|
williamr@2
|
218 |
_Base::append(__n, __c);
|
williamr@2
|
219 |
return *this;
|
williamr@2
|
220 |
}
|
williamr@2
|
221 |
|
williamr@2
|
222 |
#ifdef _STLP_MEMBER_TEMPLATES
|
williamr@2
|
223 |
|
williamr@2
|
224 |
// Check to see if _InputIterator is an integer type. If so, then
|
williamr@2
|
225 |
// it can't be an iterator.
|
williamr@2
|
226 |
template <class _InputIter>
|
williamr@2
|
227 |
_Self& append(_InputIter __first, _InputIter __last) {
|
williamr@2
|
228 |
_Base::append(__first, __last);
|
williamr@2
|
229 |
return *this;
|
williamr@2
|
230 |
}
|
williamr@2
|
231 |
|
williamr@2
|
232 |
#ifdef _STLP_MSVC
|
williamr@2
|
233 |
// specialization for append
|
williamr@2
|
234 |
template <>
|
williamr@2
|
235 |
inline _Self& append(iterator __f, iterator __l) {
|
williamr@2
|
236 |
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
|
williamr@2
|
237 |
__check_range(__f, __l);
|
williamr@2
|
238 |
_Base::append(__f._M_iterator, __l._M_iterator);
|
williamr@2
|
239 |
return *this;
|
williamr@2
|
240 |
}
|
williamr@2
|
241 |
#endif
|
williamr@2
|
242 |
|
williamr@2
|
243 |
#else /* _STLP_MEMBER_TEMPLATES */
|
williamr@2
|
244 |
|
williamr@2
|
245 |
_Self& append(const _CharT* __first, const _CharT* __last) {
|
williamr@2
|
246 |
_Base::append(__first, __last);
|
williamr@2
|
247 |
return *this;
|
williamr@2
|
248 |
}
|
williamr@2
|
249 |
|
williamr@2
|
250 |
_Self& append(const_iterator __first, const_iterator __last) {
|
williamr@2
|
251 |
_Base::append(__first._M_iterator, __last._M_iterator);
|
williamr@2
|
252 |
return *this;
|
williamr@2
|
253 |
}
|
williamr@2
|
254 |
#endif /* _STLP_MEMBER_TEMPLATES */
|
williamr@2
|
255 |
|
williamr@2
|
256 |
void push_back(_CharT __c) {
|
williamr@2
|
257 |
_Base::push_back(__c);
|
williamr@2
|
258 |
}
|
williamr@2
|
259 |
|
williamr@2
|
260 |
void pop_back() {
|
williamr@2
|
261 |
__invalidate_iterator(&_M_iter_list,end());
|
williamr@2
|
262 |
_Base::pop_back();
|
williamr@2
|
263 |
}
|
williamr@2
|
264 |
|
williamr@2
|
265 |
|
williamr@2
|
266 |
public: // Assign
|
williamr@2
|
267 |
|
williamr@2
|
268 |
_Self& assign(const _Self& __s) {
|
williamr@2
|
269 |
_Base::assign(__s);
|
williamr@2
|
270 |
return *this;
|
williamr@2
|
271 |
}
|
williamr@2
|
272 |
|
williamr@2
|
273 |
_Self& assign(const _Self& __s,
|
williamr@2
|
274 |
size_type __pos, size_type __n) {
|
williamr@2
|
275 |
_Base::assign(__s, __pos, __n);
|
williamr@2
|
276 |
return *this;
|
williamr@2
|
277 |
}
|
williamr@2
|
278 |
|
williamr@2
|
279 |
_Self& assign(const _CharT* __s, size_type __n)
|
williamr@2
|
280 |
{ _STLP_FIX_LITERAL_BUG(__s) return assign(__s, __s + __n); }
|
williamr@2
|
281 |
|
williamr@2
|
282 |
_Self& assign(const _CharT* __s)
|
williamr@2
|
283 |
{ _STLP_FIX_LITERAL_BUG(__s) return assign(__s, __s + _Traits::length(__s)); }
|
williamr@2
|
284 |
|
williamr@2
|
285 |
_Self& assign(size_type __n, _CharT __c) {
|
williamr@2
|
286 |
_Base::assign(__n, __c);
|
williamr@2
|
287 |
return *this;
|
williamr@2
|
288 |
}
|
williamr@2
|
289 |
|
williamr@2
|
290 |
#ifdef _STLP_MEMBER_TEMPLATES
|
williamr@2
|
291 |
template <class _InputIter>
|
williamr@2
|
292 |
inline _Self& assign(_InputIter __first, _InputIter __last) {
|
williamr@2
|
293 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@2
|
294 |
__check_range(__first, __last);
|
williamr@2
|
295 |
_Base::assign(__first, __last);
|
williamr@2
|
296 |
return *this;
|
williamr@2
|
297 |
}
|
williamr@2
|
298 |
|
williamr@2
|
299 |
#ifdef _STLP_MSVC
|
williamr@2
|
300 |
// partial specialization for assign
|
williamr@2
|
301 |
template <>
|
williamr@2
|
302 |
inline _Self& assign(iterator __f, iterator __l) {
|
williamr@2
|
303 |
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
|
williamr@2
|
304 |
__check_range(__f, __l);
|
williamr@2
|
305 |
_Base::assign(__f._M_iterator, __l._M_iterator);
|
williamr@2
|
306 |
return *this;
|
williamr@2
|
307 |
}
|
williamr@2
|
308 |
#endif
|
williamr@2
|
309 |
|
williamr@2
|
310 |
#else
|
williamr@2
|
311 |
_Self& assign(const _CharT* __f, const _CharT* __l) {
|
williamr@2
|
312 |
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
|
williamr@2
|
313 |
__check_range(__f, __l);
|
williamr@2
|
314 |
_Base::assign(__f, __l);
|
williamr@2
|
315 |
return *this;
|
williamr@2
|
316 |
}
|
williamr@2
|
317 |
_Self& assign(const_iterator __f, const_iterator __l) {
|
williamr@2
|
318 |
|
williamr@2
|
319 |
_Base::assign(__f._M_iterator, __l._M_iterator);
|
williamr@2
|
320 |
return *this;
|
williamr@2
|
321 |
}
|
williamr@2
|
322 |
#endif /* _STLP_MEMBER_TEMPLATES */
|
williamr@2
|
323 |
|
williamr@2
|
324 |
public: // Insert
|
williamr@2
|
325 |
|
williamr@2
|
326 |
_Self& insert(size_type __pos, const _Self& __s) {
|
williamr@2
|
327 |
_Base::insert(__pos, __s);
|
williamr@2
|
328 |
return *this;
|
williamr@2
|
329 |
}
|
williamr@2
|
330 |
|
williamr@2
|
331 |
_Self& insert(size_type __pos, const _Self& __s,
|
williamr@2
|
332 |
size_type __beg, size_type __n) {
|
williamr@2
|
333 |
_Base::insert(__pos, __s, __beg, __n);
|
williamr@2
|
334 |
return *this;
|
williamr@2
|
335 |
}
|
williamr@2
|
336 |
|
williamr@2
|
337 |
_Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
|
williamr@2
|
338 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
339 |
_Base::insert(__pos, __s, __n);
|
williamr@2
|
340 |
return *this;
|
williamr@2
|
341 |
}
|
williamr@2
|
342 |
|
williamr@2
|
343 |
_Self& insert(size_type __pos, const _CharT* __s) {
|
williamr@2
|
344 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
345 |
_Base::insert(__pos, __s);
|
williamr@2
|
346 |
return *this;
|
williamr@2
|
347 |
}
|
williamr@2
|
348 |
|
williamr@2
|
349 |
_Self& insert(size_type __pos, size_type __n, _CharT __c) {
|
williamr@2
|
350 |
_Base::insert(__pos, __n, __c);
|
williamr@2
|
351 |
return *this;
|
williamr@2
|
352 |
}
|
williamr@2
|
353 |
|
williamr@2
|
354 |
iterator insert(iterator __p, _CharT __c) {
|
williamr@2
|
355 |
_STLP_FIX_LITERAL_BUG(__p)
|
williamr@2
|
356 |
__check_if_owner(&_M_iter_list,__p);
|
williamr@2
|
357 |
return iterator(&_M_iter_list,_Base::insert(__p._M_iterator, __c));
|
williamr@2
|
358 |
}
|
williamr@2
|
359 |
|
williamr@2
|
360 |
void insert(iterator __p, size_t __n, _CharT __c) {
|
williamr@2
|
361 |
__check_if_owner(&_M_iter_list,__p);
|
williamr@2
|
362 |
_Base::insert(__p._M_iterator, __n, __c);
|
williamr@2
|
363 |
}
|
williamr@2
|
364 |
|
williamr@2
|
365 |
#ifdef _STLP_MEMBER_TEMPLATES
|
williamr@2
|
366 |
template <class _InputIter>
|
williamr@2
|
367 |
void insert(iterator __p, _InputIter __first, _InputIter __last) {
|
williamr@2
|
368 |
__check_if_owner(&_M_iter_list,__p);
|
williamr@2
|
369 |
__check_range(__first,__last);
|
williamr@2
|
370 |
_Base::insert(__p._M_iterator, __first, __last);
|
williamr@2
|
371 |
}
|
williamr@2
|
372 |
#else /* _STLP_MEMBER_TEMPLATES */
|
williamr@2
|
373 |
void insert(iterator __p, const _CharT* __first, const _CharT* __last) {
|
williamr@2
|
374 |
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
williamr@2
|
375 |
__check_if_owner(&_M_iter_list,__p);
|
williamr@2
|
376 |
__check_range(__first,__last);
|
williamr@2
|
377 |
_Base::insert(__p._M_iterator, __first, __last);
|
williamr@2
|
378 |
}
|
williamr@2
|
379 |
void insert(iterator __p, const_iterator __first, const_iterator __last) {
|
williamr@2
|
380 |
__check_range(__first,__last);
|
williamr@2
|
381 |
_Base::insert(__p._M_iterator, __first._M_iterator, __last._M_iterator);
|
williamr@2
|
382 |
}
|
williamr@2
|
383 |
#endif /* _STLP_MEMBER_TEMPLATES */
|
williamr@2
|
384 |
|
williamr@2
|
385 |
public: // Erase.
|
williamr@2
|
386 |
_Self& erase(size_type __pos = 0, size_type __n = _Base::npos) {
|
williamr@2
|
387 |
_Base::erase(__pos, __n);
|
williamr@2
|
388 |
return *this;
|
williamr@2
|
389 |
}
|
williamr@2
|
390 |
iterator erase(iterator __position) {
|
williamr@2
|
391 |
__check_if_owner(&_M_iter_list, __position);
|
williamr@2
|
392 |
__invalidate_iterator(&_M_iter_list,end());
|
williamr@2
|
393 |
return iterator(&_M_iter_list, _Base::erase(__position._M_iterator));
|
williamr@2
|
394 |
}
|
williamr@2
|
395 |
iterator erase(iterator __first, iterator __last) {
|
williamr@2
|
396 |
__check_range(__first, __last)&&__check_if_owner(&_M_iter_list,__first);
|
williamr@2
|
397 |
if (__first != __last) {
|
williamr@2
|
398 |
__invalidate_range(&_M_iter_list, __last, end());
|
williamr@2
|
399 |
}
|
williamr@2
|
400 |
return iterator(&_M_iter_list, _Base::erase(__first._M_iterator, __last._M_iterator));
|
williamr@2
|
401 |
}
|
williamr@2
|
402 |
|
williamr@2
|
403 |
public: // Substring.
|
williamr@2
|
404 |
_Self substr(size_type __pos = 0, size_type __n = _Base::npos) const {
|
williamr@2
|
405 |
if (__pos > this->size())
|
williamr@2
|
406 |
this->_M_throw_out_of_range();
|
williamr@2
|
407 |
return _Self(this->begin() + __pos,
|
williamr@2
|
408 |
this->begin() + __pos + min(__n, this->size() - __pos),
|
williamr@2
|
409 |
allocator_type());
|
williamr@2
|
410 |
}
|
williamr@2
|
411 |
public: // Replace. (Conceptually equivalent
|
williamr@2
|
412 |
// to erase followed by insert.)
|
williamr@2
|
413 |
_Self& replace(size_type __pos, size_type __n,
|
williamr@2
|
414 |
const _Self& __s) {
|
williamr@2
|
415 |
_Base::replace(__pos, __n, __s);
|
williamr@2
|
416 |
return *this;
|
williamr@2
|
417 |
}
|
williamr@2
|
418 |
|
williamr@2
|
419 |
_Self& replace(size_type __pos1, size_type __n1,
|
williamr@2
|
420 |
const _Self& __s,
|
williamr@2
|
421 |
size_type __pos2, size_type __n2) {
|
williamr@2
|
422 |
_Base::replace(__pos1, __n1, (const _Base&)__s, __pos2, __n2);
|
williamr@2
|
423 |
return *this;
|
williamr@2
|
424 |
}
|
williamr@2
|
425 |
|
williamr@2
|
426 |
_Self& replace(size_type __pos, size_type __n1,
|
williamr@2
|
427 |
const _CharT* __s, size_type __n2) {
|
williamr@2
|
428 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
429 |
_Base::replace(__pos, __n1, __s, __n2);
|
williamr@2
|
430 |
return *this;
|
williamr@2
|
431 |
}
|
williamr@2
|
432 |
|
williamr@2
|
433 |
_Self& replace(size_type __pos, size_type __n1,
|
williamr@2
|
434 |
const _CharT* __s) {
|
williamr@2
|
435 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
436 |
_Base::replace(__pos, __n1, __s);
|
williamr@2
|
437 |
return *this;
|
williamr@2
|
438 |
}
|
williamr@2
|
439 |
|
williamr@2
|
440 |
_Self& replace(size_type __pos, size_type __n1,
|
williamr@2
|
441 |
size_type __n2, _CharT __c) {
|
williamr@2
|
442 |
_Base::replace(__pos, __n1, __n2, __c);
|
williamr@2
|
443 |
return *this;
|
williamr@2
|
444 |
}
|
williamr@2
|
445 |
|
williamr@2
|
446 |
_Self& replace(iterator __first, iterator __last,
|
williamr@2
|
447 |
const _Self& __s) {
|
williamr@2
|
448 |
__check_if_owner(&_M_iter_list,__first);
|
williamr@2
|
449 |
__check_range(__first, __last);
|
williamr@2
|
450 |
_Base::replace(__first._M_iterator, __last._M_iterator,__s);
|
williamr@2
|
451 |
return *this;
|
williamr@2
|
452 |
}
|
williamr@2
|
453 |
|
williamr@2
|
454 |
_Self& replace(iterator __first, iterator __last,
|
williamr@2
|
455 |
const _CharT* __s, size_type __n) {
|
williamr@2
|
456 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
457 |
__check_if_owner(&_M_iter_list,__first);
|
williamr@2
|
458 |
__check_range(__first, __last);
|
williamr@2
|
459 |
_Base::replace(__first._M_iterator, __last._M_iterator,__s, __n);
|
williamr@2
|
460 |
return *this;
|
williamr@2
|
461 |
}
|
williamr@2
|
462 |
|
williamr@2
|
463 |
_Self& replace(iterator __first, iterator __last,
|
williamr@2
|
464 |
const _CharT* __s) {
|
williamr@2
|
465 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
466 |
__check_if_owner(&_M_iter_list,__first);
|
williamr@2
|
467 |
__check_range(__first, __last);
|
williamr@2
|
468 |
_Base::replace(__first._M_iterator, __last._M_iterator,__s);
|
williamr@2
|
469 |
return *this;
|
williamr@2
|
470 |
}
|
williamr@2
|
471 |
|
williamr@2
|
472 |
_Self& replace(iterator __first, iterator __last,
|
williamr@2
|
473 |
size_type __n, _CharT __c) {
|
williamr@2
|
474 |
__check_if_owner(&_M_iter_list,__first);
|
williamr@2
|
475 |
__check_range(__first, __last);
|
williamr@2
|
476 |
_Base::replace(__first._M_iterator, __last._M_iterator, __n, __c);
|
williamr@2
|
477 |
return *this;
|
williamr@2
|
478 |
}
|
williamr@2
|
479 |
|
williamr@2
|
480 |
#ifdef _STLP_MEMBER_TEMPLATES
|
williamr@2
|
481 |
template <class _InputIter>
|
williamr@2
|
482 |
_Self& replace(iterator __first, iterator __last,
|
williamr@2
|
483 |
_InputIter __f, _InputIter __l) {
|
williamr@2
|
484 |
__check_if_owner(&_M_iter_list, __first);
|
williamr@2
|
485 |
__check_range(__first, __last);
|
williamr@2
|
486 |
__check_range(__f, __l);
|
williamr@2
|
487 |
_Base::replace(__first._M_iterator, __last._M_iterator, __f, __l);
|
williamr@2
|
488 |
return *this;
|
williamr@2
|
489 |
}
|
williamr@2
|
490 |
#else /* _STLP_MEMBER_TEMPLATES */
|
williamr@2
|
491 |
_Self& replace(iterator __first, iterator __last,
|
williamr@2
|
492 |
const _CharT* __f, const _CharT* __l) {
|
williamr@2
|
493 |
__check_if_owner(&_M_iter_list, __first);
|
williamr@2
|
494 |
__check_range(__first, __last);
|
williamr@2
|
495 |
__check_range(__f, __l);
|
williamr@2
|
496 |
_Base::replace(__first._M_iterator, __last._M_iterator, __f, __l);
|
williamr@2
|
497 |
return *this;
|
williamr@2
|
498 |
}
|
williamr@2
|
499 |
|
williamr@2
|
500 |
_Self& replace(iterator __first, iterator __last,
|
williamr@2
|
501 |
const_iterator __f, const_iterator __l) {
|
williamr@2
|
502 |
__check_if_owner(&_M_iter_list, __first);
|
williamr@2
|
503 |
__check_range(__first, __last);
|
williamr@2
|
504 |
__check_range(__f, __l);
|
williamr@2
|
505 |
_Base::replace(__first._M_iterator, __last._M_iterator,
|
williamr@2
|
506 |
__f._M_iterator, __l._M_iterator);
|
williamr@2
|
507 |
return *this;
|
williamr@2
|
508 |
}
|
williamr@2
|
509 |
#endif /* _STLP_MEMBER_TEMPLATES */
|
williamr@2
|
510 |
|
williamr@2
|
511 |
public: // Other modifier member functions.
|
williamr@2
|
512 |
|
williamr@2
|
513 |
void swap(_Self& __s) {
|
williamr@2
|
514 |
_M_iter_list._Swap_owners(__s._M_iter_list);
|
williamr@2
|
515 |
_Base::swap(__s);
|
williamr@2
|
516 |
}
|
williamr@2
|
517 |
};
|
williamr@2
|
518 |
|
williamr@2
|
519 |
|
williamr@2
|
520 |
// This is a hook to instantiate STLport exports in a designated DLL
|
williamr@2
|
521 |
# if defined (_STLP_USE_TEMPLATE_EXPORT)
|
williamr@2
|
522 |
_STLP_EXPORT template class _STLP_CLASS_DECLSPEC basic_string<char, char_traits<char>, allocator<char> >;
|
williamr@2
|
523 |
# if defined (_STLP_HAS_WCHAR_T)
|
williamr@2
|
524 |
_STLP_EXPORT template class _STLP_CLASS_DECLSPEC basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
|
williamr@2
|
525 |
# endif
|
williamr@2
|
526 |
# endif /* _STLP_USE_TEMPLATE_EXPORT */
|
williamr@2
|
527 |
|
williamr@2
|
528 |
|
williamr@2
|
529 |
// ------------------------------------------------------------
|
williamr@2
|
530 |
// Non-member functions.
|
williamr@2
|
531 |
|
williamr@2
|
532 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
533 |
inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
|
williamr@2
|
534 |
operator+(const basic_string<_CharT,_Traits,_Alloc>& __s,
|
williamr@2
|
535 |
const basic_string<_CharT,_Traits,_Alloc>& __y)
|
williamr@2
|
536 |
{
|
williamr@2
|
537 |
return basic_string<_CharT,_Traits,_Alloc>(*__s._Get_base() + *__y._Get_base());
|
williamr@2
|
538 |
}
|
williamr@2
|
539 |
|
williamr@2
|
540 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
541 |
inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
|
williamr@2
|
542 |
operator+(const _CharT* __s,
|
williamr@2
|
543 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
544 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
545 |
return basic_string<_CharT,_Traits,_Alloc>(__s + *__y._Get_base());
|
williamr@2
|
546 |
}
|
williamr@2
|
547 |
|
williamr@2
|
548 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
549 |
inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
|
williamr@2
|
550 |
operator+(_CharT __c,
|
williamr@2
|
551 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
552 |
return basic_string<_CharT,_Traits,_Alloc>(__c + *__y._Get_base());
|
williamr@2
|
553 |
}
|
williamr@2
|
554 |
|
williamr@2
|
555 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
556 |
inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
|
williamr@2
|
557 |
operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
558 |
const _CharT* __s) {
|
williamr@2
|
559 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
560 |
return basic_string<_CharT,_Traits,_Alloc>(*__x._Get_base()+ __s);
|
williamr@2
|
561 |
}
|
williamr@2
|
562 |
|
williamr@2
|
563 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
564 |
inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL
|
williamr@2
|
565 |
operator+(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
566 |
const _CharT __c) {
|
williamr@2
|
567 |
return basic_string<_CharT,_Traits,_Alloc>(*__x._Get_base() + __c);
|
williamr@2
|
568 |
}
|
williamr@2
|
569 |
|
williamr@2
|
570 |
#ifdef _STLP_EXTRA_OPERATORS_FOR_DEBUG
|
williamr@2
|
571 |
|
williamr@2
|
572 |
// Operator== and operator!=
|
williamr@2
|
573 |
|
williamr@2
|
574 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
575 |
inline bool _STLP_CALL
|
williamr@2
|
576 |
operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
577 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
578 |
return (*__x._Get_base() == *__y._Get_base());
|
williamr@2
|
579 |
}
|
williamr@2
|
580 |
|
williamr@2
|
581 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
582 |
inline bool _STLP_CALL
|
williamr@2
|
583 |
operator==(const _CharT* __s,
|
williamr@2
|
584 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
585 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
586 |
return (__s == *__y._Get_base());
|
williamr@2
|
587 |
}
|
williamr@2
|
588 |
|
williamr@2
|
589 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
590 |
inline bool _STLP_CALL
|
williamr@2
|
591 |
operator==(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
592 |
const _CharT* __s) {
|
williamr@2
|
593 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
594 |
return (*__x._Get_base() == __s);
|
williamr@2
|
595 |
}
|
williamr@2
|
596 |
|
williamr@2
|
597 |
// Operator< (and also >, <=, and >=).
|
williamr@2
|
598 |
|
williamr@2
|
599 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
600 |
inline bool _STLP_CALL
|
williamr@2
|
601 |
operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
602 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
603 |
return (*__x._Get_base() < *__y._Get_base());
|
williamr@2
|
604 |
}
|
williamr@2
|
605 |
|
williamr@2
|
606 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
607 |
inline bool _STLP_CALL
|
williamr@2
|
608 |
operator<(const _CharT* __s,
|
williamr@2
|
609 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
610 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
611 |
return (__s < *__y._Get_base());
|
williamr@2
|
612 |
}
|
williamr@2
|
613 |
|
williamr@2
|
614 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
615 |
inline bool _STLP_CALL
|
williamr@2
|
616 |
operator<(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
617 |
const _CharT* __s) {
|
williamr@2
|
618 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
619 |
return (*__x._Get_base() < __s);
|
williamr@2
|
620 |
}
|
williamr@2
|
621 |
|
williamr@2
|
622 |
#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
|
williamr@2
|
623 |
|
williamr@2
|
624 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
625 |
inline bool _STLP_CALL
|
williamr@2
|
626 |
operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
627 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
628 |
return !(__x == __y);
|
williamr@2
|
629 |
}
|
williamr@2
|
630 |
|
williamr@2
|
631 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
632 |
inline bool _STLP_CALL
|
williamr@2
|
633 |
operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
634 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
635 |
return __y < __x;
|
williamr@2
|
636 |
}
|
williamr@2
|
637 |
|
williamr@2
|
638 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
639 |
inline bool _STLP_CALL
|
williamr@2
|
640 |
operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
641 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
642 |
return !(__y < __x);
|
williamr@2
|
643 |
}
|
williamr@2
|
644 |
|
williamr@2
|
645 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
646 |
inline bool _STLP_CALL
|
williamr@2
|
647 |
operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
648 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
649 |
return !(__x < __y);
|
williamr@2
|
650 |
}
|
williamr@2
|
651 |
|
williamr@2
|
652 |
#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
|
williamr@2
|
653 |
|
williamr@2
|
654 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
655 |
inline bool _STLP_CALL
|
williamr@2
|
656 |
operator!=(const _CharT* __s,
|
williamr@2
|
657 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
658 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
659 |
return !(__s == __y);
|
williamr@2
|
660 |
}
|
williamr@2
|
661 |
|
williamr@2
|
662 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
663 |
inline bool _STLP_CALL
|
williamr@2
|
664 |
operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
665 |
const _CharT* __s) {
|
williamr@2
|
666 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
667 |
return !(__x == __s);
|
williamr@2
|
668 |
}
|
williamr@2
|
669 |
|
williamr@2
|
670 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
671 |
inline bool _STLP_CALL
|
williamr@2
|
672 |
operator>(const _CharT* __s,
|
williamr@2
|
673 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
674 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
675 |
return __y < __s;
|
williamr@2
|
676 |
}
|
williamr@2
|
677 |
|
williamr@2
|
678 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
679 |
inline bool _STLP_CALL
|
williamr@2
|
680 |
operator>(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
681 |
const _CharT* __s) {
|
williamr@2
|
682 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
683 |
return __s < __x;
|
williamr@2
|
684 |
}
|
williamr@2
|
685 |
|
williamr@2
|
686 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
687 |
inline bool _STLP_CALL
|
williamr@2
|
688 |
operator<=(const _CharT* __s,
|
williamr@2
|
689 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
690 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
691 |
return !(__y < __s);
|
williamr@2
|
692 |
}
|
williamr@2
|
693 |
|
williamr@2
|
694 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
695 |
inline bool _STLP_CALL
|
williamr@2
|
696 |
operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
697 |
const _CharT* __s) {
|
williamr@2
|
698 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
699 |
return !(__s < __x);
|
williamr@2
|
700 |
}
|
williamr@2
|
701 |
|
williamr@2
|
702 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
703 |
inline bool _STLP_CALL
|
williamr@2
|
704 |
operator>=(const _CharT* __s,
|
williamr@2
|
705 |
const basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
706 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
707 |
return !(__s < __y);
|
williamr@2
|
708 |
}
|
williamr@2
|
709 |
|
williamr@2
|
710 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
711 |
inline bool _STLP_CALL
|
williamr@2
|
712 |
operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
713 |
const _CharT* __s) {
|
williamr@2
|
714 |
_STLP_FIX_LITERAL_BUG(__s)
|
williamr@2
|
715 |
return !(__x < __s);
|
williamr@2
|
716 |
}
|
williamr@2
|
717 |
#endif /* if 0 */
|
williamr@2
|
718 |
|
williamr@2
|
719 |
// Swap.
|
williamr@2
|
720 |
#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
|
williamr@2
|
721 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
722 |
inline void swap(basic_string<_CharT,_Traits,_Alloc>& __x,
|
williamr@2
|
723 |
basic_string<_CharT,_Traits,_Alloc>& __y) {
|
williamr@2
|
724 |
__x.swap(__y);
|
williamr@2
|
725 |
}
|
williamr@2
|
726 |
#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
|
williamr@2
|
727 |
|
williamr@2
|
728 |
// I/O.
|
williamr@2
|
729 |
|
williamr@2
|
730 |
#ifdef _STLP_EXTRA_OPERATORS_FOR_DEBUG
|
williamr@2
|
731 |
#if defined (_STLP_USE_NEW_IOSTREAMS) && ! defined (_STLP_OWN_IOSTREAMS)
|
williamr@2
|
732 |
|
williamr@2
|
733 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
734 |
basic_ostream<_CharT, _Traits>& _STLP_CALL
|
williamr@2
|
735 |
operator<<(basic_ostream<_CharT, _Traits>& __os,
|
williamr@2
|
736 |
const basic_string<_CharT,_Traits,_Alloc>& __s) {
|
williamr@2
|
737 |
return __os << *__s._Get_base();
|
williamr@2
|
738 |
}
|
williamr@2
|
739 |
|
williamr@2
|
740 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
741 |
basic_istream<_CharT, _Traits>& _STLP_CALL
|
williamr@2
|
742 |
operator>>(basic_istream<_CharT, _Traits>& __is,
|
williamr@2
|
743 |
basic_string<_CharT,_Traits,_Alloc>& __s) {
|
williamr@2
|
744 |
return __is >> *__s._Get_base();
|
williamr@2
|
745 |
}
|
williamr@2
|
746 |
|
williamr@2
|
747 |
#elif ! defined ( _STLP_USE_NO_IOSTREAMS )
|
williamr@2
|
748 |
|
williamr@2
|
749 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
750 |
ostream& _STLP_CALL operator<<(ostream& __os,
|
williamr@2
|
751 |
const basic_string<_CharT,_Traits,_Alloc>& __s) {
|
williamr@2
|
752 |
return __os << *__s._Get_base();
|
williamr@2
|
753 |
}
|
williamr@2
|
754 |
|
williamr@2
|
755 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@2
|
756 |
istream& _STLP_CALL operator>>(istream& __is, basic_string<_CharT,_Traits,_Alloc>& __s) {
|
williamr@2
|
757 |
return __is >> *__s._Get_base();
|
williamr@2
|
758 |
}
|
williamr@2
|
759 |
|
williamr@2
|
760 |
#endif /* _STLP_USE_NEW_IOSTREAMS */
|
williamr@2
|
761 |
#endif /* if _STLP_EXTRA_OPERATORS_FOR_DEBUG */
|
williamr@2
|
762 |
|
williamr@2
|
763 |
|
williamr@2
|
764 |
_STLP_END_NAMESPACE
|
williamr@2
|
765 |
|
williamr@2
|
766 |
#endif /* _STLP_DBG_STRING */
|
williamr@2
|
767 |
|
williamr@2
|
768 |
|
williamr@2
|
769 |
// Local Variables:
|
williamr@2
|
770 |
// mode:C++
|
williamr@2
|
771 |
// End:
|
williamr@2
|
772 |
|