📄 _string.h
字号:
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& append(const _CharT* __s) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
size_type __old_capacity = capacity();
_M_non_dbg_impl.append(__s);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& append(size_type __n, _CharT __c) {
size_type __old_capacity = this->capacity();
_M_non_dbg_impl.append(__n, __c);
_Compare_Capacity(__old_capacity);
return *this;
}
void push_back(_CharT __c) {
size_type __old_capacity = this->capacity();
_M_non_dbg_impl.push_back(__c);
_Compare_Capacity(__old_capacity);
}
void pop_back() {
_Invalidate_iterator(this->end());
_M_non_dbg_impl.pop_back();
}
// Assign
private:
void _M_check_assign(size_type __n) {
if (__n > capacity()) {
_Invalidate_all();
}
else if (__n < size()) {
_Invalidate_iterators(begin() + __n, end());
}
}
public:
_Self& assign(const _Self& __s) {
_M_check_assign(__s.size());
_M_non_dbg_impl.assign(__s._M_non_dbg_impl);
return *this;
}
_Self& assign(const _Self& __s, size_type __pos, size_type __n) {
if (__pos < __s.size()) {
_M_check_assign((min) (__n, __s.size() - __pos));
}
_M_non_dbg_impl.assign(__s._M_non_dbg_impl, __pos, __n);
return *this;
}
_Self& assign(const _CharT* __s, size_type __n) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
_M_check_assign((min) (_Traits::length(__s), __n));
_M_non_dbg_impl.assign(__s, __s + __n);
return *this;
}
_Self& assign(const _CharT* __s) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
_M_check_assign(_Traits::length(__s));
_M_non_dbg_impl.assign(__s);
return *this;
}
_Self& assign(size_type __n, _CharT __c) {
_M_check_assign(__n);
_M_non_dbg_impl.assign(__n, __c);
return *this;
}
#if defined(_STLP_MEMBER_TEMPLATES)
private:
template <class _Integer>
void _M_assign_dispatch(_Integer __n, _Integer __x, const __true_type& /*_Integral*/) {
_M_check_assign(__n);
_M_non_dbg_impl.assign((size_type)__n, (_CharT)__x);
}
template <class _InputIter>
void _M_assign_dispatch(_InputIter __f, _InputIter __l, const __false_type& /*_Integral*/) {
_M_check_assign(distance(__f, __l));
_M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
}
public:
template <class _InputIter>
inline _Self& assign(_InputIter __first, _InputIter __last) {
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
_M_assign_dispatch(__first, __last, _Integral());
return *this;
}
#endif
#if !defined (_STLP_MEMBER_TEMPLATES) || \
!defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
_Self& assign(const _CharT* __f, const _CharT* __l) {
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
_M_check_assign(distance(__f, __l));
_M_non_dbg_impl.assign(__f, __l);
return *this;
}
_Self& assign(const_iterator __f, const_iterator __l) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
_M_check_assign(distance(__f, __l));
_M_non_dbg_impl.assign(__f._M_iterator, __l._M_iterator);
return *this;
}
#endif
// Insert
_Self& insert(size_type __pos, const _Self& __s) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& insert(size_type __pos, const _Self& __s,
size_type __beg, size_type __n) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl, __beg, __n);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__pos, __s, __n);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& insert(size_type __pos, const _CharT* __s) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
return insert(__pos, __s, _Traits::length(__s));
}
_Self& insert(size_type __pos, size_type __n, _CharT __c) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__pos, __n, __c);
_Compare_Capacity(__old_capacity);
return *this;
}
iterator insert(iterator __p, _CharT __c) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
size_type __old_capacity = capacity();
typename _Base::iterator __ret = _M_non_dbg_impl.insert(__p._M_iterator, __c);
_Compare_Capacity(__old_capacity);
return iterator(&_M_iter_list, __ret);
}
void insert(iterator __p, size_t __n, _CharT __c) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__p._M_iterator, __n, __c);
_Compare_Capacity(__old_capacity);
}
#if defined (_STLP_MEMBER_TEMPLATES)
private:
template <class _RandomIter>
void _M_insert_aux (iterator __p, _RandomIter __first, _RandomIter __last,
const __true_type& /*_IsIterator*/)
{ _M_non_dbg_impl.insert(__p._M_iterator, __first._M_iterator, __last._M_iterator); }
template<class _InputIter>
void _M_insert_aux (iterator __p, _InputIter __first, _InputIter __last,
const __false_type& /*_IsIterator*/) {
_M_non_dbg_impl.insert(__p._M_iterator,
_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
}
public:
template <class _InputIter>
void insert(iterator __p, _InputIter __first, _InputIter __last) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last))
/* In debug mode we are encapsulating non debug string iterators in debug one.
* Doing so the non debug implementation will not check for self insertion
* (x.insert(x.begin(), x.begin(), x.end()). To avoid this problem we try to
* guess when _InputIter is iterator or const_iterator and in this case call
* the non debug insert method with non debug string iterator.
*/
typedef typename _AreSameUnCVTypes<_InputIter, iterator>::_Ret _IsNonConstIterator;
typedef typename _AreSameUnCVTypes<_InputIter, const_iterator>::_Ret _IsConstIterator;
typedef typename _Lor2<_IsNonConstIterator, _IsConstIterator>::_Ret _IsIterator;
size_type __old_capacity = this->capacity();
_M_insert_aux(__p, __first, __last, _IsIterator());
_Compare_Capacity(__old_capacity);
}
#endif
#if !defined (_STLP_MEMBER_TEMPLATES) || \
!defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
void insert(iterator __p, const_iterator __f, const_iterator __l) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f,__l))
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__p._M_iterator, __f._M_iterator, __l._M_iterator);
_Compare_Capacity(__old_capacity);
}
void insert(iterator __p, const _CharT* __f, const _CharT* __l) {
_STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f,__l))
size_type __old_capacity = capacity();
_M_non_dbg_impl.insert(__p._M_iterator, __f, __l);
_Compare_Capacity(__old_capacity);
}
#endif
// Erase.
_Self& erase(size_type __pos = 0, size_type __n = npos) {
if (__pos < size()) {
_Invalidate_iterators(begin() + __pos, end());
}
_M_non_dbg_impl.erase(__pos, __n);
return *this;
}
iterator erase(iterator __pos) {
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
_Invalidate_iterators(__pos, end());
return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
}
iterator erase(iterator __f, iterator __l) {
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
_Invalidate_iterators(__f, end());
return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__f._M_iterator, __l._M_iterator));
}
// Substring.
_Self substr(size_type __pos = 0, size_type __n = npos) const
{ return _M_non_dbg_impl.substr(__pos, __n); }
// Replace. (Conceptually equivalent to erase followed by insert.)
_Self& replace(size_type __pos, size_type __n, const _Self& __s) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__pos, __n, __s._M_non_dbg_impl);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(size_type __pos1, size_type __n1, const _Self& __s,
size_type __pos2, size_type __n2) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__pos, __n1, __s, __n2);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(size_type __pos, size_type __n1, const _CharT* __s) {
_STLP_FIX_LITERAL_BUG(__s)
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__pos, __n1, __s);
_Compare_Capacity(__old_capacity);
return *this;
}
_Self& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) {
size_type __old_capacity = capacity();
_M_non_dbg_impl.replace(__pos, __n1, __n2, __c);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -