source: svn/trunk/newcon3bcm2_21bu/toolchain/include/c++/3.4.2/debug/string

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 28.0 KB
Line 
1// Debugging string implementation -*- C++ -*-
2
3// Copyright (C) 2003
4// 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 2, 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 COPYING.  If not, write to the Free
19// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20// USA.
21
22// As a special exception, you may use this file as part of a free software
23// library without restriction.  Specifically, if other files instantiate
24// templates or use macros or inline functions from this file, or you compile
25// this file and link it with other files to produce an executable, this
26// file does not by itself cause the resulting executable to be covered by
27// the GNU General Public License.  This exception does not however
28// invalidate any other reasons why the executable file might be covered by
29// the GNU General Public License.
30
31#ifndef _GLIBCXX_DEBUG_STRING
32#define _GLIBCXX_DEBUG_STRING 1
33
34#include <string>
35#include <debug/safe_sequence.h>
36#include <debug/safe_iterator.h>
37
38namespace __gnu_debug
39{
40  template<typename _CharT, typename _Traits, typename _Allocator>
41    class basic_string
42    : public std::basic_string<_CharT, _Traits, _Allocator>,
43      public __gnu_debug::_Safe_sequence<basic_string<_CharT, _Traits,
44                                                      _Allocator> >
45    {
46      typedef std::basic_string<_CharT, _Traits, _Allocator> _Base;
47      typedef __gnu_debug::_Safe_sequence<basic_string>     _Safe_base;
48
49  public:
50    // types:
51    typedef _Traits                                    traits_type;
52    typedef typename _Traits::char_type                value_type;
53    typedef _Allocator                                 allocator_type;
54    typedef typename _Allocator::size_type             size_type;
55    typedef typename _Allocator::difference_type       difference_type;
56    typedef typename _Allocator::reference             reference;
57    typedef typename _Allocator::const_reference       const_reference;
58    typedef typename _Allocator::pointer               pointer;
59    typedef typename _Allocator::const_pointer         const_pointer;
60
61    typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, basic_string>
62                                                       iterator;
63    typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
64                                         basic_string> const_iterator;
65
66    typedef std::reverse_iterator<iterator>            reverse_iterator;
67    typedef std::reverse_iterator<const_iterator>      const_reverse_iterator;
68
69    using _Base::npos;
70
71    // 21.3.1 construct/copy/destroy:
72    explicit basic_string(const _Allocator& __a = _Allocator())
73    : _Base(__a)
74    { }
75
76    // Provides conversion from a release-mode string to a debug-mode string
77    basic_string(const _Base& __base) : _Base(__base), _Safe_base() { }
78
79    // _GLIBCXX_RESOLVE_LIB_DEFECTS
80    // 42. string ctors specify wrong default allocator
81    basic_string(const basic_string& __str)
82    : _Base(__str, 0, _Base::npos, __str.get_allocator()), _Safe_base()
83    { }
84
85    // _GLIBCXX_RESOLVE_LIB_DEFECTS
86    // 42. string ctors specify wrong default allocator
87    basic_string(const basic_string& __str, size_type __pos,
88                   size_type __n = _Base::npos,
89                   const _Allocator& __a = _Allocator())
90    : _Base(__str, __pos, __n, __a)
91    { }
92
93    basic_string(const _CharT* __s, size_type __n,
94                   const _Allocator& __a = _Allocator())
95    : _Base(__gnu_debug::__check_string(__s, __n), __n, __a)
96    { }
97
98    basic_string(const _CharT* __s, const _Allocator& __a = _Allocator())
99    : _Base(__gnu_debug::__check_string(__s), __a)
100    { this->assign(__s); }
101
102    basic_string(size_type __n, _CharT __c,
103                   const _Allocator& __a = _Allocator())
104    : _Base(__n, __c, __a)
105    { }
106
107    template<typename _InputIterator>
108      basic_string(_InputIterator __begin, _InputIterator __end,
109                     const _Allocator& __a = _Allocator())
110      : _Base(__gnu_debug::__check_valid_range(__begin, __end), __end, __a)
111      { }
112
113    ~basic_string() { }
114
115    basic_string&
116    operator=(const basic_string& __str)
117    {
118      *static_cast<_Base*>(this) = __str;
119      this->_M_invalidate_all();
120      return *this;
121    }
122
123    basic_string&
124    operator=(const _CharT* __s)
125    {
126      __glibcxx_check_string(__s);
127      *static_cast<_Base*>(this) = __s;
128      this->_M_invalidate_all();
129      return *this;
130    }
131
132    basic_string&
133    operator=(_CharT __c)
134    {
135      *static_cast<_Base*>(this) = __c;
136      this->_M_invalidate_all();
137      return *this;
138    }
139
140    // 21.3.2 iterators:
141    iterator
142    begin()
143    { return iterator(_Base::begin(), this); }
144
145    const_iterator
146    begin() const
147    { return const_iterator(_Base::begin(), this); }
148
149    iterator
150    end()
151    { return iterator(_Base::end(), this); }
152
153    const_iterator
154    end() const
155    { return const_iterator(_Base::end(), this); }
156
157    reverse_iterator
158    rbegin()
159    { return reverse_iterator(end()); }
160
161    const_reverse_iterator
162    rbegin() const
163    { return const_reverse_iterator(end()); }
164
165    reverse_iterator
166    rend()
167    { return reverse_iterator(begin()); }
168
169    const_reverse_iterator
170    rend() const
171    { return const_reverse_iterator(begin()); }
172
173    // 21.3.3 capacity:
174    using _Base::size;
175    using _Base::length;
176    using _Base::max_size;
177
178    void
179    resize(size_type __n, _CharT __c)
180    {
181      _Base::resize(__n, __c);
182      this->_M_invalidate_all();
183    }
184
185    void
186    resize(size_type __n)
187    { this->resize(__n, _CharT()); }
188
189    using _Base::capacity;
190    using _Base::reserve;
191
192    void
193    clear()
194    {
195      _Base::clear();
196      this->_M_invalidate_all();
197    }
198
199    using _Base::empty;
200
201    // 21.3.4 element access:
202    const_reference
203    operator[](size_type __pos) const
204    {
205      _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
206                            _M_message(::__gnu_debug::__msg_subscript_oob)
207                            ._M_sequence(*this, "this")
208                            ._M_integer(__pos, "__pos")
209                            ._M_integer(this->size(), "size"));
210      return _M_base()[__pos];
211    }
212
213    reference
214    operator[](size_type __pos)
215    {
216      __glibcxx_check_subscript(__pos);
217      return _M_base()[__pos];
218    }
219
220    using _Base::at;
221
222    // 21.3.5 modifiers:
223    basic_string&
224    operator+=(const basic_string& __str)
225    {
226      _M_base() += __str;
227      this->_M_invalidate_all();
228      return *this;
229    }
230
231    basic_string&
232    operator+=(const _CharT* __s)
233    {
234      __glibcxx_check_string(__s);
235      _M_base() += __s;
236      this->_M_invalidate_all();
237      return *this;
238    }
239
240    basic_string&
241    operator+=(_CharT __c)
242    {
243      _M_base() += __c;
244      this->_M_invalidate_all();
245      return *this;
246    }
247
248    basic_string&
249    append(const basic_string& __str)
250    {
251      _Base::append(__str);
252      this->_M_invalidate_all();
253      return *this;
254    }
255
256    basic_string&
257    append(const basic_string& __str, size_type __pos, size_type __n)
258    {
259      _Base::append(__str, __pos, __n);
260      this->_M_invalidate_all();
261      return *this;
262    }
263
264    basic_string&
265    append(const _CharT* __s, size_type __n)
266    {
267      __glibcxx_check_string_len(__s, __n);
268      _Base::append(__s, __n);
269      this->_M_invalidate_all();
270      return *this;
271    }
272
273    basic_string&
274    append(const _CharT* __s)
275    {
276      __glibcxx_check_string(__s);
277      _Base::append(__s);
278      this->_M_invalidate_all();
279      return *this;
280    }
281
282    basic_string&
283    append(size_type __n, _CharT __c)
284    {
285      _Base::append(__n, __c);
286      this->_M_invalidate_all();
287      return *this;
288    }
289
290    template<typename _InputIterator>
291      basic_string&
292      append(_InputIterator __first, _InputIterator __last)
293      {
294        __glibcxx_check_valid_range(__first, __last);
295        _Base::append(__first, __last);
296        this->_M_invalidate_all();
297        return *this;
298      }
299
300    // _GLIBCXX_RESOLVE_LIB_DEFECTS
301    // 7. string clause minor problems
302    void
303    push_back(_CharT __c)
304    {
305      _Base::push_back(__c);
306      this->_M_invalidate_all();
307    }
308
309    basic_string&
310    assign(const basic_string& __x)
311    {
312      _Base::assign(__x);
313      this->_M_invalidate_all();
314      return *this;
315    }
316
317    basic_string&
318    assign(const basic_string& __str, size_type __pos, size_type __n)
319    {
320      _Base::assign(__str, __pos, __n);
321      this->_M_invalidate_all();
322      return *this;
323    }
324
325    basic_string&
326    assign(const _CharT* __s, size_type __n)
327    {
328      __glibcxx_check_string_len(__s, __n);
329      _Base::assign(__s, __n);
330      this->_M_invalidate_all();
331      return *this;
332    }
333
334    basic_string&
335    assign(const _CharT* __s)
336    {
337      __glibcxx_check_string(__s);
338      _Base::assign(__s);
339      this->_M_invalidate_all();
340      return *this;
341    }
342
343    basic_string&
344    assign(size_type __n, _CharT __c)
345    {
346      _Base::assign(__n, __c);
347      this->_M_invalidate_all();
348      return *this;
349    }
350
351    template<typename _InputIterator>
352      basic_string&
353      assign(_InputIterator __first, _InputIterator __last)
354      {
355        __glibcxx_check_valid_range(__first, __last);
356        _Base::assign(__first, __last);
357        this->_M_invalidate_all();
358        return *this;
359      }
360
361    basic_string&
362    insert(size_type __pos1, const basic_string& __str)
363    {
364      _Base::insert(__pos1, __str);
365      this->_M_invalidate_all();
366      return *this;
367    }
368
369    basic_string&
370    insert(size_type __pos1, const basic_string& __str,
371           size_type __pos2, size_type __n)
372    {
373      _Base::insert(__pos1, __str, __pos2, __n);
374      this->_M_invalidate_all();
375      return *this;
376    }
377
378    basic_string&
379    insert(size_type __pos, const _CharT* __s, size_type __n)
380    {
381      __glibcxx_check_string(__s);
382      _Base::insert(__pos, __s, __n);
383      this->_M_invalidate_all();
384      return *this;
385    }
386
387    basic_string&
388    insert(size_type __pos, const _CharT* __s)
389    {
390      __glibcxx_check_string(__s);
391      _Base::insert(__pos, __s);
392      this->_M_invalidate_all();
393      return *this;
394    }
395
396    basic_string&
397    insert(size_type __pos, size_type __n, _CharT __c)
398    {
399      _Base::insert(__pos, __n, __c);
400      this->_M_invalidate_all();
401      return *this;
402    }
403
404    iterator
405    insert(iterator __p, _CharT __c)
406    {
407      __glibcxx_check_insert(__p);
408      typename _Base::iterator __res = _Base::insert(__p.base(), __c);
409      this->_M_invalidate_all();
410      return iterator(__res, this);
411    }
412
413    void
414    insert(iterator __p, size_type __n, _CharT __c)
415    {
416      __glibcxx_check_insert(__p);
417      _Base::insert(__p.base(), __n, __c);
418      this->_M_invalidate_all();
419    }
420
421    template<typename _InputIterator>
422      void
423      insert(iterator __p, _InputIterator __first, _InputIterator __last)
424      {
425        __glibcxx_check_insert_range(__p, __first, __last);
426        _Base::insert(__p.base(), __first, __last);
427        this->_M_invalidate_all();
428      }
429
430    basic_string&
431    erase(size_type __pos = 0, size_type __n = _Base::npos)
432    {
433      _Base::erase(__pos, __n);
434      this->_M_invalidate_all();
435      return *this;
436    }
437
438    iterator
439    erase(iterator __position)
440    {
441      __glibcxx_check_erase(__position);
442      typename _Base::iterator __res = _Base::erase(__position.base());
443      this->_M_invalidate_all();
444      return iterator(__res, this);
445    }
446
447    iterator
448    erase(iterator __first, iterator __last)
449    {
450      // _GLIBCXX_RESOLVE_LIB_DEFECTS
451      // 151. can't currently clear() empty container
452      __glibcxx_check_erase_range(__first, __last);
453      typename _Base::iterator __res = _Base::erase(__first.base(),
454                                                       __last.base());
455      this->_M_invalidate_all();
456      return iterator(__res, this);
457    }
458
459    basic_string&
460    replace(size_type __pos1, size_type __n1, const basic_string& __str)
461    {
462      _Base::replace(__pos1, __n1, __str);
463      this->_M_invalidate_all();
464      return *this;
465    }
466
467    basic_string&
468    replace(size_type __pos1, size_type __n1, const basic_string& __str,
469            size_type __pos2, size_type __n2)
470    {
471      _Base::replace(__pos1, __n1, __str, __pos2, __n2);
472      this->_M_invalidate_all();
473      return *this;
474    }
475
476    basic_string&
477    replace(size_type __pos, size_type __n1, const _CharT* __s,
478            size_type __n2)
479    {
480      __glibcxx_check_string_len(__s, __n2);
481      _Base::replace(__pos, __n1, __s, __n2);
482      this->_M_invalidate_all();
483      return *this;
484    }
485
486    basic_string&
487    replace(size_type __pos, size_type __n1, const _CharT* __s)
488    {
489      __glibcxx_check_string(__s);
490      _Base::replace(__pos, __n1, __s);
491      this->_M_invalidate_all();
492      return *this;
493    }
494
495    basic_string&
496    replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
497    {
498      _Base::replace(__pos, __n1, __n2, __c);
499      this->_M_invalidate_all();
500      return *this;
501    }
502
503    basic_string&
504    replace(iterator __i1, iterator __i2, const basic_string& __str)
505    {
506      __glibcxx_check_erase_range(__i1, __i2);
507      _Base::replace(__i1.base(), __i2.base(), __str);
508      this->_M_invalidate_all();
509      return *this;
510    }
511
512    basic_string&
513    replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
514    {
515      __glibcxx_check_erase_range(__i1, __i2);
516      __glibcxx_check_string_len(__s, __n);
517      _Base::replace(__i1.base(), __i2.base(), __s, __n);
518      this->_M_invalidate_all();
519      return *this;
520    }
521
522    basic_string&
523    replace(iterator __i1, iterator __i2, const _CharT* __s)
524    {
525      __glibcxx_check_erase_range(__i1, __i2);
526      __glibcxx_check_string(__s);
527      _Base::replace(__i1.base(), __i2.base(), __s);
528      this->_M_invalidate_all();
529      return *this;
530    }
531
532    basic_string&
533    replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
534    {
535      __glibcxx_check_erase_range(__i1, __i2);
536      _Base::replace(__i1.base(), __i2.base(), __n, __c);
537      this->_M_invalidate_all();
538      return *this;
539    }
540
541    template<typename _InputIterator>
542      basic_string&
543      replace(iterator __i1, iterator __i2,
544              _InputIterator __j1, _InputIterator __j2)
545      {
546        __glibcxx_check_erase_range(__i1, __i2);
547        __glibcxx_check_valid_range(__j1, __j2);
548        _Base::replace(__i1.base(), __i2.base(), __j1, __j2);
549        this->_M_invalidate_all();
550        return *this;
551      }
552
553    size_type
554    copy(_CharT* __s, size_type __n, size_type __pos = 0) const
555    {
556      __glibcxx_check_string_len(__s, __n);
557      return _Base::copy(__s, __n, __pos);
558    }
559
560    void
561    swap(basic_string<_CharT,_Traits,_Allocator>& __x)
562    {
563      _Base::swap(__x);
564      this->_M_swap(__x);
565      this->_M_invalidate_all();
566      __x._M_invalidate_all();
567    }
568
569    // 21.3.6 string operations:
570    const _CharT*
571    c_str() const
572    {
573      const _CharT* __res = _Base::c_str();
574      this->_M_invalidate_all();
575      return __res;
576    }
577
578    const _CharT*
579    data() const
580    {
581      const _CharT* __res = _Base::data();
582      this->_M_invalidate_all();
583      return __res;
584    }
585
586    using _Base::get_allocator;
587
588    size_type
589    find(const basic_string& __str, size_type __pos = 0) const
590    { return _Base::find(__str, __pos); }
591
592    size_type
593    find(const _CharT* __s, size_type __pos, size_type __n) const
594    {
595      __glibcxx_check_string(__s);
596      return _Base::find(__s, __pos, __n);
597    }
598
599    size_type
600    find(const _CharT* __s, size_type __pos = 0) const
601    {
602      __glibcxx_check_string(__s);
603      return _Base::find(__s, __pos);
604    }
605
606    size_type
607    find(_CharT __c, size_type __pos = 0) const
608    { return _Base::find(__c, __pos); }
609
610    size_type
611    rfind(const basic_string& __str, size_type __pos = _Base::npos) const
612    { return _Base::rfind(__str, __pos); }
613
614    size_type
615    rfind(const _CharT* __s, size_type __pos, size_type __n) const
616    {
617      __glibcxx_check_string_len(__s, __n);
618      return _Base::rfind(__s, __pos, __n);
619    }
620
621    size_type
622    rfind(const _CharT* __s, size_type __pos = _Base::npos) const
623    {
624      __glibcxx_check_string(__s);
625      return _Base::rfind(__s, __pos);
626    }
627
628    size_type
629    rfind(_CharT __c, size_type __pos = _Base::npos) const
630    { return _Base::rfind(__c, __pos); }
631
632    size_type
633    find_first_of(const basic_string& __str, size_type __pos = 0) const
634    { return _Base::find_first_of(__str, __pos); }
635
636    size_type
637    find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
638    {
639      __glibcxx_check_string(__s);
640      return _Base::find_first_of(__s, __pos, __n);
641    }
642
643    size_type
644    find_first_of(const _CharT* __s, size_type __pos = 0) const
645    {
646      __glibcxx_check_string(__s);
647      return _Base::find_first_of(__s, __pos);
648    }
649
650    size_type
651    find_first_of(_CharT __c, size_type __pos = 0) const
652    { return _Base::find_first_of(__c, __pos); }
653
654    size_type
655    find_last_of(const basic_string& __str, size_type __pos = _Base::npos) const
656    { return _Base::find_last_of(__str, __pos); }
657
658    size_type
659    find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
660    {
661      __glibcxx_check_string(__s);
662      return _Base::find_last_of(__s, __pos, __n);
663    }
664
665    size_type
666    find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
667    {
668      __glibcxx_check_string(__s);
669      return _Base::find_last_of(__s, __pos);
670    }
671
672    size_type
673    find_last_of(_CharT __c, size_type __pos = _Base::npos) const
674    { return _Base::find_last_of(__c, __pos); }
675
676    size_type
677    find_first_not_of(const basic_string& __str, size_type __pos = 0) const
678    { return _Base::find_first_not_of(__str, __pos); }
679
680    size_type
681    find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
682    {
683      __glibcxx_check_string_len(__s, __n);
684      return _Base::find_first_not_of(__s, __pos, __n);
685    }
686
687    size_type
688    find_first_not_of(const _CharT* __s, size_type __pos = 0) const
689    {
690      __glibcxx_check_string(__s);
691      return _Base::find_first_not_of(__s, __pos);
692    }
693
694    size_type
695    find_first_not_of(_CharT __c, size_type __pos = 0) const
696    { return _Base::find_first_not_of(__c, __pos); }
697
698    size_type
699    find_last_not_of(const basic_string& __str,
700                                  size_type __pos = _Base::npos) const
701    { return _Base::find_last_not_of(__str, __pos); }
702
703    size_type
704    find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
705    {
706      __glibcxx_check_string(__s);
707      return _Base::find_last_not_of(__s, __pos, __n);
708    }
709
710    size_type
711    find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
712    {
713      __glibcxx_check_string(__s);
714      return _Base::find_last_not_of(__s, __pos);
715    }
716
717    size_type
718    find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
719    { return _Base::find_last_not_of(__c, __pos); }
720
721    basic_string
722    substr(size_type __pos = 0, size_type __n = _Base::npos) const
723    { return basic_string(_Base::substr(__pos, __n)); }
724
725    int
726    compare(const basic_string& __str) const
727    { return _Base::compare(__str); }
728
729    int
730    compare(size_type __pos1, size_type __n1,
731                  const basic_string& __str) const
732    { return _Base::compare(__pos1, __n1, __str); }
733
734    int
735    compare(size_type __pos1, size_type __n1, const basic_string& __str,
736              size_type __pos2, size_type __n2) const
737    { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
738
739    int
740    compare(const _CharT* __s) const
741    {
742      __glibcxx_check_string(__s);
743      return _Base::compare(__s);
744    }
745
746    //  _GLIBCXX_RESOLVE_LIB_DEFECTS
747    //  5. string::compare specification questionable
748    int
749    compare(size_type __pos1, size_type __n1, const _CharT* __s) const
750    {
751      __glibcxx_check_string(__s);
752      return _Base::compare(__pos1, __n1, __s);
753    }
754
755    //  _GLIBCXX_RESOLVE_LIB_DEFECTS
756    //  5. string::compare specification questionable
757    int
758    compare(size_type __pos1, size_type __n1,const _CharT* __s,
759              size_type __n2) const
760    {
761      __glibcxx_check_string_len(__s, __n2);
762      return _Base::compare(__pos1, __n1, __s, __n2);
763    }
764
765    _Base&
766    _M_base() { return *this; }
767
768    const _Base&
769    _M_base() const { return *this; }
770
771    using _Safe_base::_M_invalidate_all;
772  };
773
774  template<typename _CharT, typename _Traits, typename _Allocator>
775    inline basic_string<_CharT,_Traits,_Allocator>
776    operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
777              const basic_string<_CharT,_Traits,_Allocator>& __rhs)
778    { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
779
780  template<typename _CharT, typename _Traits, typename _Allocator>
781    inline basic_string<_CharT,_Traits,_Allocator>
782    operator+(const _CharT* __lhs,
783              const basic_string<_CharT,_Traits,_Allocator>& __rhs)
784    {
785      __glibcxx_check_string(__lhs);
786      return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
787    }
788
789  template<typename _CharT, typename _Traits, typename _Allocator>
790    inline basic_string<_CharT,_Traits,_Allocator>
791    operator+(_CharT __lhs,
792              const basic_string<_CharT,_Traits,_Allocator>& __rhs)
793    { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
794
795  template<typename _CharT, typename _Traits, typename _Allocator>
796    inline basic_string<_CharT,_Traits,_Allocator>
797    operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
798              const _CharT* __rhs)
799    {
800      __glibcxx_check_string(__rhs);
801      return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
802    }
803
804  template<typename _CharT, typename _Traits, typename _Allocator>
805    inline basic_string<_CharT,_Traits,_Allocator>
806    operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
807              _CharT __rhs)
808    { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
809
810  template<typename _CharT, typename _Traits, typename _Allocator>
811    inline bool
812    operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
813               const basic_string<_CharT,_Traits,_Allocator>& __rhs)
814    { return __lhs._M_base() == __rhs._M_base(); }
815
816  template<typename _CharT, typename _Traits, typename _Allocator>
817    inline bool
818    operator==(const _CharT* __lhs,
819               const basic_string<_CharT,_Traits,_Allocator>& __rhs)
820    {
821      __glibcxx_check_string(__lhs);
822      return __lhs == __rhs._M_base();
823    }
824
825  template<typename _CharT, typename _Traits, typename _Allocator>
826    inline bool
827    operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
828               const _CharT* __rhs)
829    {
830      __glibcxx_check_string(__rhs);
831      return __lhs._M_base() == __rhs;
832    }
833
834  template<typename _CharT, typename _Traits, typename _Allocator>
835    inline bool
836    operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
837               const basic_string<_CharT,_Traits,_Allocator>& __rhs)
838    { return __lhs._M_base() != __rhs._M_base(); }
839
840  template<typename _CharT, typename _Traits, typename _Allocator>
841    inline bool
842    operator!=(const _CharT* __lhs,
843               const basic_string<_CharT,_Traits,_Allocator>& __rhs)
844    {
845      __glibcxx_check_string(__lhs);
846      return __lhs != __rhs._M_base();
847    }
848
849  template<typename _CharT, typename _Traits, typename _Allocator>
850    inline bool
851    operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
852               const _CharT* __rhs)
853    {
854      __glibcxx_check_string(__rhs);
855      return __lhs._M_base() != __rhs;
856    }
857
858  template<typename _CharT, typename _Traits, typename _Allocator>
859    inline bool
860    operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
861              const basic_string<_CharT,_Traits,_Allocator>& __rhs)
862    { return __lhs._M_base() < __rhs._M_base(); }
863
864  template<typename _CharT, typename _Traits, typename _Allocator>
865    inline bool
866    operator<(const _CharT* __lhs,
867              const basic_string<_CharT,_Traits,_Allocator>& __rhs)
868    {
869      __glibcxx_check_string(__lhs);
870      return __lhs < __rhs._M_base();
871    }
872
873  template<typename _CharT, typename _Traits, typename _Allocator>
874    inline bool
875    operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
876              const _CharT* __rhs)
877    {
878      __glibcxx_check_string(__rhs);
879      return __lhs._M_base() < __rhs;
880    }
881
882  template<typename _CharT, typename _Traits, typename _Allocator>
883    inline bool
884    operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
885               const basic_string<_CharT,_Traits,_Allocator>& __rhs)
886    { return __lhs._M_base() <= __rhs._M_base(); }
887
888  template<typename _CharT, typename _Traits, typename _Allocator>
889    inline bool
890    operator<=(const _CharT* __lhs,
891               const basic_string<_CharT,_Traits,_Allocator>& __rhs)
892    {
893      __glibcxx_check_string(__lhs);
894      return __lhs <= __rhs._M_base();
895    }
896
897  template<typename _CharT, typename _Traits, typename _Allocator>
898    inline bool
899    operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
900               const _CharT* __rhs)
901    {
902      __glibcxx_check_string(__rhs);
903      return __lhs._M_base() <= __rhs;
904    }
905
906  template<typename _CharT, typename _Traits, typename _Allocator>
907    inline bool
908    operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
909               const basic_string<_CharT,_Traits,_Allocator>& __rhs)
910    { return __lhs._M_base() >= __rhs._M_base(); }
911
912  template<typename _CharT, typename _Traits, typename _Allocator>
913    inline bool
914    operator>=(const _CharT* __lhs,
915               const basic_string<_CharT,_Traits,_Allocator>& __rhs)
916    {
917      __glibcxx_check_string(__lhs);
918      return __lhs >= __rhs._M_base();
919    }
920
921  template<typename _CharT, typename _Traits, typename _Allocator>
922    inline bool
923    operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
924               const _CharT* __rhs)
925    {
926      __glibcxx_check_string(__rhs);
927      return __lhs._M_base() >= __rhs;
928    }
929
930  template<typename _CharT, typename _Traits, typename _Allocator>
931    inline bool
932    operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
933              const basic_string<_CharT,_Traits,_Allocator>& __rhs)
934    { return __lhs._M_base() > __rhs._M_base(); }
935
936  template<typename _CharT, typename _Traits, typename _Allocator>
937    inline bool
938    operator>(const _CharT* __lhs,
939              const basic_string<_CharT,_Traits,_Allocator>& __rhs)
940    {
941      __glibcxx_check_string(__lhs);
942      return __lhs > __rhs._M_base();
943    }
944
945  template<typename _CharT, typename _Traits, typename _Allocator>
946    inline bool
947    operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
948              const _CharT* __rhs)
949    {
950      __glibcxx_check_string(__rhs);
951      return __lhs._M_base() > __rhs;
952    }
953
954  // 21.3.7.8:
955  template<typename _CharT, typename _Traits, typename _Allocator>
956    inline void
957    swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
958         basic_string<_CharT,_Traits,_Allocator>& __rhs)
959    { __lhs.swap(__rhs); }
960
961  template<typename _CharT, typename _Traits, typename _Allocator>
962    std::basic_ostream<_CharT, _Traits>&
963    operator<<(std::basic_ostream<_CharT, _Traits>& __os,
964               const basic_string<_CharT, _Traits, _Allocator>& __str)
965    { return __os << __str._M_base(); }
966
967  template<typename _CharT, typename _Traits, typename _Allocator>
968    std::basic_istream<_CharT,_Traits>&
969    operator>>(std::basic_istream<_CharT,_Traits>& __is,
970               basic_string<_CharT,_Traits,_Allocator>& __str)
971    {
972      std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
973      __str._M_invalidate_all();
974      return __res;
975    }
976
977  template<typename _CharT, typename _Traits, typename _Allocator>
978    std::basic_istream<_CharT,_Traits>&
979    getline(std::basic_istream<_CharT,_Traits>& __is,
980            basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
981    {
982      std::basic_istream<_CharT,_Traits>& __res = getline(__is,
983                                                          __str._M_base(),
984                                                        __delim);
985      __str._M_invalidate_all();
986      return __res;
987    }
988
989  template<typename _CharT, typename _Traits, typename _Allocator>
990    std::basic_istream<_CharT,_Traits>&
991    getline(std::basic_istream<_CharT,_Traits>& __is,
992            basic_string<_CharT,_Traits,_Allocator>& __str)
993    {
994      std::basic_istream<_CharT,_Traits>& __res = getline(__is,
995                                                          __str._M_base());
996      __str._M_invalidate_all();
997      return __res;
998    }
999} // namespace __gnu_debug
1000
1001#endif
Note: See TracBrowser for help on using the repository browser.