_string_sum.h

来自「stl的源码」· C头文件 代码 · 共 415 行 · 第 1/2 页

H
415
字号
  { return _M_get_storage().find_last_of(__s, __pos); }  size_type find_last_of(const _CharT* __s, size_type __pos = _BString::npos) const  { return _M_get_storage().find_last_of(__s, __pos); }  size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const  { return _M_get_storage().find_last_of(__s, __pos, __n); }  size_type find_last_of(_CharT __c, size_type __pos = _BString::npos) const  { return _M_get_storage().rfind(__c, __pos); }  size_type find_first_not_of(const _BString& __s, size_type __pos = 0) const  { return _M_get_storage().find_first_not_of(__s, __pos); }  size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const  { return _M_get_storage().find_first_not_of(__s, __pos); }  size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const  { return _M_get_storage().find_first_not_of(__s, __pos, __n); }  size_type find_first_not_of(_CharT __c, size_type __pos = 0) const  { return _M_get_storage().find_first_not_of(__c, __pos); }  size_type find_last_not_of(const _BString& __s, size_type __pos = _BString::npos) const  { return _M_get_storage().find_last_not_of(__s, __pos); }  size_type find_last_not_of(const _CharT* __s, size_type __pos =_BString:: npos) const  { return _M_get_storage().find_last_not_of(__s, __pos); }  size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const  { return _M_get_storage().find_last_not_of(__s, __pos, __n); }  size_type find_last_not_of(_CharT __c, size_type __pos = _BString::npos) const  { return _M_get_storage().find_last_not_of(__c, __pos); }  _BString substr(size_type __pos = 0, size_type __n = _BString::npos) const  { return _M_get_storage().substr(__pos, __n); }  //compare  int compare(const _BString& __s) const  { return _M_get_storage().compare(__s); }  int compare(size_type __pos1, size_type __n1, const _Self& __s) const  { return _M_get_storage().compare(__pos1, __n1, __s); }  int compare(size_type __pos1, size_type __n1, const _Self& __s, size_type __pos2, size_type __n2) const  { return _M_get_storage().compare(__pos1, __n1, __s, __pos2, __n2); }  int compare(const _CharT* __s) const  { return _M_get_storage().compare(__s); }  int compare(size_type __pos1, size_type __n1, const _CharT* __s) const  { return _M_get_storage().compare(__pos1, __n1, __s); }  int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const  { return _M_get_storage().compare(__pos1, __n1, __s, __n2); }  //Returns the underlying basic_string representation of the template expression  //The non const method will always initialise it.  _BString& _M_get_storage()  { return _rhs._M_get_storage(*this, _StorageDirection()); }  template <class _Lhs, class _Rhs, class _StorageDir>  _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref,                           __on_left const& /*StorageDir*/)  { return _lhs._M_get_storage(__ref); }  template <class _Lhs, class _Rhs, class _StorageDir>  _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref,                           __on_right const& /*StorageDir*/)  { return _rhs._M_get_storage(__ref); }  template <class _Lhs, class _Rhs, class _StorageDir>  _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref)  { return _M_get_storage(__ref, _StorageDirection()); }  //The const method can be invoked without initialising the basic_string so avoiding dynamic allocation.  _BString const& _M_get_storage(bool __do_init = true) const  { return _M_get_storage(*this, __do_init, _StorageDirection()); }  template <class _Lhs, class _Rhs, class _StorageDir>  _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref,                                 bool __do_init, __on_left const& /*StorageDir*/) const  { return _lhs._M_get_storage(__ref, __do_init); }  template <class _Lhs, class _Rhs, class _StorageDir>  _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref,                                 bool __do_init, __on_right const& /*StorageDir*/) const  { return _rhs._M_get_storage(__ref, __do_init); }  template <class _Lhs, class _Rhs, class _StorageDir>  _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref,                                 bool __do_init) const  { return _M_get_storage(__ref, __do_init, _StorageDirection()); }private:  _Left  _lhs;  _Right _rhs;};/* * For this operator we choose to use the right part as the storage part */template <class _CharT, class _Traits, class _Alloc,          class _Lh1, class _Rh1, class _StoreDir1,          class _Lh2, class _Rh2, class _StoreDir2>inline __bstr_sum<_CharT, _Traits, _Alloc,                  __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1>,                  __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2>,                  __on_right> _STLP_CALLoperator + (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,            const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs) {  return __bstr_sum<_CharT, _Traits, _Alloc,                    __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1>,                    __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2>,                    __on_right>(__lhs, __rhs);}template <class _CharT, class _Traits, class _Alloc,          class _Lh1, class _Rh1, class _StoreDir1,          class _Lh2, class _Rh2, class _StoreDir2>inline bool _STLP_CALLoperator == (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,             const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs){ return (__lhs.size() == __rhs.size()) && (__lhs._M_get_storage() == __rhs._M_get_storage()); }template <class _CharT, class _Traits, class _Alloc,          class _Lh1, class _Rh1, class _StoreDir1,          class _Lh2, class _Rh2, class _StoreDir2>inline bool _STLP_CALLoperator < (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,            const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs){ return __lhs._M_get_storage() < __rhs._M_get_storage(); }#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACEtemplate <class _CharT, class _Traits, class _Alloc,          class _Lh1, class _Rh1, class _StoreDir1,          class _Lh2, class _Rh2, class _StoreDir2>inline bool _STLP_CALLoperator != (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,             const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs){ return !(__lhs == __rhs); }template <class _CharT, class _Traits, class _Alloc,          class _Lh1, class _Rh1, class _StoreDir1,          class _Lh2, class _Rh2, class _StoreDir2>inline bool _STLP_CALLoperator > (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,            const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs){ return __rhs < __lhs; }template <class _CharT, class _Traits, class _Alloc,          class _Lh1, class _Rh1, class _StoreDir1,          class _Lh2, class _Rh2, class _StoreDir2>inline bool _STLP_CALLoperator <= (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,             const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs){ return !(__rhs < __lhs); }template <class _CharT, class _Traits, class _Alloc,          class _Lh1, class _Rh1, class _StoreDir1,          class _Lh2, class _Rh2, class _StoreDir2>inline bool _STLP_CALLoperator >= (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,             const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs){ return !(__lhs < __rhs); }#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE *//* * This class will be used to simulate a temporary string that is required for * a call to the c_str method on the __bstr_sum class. */template <class _CharT, class _Traits, class _Alloc>struct __sum_storage_elem {  typedef __sum_storage_elem<_CharT, _Traits, _Alloc> _Self;  typedef basic_string<_CharT, _Traits, _Alloc> _BString;  __sum_storage_elem(_Alloc __alloc) : _M_init(false), _M_storage(__alloc)  {}  template <class _Left, class _Right, class _StorageDir>  void _M_Init(__bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>  const& __ref) const {    if (!_M_init) {      _STLP_MUTABLE(_Self, _M_storage) = __ref;      _STLP_MUTABLE(_Self, _M_init) = true;    }  }  template <class _Left, class _Right, class _StorageDir>  _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>  const& __ref,                                 bool __do_init) const {    if (__do_init) {      _M_Init(__ref);    }    return _M_storage;  }  template <class _Left, class _Right, class _StorageDir>  _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>  const& __ref) {    _M_Init(__ref);    return _M_storage;  }  size_t size() const { return 0; }  _CharT const& operator[](size_t __n) const  { return __STATIC_CAST(_CharT*, 0)[__n]; }private:  mutable bool _M_init;  mutable basic_string<_CharT, _Traits, _Alloc> _M_storage;};_STLP_MOVE_TO_STD_NAMESPACE_STLP_END_NAMESPACE#endif /*_STLP_STRING_SUM_H*/

⌨️ 快捷键说明

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