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 27 template <class _CharT, class _Traits, class _Alloc> 28 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL 29 operator+(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 44 template <class _CharT, class _Traits, class _Alloc> 45 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL 46 operator+(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 62 template <class _CharT, class _Traits, class _Alloc> 63 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL 64 operator+(_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 78 template <class _CharT, class _Traits, class _Alloc> 79 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL 80 operator+(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 96 template <class _CharT, class _Traits, class _Alloc> 97 inline basic_string<_CharT,_Traits,_Alloc> _STLP_CALL 98 operator+(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 117 template <class _CharT, class _Traits, class _Alloc> 118 inline _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 125 operator+(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 136 template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 137 inline _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 141 operator+(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 148 template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 149 inline _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 153 operator+(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 161 template <class _CharT, class _Traits, class _Alloc> 162 inline _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 169 operator+(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 180 template <class _CharT, class _Traits, class _Alloc> 181 inline _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 188 operator+(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 200 template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 201 inline _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 205 operator+(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 213 template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 214 inline _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 218 operator+(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 227 template <class _CharT, class _Traits, class _Alloc> 228 inline _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 235 operator+(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 244 template <class _CharT, class _Traits, class _Alloc> 245 inline _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 252 operator+(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 261 template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 262 inline _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 266 operator+(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 271 template <class _CharT, class _Traits, class _Alloc, class _Left, class _Right, class _StorageDir> 272 inline _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 275 operator+(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 285 template <class _CharT, class _Traits, class _Alloc> 286 inline bool _STLP_CALL 287 operator==(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) 293 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 294 inline bool _STLP_CALL 295 operator==(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 300 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 301 inline bool _STLP_CALL 302 operator==(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 309 template <class _CharT, class _Traits, class _Alloc> 310 inline bool _STLP_CALL 311 operator==(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 318 template <class _CharT, class _Traits, class _Alloc> 319 inline bool _STLP_CALL 320 operator==(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) 328 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 329 inline bool _STLP_CALL 330 operator==(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 337 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 338 inline bool _STLP_CALL 339 operator==(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 349 template <class _CharT, class _Traits, class _Alloc> 350 inline bool _STLP_CALL 351 operator<(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) 358 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 359 inline bool _STLP_CALL 360 operator<(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 366 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 367 inline bool _STLP_CALL 368 operator<(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 375 template <class _CharT, class _Traits, class _Alloc> 376 inline bool _STLP_CALL 377 operator<(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 385 template <class _CharT, class _Traits, class _Alloc> 386 inline bool _STLP_CALL 387 operator<(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) 396 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 397 inline bool _STLP_CALL 398 operator<(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 406 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 407 inline bool _STLP_CALL 408 operator<(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 */ 423 template <class _CharT, class _Traits, class _Alloc> 424 inline bool _STLP_CALL 425 operator!=(const basic_string<_CharT,_Traits,_Alloc>& __x, 426 const basic_string<_CharT,_Traits,_Alloc>& __y) 427 { return !(__x == __y); } 428 429 template <class _CharT, class _Traits, class _Alloc> 430 inline bool _STLP_CALL 431 operator>(const basic_string<_CharT,_Traits,_Alloc>& __x, 432 const basic_string<_CharT,_Traits,_Alloc>& __y) 433 { return __y < __x; } 434 435 template <class _CharT, class _Traits, class _Alloc> 436 inline bool _STLP_CALL 437 operator<=(const basic_string<_CharT,_Traits,_Alloc>& __x, 438 const basic_string<_CharT,_Traits,_Alloc>& __y) 439 { return !(__y < __x); } 440 441 template <class _CharT, class _Traits, class _Alloc> 442 inline bool _STLP_CALL 443 operator>=(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) 448 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 449 inline bool _STLP_CALL 450 operator!=(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 454 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 455 inline bool _STLP_CALL 456 operator!=(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 463 template <class _CharT, class _Traits, class _Alloc> 464 inline bool _STLP_CALL 465 operator!=(const _CharT* __s, 466 const basic_string<_CharT,_Traits,_Alloc>& __y) { 467 _STLP_FIX_LITERAL_BUG(__s) 468 return !(__s == __y); 469 } 470 471 template <class _CharT, class _Traits, class _Alloc> 472 inline bool _STLP_CALL 473 operator!=(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) 480 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 481 inline bool _STLP_CALL 482 operator!=(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 488 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 489 inline bool _STLP_CALL 490 operator!=(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 497 template <class _CharT, class _Traits, class _Alloc> 498 inline bool _STLP_CALL 499 operator>(const _CharT* __s, 500 const basic_string<_CharT,_Traits,_Alloc>& __y) { 501 _STLP_FIX_LITERAL_BUG(__s) 502 return __y < __s; 503 } 504 505 template <class _CharT, class _Traits, class _Alloc> 506 inline bool _STLP_CALL 507 operator>(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) 514 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 515 inline bool _STLP_CALL 516 operator>(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 522 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 523 inline bool _STLP_CALL 524 operator>(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 531 template <class _CharT, class _Traits, class _Alloc> 532 inline bool _STLP_CALL 533 operator<=(const _CharT* __s, 534 const basic_string<_CharT,_Traits,_Alloc>& __y) { 535 _STLP_FIX_LITERAL_BUG(__s) 536 return !(__y < __s); 537 } 538 539 template <class _CharT, class _Traits, class _Alloc> 540 inline bool _STLP_CALL 541 operator<=(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) 548 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 549 inline bool _STLP_CALL 550 operator<=(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 556 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 557 inline bool _STLP_CALL 558 operator<=(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 565 template <class _CharT, class _Traits, class _Alloc> 566 inline bool _STLP_CALL 567 operator>=(const _CharT* __s, 568 const basic_string<_CharT,_Traits,_Alloc>& __y) { 569 _STLP_FIX_LITERAL_BUG(__s) 570 return !(__s < __y); 571 } 572 573 template <class _CharT, class _Traits, class _Alloc> 574 inline bool _STLP_CALL 575 operator>=(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) 582 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 583 inline bool _STLP_CALL 584 operator>=(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 590 template <class _CharT, class _Traits, class _Alloc, class _Lhs, class _Rhs, class _StoreDir> 591 inline bool _STLP_CALL 592 operator>=(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