_string_operators.h 27 KB

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