1/* 2 * Copyright (c) 2003 3 * Francois Dumont 4 * 5 * This material is provided "as is", with absolutely no warranty expressed 6 * or implied. Any use is at your own risk. 7 * 8 * Permission to use or copy this software for any purpose is hereby granted 9 * without fee, provided the above notices are retained on all copies. 10 * Permission to modify the code and to distribute modified code is granted, 11 * provided the above notices are retained, and a notice that the code was 12 * modified is included with the above copyright notice. 13 * 14 */ 15 16#ifndef _STLP_STRING_OPERATORS_H 17#define _STLP_STRING_OPERATORS_H 18 19_STLP_BEGIN_NAMESPACE 20 21#if !defined (_STLP_USE_TEMPLATE_EXPRESSION) 22 23# if defined (__GNUC__) || defined (__MLCCPP__) 24# define _STLP_INIT_AMBIGUITY 1 25# endif 26 27template <class _CharT, class _Traits, class _Alloc> 28inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL 29operator+(const basic_string<_CharT,_Traits,_Alloc>& __s, 30 const basic_string<_CharT,_Traits,_Alloc>& __y) { 31 typedef basic_string<_CharT,_Traits,_Alloc> _Str; 32 typedef typename _Str::_Reserve_t _Reserve_t; 33# if defined (_STLP_INIT_AMBIGUITY) 34 // gcc counts this as a function 35 _Str __result = _Str(_Reserve_t(), __s.size() + __y.size(), __s.get_allocator()); 36# else 37 _Str __result(_Reserve_t(), __s.size() + __y.size(), __s.get_allocator()); 38# endif 39 __result.append(__s); 40 __result.append(__y); 41 return __result; 42} 43 44template <class _CharT, class _Traits, class _Alloc> 45inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL 46operator+(const _CharT* __s, 47 const basic_string<_CharT,_Traits,_Alloc>& __y) { 48 _STLP_FIX_LITERAL_BUG(__s) 49 typedef basic_string<_CharT,_Traits,_Alloc> _Str; 50 typedef typename _Str::_Reserve_t _Reserve_t; 51 const size_t __n = _Traits::length(__s); 52# if defined (_STLP_INIT_AMBIGUITY) 53 _Str __result = _Str(_Reserve_t(), __n + __y.size(), __y.get_allocator()); 54# else 55 _Str __result(_Reserve_t(), __n + __y.size(), __y.get_allocator()); 56# endif 57 __result.append(__s, __s + __n); 58 __result.append(__y); 59 return __result; 60} 61 62template <class _CharT, class _Traits, class _Alloc> 63inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL 64operator+(_CharT __c, 65 const basic_string<_CharT,_Traits,_Alloc>& __y) { 66 typedef basic_string<_CharT,_Traits,_Alloc> _Str; 67 typedef typename _Str::_Reserve_t _Reserve_t; 68# if defined (_STLP_INIT_AMBIGUITY) 69 _Str __result = _Str(_Reserve_t(), 1 + __y.size(), __y.get_allocator()); 70# else 71 _Str __result(_Reserve_t(), 1 + __y.size(), __y.get_allocator()); 72# endif 73 __result.push_back(__c); 74 __result.append(__y); 75 return __result; 76} 77 78template <class _CharT, class _Traits, class _Alloc> 79inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL 80operator+(const basic_string<_CharT,_Traits,_Alloc>& __x, 81 const _CharT* __s) { 82 _STLP_FIX_LITERAL_BUG(__s) 83 typedef basic_string<_CharT,_Traits,_Alloc> _Str; 84 typedef typename _Str::_Reserve_t _Reserve_t; 85 const size_t __n = _Traits::length(__s); 86# if defined (_STLP_INIT_AMBIGUITY) 87 _Str __result = _Str(_Reserve_t(), __x.size() + __n, __x.get_allocator()); 88# else 89 _Str __result(_Reserve_t(), __x.size() + __n, __x.get_allocator()); 90# endif 91 __result.append(__x); 92 __result.append(__s, __s + __n); 93 return __result; 94} 95 96template <class _CharT, class _Traits, class _Alloc> 97inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL 98operator+(const basic_string<_CharT,_Traits,_Alloc>& __x, 99 const _CharT __c) { 100 typedef basic_string<_CharT,_Traits,_Alloc> _Str; 101 typedef typename _Str::_Reserve_t _Reserve_t; 102# if defined (_STLP_INIT_AMBIGUITY) 103 _Str __result = _Str(_Reserve_t(), __x.size() + 1, __x.get_allocator()); 104# else 105 _Str __result(_Reserve_t(), __x.size() + 1, __x.get_allocator()); 106# endif 107 __result.append(__x); 108 __result.push_back(__c); 109 return __result; 110} 111 112# undef _STLP_INIT_AMBIGUITY 113 114#else /* _STLP_USE_TEMPLATE_EXPRESSION */ 115 116// addition with basic_string 117template <class _CharT, class _Traits, class _Alloc> 118inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 119 _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 120 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 121 _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 122 _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, 123 _STLP_PRIV __on_right>, 124 _STLP_PRIV __on_right> _STLP_CALL 125operator+(const basic_string<_CharT,_Traits,_Alloc>& __lhs, 126 const basic_string<_CharT,_Traits,_Alloc>& __rhs) { 127 typedef _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 128 _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, 129 _STLP_PRIV __on_right> __root_type; 130 __root_type __root(__rhs, _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>(__lhs.get_allocator())); 131 return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 132 __root_type, 133 _STLP_PRIV __on_right>(__lhs, __root); 134} 135 136template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 137inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 138 _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 139 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 140 _STLP_PRIV __on_right> _STLP_CALL 141operator+(const basic_string<_CharT,_Traits,_Alloc>& __lhs, 142 const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __rhs) { 143 return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 144 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 145 _STLP_PRIV __on_right>(__lhs, __rhs); 146} 147 148template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 149inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 150 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 151 _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 152 _STLP_PRIV __on_left> _STLP_CALL 153operator+(const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __lhs, 154 const basic_string<_CharT,_Traits,_Alloc>& __rhs) { 155 return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 156 _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 157 _STLP_PRIV __on_left>(__lhs, __rhs); 158} 159 160// addition with C string 161template <class _CharT, class _Traits, class _Alloc> 162inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 163 _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 164 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 165 _STLP_PRIV __cstr_wrapper<_CharT>, 166 _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, 167 _STLP_PRIV __on_right>, 168 _STLP_PRIV __on_right> _STLP_CALL 169operator+(const basic_string<_CharT,_Traits,_Alloc>& __x, 170 const _CharT* __s) { 171 const size_t __n = _Traits::length(__s); 172 typedef _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __cstr_wrapper<_CharT>, 173 _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, 174 _STLP_PRIV __on_right> __root_type; 175 __root_type __root(_STLP_PRIV __cstr_wrapper<_CharT>(__s, __n), _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>(__x.get_allocator())); 176 return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 177 __root_type, _STLP_PRIV __on_right>(__x, __root); 178} 179 180template <class _CharT, class _Traits, class _Alloc> 181inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 182 _STLP_PRIV __cstr_wrapper<_CharT>, 183 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 184 _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 185 _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, 186 _STLP_PRIV __on_right>, 187 _STLP_PRIV __on_right> _STLP_CALL 188operator+(const _CharT* __s, 189 const basic_string<_CharT,_Traits,_Alloc>& __y) { 190 const size_t __n = _Traits::length(__s); 191 typedef _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 192 _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, 193 _STLP_PRIV __on_right> __root_type; 194 __root_type __root(__y, _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>(__y.get_allocator())); 195 return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __cstr_wrapper<_CharT>, 196 __root_type, 197 _STLP_PRIV __on_right>(_STLP_PRIV __cstr_wrapper<_CharT>(__s, __n), __root); 198} 199 200template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 201inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 202 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 203 _STLP_PRIV __cstr_wrapper<_CharT>, 204 _STLP_PRIV __on_left> _STLP_CALL 205operator+(const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __x, 206 const _CharT* __s) { 207 const size_t __n = _Traits::length(__s); 208 return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 209 _STLP_PRIV __cstr_wrapper<_CharT>, 210 _STLP_PRIV __on_left>(__x, _STLP_PRIV __cstr_wrapper<_CharT>(__s, __n)); 211} 212 213template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 214inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 215 _STLP_PRIV __cstr_wrapper<_CharT>, 216 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 217 _STLP_PRIV __on_right> _STLP_CALL 218operator+(const _CharT* __s, 219 const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __y) { 220 const size_t __n = _Traits::length(__s); 221 return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __cstr_wrapper<_CharT>, 222 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 223 _STLP_PRIV __on_right>(_STLP_PRIV __cstr_wrapper<_CharT>(__s, __n), __y); 224} 225 226// addition with char 227template <class _CharT, class _Traits, class _Alloc> 228inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 229 _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 230 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 231 _STLP_PRIV __char_wrapper<_CharT>, 232 _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, 233 _STLP_PRIV __on_right>, 234 _STLP_PRIV __on_right> _STLP_CALL 235operator+(const basic_string<_CharT,_Traits,_Alloc>& __x, const _CharT __c) { 236 typedef _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __char_wrapper<_CharT>, 237 _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, 238 _STLP_PRIV __on_right> __root_type; 239 __root_type __root(__c, _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>(__x.get_allocator())); 240 return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 241 __root_type, _STLP_PRIV __on_right>(__x, __root); 242} 243 244template <class _CharT, class _Traits, class _Alloc> 245inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 246 _STLP_PRIV __char_wrapper<_CharT>, 247 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 248 _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 249 _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, 250 _STLP_PRIV __on_right>, 251 _STLP_PRIV __on_right> _STLP_CALL 252operator+(const _CharT __c, const basic_string<_CharT,_Traits,_Alloc>& __x) { 253 typedef _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_wrapper<_CharT,_Traits,_Alloc>, 254 _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>, 255 _STLP_PRIV __on_right> __root_type; 256 __root_type __root(__x, _STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc>(__x.get_allocator())); 257 return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __char_wrapper<_CharT>, 258 __root_type, _STLP_PRIV __on_right>(__c, __root); 259} 260 261template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 262inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, 263 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 264 _STLP_PRIV __char_wrapper<_CharT>, 265 _STLP_PRIV __on_left> _STLP_CALL 266operator+(const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __x, const _CharT __c) { 267 return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 268 _STLP_PRIV __char_wrapper<_CharT>, _STLP_PRIV __on_left>(__x, __c); 269} 270 271template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 272inline _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __char_wrapper<_CharT>, 273 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 274 _STLP_PRIV __on_right> _STLP_CALL 275operator+(const _CharT __c, const _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>& __x) { 276 return _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _STLP_PRIV __char_wrapper<_CharT>, 277 _STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>, 278 _STLP_PRIV __on_right>(__c, __x); 279} 280 281#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ 282 283// Operator== and operator!= 284 285template <class _CharT, class _Traits, class _Alloc> 286inline bool _STLP_CALL 287operator==(const basic_string<_CharT,_Traits,_Alloc>& __x, 288 const basic_string<_CharT,_Traits,_Alloc>& __y) { 289 return __x.size() == __y.size() && _Traits::compare(__x.data(), __y.data(), __x.size()) == 0; 290} 291 292#if defined (_STLP_USE_TEMPLATE_EXPRESSION) 293template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 294inline bool _STLP_CALL 295operator==(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, 296 const basic_string<_CharT,_Traits,_Alloc>& __y) { 297 return __x.size() == __y.size() && _Traits::compare(__x.data(), __y.data(), __x.size()) == 0; 298} 299 300template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 301inline bool _STLP_CALL 302operator==(const basic_string<_CharT,_Traits,_Alloc>& __x, 303 const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { 304 return __x.size() == __y.size() && _Traits::compare(__x.data(), __y.data(), __x.size()) == 0; 305} 306#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ 307 308 309template <class _CharT, class _Traits, class _Alloc> 310inline bool _STLP_CALL 311operator==(const _CharT* __s, 312 const basic_string<_CharT,_Traits,_Alloc>& __y) { 313 _STLP_FIX_LITERAL_BUG(__s) 314 size_t __n = _Traits::length(__s); 315 return __n == __y.size() && _Traits::compare(__s, __y.data(), __n) == 0; 316} 317 318template <class _CharT, class _Traits, class _Alloc> 319inline bool _STLP_CALL 320operator==(const basic_string<_CharT,_Traits,_Alloc>& __x, 321 const _CharT* __s) { 322 _STLP_FIX_LITERAL_BUG(__s) 323 size_t __n = _Traits::length(__s); 324 return __x.size() == __n && _Traits::compare(__x.data(), __s, __n) == 0; 325} 326 327#if defined (_STLP_USE_TEMPLATE_EXPRESSION) 328template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 329inline bool _STLP_CALL 330operator==(const _CharT* __s, 331 const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { 332 _STLP_FIX_LITERAL_BUG(__s) 333 size_t __n = _Traits::length(__s); 334 return __n == __y.size() && _Traits::compare(__s, __y.data(), __n) == 0; 335} 336 337template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 338inline bool _STLP_CALL 339operator==(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, 340 const _CharT* __s) { 341 _STLP_FIX_LITERAL_BUG(__s) 342 size_t __n = _Traits::length(__s); 343 return __x.size() == __n && _Traits::compare(__x.data(), __s, __n) == 0; 344} 345#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ 346 347// Operator< (and also >, <=, and >=). 348 349template <class _CharT, class _Traits, class _Alloc> 350inline bool _STLP_CALL 351operator<(const basic_string<_CharT,_Traits,_Alloc>& __x, 352 const basic_string<_CharT,_Traits,_Alloc>& __y) { 353 return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), 354 __y.begin(), __y.end()) < 0; 355} 356 357#if defined (_STLP_USE_TEMPLATE_EXPRESSION) 358template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 359inline bool _STLP_CALL 360operator<(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, 361 const basic_string<_CharT,_Traits,_Alloc>& __y) { 362 return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), 363 __y.begin(), __y.end()) < 0; 364} 365 366template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 367inline bool _STLP_CALL 368operator<(const basic_string<_CharT,_Traits,_Alloc>& __x, 369 const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { 370 return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), 371 __y.begin(), __y.end()) < 0; 372} 373#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ 374 375template <class _CharT, class _Traits, class _Alloc> 376inline bool _STLP_CALL 377operator<(const _CharT* __s, 378 const basic_string<_CharT,_Traits,_Alloc>& __y) { 379 _STLP_FIX_LITERAL_BUG(__s) 380 size_t __n = _Traits::length(__s); 381 return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__s, __s + __n, 382 __y.begin(), __y.end()) < 0; 383} 384 385template <class _CharT, class _Traits, class _Alloc> 386inline bool _STLP_CALL 387operator<(const basic_string<_CharT,_Traits,_Alloc>& __x, 388 const _CharT* __s) { 389 _STLP_FIX_LITERAL_BUG(__s) 390 size_t __n = _Traits::length(__s); 391 return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), 392 __s, __s + __n) < 0; 393} 394 395#if defined (_STLP_USE_TEMPLATE_EXPRESSION) 396template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 397inline bool _STLP_CALL 398operator<(const _CharT* __s, 399 const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { 400 _STLP_FIX_LITERAL_BUG(__s) 401 size_t __n = _Traits::length(__s); 402 return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__s, __s + __n, 403 __y.begin(), __y.end()) < 0; 404} 405 406template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 407inline bool _STLP_CALL 408operator<(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, 409 const _CharT* __s) { 410 _STLP_FIX_LITERAL_BUG(__s) 411 size_t __n = _Traits::length(__s); 412 return basic_string<_CharT,_Traits,_Alloc> ::_M_compare(__x.begin(), __x.end(), 413 __s, __s + __n) < 0; 414} 415#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ 416 417#if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) 418 419/* Only defined if _STLP_USE_SEPARATE_RELOPS_NAMESPACE is defined otherwise 420 * it might introduce ambiguity with pure template relational operators 421 * from rel_ops namespace. 422 */ 423template <class _CharT, class _Traits, class _Alloc> 424inline bool _STLP_CALL 425operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x, 426 const basic_string<_CharT,_Traits,_Alloc>& __y) 427{ return !(__x == __y); } 428 429template <class _CharT, class _Traits, class _Alloc> 430inline bool _STLP_CALL 431operator>(const basic_string<_CharT,_Traits,_Alloc>& __x, 432 const basic_string<_CharT,_Traits,_Alloc>& __y) 433{ return __y < __x; } 434 435template <class _CharT, class _Traits, class _Alloc> 436inline bool _STLP_CALL 437operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x, 438 const basic_string<_CharT,_Traits,_Alloc>& __y) 439{ return !(__y < __x); } 440 441template <class _CharT, class _Traits, class _Alloc> 442inline bool _STLP_CALL 443operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x, 444 const basic_string<_CharT,_Traits,_Alloc>& __y) 445{ return !(__x < __y); } 446 447# if defined (_STLP_USE_TEMPLATE_EXPRESSION) 448template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 449inline bool _STLP_CALL 450operator!=(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, 451 const basic_string<_CharT,_Traits,_Alloc>& __y) 452{ return !(__x==__y); } 453 454template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 455inline bool _STLP_CALL 456operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x, 457 const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) 458{ return !(__x==__y); } 459# endif 460 461#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ 462 463template <class _CharT, class _Traits, class _Alloc> 464inline bool _STLP_CALL 465operator!=(const _CharT* __s, 466 const basic_string<_CharT,_Traits,_Alloc>& __y) { 467 _STLP_FIX_LITERAL_BUG(__s) 468 return !(__s == __y); 469} 470 471template <class _CharT, class _Traits, class _Alloc> 472inline bool _STLP_CALL 473operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x, 474 const _CharT* __s) { 475 _STLP_FIX_LITERAL_BUG(__s) 476 return !(__x == __s); 477} 478 479#if defined (_STLP_USE_TEMPLATE_EXPRESSION) 480template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 481inline bool _STLP_CALL 482operator!=(const _CharT* __s, 483 const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { 484 _STLP_FIX_LITERAL_BUG(__s) 485 return !(__s == __y); 486} 487 488template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 489inline bool _STLP_CALL 490operator!=(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, 491 const _CharT* __s) { 492 _STLP_FIX_LITERAL_BUG(__s) 493 return !(__x == __s); 494} 495#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ 496 497template <class _CharT, class _Traits, class _Alloc> 498inline bool _STLP_CALL 499operator>(const _CharT* __s, 500 const basic_string<_CharT,_Traits,_Alloc>& __y) { 501 _STLP_FIX_LITERAL_BUG(__s) 502 return __y < __s; 503} 504 505template <class _CharT, class _Traits, class _Alloc> 506inline bool _STLP_CALL 507operator>(const basic_string<_CharT,_Traits,_Alloc>& __x, 508 const _CharT* __s) { 509 _STLP_FIX_LITERAL_BUG(__s) 510 return __s < __x; 511} 512 513#if defined (_STLP_USE_TEMPLATE_EXPRESSION) 514template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 515inline bool _STLP_CALL 516operator>(const _CharT* __s, 517 const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { 518 _STLP_FIX_LITERAL_BUG(__s) 519 return __y < __s; 520} 521 522template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 523inline bool _STLP_CALL 524operator>(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, 525 const _CharT* __s) { 526 _STLP_FIX_LITERAL_BUG(__s) 527 return __s < __x; 528} 529#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ 530 531template <class _CharT, class _Traits, class _Alloc> 532inline bool _STLP_CALL 533operator<=(const _CharT* __s, 534 const basic_string<_CharT,_Traits,_Alloc>& __y) { 535 _STLP_FIX_LITERAL_BUG(__s) 536 return !(__y < __s); 537} 538 539template <class _CharT, class _Traits, class _Alloc> 540inline bool _STLP_CALL 541operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x, 542 const _CharT* __s) { 543 _STLP_FIX_LITERAL_BUG(__s) 544 return !(__s < __x); 545} 546 547#if defined (_STLP_USE_TEMPLATE_EXPRESSION) 548template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 549inline bool _STLP_CALL 550operator<=(const _CharT* __s, 551 const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { 552 _STLP_FIX_LITERAL_BUG(__s) 553 return !(__y < __s); 554} 555 556template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 557inline bool _STLP_CALL 558operator<=(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, 559 const _CharT* __s) { 560 _STLP_FIX_LITERAL_BUG(__s) 561 return !(__s < __x); 562} 563#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ 564 565template <class _CharT, class _Traits, class _Alloc> 566inline bool _STLP_CALL 567operator>=(const _CharT* __s, 568 const basic_string<_CharT,_Traits,_Alloc>& __y) { 569 _STLP_FIX_LITERAL_BUG(__s) 570 return !(__s < __y); 571} 572 573template <class _CharT, class _Traits, class _Alloc> 574inline bool _STLP_CALL 575operator>=(const basic_string<_CharT,_Traits,_Alloc>& __x, 576 const _CharT* __s) { 577 _STLP_FIX_LITERAL_BUG(__s) 578 return !(__x < __s); 579} 580 581#if defined (_STLP_USE_TEMPLATE_EXPRESSION) 582template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 583inline bool _STLP_CALL 584operator>=(const _CharT* __s, 585 const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __y) { 586 _STLP_FIX_LITERAL_BUG(__s) 587 return !(__s < __y); 588} 589 590template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 591inline bool _STLP_CALL 592operator>=(const _STLP_PRIV __bstr_sum<_CharT,_Traits,_Alloc,_Lhs,_Rhs,_StoreDir>& __x, 593 const _CharT* __s) { 594 _STLP_FIX_LITERAL_BUG(__s) 595 return !(__x < __s); 596} 597#endif /* _STLP_USE_TEMPLATE_EXPRESSION */ 598 599_STLP_END_NAMESPACE 600 601#endif /* _STLP_STRING_OPERATORS_H */ 602 603