basic_regex.qbk 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. [/
  2. Copyright 2006-2007 John Maddock.
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. ]
  7. [section:basic_regex basic_regex]
  8. [h4 Synopsis]
  9. #include <boost/regex.hpp>
  10. The template class `basic_regex` encapsulates regular expression
  11. parsing and compilation. The class takes two template parameters:
  12. * `charT`: determines the character type, i.e. either `char` or `wchar_t`;
  13. see [link boost_regex.ref.concepts.charT_concept charT concept].
  14. * `traits`: determines the behavior of the character type, for example which
  15. character class names are recognized. A default traits class is provided:
  16. `regex_traits<charT>`. See also
  17. [link boost_regex.ref.concepts.traits_concept traits concept].
  18. For ease of use there are two typedefs that define the two standard
  19. `basic_regex` instances, unless you want to use custom traits classes or
  20. non-standard character types (for example see
  21. [link boost_regex.ref.non_std_strings.icu unicode support]),
  22. you won't need to use anything other than these:
  23. namespace boost{
  24. template <class charT, class traits = regex_traits<charT> >
  25. class basic_regex;
  26. typedef basic_regex<char> regex;
  27. typedef basic_regex<wchar_t> wregex;
  28. }
  29. The definition of `basic_regex` follows: it is based very closely on class
  30. `basic_string`, and fulfils the requirements for a constant-container of `charT`.
  31. namespace boost{
  32. template <class charT, class traits = regex_traits<charT> >
  33. class basic_regex {
  34. public:
  35. // types:
  36. typedef charT value_type;
  37. typedef implementation-specific const_iterator;
  38. typedef const_iterator iterator;
  39. typedef charT& reference;
  40. typedef const charT& const_reference;
  41. typedef std::ptrdiff_t difference_type;
  42. typedef std::size_t size_type;
  43. typedef regex_constants::``[syntax_option_type]`` flag_type;
  44. typedef typename traits::locale_type locale_type;
  45. // constants:
  46. // main option selection:
  47. static const regex_constants::``[syntax_option_type]`` normal
  48. = regex_constants::normal;
  49. static const regex_constants::``[syntax_option_type]`` ECMAScript
  50. = normal;
  51. static const regex_constants::``[syntax_option_type]`` JavaScript
  52. = normal;
  53. static const regex_constants::``[syntax_option_type]`` JScript
  54. = normal;
  55. static const regex_constants::``[syntax_option_type]`` basic
  56. = regex_constants::basic;
  57. static const regex_constants::``[syntax_option_type]`` extended
  58. = regex_constants::extended;
  59. static const regex_constants::``[syntax_option_type]`` awk
  60. = regex_constants::awk;
  61. static const regex_constants::``[syntax_option_type]`` grep
  62. = regex_constants::grep;
  63. static const regex_constants::``[syntax_option_type]`` egrep
  64. = regex_constants::egrep;
  65. static const regex_constants::``[syntax_option_type]`` sed
  66. = basic = regex_constants::sed;
  67. static const regex_constants::``[syntax_option_type]`` perl
  68. = regex_constants::perl;
  69. static const regex_constants::``[syntax_option_type]`` literal
  70. = regex_constants::literal;
  71. // modifiers specific to perl expressions:
  72. static const regex_constants::``[syntax_option_type]`` no_mod_m
  73. = regex_constants::no_mod_m;
  74. static const regex_constants::``[syntax_option_type]`` no_mod_s
  75. = regex_constants::no_mod_s;
  76. static const regex_constants::``[syntax_option_type]`` mod_s
  77. = regex_constants::mod_s;
  78. static const regex_constants::``[syntax_option_type]`` mod_x
  79. = regex_constants::mod_x;
  80. // modifiers specific to POSIX basic expressions:
  81. static const regex_constants::``[syntax_option_type]`` bk_plus_qm
  82. = regex_constants::bk_plus_qm;
  83. static const regex_constants::``[syntax_option_type]`` bk_vbar
  84. = regex_constants::bk_vbar
  85. static const regex_constants::``[syntax_option_type]`` no_char_classes
  86. = regex_constants::no_char_classes
  87. static const regex_constants::``[syntax_option_type]`` no_intervals
  88. = regex_constants::no_intervals
  89. // common modifiers:
  90. static const regex_constants::``[syntax_option_type]`` nosubs
  91. = regex_constants::nosubs;
  92. static const regex_constants::``[syntax_option_type]`` optimize
  93. = regex_constants::optimize;
  94. static const regex_constants::``[syntax_option_type]`` collate
  95. = regex_constants::collate;
  96. static const regex_constants::``[syntax_option_type]`` newline_alt
  97. = regex_constants::newline_alt;
  98. static const regex_constants::``[syntax_option_type]`` no_except
  99. = regex_constants::newline_alt;
  100. // construct/copy/destroy:
  101. explicit ``[link boost_regex.basic_regex.construct1 basic_regex]`` ();
  102. explicit ``[link boost_regex.basic_regex.construct2 basic_regex]``(const charT* p, flag_type f = regex_constants::normal);
  103. ``[link boost_regex.basic_regex.construct3 basic_regex]``(const charT* p1, const charT* p2,
  104. flag_type f = regex_constants::normal);
  105. ``[link boost_regex.basic_regex.construct4 basic_regex]``(const charT* p, size_type len, flag_type f);
  106. ``[link boost_regex.basic_regex.construct5 basic_regex]``(const basic_regex&);
  107. template <class ST, class SA>
  108. explicit ``[link boost_regex.basic_regex.construct6 basic_regex]``(const basic_string<charT, ST, SA>& p,
  109. flag_type f = regex_constants::normal);
  110. template <class InputIterator>
  111. ``[link boost_regex.basic_regex.construct7 basic_regex]``(InputIterator first, InputIterator last,
  112. flag_type f = regex_constants::normal);
  113. ~basic_regex();
  114. ``[link boost_regex.basic_regex.opeq1 basic_regex& operator=]``(const basic_regex&);
  115. ``[link boost_regex.basic_regex.opeq2 basic_regex& operator=]`` (const charT* ptr);
  116. template <class ST, class SA>
  117. ``[link boost_regex.basic_regex.opeq3 basic_regex& operator=]`` (const basic_string<charT, ST, SA>& p);
  118. // iterators:
  119. ``[link boost_regex.basic_regex.subexpression std::pair<const_iterator, const_iterator> subexpression]``(size_type n) const;
  120. ``[link boost_regex.basic_regex.begin const_iterator begin]``() const;
  121. ``[link boost_regex.basic_regex.end const_iterator end]``() const;
  122. // capacity:
  123. ``[link boost_regex.basic_regex.size size_type size]``() const;
  124. ``[link boost_regex.basic_regex.max_size size_type max_size]``() const;
  125. ``[link boost_regex.basic_regex.empty bool empty]``() const;
  126. ``[link boost_regex.basic_regex.mark_count size_type mark_count]``()const;
  127. //
  128. // modifiers:
  129. ``[link boost_regex.basic_regex.assign1 basic_regex& assign]``(const basic_regex& that);
  130. ``[link boost_regex.basic_regex.assign2 basic_regex& assign]``(const charT* ptr,
  131. flag_type f = regex_constants::normal);
  132. ``[link boost_regex.basic_regex.assign3 basic_regex& assign]``(const charT* ptr, unsigned int len, flag_type f);
  133. template <class string_traits, class A>
  134. ``[link boost_regex.basic_regex.assign4 basic_regex& assign]``(const basic_string<charT, string_traits, A>& s,
  135. flag_type f = regex_constants::normal);
  136. template <class InputIterator>
  137. ``[link boost_regex.basic_regex.assign5 basic_regex& assign]``(InputIterator first, InputIterator last,
  138. flag_type f = regex_constants::normal);
  139. // const operations:
  140. ``[link boost_regex.basic_regex.flags flag_type flags]``() const;
  141. ``[link boost_regex.basic_regex.status int status]``()const;
  142. ``[link boost_regex.basic_regex.str basic_string<charT> str]``() const;
  143. ``[link boost_regex.basic_regex.compare int compare]``(basic_regex&) const;
  144. // locale:
  145. ``[link boost_regex.basic_regex.imbue locale_type imbue]``(locale_type loc);
  146. ``[link boost_regex.basic_regex.getloc locale_type getloc]``() const;
  147. // swap
  148. ``[link boost_regex.basic_regex.swap void swap]``(basic_regex&) throw();
  149. };
  150. template <class charT, class traits>
  151. ``[link boost_regex.basic_regex.op_eq bool operator ==]`` (const basic_regex<charT, traits>& lhs,
  152. const basic_regex<charT, traits>& rhs);
  153. template <class charT, class traits>
  154. ``[link boost_regex.basic_regex.op_ne bool operator !=]`` (const basic_regex<charT, traits>& lhs,
  155. const basic_regex<charT, traits>& rhs);
  156. template <class charT, class traits>
  157. ``[link boost_regex.basic_regex.op_lt bool operator <]`` (const basic_regex<charT, traits>& lhs,
  158. const basic_regex<charT, traits>& rhs);
  159. template <class charT, class traits>
  160. ``[link boost_regex.basic_regex.op_le bool operator <=]`` (const basic_regex<charT, traits>& lhs,
  161. const basic_regex<charT, traits>& rhs);
  162. template <class charT, class traits>
  163. ``[link boost_regex.basic_regex.op_ge bool operator >=]`` (const basic_regex<charT, traits>& lhs,
  164. const basic_regex<charT, traits>& rhs);
  165. template <class charT, class traits>
  166. ``[link boost_regex.basic_regex.op_gt bool operator >]`` (const basic_regex<charT, traits>& lhs,
  167. const basic_regex<charT, traits>& rhs);
  168. template <class charT, class io_traits, class re_traits>
  169. basic_ostream<charT, io_traits>&
  170. ``[link boost_regex.basic_regex.op_stream operator <<]`` (basic_ostream<charT, io_traits>& os,
  171. const basic_regex<charT, re_traits>& e);
  172. template <class charT, class traits>
  173. ``[link boost_regex.basic_regex.op_swap void swap]``(basic_regex<charT, traits>& e1,
  174. basic_regex<charT, traits>& e2);
  175. typedef basic_regex<char> regex;
  176. typedef basic_regex<wchar_t> wregex;
  177. } // namespace boost
  178. [h4 Description]
  179. Class `basic_regex` has the following public members:
  180. // main option selection:
  181. static const regex_constants::``[syntax_option_type]`` normal
  182. = regex_constants::normal;
  183. static const regex_constants::``[syntax_option_type]`` ECMAScript
  184. = normal;
  185. static const regex_constants::``[syntax_option_type]`` JavaScript
  186. = normal;
  187. static const regex_constants::``[syntax_option_type]`` JScript
  188. = normal;
  189. static const regex_constants::``[syntax_option_type]`` basic
  190. = regex_constants::basic;
  191. static const regex_constants::``[syntax_option_type]`` extended
  192. = regex_constants::extended;
  193. static const regex_constants::``[syntax_option_type]`` awk
  194. = regex_constants::awk;
  195. static const regex_constants::``[syntax_option_type]`` grep
  196. = regex_constants::grep;
  197. static const regex_constants::``[syntax_option_type]`` egrep
  198. = regex_constants::egrep;
  199. static const regex_constants::``[syntax_option_type]`` sed
  200. = regex_constants::sed;
  201. static const regex_constants::``[syntax_option_type]`` perl
  202. = regex_constants::perl;
  203. static const regex_constants::``[syntax_option_type]`` literal
  204. = regex_constants::literal;
  205. // modifiers specific to perl expressions:
  206. static const regex_constants::``[syntax_option_type]`` no_mod_m
  207. = regex_constants::no_mod_m;
  208. static const regex_constants::``[syntax_option_type]`` no_mod_s
  209. = regex_constants::no_mod_s;
  210. static const regex_constants::``[syntax_option_type]`` mod_s
  211. = regex_constants::mod_s;
  212. static const regex_constants::``[syntax_option_type]`` mod_x
  213. = regex_constants::mod_x;
  214. // modifiers specific to POSIX basic expressions:
  215. static const regex_constants::``[syntax_option_type]`` bk_plus_qm
  216. = regex_constants::bk_plus_qm;
  217. static const regex_constants::``[syntax_option_type]`` bk_vbar
  218. = regex_constants::bk_vbar
  219. static const regex_constants::``[syntax_option_type]`` no_char_classes
  220. = regex_constants::no_char_classes
  221. static const regex_constants::``[syntax_option_type]`` no_intervals
  222. = regex_constants::no_intervals
  223. // common modifiers:
  224. static const regex_constants::``[syntax_option_type]`` nosubs
  225. = regex_constants::nosubs;
  226. static const regex_constants::``[syntax_option_type]`` optimize
  227. = regex_constants::optimize;
  228. static const regex_constants::``[syntax_option_type]`` collate
  229. = regex_constants::collate;
  230. static const regex_constants::``[syntax_option_type]`` newline_alt
  231. = regex_constants::newline_alt;
  232. The meaning of these options is documented in the [syntax_option_type]
  233. section.
  234. The static constant members are provided as synonyms for the constants declared
  235. in namespace `boost::regex_constants`; for each constant of type [syntax_option_type]
  236. declared in namespace `boost::regex_constants` then a constant with the same name,
  237. type and value is declared within the scope of basic_regex.
  238. [#boost_regex.basic_regex.construct1]
  239. basic_regex();
  240. [*Effects]: Constructs an object of class `basic_regex`.
  241. [table basic_regex default construction postconditions
  242. [[Element][Value]]
  243. [[`empty()`][`true`]]
  244. [[`size()`][`0`]]
  245. [[`str()`][`basic_string<charT>()`]]
  246. ]
  247. [#boost_regex.basic_regex.construct2]
  248. basic_regex(const charT* p, flag_type f = regex_constants::normal);
  249. [*Requires]: /p/ shall not be a null pointer.
  250. [*Throws]: [bad_expression] if /p/ is not a valid regular expression,
  251. unless the flag `no_except` is set in /f/.
  252. [*Effects]: Constructs an object of class [basic_regex]; the object's internal
  253. finite state machine is constructed from the regular expression contained
  254. in the null-terminated string /p/, and interpreted according to the
  255. [link boost_regex.ref.syntax_option_type option
  256. flags] specified in /f/.
  257. [table Postconditions for basic_regex construction
  258. [[Element][Value]]
  259. [[`empty()`][`false`]]
  260. [[`size()`][`char_traits<charT>::length(p)`]]
  261. [[`str()`][`basic_string<charT>(p)`]]
  262. [[`flags()`][['f]]]
  263. [[`mark_count()`][The number of marked sub-expressions within the expression.]]
  264. ]
  265. [#boost_regex.basic_regex.construct3]
  266. basic_regex(const charT* p1, const charT* p2,
  267. flag_type f = regex_constants::normal);
  268. [*Requires]: /p1/ and /p2/ are not null pointers, `p1 < p2`.
  269. [*Throws]: bad_expression if \[p1,p2) is not a valid regular expression, unless
  270. the flag `no_except` is set in /f/.
  271. [*Effects]: Constructs an object of class [basic_regex]; the object's
  272. internal finite state machine is constructed from the regular expression
  273. contained in the sequence of characters \[p1,p2), and interpreted according the
  274. [link boost_regex.ref.syntax_option_type option flags] specified in /f/.
  275. [table Postconditions for basic_regex construction
  276. [[Element][Value]]
  277. [[`empty()`][`false`]]
  278. [[`size()`][`std::distance(p1,p2)`]]
  279. [[`str()`][`basic_string<charT>(p1,p2)`]]
  280. [[`flags()`][['f]]]
  281. [[`mark_count()`][The number of marked sub-expressions within the expression.]]
  282. ]
  283. [#boost_regex.basic_regex.construct4]
  284. basic_regex(const charT* p, size_type len, flag_type f);
  285. [*Requires]: /p/ shall not be a null pointer, `len < max_size()`.
  286. [*Throws]: [bad_expression] if /p/ is not a valid regular expression, unless
  287. the flag `no_except` is set in /f/.
  288. [*Effects]: Constructs an object of class [basic_regex]; the object's
  289. internal finite state machine is constructed from the regular expression
  290. contained in the sequence of characters \[p, p+len), and interpreted
  291. according the option flags specified in /f/.
  292. [table Postconditions for basic_regex construction
  293. [[Element][Value]]
  294. [[`empty()`][`false`]]
  295. [[`size()`][['len]]]
  296. [[`str()`][`basic_string<charT>(p, len)`]]
  297. [[`flags()`][['f]]]
  298. [[`mark_count()`][The number of marked sub-expressions within the expression.]]
  299. ]
  300. [#boost_regex.basic_regex.construct5]
  301. basic_regex(const basic_regex& e);
  302. [*Effects]: Constructs an object of class [basic_regex] as a copy of the object
  303. /e/.
  304. [#boost_regex.basic_regex.construct6]
  305. template <class ST, class SA>
  306. basic_regex(const basic_string<charT, ST, SA>& s,
  307. flag_type f = regex_constants::normal);
  308. [*Throws]: [bad_expression] if /s/ is not a valid regular expression,
  309. unless the flag `no_except` is set in /f/.
  310. [*Effects]: Constructs an object of class [basic_regex]; the object's
  311. internal finite state machine is constructed from the regular expression
  312. contained in the string /s/, and interpreted according to the [link boost_regex.ref.syntax_option_type option
  313. flags] specified in /f/.
  314. [table Postconditions for basic_regex construction
  315. [[Element][Value]]
  316. [[`empty()`][`false`]]
  317. [[`size()`][`s.size()`]]
  318. [[`str()`][['s]]]
  319. [[`flags()`][['f]]]
  320. [[`mark_count()`][The number of marked sub-expressions within the expression.]]
  321. ]
  322. [#boost_regex.basic_regex.construct7]
  323. template <class ForwardIterator>
  324. basic_regex(ForwardIterator first, ForwardIterator last,
  325. flag_type f = regex_constants::normal);
  326. [*Throws]: [bad_expression] if the sequence \[first, last) is not a valid
  327. regular expression, unless the flag `no_except` is set in /f/.
  328. [*Effects]: Constructs an object of class [basic_regex]; the object's
  329. internal finite state machine is constructed from the regular expression
  330. contained in the sequence of characters \[first, last), and interpreted
  331. according to the [link boost_regex.ref.syntax_option_type option flags] specified in /f/.
  332. [table Postconditions for basic_regex construction
  333. [[Element][Value]]
  334. [[`empty()`][`false`]]
  335. [[`size()`][`distance(first,last)`]]
  336. [[`str()`][`basic_string<charT>(first,last)`]]
  337. [[`flags()`][['f]]]
  338. [[`mark_count()`][The number of marked sub-expressions within the expression.]]
  339. ]
  340. [#boost_regex.basic_regex.opeq1]
  341. basic_regex& operator=(const basic_regex& e);
  342. [*Effects]: Returns the result of `assign(e.str(), e.flags())`.
  343. [#boost_regex.basic_regex.opeq2]
  344. basic_regex& operator=(const charT* ptr);
  345. [*Requires]: /p/ shall not be a null pointer.
  346. [*Effects]: Returns the result of `assign(ptr)`.
  347. [#boost_regex.basic_regex.opeq3]
  348. template <class ST, class SA>
  349. basic_regex& operator=(const basic_string<charT, ST, SA>& p);
  350. [*Effects]: Returns the result of `assign(p)`.
  351. [#boost_regex.basic_regex.subexpression]
  352. std::pair<const_iterator, const_iterator> subexpression(size_type n) const;
  353. [*Effects]: Returns a pair of iterators denoting the location of
  354. marked subexpression /n/ within the original regular expression string.
  355. The returned iterators are relative to `begin()` and `end()`.
  356. [*Requires]: The expression must have been compiled with the
  357. [syntax_option_type] save_subexpression_location set. Argument
  358. /n/ must be in within the range `0 <= n < mark_count()`.
  359. [#boost_regex.basic_regex.begin]
  360. const_iterator begin() const;
  361. [*Effects]: Returns a starting iterator to a sequence of characters representing
  362. the regular expression.
  363. [#boost_regex.basic_regex.end]
  364. const_iterator end() const;
  365. [*Effects]: Returns termination iterator to a sequence of characters representing
  366. the regular expression.
  367. [#boost_regex.basic_regex.size]
  368. size_type size() const;
  369. [*Effects]: Returns the length of the sequence of characters representing the regular expression.
  370. [#boost_regex.basic_regex.max_size]
  371. size_type max_size() const;
  372. [*Effects]: Returns the maximum length of the sequence of characters representing
  373. the regular expression.
  374. [#boost_regex.basic_regex.empty]
  375. bool empty() const;
  376. [*Effects]: Returns true if the object does not contain a valid regular expression,
  377. otherwise false.
  378. [#boost_regex.basic_regex.mark_count]
  379. size_type mark_count() const;
  380. [*Effects]: Returns the number of marked sub-expressions within the regular expression.
  381. [#boost_regex.basic_regex.assign1]
  382. basic_regex& assign(const basic_regex& that);
  383. [*Effects]: Returns [link boost_regex.basic_regex.assign4 `assign(that.str(), that.flags())`].
  384. [#boost_regex.basic_regex.assign2]
  385. basic_regex& assign(const charT* ptr, flag_type f = regex_constants::normal);
  386. [*Effects]: Returns [link boost_regex.basic_regex.assign4 `assign(string_type(ptr), f)`].
  387. [#boost_regex.basic_regex.assign3]
  388. basic_regex& assign(const charT* ptr, unsigned int len, flag_type f);
  389. [*Effects]: Returns [link boost_regex.basic_regex.assign4 `assign(string_type(ptr, len), f)`].
  390. [#boost_regex.basic_regex.assign4]
  391. template <class string_traits, class A>
  392. basic_regex& assign(const basic_string<charT, string_traits, A>& s,
  393. flag_type f = regex_constants::normal);
  394. [*Throws]: [bad_expression] if /s/ is not a valid regular expression,
  395. unless the flag `no_except` is set in /f/.
  396. [*Returns]: *this.
  397. [*Effects]: Assigns the regular expression contained in the string /s/,
  398. interpreted according the [link boost_regex.ref.syntax_option_type option flags]
  399. specified in /f/.
  400. [table Postconditions for basic_regex::assign
  401. [[Element][Value]]
  402. [[`empty()`][`false`]]
  403. [[`size()`][`s.size()`]]
  404. [[`str()`][['s]]]
  405. [[`flags()`][['f]]]
  406. [[`mark_count()`][The number of marked sub-expressions within the expression.]]
  407. ]
  408. [#boost_regex.basic_regex.assign5]
  409. template <class InputIterator>
  410. basic_regex& assign(InputIterator first, InputIterator last,
  411. flag_type f = regex_constants::normal);
  412. [*Requires]: The type `InputIterator` corresponds to the
  413. [@http://input_iterator Input Iterator requirements
  414. (24.1.1)].
  415. [*Effects]: Returns [link boost_regex.basic_regex.assign4 `assign(string_type(first, last), f)`].
  416. [#boost_regex.basic_regex.flags]
  417. flag_type flags() const;
  418. [*Effects]: Returns a copy of the [link boost_regex.ref.syntax_option_type
  419. regular expression syntax flags] that were passed to the object's constructor,
  420. or the last call to `assign`.
  421. [#boost_regex.basic_regex.status]
  422. int status() const;
  423. [*Effects]: Returns zero if the expression contains a valid regular expression,
  424. otherwise an error code. This member function is retained for use in
  425. environments that cannot use exception handling.
  426. [#boost_regex.basic_regex.str]
  427. basic_string<charT> str() const;
  428. [*Effects]: Returns a copy of the character sequence passed to the object's constructor,
  429. or the last call to assign.
  430. [#boost_regex.basic_regex.compare]
  431. int compare(basic_regex& e)const;
  432. [*Effects]: If `flags() == e.flags()` then returns `str().compare(e.str())`,
  433. otherwise returns `flags() - e.flags()`.
  434. [#boost_regex.basic_regex.imbue]
  435. locale_type imbue(locale_type l);
  436. [*Effects]: Returns the result of `traits_inst.imbue(l)` where `traits_inst` is
  437. a (default initialized) instance of the template parameter `traits` stored
  438. within the object. Calls to `imbue` invalidate any currently contained
  439. regular expression.
  440. [*Postcondition]: `empty() == true`.
  441. [#boost_regex.basic_regex.getloc]
  442. locale_type getloc() const;
  443. [*Effects]: Returns the result of `traits_inst.getloc()` where `traits_inst` is
  444. a (default initialized) instance of the template parameter traits stored
  445. within the object.
  446. [#boost_regex.basic_regex.swap]
  447. void swap(basic_regex& e) throw();
  448. [*Effects]: Swaps the contents of the two regular expressions.
  449. [*Postcondition]: `*this` contains the regular expression that was in /e/, /e/ contains
  450. the regular expression that was in `*this`.
  451. [*Complexity]: constant time.
  452. [note Comparisons between [basic_regex] objects are provided on an
  453. experimental basis: please note that these are not present in the [tr1],
  454. so use with care if you are writing code that may need to be ported
  455. to other implementations of [basic_regex].]
  456. [#boost_regex.basic_regex.op_eq]
  457. template <class charT, class traits>
  458. bool operator == (const basic_regex<charT, traits>& lhs,
  459. const basic_regex<charT, traits>& rhs);
  460. [*Effects]: Returns `lhs.compare(rhs) == 0`.
  461. [#boost_regex.basic_regex.op_ne]
  462. template <class charT, class traits>
  463. bool operator != (const basic_regex<charT, traits>& lhs,
  464. const basic_regex<charT, traits>& rhs);
  465. [*Effects]: Returns `lhs.compare(rhs) != 0`.
  466. [#boost_regex.basic_regex.op_lt]
  467. template <class charT, class traits>
  468. bool operator < (const basic_regex<charT, traits>& lhs,
  469. const basic_regex<charT, traits>& rhs);
  470. [*Effects]: Returns `lhs.compare(rhs) < 0`.
  471. [#boost_regex.basic_regex.op_le]
  472. template <class charT, class traits>
  473. bool operator <= (const basic_regex<charT, traits>& lhs,
  474. const basic_regex<charT, traits>& rhs);
  475. [*Effects]: Returns `lhs.compare(rhs) <= 0`.
  476. [#boost_regex.basic_regex.op_ge]
  477. template <class charT, class traits>
  478. bool operator >= (const basic_regex<charT, traits>& lhs,
  479. const basic_regex<charT, traits>& rhs);
  480. [*Effects]: Returns `lhs.compare(rhs) >= 0`.
  481. [#boost_regex.basic_regex.op_gt]
  482. template <class charT, class traits>
  483. bool operator > (const basic_regex<charT, traits>& lhs,
  484. const basic_regex<charT, traits>& rhs);
  485. [*Effects]: Returns `lhs.compare(rhs) > 0`.
  486. [note The basic_regex stream inserter is provided on an experimental basis,
  487. and outputs the textual representation of the expression to the stream.]
  488. [#boost_regex.basic_regex.op_stream]
  489. template <class charT, class io_traits, class re_traits>
  490. basic_ostream<charT, io_traits>&
  491. operator << (basic_ostream<charT, io_traits>& os
  492. const basic_regex<charT, re_traits>& e);
  493. [*Effects]: Returns `(os << e.str())`.
  494. [#boost_regex.basic_regex.op_swap]
  495. template <class charT, class traits>
  496. void swap(basic_regex<charT, traits>& lhs,
  497. basic_regex<charT, traits>& rhs);
  498. [*Effects]: calls `lhs.swap(rhs)`.
  499. [endsect]