📄 string
字号:
return find_last_not_of (__tmp, __pos);
}
template <class _CharT, class _Traits, class _Allocator>
inline void
basic_string<_CharT, _Traits, _Allocator>::
_C_clone (size_type __nc /* = npos */)
{
size_type __len = size();
_C_string_ref_type * __temp = _C_getRep (npos == __nc ? size () : __nc,
__len > __nc ? __nc : __len);
traits_type::copy (__temp->data(), _C_data, size());
_C_unlink ();
_C_data = __temp->data ();
}
template <class _CharT, class _Traits, class _Allocator>
inline int
basic_string<_CharT, _Traits, _Allocator>::
compare (const basic_string &__str) const
{
int __res = traits_type::compare (data (), __str.data (),
_STD::min (size (), __str.size ()));
if (0 == __res)
__res = size () < __str.size () ? -1 : size () != __str.size ();
return __res;
}
template <class _CharT, class _Traits, class _Allocator>
inline basic_string<_CharT, _Traits, _Allocator>&
basic_string<_CharT, _Traits, _Allocator>::append (const basic_string &__str)
{
size_type __len = size () + __str.size ();
if (__len > capacity () || _C_pref ()->_C_ref_count () > 1)
return append (__str, 0, __str.size ());
traits_type::copy (_C_data + size (), __str.data (), __str.size () + 1);
_C_pref ()->_C_size = __len;
return *this;
}
// 21.3.7.1, p1
template <class _CharT, class _Traits , class _Allocator>
inline basic_string<_CharT, _Traits, _Allocator>
operator+ (const basic_string<_CharT, _Traits, _Allocator> &__lhs,
const basic_string<_CharT, _Traits, _Allocator> &__rhs)
{
typedef basic_string<_CharT, _Traits, _Allocator> string_type;
// prevent reference counting while creating a copy of lhs
return string_type (__lhs.data (), __lhs.data () + __lhs.size ()) += __rhs;
}
// 21.3.7.1, p2
template <class _CharT, class _Traits , class _Allocator>
inline basic_string<_CharT, _Traits, _Allocator>
operator+ (const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return basic_string<_CharT, _Traits, _Allocator>(__lhs) += __rhs;
}
// 21.3.7.1, p4
template <class _CharT, class _Traits , class _Allocator>
inline basic_string<_CharT, _Traits, _Allocator>
operator+ (_CharT __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return basic_string<_CharT, _Traits, _Allocator>(1, __lhs) += __rhs;
}
// 21.3.7.1, p5
template <class _CharT, class _Traits , class _Allocator>
inline basic_string<_CharT, _Traits, _Allocator>
operator+ (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs)
{
typedef basic_string<_CharT, _Traits, _Allocator> string_type;
// prevent reference counting while creating a copy of lhs
return string_type (__lhs.data (), __lhs.data () + __lhs.size ()) += __rhs;
}
// 21.3.7.1, p7
template <class _CharT, class _Traits , class _Allocator>
inline basic_string<_CharT, _Traits, _Allocator>
operator+ (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
_CharT __rhs)
{
typedef basic_string<_CharT, _Traits, _Allocator> string_type;
// prevent reference counting while creating a copy of lhs
return string_type (__lhs.data (), __lhs.data () + __lhs.size ()) += __rhs;
}
// 21.3.7.2, p1
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator== (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return __lhs.size () == __rhs.size () && 0 == __lhs.compare (__rhs);
}
// 21.3.7.2, p2
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator== (const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return 0 == __rhs.compare (__lhs);
}
// 21.3.7.2, p3
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator== (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs)
{
return 0 == __lhs.compare (__rhs);
}
// 21.3.7.4, p1
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return 0 > __lhs.compare (__rhs);
}
// 21.3.7.4, p2
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator< (const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return 0 < __rhs.compare (__lhs);
}
// 21.3.7.4, p3
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs)
{
return 0 > __lhs.compare (__rhs);
}
// 21.3.7.3, p1
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator!= (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return !(__lhs == __rhs);
}
// 21.3.7.5, p1
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return __rhs < __lhs;
}
// 21.3.7.6, p1
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator<= (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return !(__rhs < __lhs);
}
// 21.3.7.7, p1
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator>= (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return !(__lhs < __rhs);
}
// 21.3.7.8, p1
#ifndef _RWSTD_NO_PART_SPEC_OVERLOAD
template <class _CharT, class _Traits, class _Allocator>
inline void swap (basic_string<_CharT, _Traits, _Allocator>& __a,
basic_string<_CharT, _Traits, _Allocator>& __b)
{
__a.swap (__b);
}
#endif // _RWSTD_NO_PART_SPEC_OVERLOAD
// 21.3.7.3, p2
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator!= (const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return !(__lhs == __rhs);
}
// 21.3.7.3, p3
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator!= (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs)
{
return !(__lhs == __rhs);
}
// 21.3.7.5, p2
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator> (const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return __rhs < __lhs;
}
// 21.3.7.5, p3
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs)
{
return __rhs < __lhs;
}
// 21.3.7.6, p2
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator<= (const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return !(__rhs < __lhs);
}
// 21.3.7.6, p3
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator<= (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs)
{
return !(__rhs < __lhs);
}
// 21.3.7.7, p2
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator>= (const _CharT* __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs)
{
return !(__lhs < __rhs);
}
// 21.3.7.7, p3
template <class _CharT, class _Traits , class _Allocator>
inline bool
operator>= (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const _CharT* __rhs)
{
return !(__lhs < __rhs);
}
// 21.3.7.9, p3 - declared here, defined inline in <ostream>
template<class _CharT, class _Traits, class _Allocator>
inline basic_ostream<_CharT, _Traits>&
operator<< (basic_ostream<_CharT, _Traits>&,
const basic_string<_CharT, _Traits, _Allocator>&);
_RWSTD_NAMESPACE_END // std
_RWSTD_NAMESPACE_BEGIN (__rw)
_USING (namespace std);
#ifndef _RWSTD_NO_FUNC_PARTIAL_SPEC
// more specialized version for basic_string<>; may be further specialized
// in user code for example on a user-defined allocator
template <class _CharT, class _Traits, class _Allocator>
inline size_t
__rw_new_capacity (size_t __size,
const basic_string<_CharT, _Traits, _Allocator>*)
{
size_t __cap =
_RWSTD_STATIC_CAST (size_t, _RWSTD_INCREASE_STRING_CAPACITY(__size)
/*__size * _RWSTD_STRING_CAPACITY_RATIO*/);
return (__size += _RWSTD_MINIMUM_STRING_CAPACITY) > __cap ? __size : __cap;
}
#else // if defined (_RWSTD_NO_FUNC_PARTIAL_SPEC)
// the following specializations of the __rw_new_capacity<> function template
// are provided for char and wchar_t; the general case is given in the <memory>
_RWSTD_SPECIALIZED_FUNCTION
inline size_t __rw_new_capacity (size_t __size, const string*)
{
size_t __cap =
_RWSTD_STATIC_CAST (size_t, _RWSTD_INCREASE_STRING_CAPACITY(__size)
/*__size * _RWSTD_STRING_CAPACITY_RATIO*/);
return (__size += _RWSTD_MINIMUM_STRING_CAPACITY) > __cap ? __size : __cap;
}
_RWSTD_SPECIALIZED_FUNCTION
inline size_t __rw_new_capacity (size_t __size, const wstring*)
{
size_t __cap =
_RWSTD_STATIC_CAST (size_t, _RWSTD_INCREASE_STRING_CAPACITY(__size)
/*__size * _RWSTD_STRING_CAPACITY_RATIO*/);
return (__size += _RWSTD_MINIMUM_STRING_CAPACITY) > __cap ? __size : __cap;
}
#endif // _RWSTD_NO_FUNC_PARTIAL_SPEC
_RWSTD_NAMESPACE_END // __rw
#if _RWSTD_DEFINE_TEMPLATE (BASIC_STRING)
# include <string.cc>
#endif
_RWSTD_NAMESPACE_BEGIN (std)
_RWSTD_INSTANTIATE_3 (class _RWSTD_EXPORT
basic_string<char, char_traits<char>, allocator<char> >);
#ifndef _RWSTD_NO_WCHAR_T
_RWSTD_INSTANTIATE_3 (class _RWSTD_EXPORT
basic_string<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> >);
#endif // _RWSTD_NO_WCHAR_T
_RWSTD_NAMESPACE_END // std
#endif // _RWSTD_STRING_INCLUDED
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -