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

📄 _string.tcc

📁 symbian上STL模板库的实现
💻 TCC
📖 第 1 页 / 共 2 页
字号:
            _STLP_STD::_Destroy(this->_M_start, this->_M_finish + 1);            this->_M_deallocate_block();            this->_M_start = __new_start;            this->_M_finish = __new_finish;            this->_M_end_of_storage._M_data = __new_start + __len;         }    }}#endif /* _STLP_MEMBER_TEMPLATES */template <class _CharT, class _Traits, class _Alloc> basic_string<_CharT,_Traits,_Alloc>& basic_string<_CharT,_Traits,_Alloc> ::replace(iterator __first, iterator __last, size_type __n, _CharT __c){    size_type __len = (size_type)(__last - __first);    if (__len >= __n) {        _Traits::assign(__first, __n, __c);        erase(__first + __n, __last);    }    else {        _Traits::assign(__first, __len, __c);        insert(__last, __n - __len, __c);    }    return *this;}#ifndef _STLP_MEMBER_TEMPLATEStemplate <class _CharT, class _Traits, class _Alloc> basic_string<_CharT,_Traits,_Alloc>& basic_string<_CharT,_Traits,_Alloc> ::replace(iterator __first, iterator __last,        const _CharT* __f, const _CharT* __l){    const ptrdiff_t         __n = __l - __f;    const difference_type __len = __last - __first;    if (__len >= __n) {        _M_copy(__f, __l, __first);        erase(__first + __n, __last);    }    else {        const _CharT* __m = __f + __len;        _M_copy(__f, __m, __first);        insert(__last, __m, __l);    }    return *this;}#endif /* _STLP_MEMBER_TEMPLATES */template <class _CharT, class _Traits, class _Alloc> __size_type__basic_string<_CharT,_Traits,_Alloc> ::find(const _CharT* __s, size_type __pos, size_type __n) const {    if (__pos + __n > size())        return npos;    else {        const const_pointer __result =            _STLP_STD::search((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish,                     __s, __s + __n, _Eq_traits<_Traits>());        return __result != this->_M_finish ? __result - this->_M_start : npos;    }}template <class _CharT, class _Traits, class _Alloc> __size_type__basic_string<_CharT,_Traits,_Alloc> ::find(_CharT __c, size_type __pos) const {    if (__pos >= size())        return npos;    else {        const const_pointer __result =            _STLP_STD::find_if((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish,                    _Eq_char_bound<_Traits>(__c));        return __result != this->_M_finish ? __result - this->_M_start : npos;    }}    template <class _CharT, class _Traits, class _Alloc> __size_type__basic_string<_CharT,_Traits,_Alloc> ::rfind(const _CharT* __s, size_type __pos, size_type __n) const {    const size_t __len = size();    if (__n > __len)        return npos;    else if (__n == 0)        return (min) (__len, __pos);    else {        const_pointer __last = this->_M_start + (min) (__len - __n, __pos) + __n;        const_pointer __result = _STLP_STD::find_end((const_pointer)this->_M_start, __last,                __s, __s + __n,                _Eq_traits<_Traits>());        return __result != __last ? __result - this->_M_start : npos;    }}template <class _CharT, class _Traits, class _Alloc> __size_type__basic_string<_CharT,_Traits,_Alloc> ::rfind(_CharT __c, size_type __pos) const {    const size_type __len = size();    if (__len < 1)        return npos;    else {        const const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;        const_reverse_iterator __rresult =            _STLP_STD::find_if(const_reverse_iterator(__last), rend(),                    _Eq_char_bound<_Traits>(__c));        return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;    }}template <class _CharT, class _Traits, class _Alloc> __size_type__basic_string<_CharT,_Traits,_Alloc> ::find_first_of(const _CharT* __s, size_type __pos, size_type __n) const{    if (__pos >= size())        return npos;    else {        const_iterator __result = __find_first_of(begin() + __pos, end(),                __s, __s + __n,                _Eq_traits<_Traits>());        return __result != end() ? __result - begin() : npos;    }}template <class _CharT, class _Traits, class _Alloc> __size_type__basic_string<_CharT,_Traits,_Alloc> ::find_last_of(const _CharT* __s, size_type __pos, size_type __n) const{    const size_type __len = size();    if (__len < 1)        return npos;    else {        const const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;        const const_reverse_iterator __rresult =            __find_first_of(const_reverse_iterator(__last), rend(),                    __s, __s + __n,                    _Eq_traits<_Traits>());        return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;    }}template <class _CharT, class _Traits, class _Alloc> __size_type__basic_string<_CharT,_Traits,_Alloc> ::find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const{    typedef typename _Traits::char_type _CharType;    if (__pos > size())        return npos;    else {        const_pointer __result = _STLP_STD::find_if((const _CharT*)this->_M_start + __pos,                 (const _CharT*)this->_M_finish,                _Not_within_traits<_Traits>((const _CharType*)__s,                     (const _CharType*)__s + __n));        return __result != this->_M_finish ? __result - this->_M_start : npos;    }}template <class _CharT, class _Traits, class _Alloc> __size_type__basic_string<_CharT,_Traits,_Alloc> ::find_first_not_of(_CharT __c, size_type __pos) const{    if (__pos > size())        return npos;    else {        const_pointer __result = _STLP_STD::find_if((const _CharT*)this->_M_start + __pos, (const _CharT*)this->_M_finish,                _Neq_char_bound<_Traits>(__c));        return __result != this->_M_finish ? __result - this->_M_start : npos;    }}    template <class _CharT, class _Traits, class _Alloc> __size_type__basic_string<_CharT,_Traits,_Alloc> ::find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const {    typedef typename _Traits::char_type _CharType;    const size_type __len = size();    if (__len < 1)        return npos;    else {        const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;        const_reverse_iterator __rlast = const_reverse_iterator(__last);        const_reverse_iterator __rresult =            _STLP_STD::find_if(__rlast, rend(),                    _Not_within_traits<_Traits>((const _CharType*)__s,                         (const _CharType*)__s + __n));        return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;    }}template <class _CharT, class _Traits, class _Alloc> __size_type__basic_string<_CharT, _Traits, _Alloc> ::find_last_not_of(_CharT __c, size_type __pos) const {    const size_type __len = size();    if (__len < 1)        return npos;    else {        const_iterator __last = begin() + (min) (__len - 1, __pos) + 1;        const_reverse_iterator __rlast = const_reverse_iterator(__last);        const_reverse_iterator __rresult =            _STLP_STD::find_if(__rlast, rend(),                    _Neq_char_bound<_Traits>(__c));        return __rresult != rend() ? (__rresult.base() - 1) - begin() : npos;    }}template <class _CharT, class _Traits, class _Alloc> void _STLP_CALL _S_string_copy(const basic_string<_CharT,_Traits,_Alloc>& __s,        _CharT* __buf,        size_t __n){    if (__n > 0) {        __n = (min) (__n - 1, __s.size());        _STLP_STD::copy(__s.begin(), __s.begin() + __n, __buf);        __buf[__n] = _CharT();    }}_STLP_END_NAMESPACE// _string_fwd has to see clean basic_string# undef basic_string# if !defined (_STLP_LINK_TIME_INSTANTIATION)//#  include <stl/_string_fwd.c> # endif# ifdef _STLP_DEBUG#  define basic_string _Nondebug_string# endif#include <bits/STLPort/_range_errors.h>  _STLP_BEGIN_NAMESPACE// _String_base methodstemplate <class _Tp, class _Alloc> void _String_base<_Tp,_Alloc>::_M_throw_length_error() const {    __stl_throw_length_error("basic_string");}template <class _Tp, class _Alloc> void _String_base<_Tp, _Alloc>::_M_throw_out_of_range() const {    __stl_throw_out_of_range("basic_string");}template <class _Tp, class _Alloc> void _String_base<_Tp, _Alloc>::_M_allocate_block(size_t __n) {      if ((__n <= (max_size()+1)) && (__n>0)){         _M_start  = _M_end_of_storage.allocate(__n);         _M_finish = _M_start;         _M_end_of_storage._M_data = _M_start + __n;     }     else         _M_throw_length_error(); } template <class _CharT, class _Traits, class _Alloc> basic_string<_CharT, _Traits, _Alloc>::basic_string()    : _String_base<_CharT,_Alloc>(allocator_type()) {          this->_M_start = this->_M_end_of_storage.allocate(8);         this->_M_finish = this->_M_start;         this->_M_end_of_storage._M_data = this->_M_start + 8;         _M_terminate_string();      } template <class _CharT, class _Traits, class _Alloc> basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT* __s,         const allocator_type& __a) : _String_base<_CharT,_Alloc>(__a)  {     _STLP_FIX_LITERAL_BUG(__s)         _M_range_initialize(__s, __s + traits_type::length(__s));  }     template <class _CharT, class _Traits, class _Alloc> basic_string<_CharT, _Traits, _Alloc>::basic_string(const basic_string<_CharT, _Traits, _Alloc> & __s)  : _String_base<_CharT,_Alloc>(__s.get_allocator())  {      _M_range_initialize(__s._M_start, __s._M_finish);  } # if defined ( __SUNPRO_CC) && ! defined(_STLP_STATIC_CONST_INIT_BUG)template <class _CharT, class _Traits, class _Alloc> const size_t basic_string<_CharT, _Traits, _Alloc>::npos;# endif_STLP_END_NAMESPACE# undef basic_string# undef __size_type__# undef size_type# undef iterator# endif /* NATIVE */#endif /*  _STLP_STRING_C */// Local Variables:// mode:C++// End:

⌨️ 快捷键说明

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