⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _string.h

📁 symbian 上的stl_port进过编译的。
💻 H
📖 第 1 页 / 共 4 页
字号:
    if (this->_M_using_static_buf()) {      _Traits::assign(this->_M_Start(), __n, __x);      this->_M_finish = this->_M_Start() + __n;    }    else#endif /* _STLP_USE_SHORT_STRING_OPTIM */    this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_Start(), __n, __x);    this->_M_terminate_string();  }  template <class _InputIter>  void _M_initialize_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) {    _M_range_initializeT(__f, __l);  }public:  ~basic_string()  { this->_M_destroy_range(); }  _Self& operator=(const _Self& __s) {    if (&__s != this)      _M_assign(__s._M_Start(), __s._M_Finish());    return *this;  }  _Self& operator=(const _CharT* __s) {    _STLP_FIX_LITERAL_BUG(__s)    return _M_assign(__s, __s + traits_type::length(__s));  }  _Self& operator=(_CharT __c)  { return assign(__STATIC_CAST(size_type,1), __c); }protected:  static _CharT _STLP_CALL _M_null()  { return _STLP_DEFAULT_CONSTRUCTED(_CharT); }protected:                     // Helper functions used by constructors                               // and elsewhere.  // fbp : simplify integer types (char, wchar)  void _M_construct_null_aux(_CharT* __p, const __false_type& /*_Is_Integral*/) const {#if defined (_STLP_USE_SHORT_STRING_OPTIM)    if (this->_M_using_static_buf())      _Traits::assign(*__p, _M_null());    else#endif /*_STLP_USE_SHORT_STRING_OPTIM*/    _STLP_STD::_Construct(__p);  }  void _M_construct_null_aux(_CharT* __p, const __true_type& /*_Is_Integral*/) const  { *__p = 0; }  void _M_force_construct_null(_CharT*, const __true_type& /* _Is_POD */) const  { /*Nothing to do*/ }  void _M_force_construct_null(_CharT* __p, const __false_type& /* _Is_POD */) const  { _M_construct_null_aux(__p, _Char_Is_Integral()); }  void _M_construct_null(_CharT* __p) const {    typedef __false_type _Answer;    _M_force_construct_null(__p, _Answer());  }protected:  // Helper functions used by constructors.  It is a severe error for  // any of them to be called anywhere except from within constructors.  void _M_terminate_string_aux(const __false_type& __is_integral) {    _STLP_TRY {      _M_construct_null_aux(this->_M_Finish(), __is_integral);    }    _STLP_UNWIND(this->_M_destroy_range(0,0))  }  void _M_terminate_string_aux(const __true_type& __is_integral)  { _M_construct_null_aux(this->_M_Finish(), __is_integral); }  void _M_force_terminate_string(const __true_type& /* _Is_POD */)  { /*Nothing to do*/ }  void _M_force_terminate_string(const __false_type& /* _Is_POD */)  { _M_terminate_string_aux(_Char_Is_Integral()); }  void _M_terminate_string() {    typedef __false_type _Answer;    _M_force_terminate_string(_Answer());  }  bool _M_inside(const _CharT* __s) const {    _STLP_FIX_LITERAL_BUG(__s)    return (__s >= this->_M_Start()) && (__s < this->_M_Finish());  }  void _M_range_initialize(const _CharT* __f, const _CharT* __l) {    _STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)    ptrdiff_t __n = __l - __f;    this->_M_allocate_block(__n + 1);#if defined (_STLP_USE_SHORT_STRING_OPTIM)    if (this->_M_using_static_buf()) {      _M_copy(__f, __l, this->_M_Start());      this->_M_finish = this->_M_Start() + __n;    }    else#endif /* _STLP_USE_SHORT_STRING_OPTIM */    this->_M_finish = uninitialized_copy(__f, __l, this->_M_Start());    _M_terminate_string();  }public:                         // Iterators.  iterator begin()             { return this->_M_Start(); }  iterator end()               { return this->_M_Finish(); }  const_iterator begin() const { return this->_M_Start(); }  const_iterator end()   const { return this->_M_Finish(); }  reverse_iterator rbegin()    { return reverse_iterator(this->_M_Finish()); }  reverse_iterator rend()    { return reverse_iterator(this->_M_Start()); }  const_reverse_iterator rbegin() const    { return const_reverse_iterator(this->_M_Finish()); }  const_reverse_iterator rend()   const    { return const_reverse_iterator(this->_M_Start()); }public:                         // Size, capacity, etc.  size_type size() const { return this->_M_Finish() - this->_M_Start(); }  size_type length() const { return size(); }  size_t max_size() const { return _Base::max_size(); }  void resize(size_type __n, _CharT __c) {    if (__n <= size())      erase(begin() + __n, end());    else      append(__n - size(), __c);  }  void resize(size_type __n) { resize(__n, _M_null()); }  void reserve(size_type = 0);  size_type capacity() const  { return (this->_M_end_of_storage._M_data - this->_M_Start()) - 1; }  void clear() {    if (!empty()) {      _Traits::assign(*(this->_M_Start()), _M_null());      this->_M_destroy_range(1);      this->_M_finish = this->_M_Start();    }  }  bool empty() const { return this->_M_Start() == this->_M_Finish(); }public:                         // Element access.  const_reference operator[](size_type __n) const  { return *(this->_M_Start() + __n); }  reference operator[](size_type __n)  { return *(this->_M_Start() + __n); }  const_reference at(size_type __n) const {    if (__n >= size())      this->_M_throw_out_of_range();    return *(this->_M_Start() + __n);  }  reference at(size_type __n) {    if (__n >= size())      this->_M_throw_out_of_range();    return *(this->_M_Start() + __n);  }public:                         // Append, operator+=, push_back.  _Self& operator+=(const _Self& __s) { return append(__s); }  _Self& operator+=(const _CharT* __s) { _STLP_FIX_LITERAL_BUG(__s) return append(__s); }  _Self& operator+=(_CharT __c) { push_back(__c); return *this; }#if defined (_STLP_MEMBER_TEMPLATES)#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)private: // Helper functions for append.  template <class _InputIter>  _Self& _M_appendT(_InputIter __first, _InputIter __last,                    const input_iterator_tag &) {    for ( ; __first != __last ; ++__first)      push_back(*__first);    return *this;  }  template <class _ForwardIter>  _Self& _M_appendT(_ForwardIter __first, _ForwardIter __last,                    const forward_iterator_tag &) {    if (__first != __last) {      const size_type __old_size = this->size();      difference_type __n = distance(__first, __last);      if (__STATIC_CAST(size_type,__n) > this->max_size() || __old_size > this->max_size() - __STATIC_CAST(size_type,__n))        this->_M_throw_length_error();      if (__old_size + __n > this->capacity()) {        size_type __len = __old_size + (max)(__old_size, __STATIC_CAST(size_type,__n)) + 1;        pointer __new_start = this->_M_end_of_storage.allocate(__len, __len);        pointer __new_finish = __new_start;        _STLP_TRY {          __new_finish = uninitialized_copy(this->_M_Start(), this->_M_Finish(), __new_start);          __new_finish = uninitialized_copy(__first, __last, __new_finish);          _M_construct_null(__new_finish);        }        _STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish),          this->_M_end_of_storage.deallocate(__new_start, __len)))          this->_M_destroy_range();        this->_M_deallocate_block();        this->_M_reset(__new_start, __new_finish, __new_start + __len);      }      else {        _ForwardIter __f1 = __first;        ++__f1;#if defined (_STLP_USE_SHORT_STRING_OPTIM)        if (this->_M_using_static_buf())          _M_copyT(__f1, __last, this->_M_Finish() + 1);        else#endif /* _STLP_USE_SHORT_STRING_OPTIM */          uninitialized_copy(__f1, __last, this->_M_Finish() + 1);        _STLP_TRY {          _M_construct_null(this->_M_Finish() + __n);        }        _STLP_UNWIND(this->_M_destroy_ptr_range(this->_M_Finish() + 1, this->_M_Finish() + __n))        _Traits::assign(*this->_M_finish, *__first);        this->_M_finish += __n;      }    }    return *this;  }  template <class _Integer>  _Self& _M_append_dispatch(_Integer __n, _Integer __x, const __true_type& /*Integral*/)  { return append((size_type) __n, (_CharT) __x); }  template <class _InputIter>  _Self& _M_append_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*Integral*/)  { return _M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter)); }public:  // Check to see if _InputIterator is an integer type.  If so, then  // it can't be an iterator.  template <class _InputIter>  _Self& append(_InputIter __first, _InputIter __last) {    typedef typename _IsIntegral<_InputIter>::_Ret _Integral;    return _M_append_dispatch(__first, __last, _Integral());  }#  endif#endifprotected:  _Self& _M_append(const _CharT* __first, const _CharT* __last);public:#if !defined (_STLP_MEMBER_TEMPLATES) || \    !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)  _Self& append(const _CharT* __first, const _CharT* __last) {    _STLP_FIX_LITERAL_BUG(__first)_STLP_FIX_LITERAL_BUG(__last)    return _M_append(__first, __last);  }#  endif#endif  _Self& append(const _Self& __s)  { return _M_append(__s._M_Start(), __s._M_Finish()); }  _Self& append(const _Self& __s,                size_type __pos, size_type __n) {    if (__pos > __s.size())      this->_M_throw_out_of_range();    return _M_append(__s._M_Start() + __pos,                     __s._M_Start() + __pos + (min) (__n, __s.size() - __pos));  }  _Self& append(const _CharT* __s, size_type __n)  { _STLP_FIX_LITERAL_BUG(__s) return _M_append(__s, __s+__n); }  _Self& append(const _CharT* __s)  { _STLP_FIX_LITERAL_BUG(__s) return _M_append(__s, __s + traits_type::length(__s)); }  _Self& append(size_type __n, _CharT __c);public:  void push_back(_CharT __c) {    if (this->_M_Finish() + 1 == this->_M_end_of_storage._M_data)      reserve(size() + (max)(size(), __STATIC_CAST(size_type,1)));    _M_construct_null(this->_M_Finish() + 1);    _Traits::assign(*(this->_M_Finish()), __c);    ++this->_M_finish;  }  void pop_back() {    _Traits::assign(*(this->_M_Finish() - 1), _M_null());    this->_M_destroy_back();    --this->_M_finish;  }public:                         // Assign  _Self& assign(const _Self& __s)  { return _M_assign(__s._M_Start(), __s._M_Finish()); }  _Self& assign(const _Self& __s,                size_type __pos, size_type __n) {    if (__pos > __s.size())      this->_M_throw_out_of_range();    return _M_assign(__s._M_Start() + __pos,                     __s._M_Start() + __pos + (min) (__n, __s.size() - __pos));  }  _Self& assign(const _CharT* __s, size_type __n)  { _STLP_FIX_LITERAL_BUG(__s) return _M_assign(__s, __s + __n); }  _Self& assign(const _CharT* __s)  { _STLP_FIX_LITERAL_BUG(__s) return _M_assign(__s, __s + _Traits::length(__s)); }  _Self& assign(size_type __n, _CharT __c);#if defined (_STLP_MEMBER_TEMPLATES)#  if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)private:                        // Helper functions for assign.  template <class _Integer>  _Self& _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/)  { return assign((size_type) __n, (_CharT) __x); }  template <class _InputIter>  _Self& _M_assign_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) {    pointer __cur = this->_M_Start();    while (__f != __l && __cur != this->_M_Finish()) {      _Traits::assign(*__cur, *__f);      ++__f;      ++__cur;    }    if (__f == __l)      erase(__cur, this->end());    else      _M_appendT(__f, __l, _STLP_ITERATOR_CATEGORY(__f, _InputIter));    return *this;  }public:  // Check to see if _InputIterator is an integer type.  If so, then  // it can't be an iterator.  template <class _InputIter>  _Self& assign(_InputIter __first, _InputIter __last) {    typedef typename _IsIntegral<_InputIter>::_Ret _Integral;    return _M_assign_dispatch(__first, __last, _Integral());  }#  endif#endifprotected:  _Self& _M_assign(const _CharT* __f, const _CharT* __l);public:#if !defined (_STLP_MEMBER_TEMPLATES) || \    !defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -