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

📄 vstring.tcc

📁 linux下编程用 编译软件
💻 TCC
📖 第 1 页 / 共 2 页
字号:
    }  template<typename _CharT, typename _Traits, typename _Alloc,	   template <typename, typename, typename> class _Base>    typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type    __versa_string<_CharT, _Traits, _Alloc, _Base>::    find_last_of(const _CharT* __s, size_type __pos, size_type __n) const    {      __glibcxx_requires_string_len(__s, __n);      size_type __size = this->size();      if (__size && __n)	{	  if (--__size > __pos)	    __size = __pos;	  do	    {	      if (traits_type::find(__s, __n, this->_M_data()[__size]))		return __size;	    }	  while (__size-- != 0);	}      return npos;    }  template<typename _CharT, typename _Traits, typename _Alloc,	   template <typename, typename, typename> class _Base>    typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type    __versa_string<_CharT, _Traits, _Alloc, _Base>::    find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const    {      __glibcxx_requires_string_len(__s, __n);      for (; __pos < this->size(); ++__pos)	if (!traits_type::find(__s, __n, this->_M_data()[__pos]))	  return __pos;      return npos;    }  template<typename _CharT, typename _Traits, typename _Alloc,	   template <typename, typename, typename> class _Base>    typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type    __versa_string<_CharT, _Traits, _Alloc, _Base>::    find_first_not_of(_CharT __c, size_type __pos) const    {      for (; __pos < this->size(); ++__pos)	if (!traits_type::eq(this->_M_data()[__pos], __c))	  return __pos;      return npos;    }  template<typename _CharT, typename _Traits, typename _Alloc,	   template <typename, typename, typename> class _Base>    typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type    __versa_string<_CharT, _Traits, _Alloc, _Base>::    find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const    {      __glibcxx_requires_string_len(__s, __n);      size_type __size = this->size();      if (__size)	{	  if (--__size > __pos)	    __size = __pos;	  do	    {	      if (!traits_type::find(__s, __n, this->_M_data()[__size]))		return __size;	    }	  while (__size--);	}      return npos;    }  template<typename _CharT, typename _Traits, typename _Alloc,	   template <typename, typename, typename> class _Base>    typename __versa_string<_CharT, _Traits, _Alloc, _Base>::size_type    __versa_string<_CharT, _Traits, _Alloc, _Base>::    find_last_not_of(_CharT __c, size_type __pos) const    {      size_type __size = this->size();      if (__size)	{	  if (--__size > __pos)	    __size = __pos;	  do	    {	      if (!traits_type::eq(this->_M_data()[__size], __c))		return __size;	    }	  while (__size--);	}      return npos;    }  template<typename _CharT, typename _Traits, typename _Alloc,	   template <typename, typename, typename> class _Base>    int    __versa_string<_CharT, _Traits, _Alloc, _Base>::    compare(size_type __pos, size_type __n, const __versa_string& __str) const    {      _M_check(__pos, "__versa_string::compare");      __n = _M_limit(__pos, __n);      const size_type __osize = __str.size();      const size_type __len = std::min(__n, __osize);      int __r = traits_type::compare(this->_M_data() + __pos,				     __str.data(), __len);      if (!__r)	__r = __n - __osize;      return __r;    }  template<typename _CharT, typename _Traits, typename _Alloc,	   template <typename, typename, typename> class _Base>    int    __versa_string<_CharT, _Traits, _Alloc, _Base>::    compare(size_type __pos1, size_type __n1, const __versa_string& __str,	    size_type __pos2, size_type __n2) const    {      _M_check(__pos1, "__versa_string::compare");      __str._M_check(__pos2, "__versa_string::compare");      __n1 = _M_limit(__pos1, __n1);      __n2 = __str._M_limit(__pos2, __n2);      const size_type __len = std::min(__n1, __n2);      int __r = traits_type::compare(this->_M_data() + __pos1,				     __str.data() + __pos2, __len);      if (!__r)	__r = __n1 - __n2;      return __r;    }  template<typename _CharT, typename _Traits, typename _Alloc,	   template <typename, typename, typename> class _Base>    int    __versa_string<_CharT, _Traits, _Alloc, _Base>::    compare(const _CharT* __s) const    {      __glibcxx_requires_string(__s);      const size_type __size = this->size();      const size_type __osize = traits_type::length(__s);      const size_type __len = std::min(__size, __osize);      int __r = traits_type::compare(this->_M_data(), __s, __len);      if (!__r)	__r = __size - __osize;      return __r;    }  template<typename _CharT, typename _Traits, typename _Alloc,	   template <typename, typename, typename> class _Base>    int    __versa_string <_CharT, _Traits, _Alloc, _Base>::    compare(size_type __pos, size_type __n1, const _CharT* __s) const    {      __glibcxx_requires_string(__s);      _M_check(__pos, "__versa_string::compare");      __n1 = _M_limit(__pos, __n1);      const size_type __osize = traits_type::length(__s);      const size_type __len = std::min(__n1, __osize);      int __r = traits_type::compare(this->_M_data() + __pos, __s, __len);      if (!__r)	__r = __n1 - __osize;      return __r;    }  template<typename _CharT, typename _Traits, typename _Alloc,	   template <typename, typename, typename> class _Base>    int    __versa_string <_CharT, _Traits, _Alloc, _Base>::    compare(size_type __pos, size_type __n1, const _CharT* __s,	    size_type __n2) const    {      __glibcxx_requires_string_len(__s, __n2);      _M_check(__pos, "__versa_string::compare");      __n1 = _M_limit(__pos, __n1);      const size_type __len = std::min(__n1, __n2);      int __r = traits_type::compare(this->_M_data() + __pos, __s, __len);      if (!__r)	__r = __n1 - __n2;      return __r;    }} // namespace __gnu_cxxnamespace std{  template<typename _CharT, typename _Traits, typename _Alloc,           template <typename, typename, typename> class _Base>    basic_istream<_CharT, _Traits>&    operator>>(basic_istream<_CharT, _Traits>& __in,	       __gnu_cxx::__versa_string<_CharT, _Traits,	                                 _Alloc, _Base>& __str)    {      typedef basic_istream<_CharT, _Traits>	        __istream_type;      typedef typename __istream_type::int_type		__int_type;      typedef typename __istream_type::__streambuf_type __streambuf_type;      typedef typename __istream_type::__ctype_type	__ctype_type;      typedef __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>	                                                __string_type;      typedef typename __string_type::size_type		__size_type;      __size_type __extracted = 0;      ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);      typename __istream_type::sentry __cerb(__in, false);      if (__cerb)	{	  try	    {	      // Avoid reallocation for common case.	      __str.erase();	      _CharT __buf[128];	      __size_type __len = 0;	      const streamsize __w = __in.width();	      const __size_type __n = __w > 0 ? static_cast<__size_type>(__w)		                              : __str.max_size();	      const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());	      const __int_type __eof = _Traits::eof();	      __streambuf_type* __sb = __in.rdbuf();	      __int_type __c = __sb->sgetc();	      while (__extracted < __n		     && !_Traits::eq_int_type(__c, __eof)		     && !__ct.is(ctype_base::space, _Traits::to_char_type(__c)))		{		  if (__len == sizeof(__buf) / sizeof(_CharT))		    {		      __str.append(__buf, sizeof(__buf) / sizeof(_CharT));		      __len = 0;		    }		  __buf[__len++] = _Traits::to_char_type(__c);		  ++__extracted;		  __c = __sb->snextc();		}	      __str.append(__buf, __len);	      if (_Traits::eq_int_type(__c, __eof))		__err |= ios_base::eofbit;	      __in.width(0);	    }	  catch(...)	    {	      // _GLIBCXX_RESOLVE_LIB_DEFECTS	      // 91. Description of operator>> and getline() for string<>	      // might cause endless loop	      __in._M_setstate(ios_base::badbit);	    }	}      // 211.  operator>>(istream&, string&) doesn't set failbit      if (!__extracted)	__err |= ios_base::failbit;      if (__err)	__in.setstate(__err);      return __in;    }        template<typename _CharT, typename _Traits, typename _Alloc,           template <typename, typename, typename> class _Base>    basic_ostream<_CharT, _Traits>&    operator<<(basic_ostream<_CharT, _Traits>& __out,	       const __gnu_cxx::__versa_string<_CharT, _Traits,	                                       _Alloc, _Base>& __str)    {      typedef basic_ostream<_CharT, _Traits>            __ostream_type;      typename __ostream_type::sentry __cerb(__out);      if (__cerb)	{	  const streamsize __w = __out.width();	  streamsize __len = static_cast<streamsize>(__str.size());	  const _CharT* __s = __str.data();	  // _GLIBCXX_RESOLVE_LIB_DEFECTS	  // 25. String operator<< uses width() value wrong	  if (__w > __len)	    {	      _CharT* __cs = (static_cast<			      _CharT*>(__builtin_alloca(sizeof(_CharT) * __w)));	      __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs,					     __s, __w, __len, false);	      __s = __cs;	      __len = __w;	    }	  __out._M_write(__s, __len);	  __out.width(0);	}      return __out;    }  template<typename _CharT, typename _Traits, typename _Alloc,           template <typename, typename, typename> class _Base>    basic_istream<_CharT, _Traits>&    getline(basic_istream<_CharT, _Traits>& __in,	    __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str,	    _CharT __delim)    {      typedef basic_istream<_CharT, _Traits>	        __istream_type;      typedef typename __istream_type::int_type		__int_type;      typedef typename __istream_type::__streambuf_type __streambuf_type;      typedef typename __istream_type::__ctype_type	__ctype_type;      typedef __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>	                                                __string_type;      typedef typename __string_type::size_type		__size_type;      __size_type __extracted = 0;      const __size_type __n = __str.max_size();      ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);      typename __istream_type::sentry __cerb(__in, true);      if (__cerb)	{	  try	    {	      // Avoid reallocation for common case.	      __str.erase();	      _CharT __buf[128];	      __size_type __len = 0;	      const __int_type __idelim = _Traits::to_int_type(__delim);	      const __int_type __eof = _Traits::eof();	      __streambuf_type* __sb = __in.rdbuf();	      __int_type __c = __sb->sgetc();	      while (__extracted < __n		     && !_Traits::eq_int_type(__c, __eof)		     && !_Traits::eq_int_type(__c, __idelim))		{		  if (__len == sizeof(__buf) / sizeof(_CharT))		    {		      __str.append(__buf, sizeof(__buf) / sizeof(_CharT));		      __len = 0;		    }		  __buf[__len++] = _Traits::to_char_type(__c);		  ++__extracted;		  __c = __sb->snextc();		}	      __str.append(__buf, __len);	      if (_Traits::eq_int_type(__c, __eof))		__err |= ios_base::eofbit;	      else if (_Traits::eq_int_type(__c, __idelim))		{		  ++__extracted;		  		  __sb->sbumpc();		}	      else		__err |= ios_base::failbit;	    }	  catch(...)	    {	      // _GLIBCXX_RESOLVE_LIB_DEFECTS	      // 91. Description of operator>> and getline() for string<>	      // might cause endless loop	      __in._M_setstate(ios_base::badbit);	    }	}      if (!__extracted)	__err |= ios_base::failbit;      if (__err)	__in.setstate(__err);      return __in;    }        } // namespace std#endif // _VSTRING_TCC

⌨️ 快捷键说明

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