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

📄 vstring.h

📁 linux下编程用 编译软件
💻 H
📖 第 1 页 / 共 5 页
字号:
       *  @brief  Set value to multiple characters.       *  @param n  Length of the resulting string.       *  @param c  The character to use.       *  @return  Reference to this string.       *       *  This function sets the value of this string to @a n copies of       *  character @a c.       */      __versa_string&      assign(size_type __n, _CharT __c)      { return _M_replace_aux(size_type(0), this->size(), __n, __c); }      /**       *  @brief  Set value to a range of characters.       *  @param first  Iterator referencing the first character to append.       *  @param last  Iterator marking the end of the range.       *  @return  Reference to this string.       *       *  Sets value of string to characters in the range [first,last).      */      template<class _InputIterator>        __versa_string&        assign(_InputIterator __first, _InputIterator __last)        { return this->replace(_M_ibegin(), _M_iend(), __first, __last); }      /**       *  @brief  Insert multiple characters.       *  @param p  Iterator referencing location in string to insert at.       *  @param n  Number of characters to insert       *  @param c  The character to insert.       *  @throw  std::length_error  If new length exceeds @c max_size().       *       *  Inserts @a n copies of character @a c starting at the position       *  referenced by iterator @a p.  If adding characters causes the length       *  to exceed max_size(), length_error is thrown.  The value of the       *  string doesn't change if an error is thrown.      */      void      insert(iterator __p, size_type __n, _CharT __c)      {	this->replace(__p, __p, __n, __c);  }      /**       *  @brief  Insert a range of characters.       *  @param p  Iterator referencing location in string to insert at.       *  @param beg  Start of range.       *  @param end  End of range.       *  @throw  std::length_error  If new length exceeds @c max_size().       *       *  Inserts characters in range [beg,end).  If adding characters causes       *  the length to exceed max_size(), length_error is thrown.  The value       *  of the string doesn't change if an error is thrown.      */      template<class _InputIterator>        void        insert(iterator __p, _InputIterator __beg, _InputIterator __end)        { this->replace(__p, __p, __beg, __end); }      /**       *  @brief  Insert value of a string.       *  @param pos1  Iterator referencing location in string to insert at.       *  @param str  The string to insert.       *  @return  Reference to this string.       *  @throw  std::length_error  If new length exceeds @c max_size().       *       *  Inserts value of @a str starting at @a pos1.  If adding characters       *  causes the length to exceed max_size(), length_error is thrown.  The       *  value of the string doesn't change if an error is thrown.      */      __versa_string&      insert(size_type __pos1, const __versa_string& __str)      { return this->replace(__pos1, size_type(0),			     __str._M_data(), __str.size()); }      /**       *  @brief  Insert a substring.       *  @param pos1  Iterator referencing location in string to insert at.       *  @param str  The string to insert.       *  @param pos2  Start of characters in str to insert.       *  @param n  Number of characters to insert.       *  @return  Reference to this string.       *  @throw  std::length_error  If new length exceeds @c max_size().       *  @throw  std::out_of_range  If @a pos1 > size() or       *  @a pos2 > @a str.size().       *       *  Starting at @a pos1, insert @a n character of @a str beginning with       *  @a pos2.  If adding characters causes the length to exceed       *  max_size(), length_error is thrown.  If @a pos1 is beyond the end of       *  this string or @a pos2 is beyond the end of @a str, out_of_range is       *  thrown.  The value of the string doesn't change if an error is       *  thrown.      */      __versa_string&      insert(size_type __pos1, const __versa_string& __str,	     size_type __pos2, size_type __n)      { return this->replace(__pos1, size_type(0), __str._M_data()			     + __str._M_check(__pos2, "__versa_string::insert"),			     __str._M_limit(__pos2, __n)); }      /**       *  @brief  Insert a C substring.       *  @param pos  Iterator referencing location in string to insert at.       *  @param s  The C string to insert.       *  @param n  The number of characters to insert.       *  @return  Reference to this string.       *  @throw  std::length_error  If new length exceeds @c max_size().       *  @throw  std::out_of_range  If @a pos is beyond the end of this       *  string.       *       *  Inserts the first @a n characters of @a s starting at @a pos.  If       *  adding characters causes the length to exceed max_size(),       *  length_error is thrown.  If @a pos is beyond end(), out_of_range is       *  thrown.  The value of the string doesn't change if an error is       *  thrown.      */      __versa_string&      insert(size_type __pos, const _CharT* __s, size_type __n)      { return this->replace(__pos, size_type(0), __s, __n); }      /**       *  @brief  Insert a C string.       *  @param pos  Iterator referencing location in string to insert at.       *  @param s  The C string to insert.       *  @return  Reference to this string.       *  @throw  std::length_error  If new length exceeds @c max_size().       *  @throw  std::out_of_range  If @a pos is beyond the end of this       *  string.       *       *  Inserts the first @a n characters of @a s starting at @a pos.  If       *  adding characters causes the length to exceed max_size(),       *  length_error is thrown.  If @a pos is beyond end(), out_of_range is       *  thrown.  The value of the string doesn't change if an error is       *  thrown.      */      __versa_string&      insert(size_type __pos, const _CharT* __s)      {	__glibcxx_requires_string(__s);	return this->replace(__pos, size_type(0), __s,			     traits_type::length(__s));      }      /**       *  @brief  Insert multiple characters.       *  @param pos  Index in string to insert at.       *  @param n  Number of characters to insert       *  @param c  The character to insert.       *  @return  Reference to this string.       *  @throw  std::length_error  If new length exceeds @c max_size().       *  @throw  std::out_of_range  If @a pos is beyond the end of this       *  string.       *       *  Inserts @a n copies of character @a c starting at index @a pos.  If       *  adding characters causes the length to exceed max_size(),       *  length_error is thrown.  If @a pos > length(), out_of_range is       *  thrown.  The value of the string doesn't change if an error is       *  thrown.      */      __versa_string&      insert(size_type __pos, size_type __n, _CharT __c)      { return _M_replace_aux(_M_check(__pos, "__versa_string::insert"),			      size_type(0), __n, __c); }      /**       *  @brief  Insert one character.       *  @param p  Iterator referencing position in string to insert at.       *  @param c  The character to insert.       *  @return  Iterator referencing newly inserted char.       *  @throw  std::length_error  If new length exceeds @c max_size().       *       *  Inserts character @a c at position referenced by @a p.  If adding       *  character causes the length to exceed max_size(), length_error is       *  thrown.  If @a p is beyond end of string, out_of_range is thrown.       *  The value of the string doesn't change if an error is thrown.      */      iterator      insert(iterator __p, _CharT __c)      {	_GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());	const size_type __pos = __p - _M_ibegin();	_M_replace_aux(__pos, size_type(0), size_type(1), __c);	this->_M_set_leaked();	return iterator(this->_M_data() + __pos);      }      /**       *  @brief  Remove characters.       *  @param pos  Index of first character to remove (default 0).       *  @param n  Number of characters to remove (default remainder).       *  @return  Reference to this string.       *  @throw  std::out_of_range  If @a pos is beyond the end of this       *  string.       *       *  Removes @a n characters from this string starting at @a pos.  The       *  length of the string is reduced by @a n.  If there are < @a n       *  characters to remove, the remainder of the string is truncated.  If       *  @a p is beyond end of string, out_of_range is thrown.  The value of       *  the string doesn't change if an error is thrown.      */      __versa_string&      erase(size_type __pos = 0, size_type __n = npos)      { 	this->_M_erase(_M_check(__pos, "__versa_string::erase"),		       _M_limit(__pos, __n));	return *this;      }      /**       *  @brief  Remove one character.       *  @param position  Iterator referencing the character to remove.       *  @return  iterator referencing same location after removal.       *       *  Removes the character at @a position from this string. The value       *  of the string doesn't change if an error is thrown.      */      iterator      erase(iterator __position)      {	_GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()				 && __position < _M_iend());	const size_type __pos = __position - _M_ibegin();	this->_M_erase(__pos, size_type(1));	this->_M_set_leaked();	return iterator(this->_M_data() + __pos);      }      /**       *  @brief  Remove a range of characters.       *  @param first  Iterator referencing the first character to remove.       *  @param last  Iterator referencing the end of the range.       *  @return  Iterator referencing location of first after removal.       *       *  Removes the characters in the range [first,last) from this string.       *  The value of the string doesn't change if an error is thrown.      */      iterator      erase(iterator __first, iterator __last)      {	_GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last				 && __last <= _M_iend());        const size_type __pos = __first - _M_ibegin();	this->_M_erase(__pos, __last - __first);	this->_M_set_leaked();	return iterator(this->_M_data() + __pos);      }      /**       *  @brief  Replace characters with value from another string.       *  @param pos  Index of first character to replace.       *  @param n  Number of characters to be replaced.       *  @param str  String to insert.       *  @return  Reference to this string.       *  @throw  std::out_of_range  If @a pos is beyond the end of this       *  string.       *  @throw  std::length_error  If new length exceeds @c max_size().       *       *  Removes the characters in the range [pos,pos+n) from this string.       *  In place, the value of @a str is inserted.  If @a pos is beyond end       *  of string, out_of_range is thrown.  If the length of the result       *  exceeds max_size(), length_error is thrown.  The value of the string       *  doesn't change if an error is thrown.      */      __versa_string&      replace(size_type __pos, size_type __n, const __versa_string& __str)      { return this->replace(__pos, __n, __str._M_data(), __str.size()); }      /**       *  @brief  Replace characters with value from another string.       *  @param pos1  Index of first character to replace.       *  @param n1  Number of characters to be replaced.       *  @param str  String to insert.       *  @param pos2  Index of first character of str to use.       *  @param n2  Number of characters from str to use.       *  @return  Reference to this string.       *  @throw  std::out_of_range  If @a pos1 > size() or @a pos2 >       *  str.size().       *  @throw  std::length_error  If new length exceeds @c max_size().       *       *  Removes the characters in the range [pos1,pos1 + n) from this       *  string.  In place, the value of @a str is inserted.  If @a pos is       *  beyond end of string, out_of_range is thrown.  If the length of the       *  result exceeds max_size(), length_error is thrown.  The value of the       *  string doesn't change if an error is thrown.      */      __versa_string&      replace(size_type __pos1, size_type __n1, const __versa_string& __str,	      size_type __pos2, size_type __n2)      {	return this->replace(__pos1, __n1, __str._M_data()			     + __str._M_check(__pos2,					      "__versa_string::replace"),			     __str._M_limit(__pos2, __n2));      }      /**       *  @brief  Replace characters with value of a C substring.       *  @param pos  Index of first character to replace.       *  @param n1  Number of characters to be replaced.       *  @param s  C string to insert.       *  @param n2  Number of characters from @a s to use.       *  @return  Reference to this string.       *  @throw  std::out_of_range  If @a pos1 > size().       *  @throw  std::length_error  If new length exceeds @c max_size().       *       *  Removes the characters in the range [pos,pos + n1) from this string.       *  In place, the first @a n2 characters of @a s are inserted, or all       *  of @a s if @a n2 is too large.  If @a pos is beyond end of string,       *  out_of_range is thrown.  If the length of result exceeds max_size(),       *  length_error is thrown.  The value of the string doesn't change if       *  an error is thrown.      */      __versa_string&      replace(size_type __pos, size_type __n1, const _CharT* __s,	      size_type __n2)      {	__glibcxx_requires_string_len(__s, __n2);	return _M_replace(_M_check(__pos, "__versa_string::replace"),			  _M_limit(__pos, __n1), __s, __n2);      }      /**       *  @brief  Replace characters with value of a C string.       *  @param pos  Index of first character to replace.       *  @param n1  Number of characters to be replaced.       *  @param s  C string to insert.       *  @return  Reference to this string.       *  @throw  std::out_of_range  If @a pos > size().       *  @throw  std::length_error  If new length exceeds @c max_size().       *       *  Removes the characters in the range [pos,pos + n1) from this string.       *  In place, the first @a n characters of @a s are inserted.  If @a       *  pos is beyond end of string, out_of_range is thrown.  If the length       *  of result exceeds max_size(), length_error is thrown.  The value of       *  the string doesn't change if an error is thrown.      */      __versa_string&      replace(size_type __pos, size_type __n1, const _CharT* __s)      {	__glibcxx_requires_string(__s);	return this->replace(__pos, __n1, __s, traits_type::length(__s));      }      /**

⌨️ 快捷键说明

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