concepts.qbk 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. [/
  2. / Copyright (c) 2008 Eric Niebler
  3. /
  4. / Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /]
  7. [section Concepts]
  8. [h2 CharT requirements]
  9. If type `BidiIterT` is used as a template argument to _basic_regex_, then `CharT` is
  10. `iterator_traits<BidiIterT>::value_type`. Type `CharT` must have a trivial default
  11. constructor, copy constructor, assignment operator, and destructor. In addition
  12. the following requirements must be met for objects; `c` of type `CharT`, `c1` and `c2` of
  13. type `CharT const`, and `i` of type `int`:
  14. [table CharT Requirements
  15. [
  16. [[*Expression]]
  17. [[*Return type]]
  18. [[*Assertion / Note / Pre- / Post-condition]]
  19. ]
  20. [
  21. [`CharT c`]
  22. [`CharT`]
  23. [Default constructor (must be trivial).]
  24. ]
  25. [
  26. [`CharT c(c1)`]
  27. [`CharT`]
  28. [Copy constructor (must be trivial).]
  29. ]
  30. [
  31. [`c1 = c2`]
  32. [`CharT`]
  33. [Assignment operator (must be trivial).]
  34. ]
  35. [
  36. [`c1 == c2`]
  37. [`bool`]
  38. [`true` if `c1` has the same value as `c2`.]
  39. ]
  40. [
  41. [`c1 != c2`]
  42. [`bool`]
  43. [`true` if `c1` and `c2` are not equal.]
  44. ]
  45. [
  46. [`c1 < c2`]
  47. [`bool`]
  48. [`true` if the value of `c1` is less than `c2`.]
  49. ]
  50. [
  51. [`c1 > c2`]
  52. [`bool`]
  53. [`true` if the value of `c1` is greater than `c2`.]
  54. ]
  55. [
  56. [`c1 <= c2`]
  57. [`bool`]
  58. [`true` if `c1` is less than or equal to `c2`.]
  59. ]
  60. [
  61. [`c1 >= c2`]
  62. [`bool`]
  63. [`true` if `c1` is greater than or equal to `c2`.]
  64. ]
  65. [
  66. [`intmax_t i = c1`]
  67. [`int`]
  68. [
  69. `CharT` must be convertible to an integral type.
  70. ]
  71. ]
  72. [
  73. [`CharT c(i);`]
  74. [`CharT`]
  75. [`CharT` must be constructable from an integral type.]
  76. ]
  77. ]
  78. [h2 Traits Requirements]
  79. In the following table `X` denotes a traits class defining types and functions
  80. for the character container type `CharT`; `u` is an object of type `X`; `v` is an
  81. object of type `const X`; `p` is a value of type `const CharT*`; `I1` and `I2` are
  82. `Input Iterators`; `c` is a value of type `const CharT`; `s` is an object of type
  83. `X::string_type`; `cs` is an object of type `const X::string_type`; `b` is a value of
  84. type `bool`; `i` is a value of type `int`; `F1` and `F2` are values of type `const CharT*`;
  85. `loc` is an object of type `X::locale_type`; and `ch` is an object of `const char`.
  86. [table Traits Requirements
  87. [
  88. [
  89. [*Expression]
  90. ]
  91. [
  92. [*Return type]
  93. ]
  94. [
  95. [*Assertion / Note\n
  96. Pre / Post condition]
  97. ]
  98. ]
  99. [
  100. [
  101. `X::char_type`
  102. ]
  103. [
  104. `CharT`
  105. ]
  106. [
  107. The character container type used in the implementation of class template _basic_regex_.
  108. ]
  109. ]
  110. [
  111. [
  112. `X::string_type`
  113. ]
  114. [
  115. `std::basic_string<CharT>` or `std::vector<CharT>`
  116. ]
  117. [
  118. ]
  119. ]
  120. [
  121. [
  122. `X::locale_type`
  123. ]
  124. [
  125. ['Implementation defined]
  126. ]
  127. [
  128. A copy constructible type that represents the locale used by the traits class.
  129. ]
  130. ]
  131. [
  132. [
  133. `X::char_class_type`
  134. ]
  135. [
  136. ['Implementation defined]
  137. ]
  138. [
  139. A bitmask type representing a particular character classification. Multiple
  140. values of this type can be bitwise-or'ed together to obtain a new valid value.
  141. ]
  142. ]
  143. [
  144. [
  145. `X::hash(c)`
  146. ]
  147. [
  148. `unsigned char`
  149. ]
  150. [
  151. Yields a value between `0` and `UCHAR_MAX` inclusive.
  152. ]
  153. ]
  154. [
  155. [
  156. `v.widen(ch)`
  157. ]
  158. [
  159. `CharT`
  160. ]
  161. [
  162. Widens the specified `char` and returns the resulting `CharT`.
  163. ]
  164. ]
  165. [
  166. [
  167. `v.in_range(r1, r2, c)`
  168. ]
  169. [
  170. `bool`
  171. ]
  172. [
  173. For any characters `r1` and `r2`, returns `true` if `r1 <= c && c <= r2`.
  174. Requires that `r1 <= r2`.
  175. ]
  176. ]
  177. [
  178. [
  179. `v.in_range_nocase(r1, r2, c)`
  180. ]
  181. [
  182. `bool`
  183. ]
  184. [
  185. For characters `r1` and `r2`, returns `true` if there is some character
  186. `d` for which `v.translate_nocase(d) == v.translate_nocase(c)` and
  187. `r1 <= d && d <= r2`. Requires that `r1 <= r2`.
  188. ]
  189. ]
  190. [
  191. [
  192. `v.translate(c)`
  193. ]
  194. [
  195. `X::char_type`
  196. ]
  197. [
  198. Returns a character such that for any character `d` that is to be considered
  199. equivalent to `c` then `v.translate(c) == v.translate(d)`.
  200. ]
  201. ]
  202. [
  203. [
  204. `v.translate_nocase(c)`
  205. ]
  206. [
  207. `X::char_type`
  208. ]
  209. [
  210. For all characters `C` that are to be considered
  211. equivalent to `c` when comparisons are to be performed without regard to case,
  212. then `v.translate_nocase(c) == v.translate_nocase(C)`.
  213. ]
  214. ]
  215. [
  216. [
  217. `v.transform(F1, F2)`
  218. ]
  219. [
  220. `X::string_type`
  221. ]
  222. [
  223. Returns a sort key for the character sequence designated by the iterator range
  224. `[F1, F2)` such that if the character sequence `[G1, G2)` sorts before the
  225. character sequence `[H1, H2)` then `v.transform(G1, G2) < v.transform(H1, H2)`.
  226. ]
  227. ]
  228. [
  229. [
  230. `v.transform_primary(F1, F2)`
  231. ]
  232. [
  233. `X::string_type`
  234. ]
  235. [
  236. Returns a sort key for the character sequence designated by the iterator range
  237. `[F1, F2)` such that if the character sequence `[G1, G2)` sorts before the
  238. character sequence `[H1, H2)` when character case is not considered then
  239. `v.transform_primary(G1, G2) < v.transform_primary(H1, H2)`.
  240. ]
  241. ]
  242. [
  243. [
  244. `v.lookup_classname(F1, F2)`
  245. ]
  246. [
  247. `X::char_class_type`
  248. ]
  249. [
  250. Converts the character sequence designated by the iterator range `[F1,F2)` into a
  251. bitmask type that can subsequently be passed to `isctype`. Values returned from
  252. `lookup_classname` can be safely bitwise or'ed together. Returns `0` if the
  253. character sequence is not the name of a character class recognized by `X`. The
  254. value returned shall be independent of the case of the characters in the
  255. sequence.
  256. ]
  257. ]
  258. [
  259. [
  260. `v.lookup_collatename(F1, F2)`
  261. ]
  262. [
  263. `X::string_type`
  264. ]
  265. [
  266. Returns a sequence of characters that represents the collating element
  267. consisting of the character sequence designated by the iterator range `[F1, F2)`.
  268. Returns an empty string if the character sequence is not a valid collating
  269. element.
  270. ]
  271. ]
  272. [
  273. [
  274. `v.isctype(c, v.lookup_classname(F1, F2))`
  275. ]
  276. [
  277. `bool`
  278. ]
  279. [
  280. Returns `true` if character `c` is a member of the character class designated by
  281. the iterator range `[F1, F2)`, `false` otherwise.
  282. ]
  283. ]
  284. [
  285. [
  286. `v.value(c, i)`
  287. ]
  288. [
  289. `int`
  290. ]
  291. [
  292. Returns the value represented by the digit `c` in base `i` if the character `c` is a
  293. valid digit in base `i`; otherwise returns `-1`.\n
  294. \[Note: the value of `i` will only be `8`, `10`, or `16`. -end note\]
  295. ]
  296. ]
  297. [
  298. [
  299. `u.imbue(loc)`
  300. ]
  301. [
  302. `X::locale_type`
  303. ]
  304. [
  305. Imbues `u` with the locale `loc`, returns the previous
  306. locale used by `u`.
  307. ]
  308. ]
  309. [
  310. [
  311. `v.getloc()`
  312. ]
  313. [
  314. `X::locale_type`
  315. ]
  316. [
  317. Returns the current locale used by `v`.
  318. ]
  319. ]
  320. ]
  321. [h2 Acknowledgements]
  322. This section is adapted from the equivalent page in the _regexpp_ documentation and from the
  323. _proposal_ to add regular expressions to the Standard Library.
  324. [endsect]