| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1 | // -*- C++ -*- | 
|  | 2 | //===--------------------------- regex ------------------------------------===// | 
|  | 3 | // | 
|  | 4 | // The LLVM Compiler Infrastructure | 
|  | 5 | // | 
| Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open | 
|  | 7 | // Source Licenses. See LICENSE.TXT for details. | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 8 | // | 
|  | 9 | //===----------------------------------------------------------------------===// | 
|  | 10 |  | 
|  | 11 | #ifndef _LIBCPP_REGEX | 
|  | 12 | #define _LIBCPP_REGEX | 
|  | 13 |  | 
|  | 14 | /* | 
|  | 15 | regex synopsis | 
|  | 16 |  | 
|  | 17 | #include <initializer_list> | 
|  | 18 |  | 
|  | 19 | namespace std | 
|  | 20 | { | 
|  | 21 |  | 
|  | 22 | namespace regex_constants | 
|  | 23 | { | 
|  | 24 |  | 
|  | 25 | emum syntax_option_type | 
|  | 26 | { | 
|  | 27 | icase = unspecified, | 
|  | 28 | nosubs = unspecified, | 
|  | 29 | optimize = unspecified, | 
|  | 30 | collate = unspecified, | 
|  | 31 | ECMAScript = unspecified, | 
|  | 32 | basic = unspecified, | 
|  | 33 | extended = unspecified, | 
|  | 34 | awk = unspecified, | 
|  | 35 | grep = unspecified, | 
|  | 36 | egrep = unspecified | 
|  | 37 | }; | 
|  | 38 |  | 
|  | 39 | constexpr syntax_option_type operator~(syntax_option_type f); | 
|  | 40 | constexpr syntax_option_type operator&(syntax_option_type lhs, syntax_option_type rhs); | 
|  | 41 | constexpr syntax_option_type operator|(syntax_option_type lhs, syntax_option_type rhs); | 
|  | 42 |  | 
|  | 43 | enum match_flag_type | 
|  | 44 | { | 
|  | 45 | match_default = 0, | 
|  | 46 | match_not_bol = unspecified, | 
|  | 47 | match_not_eol = unspecified, | 
|  | 48 | match_not_bow = unspecified, | 
|  | 49 | match_not_eow = unspecified, | 
|  | 50 | match_any = unspecified, | 
|  | 51 | match_not_null = unspecified, | 
|  | 52 | match_continuous = unspecified, | 
|  | 53 | match_prev_avail = unspecified, | 
|  | 54 | format_default = 0, | 
|  | 55 | format_sed = unspecified, | 
|  | 56 | format_no_copy = unspecified, | 
|  | 57 | format_first_only = unspecified | 
|  | 58 | }; | 
|  | 59 |  | 
|  | 60 | constexpr match_flag_type operator~(match_flag_type f); | 
|  | 61 | constexpr match_flag_type operator&(match_flag_type lhs, match_flag_type rhs); | 
|  | 62 | constexpr match_flag_type operator|(match_flag_type lhs, match_flag_type rhs); | 
|  | 63 |  | 
|  | 64 | enum error_type | 
|  | 65 | { | 
|  | 66 | error_collate = unspecified, | 
|  | 67 | error_ctype = unspecified, | 
|  | 68 | error_escape = unspecified, | 
|  | 69 | error_backref = unspecified, | 
|  | 70 | error_brack = unspecified, | 
|  | 71 | error_paren = unspecified, | 
|  | 72 | error_brace = unspecified, | 
|  | 73 | error_badbrace = unspecified, | 
|  | 74 | error_range = unspecified, | 
|  | 75 | error_space = unspecified, | 
|  | 76 | error_badrepeat = unspecified, | 
|  | 77 | error_complexity = unspecified, | 
|  | 78 | error_stack = unspecified | 
|  | 79 | }; | 
|  | 80 |  | 
|  | 81 | } // regex_constants | 
|  | 82 |  | 
|  | 83 | class regex_error | 
|  | 84 | : public runtime_error | 
|  | 85 | { | 
|  | 86 | public: | 
|  | 87 | explicit regex_error(regex_constants::error_type ecode); | 
|  | 88 | regex_constants::error_type code() const; | 
|  | 89 | }; | 
|  | 90 |  | 
|  | 91 | template <class charT> | 
|  | 92 | struct regex_traits | 
|  | 93 | { | 
|  | 94 | public: | 
|  | 95 | typedef charT char_type; | 
|  | 96 | typedef basic_string<char_type> string_type; | 
|  | 97 | typedef locale locale_type; | 
|  | 98 | typedef /bitmask_type/ char_class_type; | 
|  | 99 |  | 
|  | 100 | regex_traits(); | 
|  | 101 |  | 
|  | 102 | static size_t length(const char_type* p); | 
|  | 103 | charT translate(charT c) const; | 
|  | 104 | charT translate_nocase(charT c) const; | 
|  | 105 | template <class ForwardIterator> | 
|  | 106 | string_type | 
|  | 107 | transform(ForwardIterator first, ForwardIterator last) const; | 
|  | 108 | template <class ForwardIterator> | 
|  | 109 | string_type | 
|  | 110 | transform_primary( ForwardIterator first, ForwardIterator last) const; | 
|  | 111 | template <class ForwardIterator> | 
|  | 112 | string_type | 
|  | 113 | lookup_collatename(ForwardIterator first, ForwardIterator last) const; | 
|  | 114 | template <class ForwardIterator> | 
|  | 115 | char_class_type | 
|  | 116 | lookup_classname(ForwardIterator first, ForwardIterator last, | 
|  | 117 | bool icase = false) const; | 
|  | 118 | bool isctype(charT c, char_class_type f) const; | 
|  | 119 | int value(charT ch, int radix) const; | 
|  | 120 | locale_type imbue(locale_type l); | 
|  | 121 | locale_type getloc()const; | 
|  | 122 | }; | 
|  | 123 |  | 
|  | 124 | template <class charT, class traits = regex_traits<charT>> | 
|  | 125 | class basic_regex | 
|  | 126 | { | 
|  | 127 | public: | 
|  | 128 | // types: | 
|  | 129 | typedef charT value_type; | 
| Hubert Tong | b49c67f | 2016-08-02 21:34:48 | [diff] [blame] | 130 | typedef traits traits_type; | 
|  | 131 | typedef typename traits::string_type string_type; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 132 | typedef regex_constants::syntax_option_type flag_type; | 
|  | 133 | typedef typename traits::locale_type locale_type; | 
|  | 134 |  | 
|  | 135 | // constants: | 
|  | 136 | static constexpr regex_constants::syntax_option_type icase = regex_constants::icase; | 
|  | 137 | static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs; | 
|  | 138 | static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize; | 
|  | 139 | static constexpr regex_constants::syntax_option_type collate = regex_constants::collate; | 
|  | 140 | static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript; | 
|  | 141 | static constexpr regex_constants::syntax_option_type basic = regex_constants::basic; | 
|  | 142 | static constexpr regex_constants::syntax_option_type extended = regex_constants::extended; | 
|  | 143 | static constexpr regex_constants::syntax_option_type awk = regex_constants::awk; | 
|  | 144 | static constexpr regex_constants::syntax_option_type grep = regex_constants::grep; | 
|  | 145 | static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep; | 
|  | 146 |  | 
|  | 147 | // construct/copy/destroy: | 
|  | 148 | basic_regex(); | 
|  | 149 | explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript); | 
| Hubert Tong | 7f6e8e2 | 2016-08-07 22:26:04 | [diff] [blame] | 150 | basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript); | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 151 | basic_regex(const basic_regex&); | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 152 | basic_regex(basic_regex&&) noexcept; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 153 | template <class ST, class SA> | 
|  | 154 | explicit basic_regex(const basic_string<charT, ST, SA>& p, | 
|  | 155 | flag_type f = regex_constants::ECMAScript); | 
|  | 156 | template <class ForwardIterator> | 
|  | 157 | basic_regex(ForwardIterator first, ForwardIterator last, | 
|  | 158 | flag_type f = regex_constants::ECMAScript); | 
|  | 159 | basic_regex(initializer_list<charT>, flag_type = regex_constants::ECMAScript); | 
|  | 160 |  | 
|  | 161 | ~basic_regex(); | 
|  | 162 |  | 
|  | 163 | basic_regex& operator=(const basic_regex&); | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 164 | basic_regex& operator=(basic_regex&&) noexcept; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 165 | basic_regex& operator=(const charT* ptr); | 
|  | 166 | basic_regex& operator=(initializer_list<charT> il); | 
|  | 167 | template <class ST, class SA> | 
|  | 168 | basic_regex& operator=(const basic_string<charT, ST, SA>& p); | 
|  | 169 |  | 
|  | 170 | // assign: | 
|  | 171 | basic_regex& assign(const basic_regex& that); | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 172 | basic_regex& assign(basic_regex&& that) noexcept; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 173 | basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript); | 
|  | 174 | basic_regex& assign(const charT* p, size_t len, flag_type f); | 
|  | 175 | template <class string_traits, class A> | 
|  | 176 | basic_regex& assign(const basic_string<charT, string_traits, A>& s, | 
|  | 177 | flag_type f = regex_constants::ECMAScript); | 
|  | 178 | template <class InputIterator> | 
|  | 179 | basic_regex& assign(InputIterator first, InputIterator last, | 
|  | 180 | flag_type f = regex_constants::ECMAScript); | 
|  | 181 | basic_regex& assign(initializer_list<charT>, flag_type = regex_constants::ECMAScript); | 
|  | 182 |  | 
|  | 183 | // const operations: | 
|  | 184 | unsigned mark_count() const; | 
|  | 185 | flag_type flags() const; | 
|  | 186 |  | 
|  | 187 | // locale: | 
|  | 188 | locale_type imbue(locale_type loc); | 
|  | 189 | locale_type getloc() const; | 
|  | 190 |  | 
|  | 191 | // swap: | 
|  | 192 | void swap(basic_regex&); | 
|  | 193 | }; | 
|  | 194 |  | 
|  | 195 | typedef basic_regex<char> regex; | 
|  | 196 | typedef basic_regex<wchar_t> wregex; | 
|  | 197 |  | 
|  | 198 | template <class charT, class traits> | 
|  | 199 | void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2); | 
|  | 200 |  | 
|  | 201 | template <class BidirectionalIterator> | 
|  | 202 | class sub_match | 
|  | 203 | : public pair<BidirectionalIterator, BidirectionalIterator> | 
|  | 204 | { | 
|  | 205 | public: | 
|  | 206 | typedef typename iterator_traits<BidirectionalIterator>::value_type value_type; | 
|  | 207 | typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type; | 
|  | 208 | typedef BidirectionalIterator iterator; | 
|  | 209 | typedef basic_string<value_type> string_type; | 
|  | 210 |  | 
|  | 211 | bool matched; | 
|  | 212 |  | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 213 | constexpr sub_match(); | 
|  | 214 |  | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 215 | difference_type length() const; | 
|  | 216 | operator string_type() const; | 
|  | 217 | string_type str() const; | 
|  | 218 |  | 
|  | 219 | int compare(const sub_match& s) const; | 
|  | 220 | int compare(const string_type& s) const; | 
|  | 221 | int compare(const value_type* s) const; | 
|  | 222 | }; | 
|  | 223 |  | 
|  | 224 | typedef sub_match<const char*> csub_match; | 
|  | 225 | typedef sub_match<const wchar_t*> wcsub_match; | 
|  | 226 | typedef sub_match<string::const_iterator> ssub_match; | 
|  | 227 | typedef sub_match<wstring::const_iterator> wssub_match; | 
|  | 228 |  | 
|  | 229 | template <class BiIter> | 
|  | 230 | bool | 
|  | 231 | operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 232 |  | 
|  | 233 | template <class BiIter> | 
|  | 234 | bool | 
|  | 235 | operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 236 |  | 
|  | 237 | template <class BiIter> | 
|  | 238 | bool | 
|  | 239 | operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 240 |  | 
|  | 241 | template <class BiIter> | 
|  | 242 | bool | 
|  | 243 | operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 244 |  | 
|  | 245 | template <class BiIter> | 
|  | 246 | bool | 
|  | 247 | operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 248 |  | 
|  | 249 | template <class BiIter> | 
|  | 250 | bool | 
|  | 251 | operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); | 
|  | 252 |  | 
|  | 253 | template <class BiIter, class ST, class SA> | 
|  | 254 | bool | 
|  | 255 | operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 256 | const sub_match<BiIter>& rhs); | 
|  | 257 |  | 
|  | 258 | template <class BiIter, class ST, class SA> | 
|  | 259 | bool | 
|  | 260 | operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 261 | const sub_match<BiIter>& rhs); | 
|  | 262 |  | 
|  | 263 | template <class BiIter, class ST, class SA> | 
|  | 264 | bool | 
|  | 265 | operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 266 | const sub_match<BiIter>& rhs); | 
|  | 267 |  | 
|  | 268 | template <class BiIter, class ST, class SA> | 
|  | 269 | bool | 
|  | 270 | operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 271 | const sub_match<BiIter>& rhs); | 
|  | 272 |  | 
|  | 273 | template <class BiIter, class ST, class SA> | 
|  | 274 | bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 275 | const sub_match<BiIter>& rhs); | 
|  | 276 |  | 
|  | 277 | template <class BiIter, class ST, class SA> | 
|  | 278 | bool | 
|  | 279 | operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, | 
|  | 280 | const sub_match<BiIter>& rhs); | 
|  | 281 |  | 
|  | 282 | template <class BiIter, class ST, class SA> | 
|  | 283 | bool | 
|  | 284 | operator==(const sub_match<BiIter>& lhs, | 
|  | 285 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 286 |  | 
|  | 287 | template <class BiIter, class ST, class SA> | 
|  | 288 | bool | 
|  | 289 | operator!=(const sub_match<BiIter>& lhs, | 
|  | 290 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 291 |  | 
|  | 292 | template <class BiIter, class ST, class SA> | 
|  | 293 | bool | 
|  | 294 | operator<(const sub_match<BiIter>& lhs, | 
|  | 295 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 296 |  | 
|  | 297 | template <class BiIter, class ST, class SA> | 
|  | 298 | bool operator>(const sub_match<BiIter>& lhs, | 
|  | 299 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 300 |  | 
|  | 301 | template <class BiIter, class ST, class SA> | 
|  | 302 | bool | 
|  | 303 | operator>=(const sub_match<BiIter>& lhs, | 
|  | 304 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 305 |  | 
|  | 306 | template <class BiIter, class ST, class SA> | 
|  | 307 | bool | 
|  | 308 | operator<=(const sub_match<BiIter>& lhs, | 
|  | 309 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); | 
|  | 310 |  | 
|  | 311 | template <class BiIter> | 
|  | 312 | bool | 
|  | 313 | operator==(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 314 | const sub_match<BiIter>& rhs); | 
|  | 315 |  | 
|  | 316 | template <class BiIter> | 
|  | 317 | bool | 
|  | 318 | operator!=(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 319 | const sub_match<BiIter>& rhs); | 
|  | 320 |  | 
|  | 321 | template <class BiIter> | 
|  | 322 | bool | 
|  | 323 | operator<(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 324 | const sub_match<BiIter>& rhs); | 
|  | 325 |  | 
|  | 326 | template <class BiIter> | 
|  | 327 | bool | 
|  | 328 | operator>(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 329 | const sub_match<BiIter>& rhs); | 
|  | 330 |  | 
|  | 331 | template <class BiIter> | 
|  | 332 | bool | 
|  | 333 | operator>=(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 334 | const sub_match<BiIter>& rhs); | 
|  | 335 |  | 
|  | 336 | template <class BiIter> | 
|  | 337 | bool | 
|  | 338 | operator<=(typename iterator_traits<BiIter>::value_type const* lhs, | 
|  | 339 | const sub_match<BiIter>& rhs); | 
|  | 340 |  | 
|  | 341 | template <class BiIter> | 
|  | 342 | bool | 
|  | 343 | operator==(const sub_match<BiIter>& lhs, | 
|  | 344 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 345 |  | 
|  | 346 | template <class BiIter> | 
|  | 347 | bool | 
|  | 348 | operator!=(const sub_match<BiIter>& lhs, | 
|  | 349 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 350 |  | 
|  | 351 | template <class BiIter> | 
|  | 352 | bool | 
|  | 353 | operator<(const sub_match<BiIter>& lhs, | 
|  | 354 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 355 |  | 
|  | 356 | template <class BiIter> | 
|  | 357 | bool | 
|  | 358 | operator>(const sub_match<BiIter>& lhs, | 
|  | 359 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 360 |  | 
|  | 361 | template <class BiIter> | 
|  | 362 | bool | 
|  | 363 | operator>=(const sub_match<BiIter>& lhs, | 
|  | 364 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 365 |  | 
|  | 366 | template <class BiIter> | 
|  | 367 | bool | 
|  | 368 | operator<=(const sub_match<BiIter>& lhs, | 
|  | 369 | typename iterator_traits<BiIter>::value_type const* rhs); | 
|  | 370 |  | 
|  | 371 | template <class BiIter> | 
|  | 372 | bool | 
|  | 373 | operator==(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 374 | const sub_match<BiIter>& rhs); | 
|  | 375 |  | 
|  | 376 | template <class BiIter> | 
|  | 377 | bool | 
|  | 378 | operator!=(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 379 | const sub_match<BiIter>& rhs); | 
|  | 380 |  | 
|  | 381 | template <class BiIter> | 
|  | 382 | bool | 
|  | 383 | operator<(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 384 | const sub_match<BiIter>& rhs); | 
|  | 385 |  | 
|  | 386 | template <class BiIter> | 
|  | 387 | bool | 
|  | 388 | operator>(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 389 | const sub_match<BiIter>& rhs); | 
|  | 390 |  | 
|  | 391 | template <class BiIter> | 
|  | 392 | bool | 
|  | 393 | operator>=(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 394 | const sub_match<BiIter>& rhs); | 
|  | 395 |  | 
|  | 396 | template <class BiIter> | 
|  | 397 | bool | 
|  | 398 | operator<=(typename iterator_traits<BiIter>::value_type const& lhs, | 
|  | 399 | const sub_match<BiIter>& rhs); | 
|  | 400 |  | 
|  | 401 | template <class BiIter> | 
|  | 402 | bool | 
|  | 403 | operator==(const sub_match<BiIter>& lhs, | 
|  | 404 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 405 |  | 
|  | 406 | template <class BiIter> | 
|  | 407 | bool | 
|  | 408 | operator!=(const sub_match<BiIter>& lhs, | 
|  | 409 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 410 |  | 
|  | 411 | template <class BiIter> | 
|  | 412 | bool | 
|  | 413 | operator<(const sub_match<BiIter>& lhs, | 
|  | 414 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 415 |  | 
|  | 416 | template <class BiIter> | 
|  | 417 | bool | 
|  | 418 | operator>(const sub_match<BiIter>& lhs, | 
|  | 419 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 420 |  | 
|  | 421 | template <class BiIter> | 
|  | 422 | bool | 
|  | 423 | operator>=(const sub_match<BiIter>& lhs, | 
|  | 424 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 425 |  | 
|  | 426 | template <class BiIter> | 
|  | 427 | bool | 
|  | 428 | operator<=(const sub_match<BiIter>& lhs, | 
|  | 429 | typename iterator_traits<BiIter>::value_type const& rhs); | 
|  | 430 |  | 
|  | 431 | template <class charT, class ST, class BiIter> | 
|  | 432 | basic_ostream<charT, ST>& | 
|  | 433 | operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m); | 
|  | 434 |  | 
|  | 435 | template <class BidirectionalIterator, | 
|  | 436 | class Allocator = allocator<sub_match<BidirectionalIterator>>> | 
|  | 437 | class match_results | 
|  | 438 | { | 
|  | 439 | public: | 
|  | 440 | typedef sub_match<BidirectionalIterator> value_type; | 
|  | 441 | typedef const value_type& const_reference; | 
| Marshall Clow | 103af34 | 2014-02-26 01:56:31 | [diff] [blame] | 442 | typedef value_type& reference; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 443 | typedef /implementation-defined/ const_iterator; | 
|  | 444 | typedef const_iterator iterator; | 
|  | 445 | typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type; | 
|  | 446 | typedef typename allocator_traits<Allocator>::size_type size_type; | 
|  | 447 | typedef Allocator allocator_type; | 
|  | 448 | typedef typename iterator_traits<BidirectionalIterator>::value_type char_type; | 
|  | 449 | typedef basic_string<char_type> string_type; | 
|  | 450 |  | 
|  | 451 | // construct/copy/destroy: | 
|  | 452 | explicit match_results(const Allocator& a = Allocator()); | 
|  | 453 | match_results(const match_results& m); | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 454 | match_results(match_results&& m) noexcept; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 455 | match_results& operator=(const match_results& m); | 
|  | 456 | match_results& operator=(match_results&& m); | 
|  | 457 | ~match_results(); | 
|  | 458 |  | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 459 | bool ready() const; | 
|  | 460 |  | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 461 | // size: | 
|  | 462 | size_type size() const; | 
|  | 463 | size_type max_size() const; | 
|  | 464 | bool empty() const; | 
|  | 465 |  | 
|  | 466 | // element access: | 
|  | 467 | difference_type length(size_type sub = 0) const; | 
|  | 468 | difference_type position(size_type sub = 0) const; | 
|  | 469 | string_type str(size_type sub = 0) const; | 
|  | 470 | const_reference operator[](size_type n) const; | 
|  | 471 |  | 
|  | 472 | const_reference prefix() const; | 
|  | 473 | const_reference suffix() const; | 
|  | 474 |  | 
|  | 475 | const_iterator begin() const; | 
|  | 476 | const_iterator end() const; | 
|  | 477 | const_iterator cbegin() const; | 
|  | 478 | const_iterator cend() const; | 
|  | 479 |  | 
|  | 480 | // format: | 
|  | 481 | template <class OutputIter> | 
|  | 482 | OutputIter | 
|  | 483 | format(OutputIter out, const char_type* fmt_first, | 
|  | 484 | const char_type* fmt_last, | 
|  | 485 | regex_constants::match_flag_type flags = regex_constants::format_default) const; | 
|  | 486 | template <class OutputIter, class ST, class SA> | 
|  | 487 | OutputIter | 
|  | 488 | format(OutputIter out, const basic_string<char_type, ST, SA>& fmt, | 
|  | 489 | regex_constants::match_flag_type flags = regex_constants::format_default) const; | 
|  | 490 | template <class ST, class SA> | 
|  | 491 | basic_string<char_type, ST, SA> | 
|  | 492 | format(const basic_string<char_type, ST, SA>& fmt, | 
|  | 493 | regex_constants::match_flag_type flags = regex_constants::format_default) const; | 
|  | 494 | string_type | 
|  | 495 | format(const char_type* fmt, | 
|  | 496 | regex_constants::match_flag_type flags = regex_constants::format_default) const; | 
|  | 497 |  | 
|  | 498 | // allocator: | 
|  | 499 | allocator_type get_allocator() const; | 
|  | 500 |  | 
|  | 501 | // swap: | 
|  | 502 | void swap(match_results& that); | 
|  | 503 | }; | 
|  | 504 |  | 
|  | 505 | typedef match_results<const char*> cmatch; | 
|  | 506 | typedef match_results<const wchar_t*> wcmatch; | 
|  | 507 | typedef match_results<string::const_iterator> smatch; | 
|  | 508 | typedef match_results<wstring::const_iterator> wsmatch; | 
|  | 509 |  | 
|  | 510 | template <class BidirectionalIterator, class Allocator> | 
|  | 511 | bool | 
|  | 512 | operator==(const match_results<BidirectionalIterator, Allocator>& m1, | 
|  | 513 | const match_results<BidirectionalIterator, Allocator>& m2); | 
|  | 514 |  | 
|  | 515 | template <class BidirectionalIterator, class Allocator> | 
|  | 516 | bool | 
|  | 517 | operator!=(const match_results<BidirectionalIterator, Allocator>& m1, | 
|  | 518 | const match_results<BidirectionalIterator, Allocator>& m2); | 
|  | 519 |  | 
|  | 520 | template <class BidirectionalIterator, class Allocator> | 
|  | 521 | void | 
|  | 522 | swap(match_results<BidirectionalIterator, Allocator>& m1, | 
|  | 523 | match_results<BidirectionalIterator, Allocator>& m2); | 
|  | 524 |  | 
|  | 525 | template <class BidirectionalIterator, class Allocator, class charT, class traits> | 
|  | 526 | bool | 
|  | 527 | regex_match(BidirectionalIterator first, BidirectionalIterator last, | 
|  | 528 | match_results<BidirectionalIterator, Allocator>& m, | 
|  | 529 | const basic_regex<charT, traits>& e, | 
|  | 530 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 531 |  | 
|  | 532 | template <class BidirectionalIterator, class charT, class traits> | 
|  | 533 | bool | 
|  | 534 | regex_match(BidirectionalIterator first, BidirectionalIterator last, | 
|  | 535 | const basic_regex<charT, traits>& e, | 
|  | 536 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 537 |  | 
|  | 538 | template <class charT, class Allocator, class traits> | 
|  | 539 | bool | 
|  | 540 | regex_match(const charT* str, match_results<const charT*, Allocator>& m, | 
|  | 541 | const basic_regex<charT, traits>& e, | 
|  | 542 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 543 |  | 
|  | 544 | template <class ST, class SA, class Allocator, class charT, class traits> | 
|  | 545 | bool | 
|  | 546 | regex_match(const basic_string<charT, ST, SA>& s, | 
|  | 547 | match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m, | 
|  | 548 | const basic_regex<charT, traits>& e, | 
|  | 549 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 550 |  | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 551 | template <class ST, class SA, class Allocator, class charT, class traits> | 
|  | 552 | bool | 
|  | 553 | regex_match(const basic_string<charT, ST, SA>&& s, | 
|  | 554 | match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m, | 
|  | 555 | const basic_regex<charT, traits>& e, | 
|  | 556 | regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14 | 
|  | 557 |  | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 558 | template <class charT, class traits> | 
|  | 559 | bool | 
|  | 560 | regex_match(const charT* str, const basic_regex<charT, traits>& e, | 
|  | 561 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 562 |  | 
|  | 563 | template <class ST, class SA, class charT, class traits> | 
|  | 564 | bool | 
|  | 565 | regex_match(const basic_string<charT, ST, SA>& s, | 
|  | 566 | const basic_regex<charT, traits>& e, | 
|  | 567 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 568 |  | 
|  | 569 | template <class BidirectionalIterator, class Allocator, class charT, class traits> | 
|  | 570 | bool | 
|  | 571 | regex_search(BidirectionalIterator first, BidirectionalIterator last, | 
|  | 572 | match_results<BidirectionalIterator, Allocator>& m, | 
|  | 573 | const basic_regex<charT, traits>& e, | 
|  | 574 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 575 |  | 
|  | 576 | template <class BidirectionalIterator, class charT, class traits> | 
|  | 577 | bool | 
|  | 578 | regex_search(BidirectionalIterator first, BidirectionalIterator last, | 
|  | 579 | const basic_regex<charT, traits>& e, | 
|  | 580 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 581 |  | 
|  | 582 | template <class charT, class Allocator, class traits> | 
|  | 583 | bool | 
|  | 584 | regex_search(const charT* str, match_results<const charT*, Allocator>& m, | 
|  | 585 | const basic_regex<charT, traits>& e, | 
|  | 586 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 587 |  | 
|  | 588 | template <class charT, class traits> | 
|  | 589 | bool | 
|  | 590 | regex_search(const charT* str, const basic_regex<charT, traits>& e, | 
|  | 591 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 592 |  | 
|  | 593 | template <class ST, class SA, class charT, class traits> | 
|  | 594 | bool | 
|  | 595 | regex_search(const basic_string<charT, ST, SA>& s, | 
|  | 596 | const basic_regex<charT, traits>& e, | 
|  | 597 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 598 |  | 
|  | 599 | template <class ST, class SA, class Allocator, class charT, class traits> | 
|  | 600 | bool | 
|  | 601 | regex_search(const basic_string<charT, ST, SA>& s, | 
|  | 602 | match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m, | 
|  | 603 | const basic_regex<charT, traits>& e, | 
|  | 604 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 605 |  | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 606 | template <class ST, class SA, class Allocator, class charT, class traits> | 
|  | 607 | bool | 
|  | 608 | regex_search(const basic_string<charT, ST, SA>&& s, | 
|  | 609 | match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m, | 
|  | 610 | const basic_regex<charT, traits>& e, | 
|  | 611 | regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14 | 
|  | 612 |  | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 613 | template <class OutputIterator, class BidirectionalIterator, | 
|  | 614 | class traits, class charT, class ST, class SA> | 
|  | 615 | OutputIterator | 
|  | 616 | regex_replace(OutputIterator out, | 
|  | 617 | BidirectionalIterator first, BidirectionalIterator last, | 
|  | 618 | const basic_regex<charT, traits>& e, | 
|  | 619 | const basic_string<charT, ST, SA>& fmt, | 
|  | 620 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 621 |  | 
|  | 622 | template <class OutputIterator, class BidirectionalIterator, | 
|  | 623 | class traits, class charT> | 
|  | 624 | OutputIterator | 
|  | 625 | regex_replace(OutputIterator out, | 
|  | 626 | BidirectionalIterator first, BidirectionalIterator last, | 
|  | 627 | const basic_regex<charT, traits>& e, const charT* fmt, | 
|  | 628 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 629 |  | 
|  | 630 | template <class traits, class charT, class ST, class SA, class FST, class FSA>> | 
|  | 631 | basic_string<charT, ST, SA> | 
|  | 632 | regex_replace(const basic_string<charT, ST, SA>& s, | 
|  | 633 | const basic_regex<charT, traits>& e, | 
|  | 634 | const basic_string<charT, FST, FSA>& fmt, | 
|  | 635 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 636 |  | 
|  | 637 | template <class traits, class charT, class ST, class SA> | 
|  | 638 | basic_string<charT, ST, SA> | 
|  | 639 | regex_replace(const basic_string<charT, ST, SA>& s, | 
|  | 640 | const basic_regex<charT, traits>& e, const charT* fmt, | 
|  | 641 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 642 |  | 
|  | 643 | template <class traits, class charT, class ST, class SA> | 
|  | 644 | basic_string<charT> | 
|  | 645 | regex_replace(const charT* s, | 
|  | 646 | const basic_regex<charT, traits>& e, | 
|  | 647 | const basic_string<charT, ST, SA>& fmt, | 
|  | 648 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 649 |  | 
|  | 650 | template <class traits, class charT> | 
|  | 651 | basic_string<charT> | 
|  | 652 | regex_replace(const charT* s, | 
|  | 653 | const basic_regex<charT, traits>& e, | 
|  | 654 | const charT* fmt, | 
|  | 655 | regex_constants::match_flag_type flags = regex_constants::match_default); | 
|  | 656 |  | 
|  | 657 | template <class BidirectionalIterator, | 
|  | 658 | class charT = typename iterator_traits< BidirectionalIterator>::value_type, | 
|  | 659 | class traits = regex_traits<charT>> | 
|  | 660 | class regex_iterator | 
|  | 661 | { | 
|  | 662 | public: | 
|  | 663 | typedef basic_regex<charT, traits> regex_type; | 
|  | 664 | typedef match_results<BidirectionalIterator> value_type; | 
|  | 665 | typedef ptrdiff_t difference_type; | 
|  | 666 | typedef const value_type* pointer; | 
|  | 667 | typedef const value_type& reference; | 
|  | 668 | typedef forward_iterator_tag iterator_category; | 
|  | 669 |  | 
|  | 670 | regex_iterator(); | 
|  | 671 | regex_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
|  | 672 | const regex_type& re, | 
|  | 673 | regex_constants::match_flag_type m = regex_constants::match_default); | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 674 | regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 675 | const regex_type&& __re, | 
|  | 676 | regex_constants::match_flag_type __m | 
|  | 677 | = regex_constants::match_default) = delete; // C++14 | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 678 | regex_iterator(const regex_iterator&); | 
|  | 679 | regex_iterator& operator=(const regex_iterator&); | 
|  | 680 |  | 
|  | 681 | bool operator==(const regex_iterator&) const; | 
|  | 682 | bool operator!=(const regex_iterator&) const; | 
|  | 683 |  | 
|  | 684 | const value_type& operator*() const; | 
|  | 685 | const value_type* operator->() const; | 
|  | 686 |  | 
|  | 687 | regex_iterator& operator++(); | 
|  | 688 | regex_iterator operator++(int); | 
|  | 689 | }; | 
|  | 690 |  | 
|  | 691 | typedef regex_iterator<const char*> cregex_iterator; | 
|  | 692 | typedef regex_iterator<const wchar_t*> wcregex_iterator; | 
|  | 693 | typedef regex_iterator<string::const_iterator> sregex_iterator; | 
|  | 694 | typedef regex_iterator<wstring::const_iterator> wsregex_iterator; | 
|  | 695 |  | 
|  | 696 | template <class BidirectionalIterator, | 
|  | 697 | class charT = typename iterator_traits< BidirectionalIterator>::value_type, | 
|  | 698 | class traits = regex_traits<charT>> | 
|  | 699 | class regex_token_iterator | 
|  | 700 | { | 
|  | 701 | public: | 
|  | 702 | typedef basic_regex<charT, traits> regex_type; | 
|  | 703 | typedef sub_match<BidirectionalIterator> value_type; | 
|  | 704 | typedef ptrdiff_t difference_type; | 
|  | 705 | typedef const value_type* pointer; | 
|  | 706 | typedef const value_type& reference; | 
|  | 707 | typedef forward_iterator_tag iterator_category; | 
|  | 708 |  | 
|  | 709 | regex_token_iterator(); | 
|  | 710 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
|  | 711 | const regex_type& re, int submatch = 0, | 
|  | 712 | regex_constants::match_flag_type m = regex_constants::match_default); | 
|  | 713 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 714 | const regex_type&& re, int submatch = 0, | 
|  | 715 | regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14 | 
|  | 716 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 717 | const regex_type& re, const vector<int>& submatches, | 
|  | 718 | regex_constants::match_flag_type m = regex_constants::match_default); | 
|  | 719 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 720 | const regex_type&& re, const vector<int>& submatches, | 
|  | 721 | regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14 | 
|  | 722 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 723 | const regex_type& re, initializer_list<int> submatches, | 
|  | 724 | regex_constants::match_flag_type m = regex_constants::match_default); | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 725 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
|  | 726 | const regex_type&& re, initializer_list<int> submatches, | 
|  | 727 | regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14 | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 728 | template <size_t N> | 
|  | 729 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
|  | 730 | const regex_type& re, const int (&submatches)[N], | 
|  | 731 | regex_constants::match_flag_type m = regex_constants::match_default); | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 732 | template <size_t N> | 
|  | 733 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, | 
|  | 734 | const regex_type& re, const int (&submatches)[N], | 
|  | 735 | regex_constants::match_flag_type m = regex_constants::match_default) = delete // C++14; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 736 | regex_token_iterator(const regex_token_iterator&); | 
|  | 737 | regex_token_iterator& operator=(const regex_token_iterator&); | 
|  | 738 |  | 
|  | 739 | bool operator==(const regex_token_iterator&) const; | 
|  | 740 | bool operator!=(const regex_token_iterator&) const; | 
|  | 741 |  | 
|  | 742 | const value_type& operator*() const; | 
|  | 743 | const value_type* operator->() const; | 
|  | 744 |  | 
|  | 745 | regex_token_iterator& operator++(); | 
|  | 746 | regex_token_iterator operator++(int); | 
|  | 747 | }; | 
|  | 748 |  | 
|  | 749 | typedef regex_token_iterator<const char*> cregex_token_iterator; | 
|  | 750 | typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; | 
|  | 751 | typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; | 
|  | 752 | typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; | 
|  | 753 |  | 
|  | 754 | } // std | 
|  | 755 | */ | 
|  | 756 |  | 
|  | 757 | #include <__config> | 
|  | 758 | #include <stdexcept> | 
|  | 759 | #include <__locale> | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 760 | #include <initializer_list> | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 761 | #include <utility> | 
|  | 762 | #include <iterator> | 
|  | 763 | #include <string> | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 764 | #include <memory> | 
|  | 765 | #include <vector> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 766 | #include <deque> | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 767 |  | 
| Howard Hinnant | 66c6f97 | 2011-11-29 16:45:27 | [diff] [blame] | 768 | #include <__undef_min_max> | 
|  | 769 |  | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 | [diff] [blame] | 770 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 771 | #pragma GCC system_header | 
| Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 | [diff] [blame] | 772 | #endif | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 773 |  | 
|  | 774 | _LIBCPP_BEGIN_NAMESPACE_STD | 
|  | 775 |  | 
|  | 776 | namespace regex_constants | 
|  | 777 | { | 
|  | 778 |  | 
|  | 779 | // syntax_option_type | 
|  | 780 |  | 
|  | 781 | enum syntax_option_type | 
|  | 782 | { | 
|  | 783 | icase = 1 << 0, | 
|  | 784 | nosubs = 1 << 1, | 
|  | 785 | optimize = 1 << 2, | 
|  | 786 | collate = 1 << 3, | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 787 | ECMAScript = 0, | 
|  | 788 | basic = 1 << 4, | 
|  | 789 | extended = 1 << 5, | 
|  | 790 | awk = 1 << 6, | 
|  | 791 | grep = 1 << 7, | 
|  | 792 | egrep = 1 << 8 | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 793 | }; | 
|  | 794 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 795 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 796 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 797 | syntax_option_type | 
|  | 798 | operator~(syntax_option_type __x) | 
|  | 799 | { | 
| Marshall Clow | 04bd79b | 2013-03-22 02:13:55 | [diff] [blame] | 800 | return syntax_option_type(~int(__x) & 0x1FF); | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 801 | } | 
|  | 802 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 803 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 804 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 805 | syntax_option_type | 
|  | 806 | operator&(syntax_option_type __x, syntax_option_type __y) | 
|  | 807 | { | 
|  | 808 | return syntax_option_type(int(__x) & int(__y)); | 
|  | 809 | } | 
|  | 810 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 811 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 812 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 813 | syntax_option_type | 
|  | 814 | operator|(syntax_option_type __x, syntax_option_type __y) | 
|  | 815 | { | 
|  | 816 | return syntax_option_type(int(__x) | int(__y)); | 
|  | 817 | } | 
|  | 818 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 819 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 820 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 821 | syntax_option_type | 
|  | 822 | operator^(syntax_option_type __x, syntax_option_type __y) | 
|  | 823 | { | 
|  | 824 | return syntax_option_type(int(__x) ^ int(__y)); | 
|  | 825 | } | 
|  | 826 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 827 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 828 | syntax_option_type& | 
|  | 829 | operator&=(syntax_option_type& __x, syntax_option_type __y) | 
|  | 830 | { | 
|  | 831 | __x = __x & __y; | 
|  | 832 | return __x; | 
|  | 833 | } | 
|  | 834 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 835 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 836 | syntax_option_type& | 
|  | 837 | operator|=(syntax_option_type& __x, syntax_option_type __y) | 
|  | 838 | { | 
|  | 839 | __x = __x | __y; | 
|  | 840 | return __x; | 
|  | 841 | } | 
|  | 842 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 843 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 844 | syntax_option_type& | 
|  | 845 | operator^=(syntax_option_type& __x, syntax_option_type __y) | 
|  | 846 | { | 
|  | 847 | __x = __x ^ __y; | 
|  | 848 | return __x; | 
|  | 849 | } | 
|  | 850 |  | 
|  | 851 | // match_flag_type | 
|  | 852 |  | 
|  | 853 | enum match_flag_type | 
|  | 854 | { | 
|  | 855 | match_default = 0, | 
|  | 856 | match_not_bol = 1 << 0, | 
|  | 857 | match_not_eol = 1 << 1, | 
|  | 858 | match_not_bow = 1 << 2, | 
|  | 859 | match_not_eow = 1 << 3, | 
|  | 860 | match_any = 1 << 4, | 
|  | 861 | match_not_null = 1 << 5, | 
|  | 862 | match_continuous = 1 << 6, | 
|  | 863 | match_prev_avail = 1 << 7, | 
|  | 864 | format_default = 0, | 
|  | 865 | format_sed = 1 << 8, | 
|  | 866 | format_no_copy = 1 << 9, | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 867 | format_first_only = 1 << 10, | 
|  | 868 | __no_update_pos = 1 << 11 | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 869 | }; | 
|  | 870 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 871 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 872 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 873 | match_flag_type | 
|  | 874 | operator~(match_flag_type __x) | 
|  | 875 | { | 
| Marshall Clow | 04bd79b | 2013-03-22 02:13:55 | [diff] [blame] | 876 | return match_flag_type(~int(__x) & 0x0FFF); | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 877 | } | 
|  | 878 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 879 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 880 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 881 | match_flag_type | 
|  | 882 | operator&(match_flag_type __x, match_flag_type __y) | 
|  | 883 | { | 
|  | 884 | return match_flag_type(int(__x) & int(__y)); | 
|  | 885 | } | 
|  | 886 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 887 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 888 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 889 | match_flag_type | 
|  | 890 | operator|(match_flag_type __x, match_flag_type __y) | 
|  | 891 | { | 
|  | 892 | return match_flag_type(int(__x) | int(__y)); | 
|  | 893 | } | 
|  | 894 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 895 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 896 | _LIBCPP_CONSTEXPR | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 897 | match_flag_type | 
|  | 898 | operator^(match_flag_type __x, match_flag_type __y) | 
|  | 899 | { | 
|  | 900 | return match_flag_type(int(__x) ^ int(__y)); | 
|  | 901 | } | 
|  | 902 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 903 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 904 | match_flag_type& | 
|  | 905 | operator&=(match_flag_type& __x, match_flag_type __y) | 
|  | 906 | { | 
|  | 907 | __x = __x & __y; | 
|  | 908 | return __x; | 
|  | 909 | } | 
|  | 910 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 911 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 912 | match_flag_type& | 
|  | 913 | operator|=(match_flag_type& __x, match_flag_type __y) | 
|  | 914 | { | 
|  | 915 | __x = __x | __y; | 
|  | 916 | return __x; | 
|  | 917 | } | 
|  | 918 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 919 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 920 | match_flag_type& | 
|  | 921 | operator^=(match_flag_type& __x, match_flag_type __y) | 
|  | 922 | { | 
|  | 923 | __x = __x ^ __y; | 
|  | 924 | return __x; | 
|  | 925 | } | 
|  | 926 |  | 
|  | 927 | enum error_type | 
|  | 928 | { | 
|  | 929 | error_collate = 1, | 
|  | 930 | error_ctype, | 
|  | 931 | error_escape, | 
|  | 932 | error_backref, | 
|  | 933 | error_brack, | 
|  | 934 | error_paren, | 
|  | 935 | error_brace, | 
|  | 936 | error_badbrace, | 
|  | 937 | error_range, | 
|  | 938 | error_space, | 
|  | 939 | error_badrepeat, | 
|  | 940 | error_complexity, | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 941 | error_stack, | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 942 | __re_err_grammar, | 
|  | 943 | __re_err_empty, | 
|  | 944 | __re_err_unknown | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 945 | }; | 
|  | 946 |  | 
|  | 947 | } // regex_constants | 
|  | 948 |  | 
|  | 949 | class _LIBCPP_EXCEPTION_ABI regex_error | 
|  | 950 | : public runtime_error | 
|  | 951 | { | 
|  | 952 | regex_constants::error_type __code_; | 
|  | 953 | public: | 
|  | 954 | explicit regex_error(regex_constants::error_type __ecode); | 
|  | 955 | virtual ~regex_error() throw(); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 956 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 957 | regex_constants::error_type code() const {return __code_;} | 
|  | 958 | }; | 
|  | 959 |  | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 960 | template <regex_constants::error_type _Ev> | 
| Marshall Clow | 14c09a2 | 2016-08-25 15:09:01 | [diff] [blame] | 961 | _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 962 | void __throw_regex_error() | 
|  | 963 | { | 
|  | 964 | #ifndef _LIBCPP_NO_EXCEPTIONS | 
| Marshall Clow | fc93ce7 | 2015-08-17 21:14:16 | [diff] [blame] | 965 | throw regex_error(_Ev); | 
|  | 966 | #else | 
| Marshall Clow | 14c09a2 | 2016-08-25 15:09:01 | [diff] [blame] | 967 | _VSTD::abort(); | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 968 | #endif | 
|  | 969 | } | 
|  | 970 |  | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 971 | template <class _CharT> | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 | [diff] [blame] | 972 | struct _LIBCPP_TYPE_VIS_ONLY regex_traits | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 973 | { | 
|  | 974 | public: | 
|  | 975 | typedef _CharT char_type; | 
|  | 976 | typedef basic_string<char_type> string_type; | 
|  | 977 | typedef locale locale_type; | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 978 | typedef ctype_base::mask char_class_type; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 979 |  | 
| Daniel Sanders | 7e87bc9 | 2016-02-17 13:16:31 | [diff] [blame] | 980 | #if defined(__mips__) && defined(__GLIBC__) | 
|  | 981 | static const char_class_type __regex_word = static_cast<char_class_type>(_ISbit(15)); | 
|  | 982 | #else | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 983 | static const char_class_type __regex_word = 0x80; | 
| Daniel Sanders | 7e87bc9 | 2016-02-17 13:16:31 | [diff] [blame] | 984 | #endif | 
|  | 985 |  | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 986 | private: | 
|  | 987 | locale __loc_; | 
|  | 988 | const ctype<char_type>* __ct_; | 
|  | 989 | const collate<char_type>* __col_; | 
|  | 990 |  | 
|  | 991 | public: | 
|  | 992 | regex_traits(); | 
|  | 993 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 994 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 995 | static size_t length(const char_type* __p) | 
|  | 996 | {return char_traits<char_type>::length(__p);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 997 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 998 | char_type translate(char_type __c) const {return __c;} | 
|  | 999 | char_type translate_nocase(char_type __c) const; | 
|  | 1000 | template <class _ForwardIterator> | 
|  | 1001 | string_type | 
|  | 1002 | transform(_ForwardIterator __f, _ForwardIterator __l) const; | 
|  | 1003 | template <class _ForwardIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1004 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1005 | string_type | 
|  | 1006 | transform_primary( _ForwardIterator __f, _ForwardIterator __l) const | 
|  | 1007 | {return __transform_primary(__f, __l, char_type());} | 
|  | 1008 | template <class _ForwardIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1009 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1010 | string_type | 
|  | 1011 | lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const | 
|  | 1012 | {return __lookup_collatename(__f, __l, char_type());} | 
|  | 1013 | template <class _ForwardIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1014 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1015 | char_class_type | 
|  | 1016 | lookup_classname(_ForwardIterator __f, _ForwardIterator __l, | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1017 | bool __icase = false) const | 
|  | 1018 | {return __lookup_classname(__f, __l, __icase, char_type());} | 
|  | 1019 | bool isctype(char_type __c, char_class_type __m) const; | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1020 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1021 | int value(char_type __ch, int __radix) const | 
| Marshall Clow | 33ae233 | 2013-10-21 15:43:25 | [diff] [blame] | 1022 | {return __regex_traits_value(__ch, __radix);} | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1023 | locale_type imbue(locale_type __l); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1024 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1025 | locale_type getloc()const {return __loc_;} | 
|  | 1026 |  | 
|  | 1027 | private: | 
|  | 1028 | void __init(); | 
|  | 1029 |  | 
|  | 1030 | template <class _ForwardIterator> | 
|  | 1031 | string_type | 
|  | 1032 | __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const; | 
|  | 1033 | template <class _ForwardIterator> | 
|  | 1034 | string_type | 
|  | 1035 | __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; | 
|  | 1036 |  | 
|  | 1037 | template <class _ForwardIterator> | 
|  | 1038 | string_type | 
|  | 1039 | __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const; | 
|  | 1040 | template <class _ForwardIterator> | 
|  | 1041 | string_type | 
|  | 1042 | __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1043 |  | 
|  | 1044 | template <class _ForwardIterator> | 
|  | 1045 | char_class_type | 
|  | 1046 | __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, | 
|  | 1047 | bool __icase, char) const; | 
|  | 1048 | template <class _ForwardIterator> | 
|  | 1049 | char_class_type | 
|  | 1050 | __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, | 
|  | 1051 | bool __icase, wchar_t) const; | 
|  | 1052 |  | 
| Marshall Clow | 33ae233 | 2013-10-21 15:43:25 | [diff] [blame] | 1053 | static int __regex_traits_value(unsigned char __ch, int __radix); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1054 | _LIBCPP_INLINE_VISIBILITY | 
| Marshall Clow | 33ae233 | 2013-10-21 15:43:25 | [diff] [blame] | 1055 | int __regex_traits_value(char __ch, int __radix) const | 
|  | 1056 | {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);} | 
| Evgeniy Stepanov | a3b25f8 | 2015-11-07 01:22:13 | [diff] [blame] | 1057 | _LIBCPP_INLINE_VISIBILITY | 
| Marshall Clow | 33ae233 | 2013-10-21 15:43:25 | [diff] [blame] | 1058 | int __regex_traits_value(wchar_t __ch, int __radix) const; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1059 | }; | 
|  | 1060 |  | 
|  | 1061 | template <class _CharT> | 
| Howard Hinnant | 23fb972 | 2013-03-07 19:38:08 | [diff] [blame] | 1062 | const typename regex_traits<_CharT>::char_class_type | 
|  | 1063 | regex_traits<_CharT>::__regex_word; | 
|  | 1064 |  | 
|  | 1065 | template <class _CharT> | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1066 | regex_traits<_CharT>::regex_traits() | 
|  | 1067 | { | 
|  | 1068 | __init(); | 
|  | 1069 | } | 
|  | 1070 |  | 
|  | 1071 | template <class _CharT> | 
|  | 1072 | typename regex_traits<_CharT>::char_type | 
|  | 1073 | regex_traits<_CharT>::translate_nocase(char_type __c) const | 
|  | 1074 | { | 
|  | 1075 | return __ct_->tolower(__c); | 
|  | 1076 | } | 
|  | 1077 |  | 
|  | 1078 | template <class _CharT> | 
|  | 1079 | template <class _ForwardIterator> | 
|  | 1080 | typename regex_traits<_CharT>::string_type | 
|  | 1081 | regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const | 
|  | 1082 | { | 
|  | 1083 | string_type __s(__f, __l); | 
|  | 1084 | return __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1085 | } | 
|  | 1086 |  | 
|  | 1087 | template <class _CharT> | 
|  | 1088 | void | 
|  | 1089 | regex_traits<_CharT>::__init() | 
|  | 1090 | { | 
|  | 1091 | __ct_ = &use_facet<ctype<char_type> >(__loc_); | 
|  | 1092 | __col_ = &use_facet<collate<char_type> >(__loc_); | 
|  | 1093 | } | 
|  | 1094 |  | 
|  | 1095 | template <class _CharT> | 
|  | 1096 | typename regex_traits<_CharT>::locale_type | 
|  | 1097 | regex_traits<_CharT>::imbue(locale_type __l) | 
|  | 1098 | { | 
|  | 1099 | locale __r = __loc_; | 
|  | 1100 | __loc_ = __l; | 
|  | 1101 | __init(); | 
|  | 1102 | return __r; | 
|  | 1103 | } | 
|  | 1104 |  | 
|  | 1105 | // transform_primary is very FreeBSD-specific | 
|  | 1106 |  | 
|  | 1107 | template <class _CharT> | 
|  | 1108 | template <class _ForwardIterator> | 
|  | 1109 | typename regex_traits<_CharT>::string_type | 
|  | 1110 | regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, | 
|  | 1111 | _ForwardIterator __l, char) const | 
|  | 1112 | { | 
|  | 1113 | const string_type __s(__f, __l); | 
|  | 1114 | string_type __d = __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1115 | switch (__d.size()) | 
|  | 1116 | { | 
|  | 1117 | case 1: | 
|  | 1118 | break; | 
|  | 1119 | case 12: | 
|  | 1120 | __d[11] = __d[3]; | 
|  | 1121 | break; | 
|  | 1122 | default: | 
|  | 1123 | __d.clear(); | 
|  | 1124 | break; | 
|  | 1125 | } | 
|  | 1126 | return __d; | 
|  | 1127 | } | 
|  | 1128 |  | 
|  | 1129 | template <class _CharT> | 
|  | 1130 | template <class _ForwardIterator> | 
|  | 1131 | typename regex_traits<_CharT>::string_type | 
|  | 1132 | regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, | 
|  | 1133 | _ForwardIterator __l, wchar_t) const | 
|  | 1134 | { | 
|  | 1135 | const string_type __s(__f, __l); | 
|  | 1136 | string_type __d = __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1137 | switch (__d.size()) | 
|  | 1138 | { | 
|  | 1139 | case 1: | 
|  | 1140 | break; | 
|  | 1141 | case 3: | 
|  | 1142 | __d[2] = __d[0]; | 
|  | 1143 | break; | 
|  | 1144 | default: | 
|  | 1145 | __d.clear(); | 
|  | 1146 | break; | 
|  | 1147 | } | 
|  | 1148 | return __d; | 
|  | 1149 | } | 
|  | 1150 |  | 
|  | 1151 | // lookup_collatename is very FreeBSD-specific | 
|  | 1152 |  | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 | [diff] [blame] | 1153 | _LIBCPP_FUNC_VIS string __get_collation_name(const char* __s); | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1154 |  | 
|  | 1155 | template <class _CharT> | 
|  | 1156 | template <class _ForwardIterator> | 
|  | 1157 | typename regex_traits<_CharT>::string_type | 
|  | 1158 | regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, | 
|  | 1159 | _ForwardIterator __l, char) const | 
|  | 1160 | { | 
|  | 1161 | string_type __s(__f, __l); | 
|  | 1162 | string_type __r; | 
|  | 1163 | if (!__s.empty()) | 
|  | 1164 | { | 
|  | 1165 | __r = __get_collation_name(__s.c_str()); | 
|  | 1166 | if (__r.empty() && __s.size() <= 2) | 
|  | 1167 | { | 
|  | 1168 | __r = __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1169 | if (__r.size() == 1 || __r.size() == 12) | 
|  | 1170 | __r = __s; | 
|  | 1171 | else | 
|  | 1172 | __r.clear(); | 
|  | 1173 | } | 
|  | 1174 | } | 
|  | 1175 | return __r; | 
|  | 1176 | } | 
|  | 1177 |  | 
|  | 1178 | template <class _CharT> | 
|  | 1179 | template <class _ForwardIterator> | 
|  | 1180 | typename regex_traits<_CharT>::string_type | 
|  | 1181 | regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, | 
|  | 1182 | _ForwardIterator __l, wchar_t) const | 
|  | 1183 | { | 
|  | 1184 | string_type __s(__f, __l); | 
|  | 1185 | string __n; | 
|  | 1186 | __n.reserve(__s.size()); | 
|  | 1187 | for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end(); | 
|  | 1188 | __i != __e; ++__i) | 
|  | 1189 | { | 
|  | 1190 | if (static_cast<unsigned>(*__i) >= 127) | 
|  | 1191 | return string_type(); | 
|  | 1192 | __n.push_back(char(*__i)); | 
|  | 1193 | } | 
|  | 1194 | string_type __r; | 
|  | 1195 | if (!__s.empty()) | 
|  | 1196 | { | 
|  | 1197 | __n = __get_collation_name(__n.c_str()); | 
|  | 1198 | if (!__n.empty()) | 
|  | 1199 | __r.assign(__n.begin(), __n.end()); | 
|  | 1200 | else if (__s.size() <= 2) | 
|  | 1201 | { | 
|  | 1202 | __r = __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1203 | if (__r.size() == 1 || __r.size() == 3) | 
|  | 1204 | __r = __s; | 
|  | 1205 | else | 
|  | 1206 | __r.clear(); | 
|  | 1207 | } | 
|  | 1208 | } | 
|  | 1209 | return __r; | 
|  | 1210 | } | 
|  | 1211 |  | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1212 | // lookup_classname | 
|  | 1213 |  | 
| Dan Albert | 1757386 | 2014-07-29 19:23:39 | [diff] [blame] | 1214 | regex_traits<char>::char_class_type _LIBCPP_FUNC_VIS | 
|  | 1215 | __get_classname(const char* __s, bool __icase); | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1216 |  | 
|  | 1217 | template <class _CharT> | 
|  | 1218 | template <class _ForwardIterator> | 
|  | 1219 | typename regex_traits<_CharT>::char_class_type | 
|  | 1220 | regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, | 
|  | 1221 | _ForwardIterator __l, | 
|  | 1222 | bool __icase, char) const | 
|  | 1223 | { | 
|  | 1224 | string_type __s(__f, __l); | 
|  | 1225 | __ct_->tolower(&__s[0], &__s[0] + __s.size()); | 
|  | 1226 | return __get_classname(__s.c_str(), __icase); | 
|  | 1227 | } | 
|  | 1228 |  | 
|  | 1229 | template <class _CharT> | 
|  | 1230 | template <class _ForwardIterator> | 
|  | 1231 | typename regex_traits<_CharT>::char_class_type | 
|  | 1232 | regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, | 
|  | 1233 | _ForwardIterator __l, | 
|  | 1234 | bool __icase, wchar_t) const | 
|  | 1235 | { | 
|  | 1236 | string_type __s(__f, __l); | 
|  | 1237 | __ct_->tolower(&__s[0], &__s[0] + __s.size()); | 
|  | 1238 | string __n; | 
|  | 1239 | __n.reserve(__s.size()); | 
|  | 1240 | for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end(); | 
|  | 1241 | __i != __e; ++__i) | 
|  | 1242 | { | 
|  | 1243 | if (static_cast<unsigned>(*__i) >= 127) | 
|  | 1244 | return char_class_type(); | 
|  | 1245 | __n.push_back(char(*__i)); | 
|  | 1246 | } | 
|  | 1247 | return __get_classname(__n.c_str(), __icase); | 
|  | 1248 | } | 
|  | 1249 |  | 
|  | 1250 | template <class _CharT> | 
|  | 1251 | bool | 
|  | 1252 | regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const | 
|  | 1253 | { | 
|  | 1254 | if (__ct_->is(__m, __c)) | 
|  | 1255 | return true; | 
|  | 1256 | return (__c == '_' && (__m & __regex_word)); | 
|  | 1257 | } | 
|  | 1258 |  | 
|  | 1259 | template <class _CharT> | 
|  | 1260 | int | 
| Marshall Clow | 33ae233 | 2013-10-21 15:43:25 | [diff] [blame] | 1261 | regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1262 | { | 
|  | 1263 | if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7' | 
|  | 1264 | return __ch - '0'; | 
|  | 1265 | if (__radix != 8) | 
|  | 1266 | { | 
|  | 1267 | if ((__ch & 0xFEu) == 0x38) // '8' <= __ch && __ch <= '9' | 
|  | 1268 | return __ch - '0'; | 
|  | 1269 | if (__radix == 16) | 
|  | 1270 | { | 
|  | 1271 | __ch |= 0x20; // tolower | 
|  | 1272 | if ('a' <= __ch && __ch <= 'f') | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1273 | return __ch - ('a' - 10); | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1274 | } | 
|  | 1275 | } | 
|  | 1276 | return -1; | 
|  | 1277 | } | 
|  | 1278 |  | 
|  | 1279 | template <class _CharT> | 
| Evgeniy Stepanov | a3b25f8 | 2015-11-07 01:22:13 | [diff] [blame] | 1280 | inline | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1281 | int | 
| Marshall Clow | 33ae233 | 2013-10-21 15:43:25 | [diff] [blame] | 1282 | regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1283 | { | 
| Marshall Clow | 33ae233 | 2013-10-21 15:43:25 | [diff] [blame] | 1284 | return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1285 | } | 
|  | 1286 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1287 | template <class _CharT> class __node; | 
|  | 1288 |  | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 | [diff] [blame] | 1289 | template <class _BidirectionalIterator> class _LIBCPP_TYPE_VIS_ONLY sub_match; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1290 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1291 | template <class _BidirectionalIterator, | 
|  | 1292 | class _Allocator = allocator<sub_match<_BidirectionalIterator> > > | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 | [diff] [blame] | 1293 | class _LIBCPP_TYPE_VIS_ONLY match_results; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1294 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1295 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1296 | struct __state | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1297 | { | 
|  | 1298 | enum | 
|  | 1299 | { | 
|  | 1300 | __end_state = -1000, | 
|  | 1301 | __consume_input, // -999 | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1302 | __begin_marked_expr, // -998 | 
|  | 1303 | __end_marked_expr, // -997 | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1304 | __pop_state, // -996 | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1305 | __accept_and_consume, // -995 | 
|  | 1306 | __accept_but_not_consume, // -994 | 
|  | 1307 | __reject, // -993 | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1308 | __split, | 
|  | 1309 | __repeat | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1310 | }; | 
|  | 1311 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1312 | int __do_; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1313 | const _CharT* __first_; | 
|  | 1314 | const _CharT* __current_; | 
|  | 1315 | const _CharT* __last_; | 
|  | 1316 | vector<sub_match<const _CharT*> > __sub_matches_; | 
|  | 1317 | vector<pair<size_t, const _CharT*> > __loop_data_; | 
|  | 1318 | const __node<_CharT>* __node_; | 
|  | 1319 | regex_constants::match_flag_type __flags_; | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 1320 | bool __at_first_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1321 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1322 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1323 | __state() | 
|  | 1324 | : __do_(0), __first_(nullptr), __current_(nullptr), __last_(nullptr), | 
|  | 1325 | __node_(nullptr), __flags_() {} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1326 | }; | 
|  | 1327 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1328 | // __node | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1329 |  | 
|  | 1330 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1331 | class __node | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1332 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1333 | __node(const __node&); | 
|  | 1334 | __node& operator=(const __node&); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1335 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1336 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1337 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1338 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1339 | __node() {} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1340 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1341 | virtual ~__node() {} | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1342 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1343 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1344 | virtual void __exec(__state&) const {}; | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1345 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1346 | virtual void __exec_split(bool, __state&) const {}; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1347 | }; | 
|  | 1348 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1349 | // __end_state | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1350 |  | 
|  | 1351 | template <class _CharT> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1352 | class __end_state | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1353 | : public __node<_CharT> | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1354 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1355 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1356 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1357 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1358 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1359 | __end_state() {} | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 1360 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1361 | virtual void __exec(__state&) const; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 1362 | }; | 
|  | 1363 |  | 
|  | 1364 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1365 | void | 
|  | 1366 | __end_state<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 1367 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1368 | __s.__do_ = __state::__end_state; | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 1369 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1370 |  | 
|  | 1371 | // __has_one_state | 
|  | 1372 |  | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 1373 | template <class _CharT> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1374 | class __has_one_state | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1375 | : public __node<_CharT> | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 1376 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1377 | __node<_CharT>* __first_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1378 |  | 
|  | 1379 | public: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1380 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1381 | explicit __has_one_state(__node<_CharT>* __s) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1382 | : __first_(__s) {} | 
|  | 1383 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1384 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1385 | __node<_CharT>* first() const {return __first_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1386 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1387 | __node<_CharT>*& first() {return __first_;} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1388 | }; | 
|  | 1389 |  | 
|  | 1390 | // __owns_one_state | 
|  | 1391 |  | 
|  | 1392 | template <class _CharT> | 
|  | 1393 | class __owns_one_state | 
|  | 1394 | : public __has_one_state<_CharT> | 
|  | 1395 | { | 
|  | 1396 | typedef __has_one_state<_CharT> base; | 
|  | 1397 |  | 
|  | 1398 | public: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1399 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1400 | explicit __owns_one_state(__node<_CharT>* __s) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1401 | : base(__s) {} | 
|  | 1402 |  | 
|  | 1403 | virtual ~__owns_one_state(); | 
|  | 1404 | }; | 
|  | 1405 |  | 
|  | 1406 | template <class _CharT> | 
|  | 1407 | __owns_one_state<_CharT>::~__owns_one_state() | 
|  | 1408 | { | 
|  | 1409 | delete this->first(); | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 1410 | } | 
|  | 1411 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1412 | // __empty_state | 
|  | 1413 |  | 
|  | 1414 | template <class _CharT> | 
|  | 1415 | class __empty_state | 
|  | 1416 | : public __owns_one_state<_CharT> | 
|  | 1417 | { | 
|  | 1418 | typedef __owns_one_state<_CharT> base; | 
|  | 1419 |  | 
|  | 1420 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1421 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1422 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1423 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1424 | explicit __empty_state(__node<_CharT>* __s) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1425 | : base(__s) {} | 
|  | 1426 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1427 | virtual void __exec(__state&) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1428 | }; | 
|  | 1429 |  | 
|  | 1430 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1431 | void | 
|  | 1432 | __empty_state<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1433 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1434 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1435 | __s.__node_ = this->first(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1436 | } | 
|  | 1437 |  | 
|  | 1438 | // __empty_non_own_state | 
|  | 1439 |  | 
|  | 1440 | template <class _CharT> | 
|  | 1441 | class __empty_non_own_state | 
|  | 1442 | : public __has_one_state<_CharT> | 
|  | 1443 | { | 
|  | 1444 | typedef __has_one_state<_CharT> base; | 
|  | 1445 |  | 
|  | 1446 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1447 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1448 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1449 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1450 | explicit __empty_non_own_state(__node<_CharT>* __s) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1451 | : base(__s) {} | 
|  | 1452 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1453 | virtual void __exec(__state&) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1454 | }; | 
|  | 1455 |  | 
|  | 1456 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1457 | void | 
|  | 1458 | __empty_non_own_state<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1459 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1460 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1461 | __s.__node_ = this->first(); | 
|  | 1462 | } | 
|  | 1463 |  | 
|  | 1464 | // __repeat_one_loop | 
|  | 1465 |  | 
|  | 1466 | template <class _CharT> | 
|  | 1467 | class __repeat_one_loop | 
|  | 1468 | : public __has_one_state<_CharT> | 
|  | 1469 | { | 
|  | 1470 | typedef __has_one_state<_CharT> base; | 
|  | 1471 |  | 
|  | 1472 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1473 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1474 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1475 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1476 | explicit __repeat_one_loop(__node<_CharT>* __s) | 
|  | 1477 | : base(__s) {} | 
|  | 1478 |  | 
|  | 1479 | virtual void __exec(__state&) const; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1480 | }; | 
|  | 1481 |  | 
|  | 1482 | template <class _CharT> | 
|  | 1483 | void | 
|  | 1484 | __repeat_one_loop<_CharT>::__exec(__state& __s) const | 
|  | 1485 | { | 
|  | 1486 | __s.__do_ = __state::__repeat; | 
|  | 1487 | __s.__node_ = this->first(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1488 | } | 
|  | 1489 |  | 
|  | 1490 | // __owns_two_states | 
|  | 1491 |  | 
|  | 1492 | template <class _CharT> | 
|  | 1493 | class __owns_two_states | 
|  | 1494 | : public __owns_one_state<_CharT> | 
|  | 1495 | { | 
|  | 1496 | typedef __owns_one_state<_CharT> base; | 
|  | 1497 |  | 
|  | 1498 | base* __second_; | 
|  | 1499 |  | 
|  | 1500 | public: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1501 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1502 | explicit __owns_two_states(__node<_CharT>* __s1, base* __s2) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1503 | : base(__s1), __second_(__s2) {} | 
|  | 1504 |  | 
|  | 1505 | virtual ~__owns_two_states(); | 
|  | 1506 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1507 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1508 | base* second() const {return __second_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1509 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1510 | base*& second() {return __second_;} | 
|  | 1511 | }; | 
|  | 1512 |  | 
|  | 1513 | template <class _CharT> | 
|  | 1514 | __owns_two_states<_CharT>::~__owns_two_states() | 
|  | 1515 | { | 
|  | 1516 | delete __second_; | 
|  | 1517 | } | 
|  | 1518 |  | 
|  | 1519 | // __loop | 
|  | 1520 |  | 
|  | 1521 | template <class _CharT> | 
|  | 1522 | class __loop | 
|  | 1523 | : public __owns_two_states<_CharT> | 
|  | 1524 | { | 
|  | 1525 | typedef __owns_two_states<_CharT> base; | 
|  | 1526 |  | 
|  | 1527 | size_t __min_; | 
|  | 1528 | size_t __max_; | 
|  | 1529 | unsigned __loop_id_; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1530 | unsigned __mexp_begin_; | 
|  | 1531 | unsigned __mexp_end_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1532 | bool __greedy_; | 
|  | 1533 |  | 
|  | 1534 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1535 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1536 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1537 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1538 | explicit __loop(unsigned __loop_id, | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1539 | __node<_CharT>* __s1, __owns_one_state<_CharT>* __s2, | 
|  | 1540 | unsigned __mexp_begin, unsigned __mexp_end, | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1541 | bool __greedy = true, | 
|  | 1542 | size_t __min = 0, | 
|  | 1543 | size_t __max = numeric_limits<size_t>::max()) | 
|  | 1544 | : base(__s1, __s2), __min_(__min), __max_(__max), __loop_id_(__loop_id), | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1545 | __mexp_begin_(__mexp_begin), __mexp_end_(__mexp_end), | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1546 | __greedy_(__greedy) {} | 
|  | 1547 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1548 | virtual void __exec(__state& __s) const; | 
|  | 1549 | virtual void __exec_split(bool __second, __state& __s) const; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1550 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1551 | private: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1552 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1553 | void __init_repeat(__state& __s) const | 
|  | 1554 | { | 
|  | 1555 | __s.__loop_data_[__loop_id_].second = __s.__current_; | 
|  | 1556 | for (size_t __i = __mexp_begin_-1; __i != __mexp_end_-1; ++__i) | 
|  | 1557 | { | 
|  | 1558 | __s.__sub_matches_[__i].first = __s.__last_; | 
|  | 1559 | __s.__sub_matches_[__i].second = __s.__last_; | 
|  | 1560 | __s.__sub_matches_[__i].matched = false; | 
|  | 1561 | } | 
|  | 1562 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1563 | }; | 
|  | 1564 |  | 
|  | 1565 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1566 | void | 
|  | 1567 | __loop<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1568 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1569 | if (__s.__do_ == __state::__repeat) | 
|  | 1570 | { | 
|  | 1571 | bool __do_repeat = ++__s.__loop_data_[__loop_id_].first < __max_; | 
|  | 1572 | bool __do_alt = __s.__loop_data_[__loop_id_].first >= __min_; | 
|  | 1573 | if (__do_repeat && __do_alt && | 
|  | 1574 | __s.__loop_data_[__loop_id_].second == __s.__current_) | 
|  | 1575 | __do_repeat = false; | 
|  | 1576 | if (__do_repeat && __do_alt) | 
|  | 1577 | __s.__do_ = __state::__split; | 
|  | 1578 | else if (__do_repeat) | 
|  | 1579 | { | 
|  | 1580 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1581 | __s.__node_ = this->first(); | 
|  | 1582 | __init_repeat(__s); | 
|  | 1583 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1584 | else | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1585 | { | 
|  | 1586 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1587 | __s.__node_ = this->second(); | 
|  | 1588 | } | 
|  | 1589 | } | 
|  | 1590 | else | 
|  | 1591 | { | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 1592 | __s.__loop_data_[__loop_id_].first = 0; | 
|  | 1593 | bool __do_repeat = 0 < __max_; | 
|  | 1594 | bool __do_alt = 0 >= __min_; | 
|  | 1595 | if (__do_repeat && __do_alt) | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1596 | __s.__do_ = __state::__split; | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 1597 | else if (__do_repeat) | 
|  | 1598 | { | 
|  | 1599 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1600 | __s.__node_ = this->first(); | 
|  | 1601 | __init_repeat(__s); | 
|  | 1602 | } | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1603 | else | 
|  | 1604 | { | 
|  | 1605 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1606 | __s.__node_ = this->second(); | 
|  | 1607 | } | 
|  | 1608 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1609 | } | 
|  | 1610 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1611 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1612 | void | 
|  | 1613 | __loop<_CharT>::__exec_split(bool __second, __state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1614 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1615 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1616 | if (__greedy_ != __second) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1617 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1618 | __s.__node_ = this->first(); | 
|  | 1619 | __init_repeat(__s); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1620 | } | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1621 | else | 
|  | 1622 | __s.__node_ = this->second(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1623 | } | 
|  | 1624 |  | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1625 | // __alternate | 
|  | 1626 |  | 
|  | 1627 | template <class _CharT> | 
|  | 1628 | class __alternate | 
|  | 1629 | : public __owns_two_states<_CharT> | 
|  | 1630 | { | 
|  | 1631 | typedef __owns_two_states<_CharT> base; | 
|  | 1632 |  | 
|  | 1633 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1634 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1635 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1636 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1637 | explicit __alternate(__owns_one_state<_CharT>* __s1, | 
|  | 1638 | __owns_one_state<_CharT>* __s2) | 
|  | 1639 | : base(__s1, __s2) {} | 
|  | 1640 |  | 
|  | 1641 | virtual void __exec(__state& __s) const; | 
|  | 1642 | virtual void __exec_split(bool __second, __state& __s) const; | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1643 | }; | 
|  | 1644 |  | 
|  | 1645 | template <class _CharT> | 
|  | 1646 | void | 
|  | 1647 | __alternate<_CharT>::__exec(__state& __s) const | 
|  | 1648 | { | 
|  | 1649 | __s.__do_ = __state::__split; | 
|  | 1650 | } | 
|  | 1651 |  | 
|  | 1652 | template <class _CharT> | 
|  | 1653 | void | 
|  | 1654 | __alternate<_CharT>::__exec_split(bool __second, __state& __s) const | 
|  | 1655 | { | 
|  | 1656 | __s.__do_ = __state::__accept_but_not_consume; | 
| Howard Hinnant | 1371b2e | 2010-07-22 14:12:20 | [diff] [blame] | 1657 | if (__second) | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1658 | __s.__node_ = this->second(); | 
| Howard Hinnant | 1371b2e | 2010-07-22 14:12:20 | [diff] [blame] | 1659 | else | 
|  | 1660 | __s.__node_ = this->first(); | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 1661 | } | 
|  | 1662 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1663 | // __begin_marked_subexpression | 
|  | 1664 |  | 
|  | 1665 | template <class _CharT> | 
|  | 1666 | class __begin_marked_subexpression | 
|  | 1667 | : public __owns_one_state<_CharT> | 
|  | 1668 | { | 
|  | 1669 | typedef __owns_one_state<_CharT> base; | 
|  | 1670 |  | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1671 | unsigned __mexp_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1672 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1673 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1674 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1675 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1676 | explicit __begin_marked_subexpression(unsigned __mexp, __node<_CharT>* __s) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1677 | : base(__s), __mexp_(__mexp) {} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1678 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1679 | virtual void __exec(__state&) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1680 | }; | 
|  | 1681 |  | 
|  | 1682 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1683 | void | 
|  | 1684 | __begin_marked_subexpression<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1685 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1686 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1687 | __s.__sub_matches_[__mexp_-1].first = __s.__current_; | 
|  | 1688 | __s.__node_ = this->first(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1689 | } | 
|  | 1690 |  | 
|  | 1691 | // __end_marked_subexpression | 
|  | 1692 |  | 
|  | 1693 | template <class _CharT> | 
|  | 1694 | class __end_marked_subexpression | 
|  | 1695 | : public __owns_one_state<_CharT> | 
|  | 1696 | { | 
|  | 1697 | typedef __owns_one_state<_CharT> base; | 
|  | 1698 |  | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1699 | unsigned __mexp_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1700 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1701 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1702 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1703 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1704 | explicit __end_marked_subexpression(unsigned __mexp, __node<_CharT>* __s) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 1705 | : base(__s), __mexp_(__mexp) {} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1706 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1707 | virtual void __exec(__state&) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1708 | }; | 
|  | 1709 |  | 
|  | 1710 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1711 | void | 
|  | 1712 | __end_marked_subexpression<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1713 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1714 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1715 | __s.__sub_matches_[__mexp_-1].second = __s.__current_; | 
|  | 1716 | __s.__sub_matches_[__mexp_-1].matched = true; | 
|  | 1717 | __s.__node_ = this->first(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1718 | } | 
|  | 1719 |  | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 1720 | // __back_ref | 
|  | 1721 |  | 
|  | 1722 | template <class _CharT> | 
|  | 1723 | class __back_ref | 
|  | 1724 | : public __owns_one_state<_CharT> | 
|  | 1725 | { | 
|  | 1726 | typedef __owns_one_state<_CharT> base; | 
|  | 1727 |  | 
|  | 1728 | unsigned __mexp_; | 
|  | 1729 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1730 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 1731 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1732 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 1733 | explicit __back_ref(unsigned __mexp, __node<_CharT>* __s) | 
|  | 1734 | : base(__s), __mexp_(__mexp) {} | 
|  | 1735 |  | 
|  | 1736 | virtual void __exec(__state&) const; | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 1737 | }; | 
|  | 1738 |  | 
|  | 1739 | template <class _CharT> | 
|  | 1740 | void | 
|  | 1741 | __back_ref<_CharT>::__exec(__state& __s) const | 
|  | 1742 | { | 
| Marshall Clow | 70e8f59 | 2015-08-24 15:57:09 | [diff] [blame] | 1743 | if (__mexp_ > __s.__sub_matches_.size()) | 
|  | 1744 | __throw_regex_error<regex_constants::error_backref>(); | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 1745 | sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1]; | 
|  | 1746 | if (__sm.matched) | 
|  | 1747 | { | 
|  | 1748 | ptrdiff_t __len = __sm.second - __sm.first; | 
|  | 1749 | if (__s.__last_ - __s.__current_ >= __len && | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1750 | _VSTD::equal(__sm.first, __sm.second, __s.__current_)) | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 1751 | { | 
|  | 1752 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1753 | __s.__current_ += __len; | 
|  | 1754 | __s.__node_ = this->first(); | 
|  | 1755 | } | 
|  | 1756 | else | 
|  | 1757 | { | 
|  | 1758 | __s.__do_ = __state::__reject; | 
|  | 1759 | __s.__node_ = nullptr; | 
|  | 1760 | } | 
|  | 1761 | } | 
|  | 1762 | else | 
|  | 1763 | { | 
|  | 1764 | __s.__do_ = __state::__reject; | 
|  | 1765 | __s.__node_ = nullptr; | 
|  | 1766 | } | 
|  | 1767 | } | 
|  | 1768 |  | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1769 | // __back_ref_icase | 
|  | 1770 |  | 
|  | 1771 | template <class _CharT, class _Traits> | 
|  | 1772 | class __back_ref_icase | 
|  | 1773 | : public __owns_one_state<_CharT> | 
|  | 1774 | { | 
|  | 1775 | typedef __owns_one_state<_CharT> base; | 
|  | 1776 |  | 
|  | 1777 | _Traits __traits_; | 
|  | 1778 | unsigned __mexp_; | 
|  | 1779 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1780 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1781 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1782 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1783 | explicit __back_ref_icase(const _Traits& __traits, unsigned __mexp, | 
|  | 1784 | __node<_CharT>* __s) | 
|  | 1785 | : base(__s), __traits_(__traits), __mexp_(__mexp) {} | 
|  | 1786 |  | 
|  | 1787 | virtual void __exec(__state&) const; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1788 | }; | 
|  | 1789 |  | 
|  | 1790 | template <class _CharT, class _Traits> | 
|  | 1791 | void | 
|  | 1792 | __back_ref_icase<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 1793 | { | 
|  | 1794 | sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1]; | 
|  | 1795 | if (__sm.matched) | 
|  | 1796 | { | 
|  | 1797 | ptrdiff_t __len = __sm.second - __sm.first; | 
|  | 1798 | if (__s.__last_ - __s.__current_ >= __len) | 
|  | 1799 | { | 
|  | 1800 | for (ptrdiff_t __i = 0; __i < __len; ++__i) | 
|  | 1801 | { | 
|  | 1802 | if (__traits_.translate_nocase(__sm.first[__i]) != | 
|  | 1803 | __traits_.translate_nocase(__s.__current_[__i])) | 
|  | 1804 | goto __not_equal; | 
|  | 1805 | } | 
|  | 1806 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1807 | __s.__current_ += __len; | 
|  | 1808 | __s.__node_ = this->first(); | 
|  | 1809 | } | 
|  | 1810 | else | 
|  | 1811 | { | 
|  | 1812 | __s.__do_ = __state::__reject; | 
|  | 1813 | __s.__node_ = nullptr; | 
|  | 1814 | } | 
|  | 1815 | } | 
|  | 1816 | else | 
|  | 1817 | { | 
|  | 1818 | __not_equal: | 
|  | 1819 | __s.__do_ = __state::__reject; | 
|  | 1820 | __s.__node_ = nullptr; | 
|  | 1821 | } | 
|  | 1822 | } | 
|  | 1823 |  | 
|  | 1824 | // __back_ref_collate | 
|  | 1825 |  | 
|  | 1826 | template <class _CharT, class _Traits> | 
|  | 1827 | class __back_ref_collate | 
|  | 1828 | : public __owns_one_state<_CharT> | 
|  | 1829 | { | 
|  | 1830 | typedef __owns_one_state<_CharT> base; | 
|  | 1831 |  | 
|  | 1832 | _Traits __traits_; | 
|  | 1833 | unsigned __mexp_; | 
|  | 1834 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1835 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1836 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1837 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1838 | explicit __back_ref_collate(const _Traits& __traits, unsigned __mexp, | 
|  | 1839 | __node<_CharT>* __s) | 
|  | 1840 | : base(__s), __traits_(__traits), __mexp_(__mexp) {} | 
|  | 1841 |  | 
|  | 1842 | virtual void __exec(__state&) const; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 1843 | }; | 
|  | 1844 |  | 
|  | 1845 | template <class _CharT, class _Traits> | 
|  | 1846 | void | 
|  | 1847 | __back_ref_collate<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 1848 | { | 
|  | 1849 | sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1]; | 
|  | 1850 | if (__sm.matched) | 
|  | 1851 | { | 
|  | 1852 | ptrdiff_t __len = __sm.second - __sm.first; | 
|  | 1853 | if (__s.__last_ - __s.__current_ >= __len) | 
|  | 1854 | { | 
|  | 1855 | for (ptrdiff_t __i = 0; __i < __len; ++__i) | 
|  | 1856 | { | 
|  | 1857 | if (__traits_.translate(__sm.first[__i]) != | 
|  | 1858 | __traits_.translate(__s.__current_[__i])) | 
|  | 1859 | goto __not_equal; | 
|  | 1860 | } | 
|  | 1861 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1862 | __s.__current_ += __len; | 
|  | 1863 | __s.__node_ = this->first(); | 
|  | 1864 | } | 
|  | 1865 | else | 
|  | 1866 | { | 
|  | 1867 | __s.__do_ = __state::__reject; | 
|  | 1868 | __s.__node_ = nullptr; | 
|  | 1869 | } | 
|  | 1870 | } | 
|  | 1871 | else | 
|  | 1872 | { | 
|  | 1873 | __not_equal: | 
|  | 1874 | __s.__do_ = __state::__reject; | 
|  | 1875 | __s.__node_ = nullptr; | 
|  | 1876 | } | 
|  | 1877 | } | 
|  | 1878 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1879 | // __word_boundary | 
|  | 1880 |  | 
|  | 1881 | template <class _CharT, class _Traits> | 
|  | 1882 | class __word_boundary | 
|  | 1883 | : public __owns_one_state<_CharT> | 
|  | 1884 | { | 
|  | 1885 | typedef __owns_one_state<_CharT> base; | 
|  | 1886 |  | 
|  | 1887 | _Traits __traits_; | 
|  | 1888 | bool __invert_; | 
|  | 1889 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1890 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1891 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1892 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1893 | explicit __word_boundary(const _Traits& __traits, bool __invert, | 
|  | 1894 | __node<_CharT>* __s) | 
|  | 1895 | : base(__s), __traits_(__traits), __invert_(__invert) {} | 
|  | 1896 |  | 
|  | 1897 | virtual void __exec(__state&) const; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1898 | }; | 
|  | 1899 |  | 
|  | 1900 | template <class _CharT, class _Traits> | 
|  | 1901 | void | 
|  | 1902 | __word_boundary<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 1903 | { | 
|  | 1904 | bool __is_word_b = false; | 
|  | 1905 | if (__s.__first_ != __s.__last_) | 
|  | 1906 | { | 
|  | 1907 | if (__s.__current_ == __s.__last_) | 
|  | 1908 | { | 
|  | 1909 | if (!(__s.__flags_ & regex_constants::match_not_eow)) | 
|  | 1910 | { | 
|  | 1911 | _CharT __c = __s.__current_[-1]; | 
|  | 1912 | __is_word_b = __c == '_' || | 
|  | 1913 | __traits_.isctype(__c, ctype_base::alnum); | 
|  | 1914 | } | 
|  | 1915 | } | 
| Howard Hinnant | f3dcca0 | 2010-07-29 15:17:28 | [diff] [blame] | 1916 | else if (__s.__current_ == __s.__first_ && | 
|  | 1917 | !(__s.__flags_ & regex_constants::match_prev_avail)) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 1918 | { | 
|  | 1919 | if (!(__s.__flags_ & regex_constants::match_not_bow)) | 
|  | 1920 | { | 
|  | 1921 | _CharT __c = *__s.__current_; | 
|  | 1922 | __is_word_b = __c == '_' || | 
|  | 1923 | __traits_.isctype(__c, ctype_base::alnum); | 
|  | 1924 | } | 
|  | 1925 | } | 
|  | 1926 | else | 
|  | 1927 | { | 
|  | 1928 | _CharT __c1 = __s.__current_[-1]; | 
|  | 1929 | _CharT __c2 = *__s.__current_; | 
|  | 1930 | bool __is_c1_b = __c1 == '_' || | 
|  | 1931 | __traits_.isctype(__c1, ctype_base::alnum); | 
|  | 1932 | bool __is_c2_b = __c2 == '_' || | 
|  | 1933 | __traits_.isctype(__c2, ctype_base::alnum); | 
|  | 1934 | __is_word_b = __is_c1_b != __is_c2_b; | 
|  | 1935 | } | 
|  | 1936 | } | 
|  | 1937 | if (__is_word_b != __invert_) | 
|  | 1938 | { | 
|  | 1939 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1940 | __s.__node_ = this->first(); | 
|  | 1941 | } | 
|  | 1942 | else | 
|  | 1943 | { | 
|  | 1944 | __s.__do_ = __state::__reject; | 
|  | 1945 | __s.__node_ = nullptr; | 
|  | 1946 | } | 
|  | 1947 | } | 
|  | 1948 |  | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 1949 | // __l_anchor | 
|  | 1950 |  | 
|  | 1951 | template <class _CharT> | 
|  | 1952 | class __l_anchor | 
|  | 1953 | : public __owns_one_state<_CharT> | 
|  | 1954 | { | 
|  | 1955 | typedef __owns_one_state<_CharT> base; | 
|  | 1956 |  | 
|  | 1957 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1958 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 1959 |  | 
|  | 1960 | _LIBCPP_INLINE_VISIBILITY | 
|  | 1961 | __l_anchor(__node<_CharT>* __s) | 
|  | 1962 | : base(__s) {} | 
|  | 1963 |  | 
|  | 1964 | virtual void __exec(__state&) const; | 
|  | 1965 | }; | 
|  | 1966 |  | 
|  | 1967 | template <class _CharT> | 
|  | 1968 | void | 
|  | 1969 | __l_anchor<_CharT>::__exec(__state& __s) const | 
|  | 1970 | { | 
| Marshall Clow | 64befb5 | 2015-03-19 17:05:59 | [diff] [blame] | 1971 | if (__s.__at_first_ && __s.__current_ == __s.__first_ && | 
|  | 1972 | !(__s.__flags_ & regex_constants::match_not_bol)) | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 1973 | { | 
|  | 1974 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 1975 | __s.__node_ = this->first(); | 
|  | 1976 | } | 
|  | 1977 | else | 
|  | 1978 | { | 
|  | 1979 | __s.__do_ = __state::__reject; | 
|  | 1980 | __s.__node_ = nullptr; | 
|  | 1981 | } | 
|  | 1982 | } | 
|  | 1983 |  | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 1984 | // __r_anchor | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1985 |  | 
|  | 1986 | template <class _CharT> | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 1987 | class __r_anchor | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1988 | : public __owns_one_state<_CharT> | 
|  | 1989 | { | 
|  | 1990 | typedef __owns_one_state<_CharT> base; | 
|  | 1991 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1992 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 1993 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1994 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 1995 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1996 | __r_anchor(__node<_CharT>* __s) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 1997 | : base(__s) {} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 1998 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 1999 | virtual void __exec(__state&) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2000 | }; | 
|  | 2001 |  | 
|  | 2002 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2003 | void | 
|  | 2004 | __r_anchor<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2005 | { | 
| Marshall Clow | 64befb5 | 2015-03-19 17:05:59 | [diff] [blame] | 2006 | if (__s.__current_ == __s.__last_ && | 
|  | 2007 | !(__s.__flags_ & regex_constants::match_not_eol)) | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2008 | { | 
|  | 2009 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 2010 | __s.__node_ = this->first(); | 
|  | 2011 | } | 
|  | 2012 | else | 
|  | 2013 | { | 
|  | 2014 | __s.__do_ = __state::__reject; | 
|  | 2015 | __s.__node_ = nullptr; | 
|  | 2016 | } | 
|  | 2017 | } | 
|  | 2018 |  | 
|  | 2019 | // __match_any | 
|  | 2020 |  | 
|  | 2021 | template <class _CharT> | 
|  | 2022 | class __match_any | 
|  | 2023 | : public __owns_one_state<_CharT> | 
|  | 2024 | { | 
|  | 2025 | typedef __owns_one_state<_CharT> base; | 
|  | 2026 |  | 
|  | 2027 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2028 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2029 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2030 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2031 | __match_any(__node<_CharT>* __s) | 
|  | 2032 | : base(__s) {} | 
|  | 2033 |  | 
|  | 2034 | virtual void __exec(__state&) const; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2035 | }; | 
|  | 2036 |  | 
|  | 2037 | template <class _CharT> | 
|  | 2038 | void | 
|  | 2039 | __match_any<_CharT>::__exec(__state& __s) const | 
|  | 2040 | { | 
|  | 2041 | if (__s.__current_ != __s.__last_ && *__s.__current_ != 0) | 
|  | 2042 | { | 
|  | 2043 | __s.__do_ = __state::__accept_and_consume; | 
|  | 2044 | ++__s.__current_; | 
|  | 2045 | __s.__node_ = this->first(); | 
|  | 2046 | } | 
|  | 2047 | else | 
|  | 2048 | { | 
|  | 2049 | __s.__do_ = __state::__reject; | 
|  | 2050 | __s.__node_ = nullptr; | 
|  | 2051 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2052 | } | 
|  | 2053 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2054 | // __match_any_but_newline | 
|  | 2055 |  | 
|  | 2056 | template <class _CharT> | 
|  | 2057 | class __match_any_but_newline | 
|  | 2058 | : public __owns_one_state<_CharT> | 
|  | 2059 | { | 
|  | 2060 | typedef __owns_one_state<_CharT> base; | 
|  | 2061 |  | 
|  | 2062 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2063 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2064 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2065 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2066 | __match_any_but_newline(__node<_CharT>* __s) | 
|  | 2067 | : base(__s) {} | 
|  | 2068 |  | 
|  | 2069 | virtual void __exec(__state&) const; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2070 | }; | 
|  | 2071 |  | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 | [diff] [blame] | 2072 | template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const; | 
|  | 2073 | template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<wchar_t>::__exec(__state&) const; | 
|  | 2074 |  | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2075 | // __match_char | 
|  | 2076 |  | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2077 | template <class _CharT> | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2078 | class __match_char | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2079 | : public __owns_one_state<_CharT> | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2080 | { | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2081 | typedef __owns_one_state<_CharT> base; | 
|  | 2082 |  | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2083 | _CharT __c_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2084 |  | 
|  | 2085 | __match_char(const __match_char&); | 
|  | 2086 | __match_char& operator=(const __match_char&); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2087 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2088 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2089 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2090 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2091 | __match_char(_CharT __c, __node<_CharT>* __s) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2092 | : base(__s), __c_(__c) {} | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2093 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2094 | virtual void __exec(__state&) const; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2095 | }; | 
|  | 2096 |  | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2097 | template <class _CharT> | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2098 | void | 
|  | 2099 | __match_char<_CharT>::__exec(__state& __s) const | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2100 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2101 | if (__s.__current_ != __s.__last_ && *__s.__current_ == __c_) | 
|  | 2102 | { | 
|  | 2103 | __s.__do_ = __state::__accept_and_consume; | 
|  | 2104 | ++__s.__current_; | 
|  | 2105 | __s.__node_ = this->first(); | 
|  | 2106 | } | 
|  | 2107 | else | 
|  | 2108 | { | 
|  | 2109 | __s.__do_ = __state::__reject; | 
|  | 2110 | __s.__node_ = nullptr; | 
|  | 2111 | } | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2112 | } | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2113 |  | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2114 | // __match_char_icase | 
|  | 2115 |  | 
|  | 2116 | template <class _CharT, class _Traits> | 
|  | 2117 | class __match_char_icase | 
|  | 2118 | : public __owns_one_state<_CharT> | 
|  | 2119 | { | 
|  | 2120 | typedef __owns_one_state<_CharT> base; | 
|  | 2121 |  | 
|  | 2122 | _Traits __traits_; | 
|  | 2123 | _CharT __c_; | 
|  | 2124 |  | 
|  | 2125 | __match_char_icase(const __match_char_icase&); | 
|  | 2126 | __match_char_icase& operator=(const __match_char_icase&); | 
|  | 2127 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2128 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2129 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2130 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2131 | __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s) | 
|  | 2132 | : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {} | 
|  | 2133 |  | 
|  | 2134 | virtual void __exec(__state&) const; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2135 | }; | 
|  | 2136 |  | 
|  | 2137 | template <class _CharT, class _Traits> | 
|  | 2138 | void | 
|  | 2139 | __match_char_icase<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 2140 | { | 
|  | 2141 | if (__s.__current_ != __s.__last_ && | 
|  | 2142 | __traits_.translate_nocase(*__s.__current_) == __c_) | 
|  | 2143 | { | 
|  | 2144 | __s.__do_ = __state::__accept_and_consume; | 
|  | 2145 | ++__s.__current_; | 
|  | 2146 | __s.__node_ = this->first(); | 
|  | 2147 | } | 
|  | 2148 | else | 
|  | 2149 | { | 
|  | 2150 | __s.__do_ = __state::__reject; | 
|  | 2151 | __s.__node_ = nullptr; | 
|  | 2152 | } | 
|  | 2153 | } | 
|  | 2154 |  | 
|  | 2155 | // __match_char_collate | 
|  | 2156 |  | 
|  | 2157 | template <class _CharT, class _Traits> | 
|  | 2158 | class __match_char_collate | 
|  | 2159 | : public __owns_one_state<_CharT> | 
|  | 2160 | { | 
|  | 2161 | typedef __owns_one_state<_CharT> base; | 
|  | 2162 |  | 
|  | 2163 | _Traits __traits_; | 
|  | 2164 | _CharT __c_; | 
|  | 2165 |  | 
|  | 2166 | __match_char_collate(const __match_char_collate&); | 
|  | 2167 | __match_char_collate& operator=(const __match_char_collate&); | 
|  | 2168 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2169 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2170 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2171 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2172 | __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s) | 
|  | 2173 | : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {} | 
|  | 2174 |  | 
|  | 2175 | virtual void __exec(__state&) const; | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 2176 | }; | 
|  | 2177 |  | 
|  | 2178 | template <class _CharT, class _Traits> | 
|  | 2179 | void | 
|  | 2180 | __match_char_collate<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 2181 | { | 
|  | 2182 | if (__s.__current_ != __s.__last_ && | 
|  | 2183 | __traits_.translate(*__s.__current_) == __c_) | 
|  | 2184 | { | 
|  | 2185 | __s.__do_ = __state::__accept_and_consume; | 
|  | 2186 | ++__s.__current_; | 
|  | 2187 | __s.__node_ = this->first(); | 
|  | 2188 | } | 
|  | 2189 | else | 
|  | 2190 | { | 
|  | 2191 | __s.__do_ = __state::__reject; | 
|  | 2192 | __s.__node_ = nullptr; | 
|  | 2193 | } | 
|  | 2194 | } | 
|  | 2195 |  | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2196 | // __bracket_expression | 
|  | 2197 |  | 
|  | 2198 | template <class _CharT, class _Traits> | 
|  | 2199 | class __bracket_expression | 
|  | 2200 | : public __owns_one_state<_CharT> | 
|  | 2201 | { | 
|  | 2202 | typedef __owns_one_state<_CharT> base; | 
|  | 2203 | typedef typename _Traits::string_type string_type; | 
|  | 2204 |  | 
|  | 2205 | _Traits __traits_; | 
|  | 2206 | vector<_CharT> __chars_; | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2207 | vector<_CharT> __neg_chars_; | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2208 | vector<pair<string_type, string_type> > __ranges_; | 
|  | 2209 | vector<pair<_CharT, _CharT> > __digraphs_; | 
|  | 2210 | vector<string_type> __equivalences_; | 
| Dan Albert | 1757386 | 2014-07-29 19:23:39 | [diff] [blame] | 2211 | typename regex_traits<_CharT>::char_class_type __mask_; | 
|  | 2212 | typename regex_traits<_CharT>::char_class_type __neg_mask_; | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2213 | bool __negate_; | 
|  | 2214 | bool __icase_; | 
|  | 2215 | bool __collate_; | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2216 | bool __might_have_digraph_; | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2217 |  | 
|  | 2218 | __bracket_expression(const __bracket_expression&); | 
|  | 2219 | __bracket_expression& operator=(const __bracket_expression&); | 
|  | 2220 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2221 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2222 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2223 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2224 | __bracket_expression(const _Traits& __traits, __node<_CharT>* __s, | 
|  | 2225 | bool __negate, bool __icase, bool __collate) | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2226 | : base(__s), __traits_(__traits), __mask_(), __neg_mask_(), | 
|  | 2227 | __negate_(__negate), __icase_(__icase), __collate_(__collate), | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2228 | __might_have_digraph_(__traits_.getloc().name() != "C") {} | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2229 |  | 
|  | 2230 | virtual void __exec(__state&) const; | 
|  | 2231 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2232 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2233 | bool __negated() const {return __negate_;} | 
|  | 2234 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2235 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2236 | void __add_char(_CharT __c) | 
|  | 2237 | { | 
|  | 2238 | if (__icase_) | 
|  | 2239 | __chars_.push_back(__traits_.translate_nocase(__c)); | 
|  | 2240 | else if (__collate_) | 
|  | 2241 | __chars_.push_back(__traits_.translate(__c)); | 
|  | 2242 | else | 
|  | 2243 | __chars_.push_back(__c); | 
|  | 2244 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2245 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2246 | void __add_neg_char(_CharT __c) | 
|  | 2247 | { | 
|  | 2248 | if (__icase_) | 
|  | 2249 | __neg_chars_.push_back(__traits_.translate_nocase(__c)); | 
|  | 2250 | else if (__collate_) | 
|  | 2251 | __neg_chars_.push_back(__traits_.translate(__c)); | 
|  | 2252 | else | 
|  | 2253 | __neg_chars_.push_back(__c); | 
|  | 2254 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2255 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2256 | void __add_range(string_type __b, string_type __e) | 
|  | 2257 | { | 
|  | 2258 | if (__collate_) | 
|  | 2259 | { | 
|  | 2260 | if (__icase_) | 
|  | 2261 | { | 
|  | 2262 | for (size_t __i = 0; __i < __b.size(); ++__i) | 
|  | 2263 | __b[__i] = __traits_.translate_nocase(__b[__i]); | 
|  | 2264 | for (size_t __i = 0; __i < __e.size(); ++__i) | 
|  | 2265 | __e[__i] = __traits_.translate_nocase(__e[__i]); | 
|  | 2266 | } | 
|  | 2267 | else | 
|  | 2268 | { | 
|  | 2269 | for (size_t __i = 0; __i < __b.size(); ++__i) | 
|  | 2270 | __b[__i] = __traits_.translate(__b[__i]); | 
|  | 2271 | for (size_t __i = 0; __i < __e.size(); ++__i) | 
|  | 2272 | __e[__i] = __traits_.translate(__e[__i]); | 
|  | 2273 | } | 
|  | 2274 | __ranges_.push_back(make_pair( | 
|  | 2275 | __traits_.transform(__b.begin(), __b.end()), | 
|  | 2276 | __traits_.transform(__e.begin(), __e.end()))); | 
|  | 2277 | } | 
|  | 2278 | else | 
|  | 2279 | { | 
|  | 2280 | if (__b.size() != 1 || __e.size() != 1) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 2281 | __throw_regex_error<regex_constants::error_collate>(); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2282 | if (__icase_) | 
|  | 2283 | { | 
|  | 2284 | __b[0] = __traits_.translate_nocase(__b[0]); | 
|  | 2285 | __e[0] = __traits_.translate_nocase(__e[0]); | 
|  | 2286 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2287 | __ranges_.push_back(make_pair(_VSTD::move(__b), _VSTD::move(__e))); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2288 | } | 
|  | 2289 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2290 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2291 | void __add_digraph(_CharT __c1, _CharT __c2) | 
|  | 2292 | { | 
|  | 2293 | if (__icase_) | 
|  | 2294 | __digraphs_.push_back(make_pair(__traits_.translate_nocase(__c1), | 
|  | 2295 | __traits_.translate_nocase(__c2))); | 
|  | 2296 | else if (__collate_) | 
|  | 2297 | __digraphs_.push_back(make_pair(__traits_.translate(__c1), | 
|  | 2298 | __traits_.translate(__c2))); | 
|  | 2299 | else | 
|  | 2300 | __digraphs_.push_back(make_pair(__c1, __c2)); | 
|  | 2301 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2302 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2303 | void __add_equivalence(const string_type& __s) | 
|  | 2304 | {__equivalences_.push_back(__s);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2305 | _LIBCPP_INLINE_VISIBILITY | 
| Dan Albert | 1757386 | 2014-07-29 19:23:39 | [diff] [blame] | 2306 | void __add_class(typename regex_traits<_CharT>::char_class_type __mask) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2307 | {__mask_ |= __mask;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2308 | _LIBCPP_INLINE_VISIBILITY | 
| Dan Albert | 1757386 | 2014-07-29 19:23:39 | [diff] [blame] | 2309 | void __add_neg_class(typename regex_traits<_CharT>::char_class_type __mask) | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2310 | {__neg_mask_ |= __mask;} | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2311 | }; | 
|  | 2312 |  | 
|  | 2313 | template <class _CharT, class _Traits> | 
|  | 2314 | void | 
|  | 2315 | __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 2316 | { | 
|  | 2317 | bool __found = false; | 
|  | 2318 | unsigned __consumed = 0; | 
|  | 2319 | if (__s.__current_ != __s.__last_) | 
|  | 2320 | { | 
|  | 2321 | ++__consumed; | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2322 | if (__might_have_digraph_) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2323 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2324 | const _CharT* __next = _VSTD::next(__s.__current_); | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2325 | if (__next != __s.__last_) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2326 | { | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2327 | pair<_CharT, _CharT> __ch2(*__s.__current_, *__next); | 
|  | 2328 | if (__icase_) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2329 | { | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 2330 | __ch2.first = __traits_.translate_nocase(__ch2.first); | 
|  | 2331 | __ch2.second = __traits_.translate_nocase(__ch2.second); | 
|  | 2332 | } | 
|  | 2333 | else if (__collate_) | 
|  | 2334 | { | 
|  | 2335 | __ch2.first = __traits_.translate(__ch2.first); | 
|  | 2336 | __ch2.second = __traits_.translate(__ch2.second); | 
|  | 2337 | } | 
|  | 2338 | if (!__traits_.lookup_collatename(&__ch2.first, &__ch2.first+2).empty()) | 
|  | 2339 | { | 
|  | 2340 | // __ch2 is a digraph in this locale | 
|  | 2341 | ++__consumed; | 
|  | 2342 | for (size_t __i = 0; __i < __digraphs_.size(); ++__i) | 
|  | 2343 | { | 
|  | 2344 | if (__ch2 == __digraphs_[__i]) | 
|  | 2345 | { | 
|  | 2346 | __found = true; | 
|  | 2347 | goto __exit; | 
|  | 2348 | } | 
|  | 2349 | } | 
|  | 2350 | if (__collate_ && !__ranges_.empty()) | 
|  | 2351 | { | 
|  | 2352 | string_type __s2 = __traits_.transform(&__ch2.first, | 
|  | 2353 | &__ch2.first + 2); | 
|  | 2354 | for (size_t __i = 0; __i < __ranges_.size(); ++__i) | 
|  | 2355 | { | 
|  | 2356 | if (__ranges_[__i].first <= __s2 && | 
|  | 2357 | __s2 <= __ranges_[__i].second) | 
|  | 2358 | { | 
|  | 2359 | __found = true; | 
|  | 2360 | goto __exit; | 
|  | 2361 | } | 
|  | 2362 | } | 
|  | 2363 | } | 
|  | 2364 | if (!__equivalences_.empty()) | 
|  | 2365 | { | 
|  | 2366 | string_type __s2 = __traits_.transform_primary(&__ch2.first, | 
|  | 2367 | &__ch2.first + 2); | 
|  | 2368 | for (size_t __i = 0; __i < __equivalences_.size(); ++__i) | 
|  | 2369 | { | 
|  | 2370 | if (__s2 == __equivalences_[__i]) | 
|  | 2371 | { | 
|  | 2372 | __found = true; | 
|  | 2373 | goto __exit; | 
|  | 2374 | } | 
|  | 2375 | } | 
|  | 2376 | } | 
|  | 2377 | if (__traits_.isctype(__ch2.first, __mask_) && | 
|  | 2378 | __traits_.isctype(__ch2.second, __mask_)) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2379 | { | 
|  | 2380 | __found = true; | 
|  | 2381 | goto __exit; | 
|  | 2382 | } | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2383 | if (!__traits_.isctype(__ch2.first, __neg_mask_) && | 
|  | 2384 | !__traits_.isctype(__ch2.second, __neg_mask_)) | 
|  | 2385 | { | 
|  | 2386 | __found = true; | 
|  | 2387 | goto __exit; | 
|  | 2388 | } | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2389 | goto __exit; | 
|  | 2390 | } | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2391 | } | 
|  | 2392 | } | 
|  | 2393 | // test *__s.__current_ as not a digraph | 
|  | 2394 | _CharT __ch = *__s.__current_; | 
|  | 2395 | if (__icase_) | 
|  | 2396 | __ch = __traits_.translate_nocase(__ch); | 
|  | 2397 | else if (__collate_) | 
|  | 2398 | __ch = __traits_.translate(__ch); | 
|  | 2399 | for (size_t __i = 0; __i < __chars_.size(); ++__i) | 
|  | 2400 | { | 
|  | 2401 | if (__ch == __chars_[__i]) | 
|  | 2402 | { | 
|  | 2403 | __found = true; | 
|  | 2404 | goto __exit; | 
|  | 2405 | } | 
|  | 2406 | } | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2407 | if (!__neg_chars_.empty()) | 
|  | 2408 | { | 
|  | 2409 | for (size_t __i = 0; __i < __neg_chars_.size(); ++__i) | 
|  | 2410 | { | 
|  | 2411 | if (__ch == __neg_chars_[__i]) | 
|  | 2412 | goto __is_neg_char; | 
|  | 2413 | } | 
|  | 2414 | __found = true; | 
|  | 2415 | goto __exit; | 
|  | 2416 | } | 
|  | 2417 | __is_neg_char: | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2418 | if (!__ranges_.empty()) | 
|  | 2419 | { | 
|  | 2420 | string_type __s2 = __collate_ ? | 
|  | 2421 | __traits_.transform(&__ch, &__ch + 1) : | 
|  | 2422 | string_type(1, __ch); | 
|  | 2423 | for (size_t __i = 0; __i < __ranges_.size(); ++__i) | 
|  | 2424 | { | 
|  | 2425 | if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second) | 
|  | 2426 | { | 
|  | 2427 | __found = true; | 
|  | 2428 | goto __exit; | 
|  | 2429 | } | 
|  | 2430 | } | 
|  | 2431 | } | 
|  | 2432 | if (!__equivalences_.empty()) | 
|  | 2433 | { | 
|  | 2434 | string_type __s2 = __traits_.transform_primary(&__ch, &__ch + 1); | 
|  | 2435 | for (size_t __i = 0; __i < __equivalences_.size(); ++__i) | 
|  | 2436 | { | 
|  | 2437 | if (__s2 == __equivalences_[__i]) | 
|  | 2438 | { | 
|  | 2439 | __found = true; | 
|  | 2440 | goto __exit; | 
|  | 2441 | } | 
|  | 2442 | } | 
|  | 2443 | } | 
|  | 2444 | if (__traits_.isctype(__ch, __mask_)) | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2445 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2446 | __found = true; | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2447 | goto __exit; | 
|  | 2448 | } | 
|  | 2449 | if (__neg_mask_ && !__traits_.isctype(__ch, __neg_mask_)) | 
|  | 2450 | { | 
|  | 2451 | __found = true; | 
|  | 2452 | goto __exit; | 
|  | 2453 | } | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2454 | } | 
|  | 2455 | else | 
|  | 2456 | __found = __negate_; // force reject | 
|  | 2457 | __exit: | 
|  | 2458 | if (__found != __negate_) | 
|  | 2459 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2460 | __s.__do_ = __state::__accept_and_consume; | 
|  | 2461 | __s.__current_ += __consumed; | 
|  | 2462 | __s.__node_ = this->first(); | 
|  | 2463 | } | 
|  | 2464 | else | 
|  | 2465 | { | 
|  | 2466 | __s.__do_ = __state::__reject; | 
|  | 2467 | __s.__node_ = nullptr; | 
|  | 2468 | } | 
|  | 2469 | } | 
|  | 2470 |  | 
| Howard Hinnant | 2b1b2d4 | 2011-06-14 19:58:17 | [diff] [blame] | 2471 | template <class _CharT, class _Traits> class __lookahead; | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2472 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2473 | template <class _CharT, class _Traits = regex_traits<_CharT> > | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 | [diff] [blame] | 2474 | class _LIBCPP_TYPE_VIS_ONLY basic_regex | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2475 | { | 
|  | 2476 | public: | 
|  | 2477 | // types: | 
|  | 2478 | typedef _CharT value_type; | 
| Hubert Tong | b49c67f | 2016-08-02 21:34:48 | [diff] [blame] | 2479 | typedef _Traits traits_type; | 
|  | 2480 | typedef typename _Traits::string_type string_type; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2481 | typedef regex_constants::syntax_option_type flag_type; | 
|  | 2482 | typedef typename _Traits::locale_type locale_type; | 
|  | 2483 |  | 
|  | 2484 | private: | 
|  | 2485 | _Traits __traits_; | 
|  | 2486 | flag_type __flags_; | 
|  | 2487 | unsigned __marked_count_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2488 | unsigned __loop_count_; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2489 | int __open_count_; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2490 | shared_ptr<__empty_state<_CharT> > __start_; | 
|  | 2491 | __owns_one_state<_CharT>* __end_; | 
|  | 2492 |  | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2493 | typedef _VSTD::__state<_CharT> __state; | 
|  | 2494 | typedef _VSTD::__node<_CharT> __node; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2495 |  | 
|  | 2496 | public: | 
|  | 2497 | // constants: | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 2498 | static const regex_constants::syntax_option_type icase = regex_constants::icase; | 
|  | 2499 | static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs; | 
|  | 2500 | static const regex_constants::syntax_option_type optimize = regex_constants::optimize; | 
|  | 2501 | static const regex_constants::syntax_option_type collate = regex_constants::collate; | 
|  | 2502 | static const regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript; | 
|  | 2503 | static const regex_constants::syntax_option_type basic = regex_constants::basic; | 
|  | 2504 | static const regex_constants::syntax_option_type extended = regex_constants::extended; | 
|  | 2505 | static const regex_constants::syntax_option_type awk = regex_constants::awk; | 
|  | 2506 | static const regex_constants::syntax_option_type grep = regex_constants::grep; | 
|  | 2507 | static const regex_constants::syntax_option_type egrep = regex_constants::egrep; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2508 |  | 
|  | 2509 | // construct/copy/destroy: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2510 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2511 | basic_regex() | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2512 | : __flags_(), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2513 | __end_(0) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2514 | {} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2515 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2516 | explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2517 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2518 | __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2519 | {__parse(__p, __p + __traits_.length(__p));} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2520 | _LIBCPP_INLINE_VISIBILITY | 
| Hubert Tong | 7f6e8e2 | 2016-08-07 22:26:04 | [diff] [blame] | 2521 | basic_regex(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2522 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2523 | __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2524 | {__parse(__p, __p + __len);} | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2525 | // basic_regex(const basic_regex&) = default; | 
|  | 2526 | // basic_regex(basic_regex&&) = default; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2527 | template <class _ST, class _SA> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2528 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2529 | explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p, | 
|  | 2530 | flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2531 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2532 | __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2533 | {__parse(__p.begin(), __p.end());} | 
|  | 2534 | template <class _ForwardIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2535 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2536 | basic_regex(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2537 | flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2538 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2539 | __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2540 | {__parse(__first, __last);} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2541 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2542 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2543 | basic_regex(initializer_list<value_type> __il, | 
|  | 2544 | flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2545 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2546 | __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2547 | {__parse(__il.begin(), __il.end());} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2548 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2549 |  | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2550 | // ~basic_regex() = default; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2551 |  | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2552 | // basic_regex& operator=(const basic_regex&) = default; | 
|  | 2553 | // basic_regex& operator=(basic_regex&&) = default; | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2554 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2555 | basic_regex& operator=(const value_type* __p) | 
|  | 2556 | {return assign(__p);} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2557 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2558 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2559 | basic_regex& operator=(initializer_list<value_type> __il) | 
|  | 2560 | {return assign(__il);} | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2561 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2562 | template <class _ST, class _SA> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2563 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2564 | basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p) | 
|  | 2565 | {return assign(__p);} | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2566 |  | 
|  | 2567 | // assign: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2568 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2569 | basic_regex& assign(const basic_regex& __that) | 
|  | 2570 | {return *this = __that;} | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 2571 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES | 
|  | 2572 | _LIBCPP_INLINE_VISIBILITY | 
|  | 2573 | basic_regex& assign(basic_regex&& __that) _NOEXCEPT | 
|  | 2574 | {return *this = _VSTD::move(__that);} | 
|  | 2575 | #endif | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2576 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2577 | basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript) | 
|  | 2578 | {return assign(__p, __p + __traits_.length(__p), __f);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2579 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2580 | basic_regex& assign(const value_type* __p, size_t __len, flag_type __f) | 
|  | 2581 | {return assign(__p, __p + __len, __f);} | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2582 | template <class _ST, class _SA> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2583 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2584 | basic_regex& assign(const basic_string<value_type, _ST, _SA>& __s, | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2585 | flag_type __f = regex_constants::ECMAScript) | 
|  | 2586 | {return assign(__s.begin(), __s.end(), __f);} | 
|  | 2587 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2588 | template <class _InputIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2589 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2590 | typename enable_if | 
|  | 2591 | < | 
|  | 2592 | __is_input_iterator <_InputIterator>::value && | 
|  | 2593 | !__is_forward_iterator<_InputIterator>::value, | 
|  | 2594 | basic_regex& | 
|  | 2595 | >::type | 
|  | 2596 | assign(_InputIterator __first, _InputIterator __last, | 
|  | 2597 | flag_type __f = regex_constants::ECMAScript) | 
|  | 2598 | { | 
|  | 2599 | basic_string<_CharT> __t(__first, __last); | 
|  | 2600 | return assign(__t.begin(), __t.end(), __f); | 
|  | 2601 | } | 
|  | 2602 |  | 
|  | 2603 | private: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2604 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2605 | void __member_init(flag_type __f) | 
|  | 2606 | { | 
|  | 2607 | __flags_ = __f; | 
|  | 2608 | __marked_count_ = 0; | 
|  | 2609 | __loop_count_ = 0; | 
|  | 2610 | __open_count_ = 0; | 
|  | 2611 | __end_ = nullptr; | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2612 | } | 
|  | 2613 | public: | 
|  | 2614 |  | 
|  | 2615 | template <class _ForwardIterator> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2616 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2617 | typename enable_if | 
|  | 2618 | < | 
|  | 2619 | __is_forward_iterator<_ForwardIterator>::value, | 
|  | 2620 | basic_regex& | 
|  | 2621 | >::type | 
|  | 2622 | assign(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2623 | flag_type __f = regex_constants::ECMAScript) | 
|  | 2624 | { | 
| Marshall Clow | 083e011 | 2015-01-13 16:49:52 | [diff] [blame] | 2625 | return assign(basic_regex(__first, __last, __f)); | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2626 | } | 
|  | 2627 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2628 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 2629 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2630 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2631 | basic_regex& assign(initializer_list<value_type> __il, | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2632 | flag_type __f = regex_constants::ECMAScript) | 
|  | 2633 | {return assign(__il.begin(), __il.end(), __f);} | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2634 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 2635 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 2636 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2637 | // const operations: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2638 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2639 | unsigned mark_count() const {return __marked_count_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2640 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2641 | flag_type flags() const {return __flags_;} | 
|  | 2642 |  | 
|  | 2643 | // locale: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2644 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2645 | locale_type imbue(locale_type __loc) | 
|  | 2646 | { | 
|  | 2647 | __member_init(ECMAScript); | 
|  | 2648 | __start_.reset(); | 
|  | 2649 | return __traits_.imbue(__loc); | 
|  | 2650 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2651 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2652 | locale_type getloc() const {return __traits_.getloc();} | 
|  | 2653 |  | 
|  | 2654 | // swap: | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2655 | void swap(basic_regex& __r); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2656 |  | 
|  | 2657 | private: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2658 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2659 | unsigned __loop_count() const {return __loop_count_;} | 
|  | 2660 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2661 | template <class _ForwardIterator> | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2662 | _ForwardIterator | 
|  | 2663 | __parse(_ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2664 | template <class _ForwardIterator> | 
|  | 2665 | _ForwardIterator | 
|  | 2666 | __parse_basic_reg_exp(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2667 | template <class _ForwardIterator> | 
|  | 2668 | _ForwardIterator | 
|  | 2669 | __parse_RE_expression(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2670 | template <class _ForwardIterator> | 
|  | 2671 | _ForwardIterator | 
|  | 2672 | __parse_simple_RE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2673 | template <class _ForwardIterator> | 
|  | 2674 | _ForwardIterator | 
|  | 2675 | __parse_nondupl_RE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2676 | template <class _ForwardIterator> | 
|  | 2677 | _ForwardIterator | 
|  | 2678 | __parse_one_char_or_coll_elem_RE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2679 | template <class _ForwardIterator> | 
|  | 2680 | _ForwardIterator | 
|  | 2681 | __parse_Back_open_paren(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2682 | template <class _ForwardIterator> | 
|  | 2683 | _ForwardIterator | 
|  | 2684 | __parse_Back_close_paren(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2685 | template <class _ForwardIterator> | 
|  | 2686 | _ForwardIterator | 
|  | 2687 | __parse_Back_open_brace(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2688 | template <class _ForwardIterator> | 
|  | 2689 | _ForwardIterator | 
|  | 2690 | __parse_Back_close_brace(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2691 | template <class _ForwardIterator> | 
|  | 2692 | _ForwardIterator | 
|  | 2693 | __parse_BACKREF(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2694 | template <class _ForwardIterator> | 
|  | 2695 | _ForwardIterator | 
|  | 2696 | __parse_ORD_CHAR(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2697 | template <class _ForwardIterator> | 
|  | 2698 | _ForwardIterator | 
|  | 2699 | __parse_QUOTED_CHAR(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2700 | template <class _ForwardIterator> | 
|  | 2701 | _ForwardIterator | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2702 | __parse_RE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last, | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 2703 | __owns_one_state<_CharT>* __s, | 
|  | 2704 | unsigned __mexp_begin, unsigned __mexp_end); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2705 | template <class _ForwardIterator> | 
|  | 2706 | _ForwardIterator | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 2707 | __parse_ERE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2708 | __owns_one_state<_CharT>* __s, | 
|  | 2709 | unsigned __mexp_begin, unsigned __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2710 | template <class _ForwardIterator> | 
|  | 2711 | _ForwardIterator | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2712 | __parse_bracket_expression(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2713 | template <class _ForwardIterator> | 
|  | 2714 | _ForwardIterator | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2715 | __parse_follow_list(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2716 | __bracket_expression<_CharT, _Traits>* __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2717 | template <class _ForwardIterator> | 
|  | 2718 | _ForwardIterator | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2719 | __parse_expression_term(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2720 | __bracket_expression<_CharT, _Traits>* __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2721 | template <class _ForwardIterator> | 
|  | 2722 | _ForwardIterator | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2723 | __parse_equivalence_class(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2724 | __bracket_expression<_CharT, _Traits>* __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2725 | template <class _ForwardIterator> | 
|  | 2726 | _ForwardIterator | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2727 | __parse_character_class(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2728 | __bracket_expression<_CharT, _Traits>* __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2729 | template <class _ForwardIterator> | 
|  | 2730 | _ForwardIterator | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2731 | __parse_collating_symbol(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2732 | basic_string<_CharT>& __col_sym); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2733 | template <class _ForwardIterator> | 
|  | 2734 | _ForwardIterator | 
|  | 2735 | __parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2736 | template <class _ForwardIterator> | 
|  | 2737 | _ForwardIterator | 
|  | 2738 | __parse_extended_reg_exp(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2739 | template <class _ForwardIterator> | 
|  | 2740 | _ForwardIterator | 
|  | 2741 | __parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2742 | template <class _ForwardIterator> | 
|  | 2743 | _ForwardIterator | 
|  | 2744 | __parse_ERE_expression(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2745 | template <class _ForwardIterator> | 
|  | 2746 | _ForwardIterator | 
|  | 2747 | __parse_one_char_or_coll_elem_ERE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2748 | template <class _ForwardIterator> | 
|  | 2749 | _ForwardIterator | 
|  | 2750 | __parse_ORD_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2751 | template <class _ForwardIterator> | 
|  | 2752 | _ForwardIterator | 
|  | 2753 | __parse_QUOTED_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 2754 | template <class _ForwardIterator> | 
|  | 2755 | _ForwardIterator | 
|  | 2756 | __parse_ecma_exp(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2757 | template <class _ForwardIterator> | 
|  | 2758 | _ForwardIterator | 
|  | 2759 | __parse_alternative(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2760 | template <class _ForwardIterator> | 
|  | 2761 | _ForwardIterator | 
|  | 2762 | __parse_term(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2763 | template <class _ForwardIterator> | 
|  | 2764 | _ForwardIterator | 
|  | 2765 | __parse_assertion(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2766 | template <class _ForwardIterator> | 
|  | 2767 | _ForwardIterator | 
|  | 2768 | __parse_atom(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2769 | template <class _ForwardIterator> | 
|  | 2770 | _ForwardIterator | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2771 | __parse_atom_escape(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2772 | template <class _ForwardIterator> | 
|  | 2773 | _ForwardIterator | 
|  | 2774 | __parse_decimal_escape(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2775 | template <class _ForwardIterator> | 
|  | 2776 | _ForwardIterator | 
|  | 2777 | __parse_character_class_escape(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2778 | template <class _ForwardIterator> | 
|  | 2779 | _ForwardIterator | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2780 | __parse_character_escape(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2781 | basic_string<_CharT>* __str = nullptr); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2782 | template <class _ForwardIterator> | 
|  | 2783 | _ForwardIterator | 
|  | 2784 | __parse_pattern_character(_ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 2785 | template <class _ForwardIterator> | 
|  | 2786 | _ForwardIterator | 
|  | 2787 | __parse_grep(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 2788 | template <class _ForwardIterator> | 
|  | 2789 | _ForwardIterator | 
|  | 2790 | __parse_egrep(_ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 2791 | template <class _ForwardIterator> | 
|  | 2792 | _ForwardIterator | 
|  | 2793 | __parse_class_escape(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2794 | basic_string<_CharT>& __str, | 
|  | 2795 | __bracket_expression<_CharT, _Traits>* __ml); | 
|  | 2796 | template <class _ForwardIterator> | 
|  | 2797 | _ForwardIterator | 
|  | 2798 | __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 2799 | basic_string<_CharT>* __str = nullptr); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2800 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2801 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2802 | void __push_l_anchor(); | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 2803 | void __push_r_anchor(); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 2804 | void __push_match_any(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2805 | void __push_match_any_but_newline(); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2806 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 2807 | void __push_greedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s, | 
|  | 2808 | unsigned __mexp_begin = 0, unsigned __mexp_end = 0) | 
|  | 2809 | {__push_loop(__min, numeric_limits<size_t>::max(), __s, | 
|  | 2810 | __mexp_begin, __mexp_end);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2811 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2812 | void __push_nongreedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s, | 
|  | 2813 | unsigned __mexp_begin = 0, unsigned __mexp_end = 0) | 
|  | 2814 | {__push_loop(__min, numeric_limits<size_t>::max(), __s, | 
|  | 2815 | __mexp_begin, __mexp_end, false);} | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2816 | void __push_loop(size_t __min, size_t __max, __owns_one_state<_CharT>* __s, | 
|  | 2817 | size_t __mexp_begin = 0, size_t __mexp_end = 0, | 
|  | 2818 | bool __greedy = true); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 2819 | __bracket_expression<_CharT, _Traits>* __start_matching_list(bool __negate); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 2820 | void __push_char(value_type __c); | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 2821 | void __push_back_ref(int __i); | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 2822 | void __push_alternation(__owns_one_state<_CharT>* __sa, | 
|  | 2823 | __owns_one_state<_CharT>* __sb); | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 2824 | void __push_begin_marked_subexpression(); | 
|  | 2825 | void __push_end_marked_subexpression(unsigned); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 2826 | void __push_empty(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2827 | void __push_word_boundary(bool); | 
| Howard Hinnant | cd59acc | 2013-07-23 16:18:04 | [diff] [blame] | 2828 | void __push_lookahead(const basic_regex&, bool, unsigned); | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2829 |  | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2830 | template <class _Allocator> | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2831 | bool | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2832 | __search(const _CharT* __first, const _CharT* __last, | 
|  | 2833 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2834 | regex_constants::match_flag_type __flags) const; | 
|  | 2835 |  | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2836 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2837 | bool | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2838 | __match_at_start(const _CharT* __first, const _CharT* __last, | 
|  | 2839 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2840 | regex_constants::match_flag_type __flags, bool) const; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2841 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2842 | bool | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 2843 | __match_at_start_ecma(const _CharT* __first, const _CharT* __last, | 
|  | 2844 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2845 | regex_constants::match_flag_type __flags, bool) const; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2846 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2847 | bool | 
|  | 2848 | __match_at_start_posix_nosubs(const _CharT* __first, const _CharT* __last, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2849 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2850 | regex_constants::match_flag_type __flags, bool) const; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2851 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2852 | bool | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2853 | __match_at_start_posix_subs(const _CharT* __first, const _CharT* __last, | 
|  | 2854 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2855 | regex_constants::match_flag_type __flags, bool) const; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2856 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2857 | template <class _Bp, class _Ap, class _Cp, class _Tp> | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2858 | friend | 
|  | 2859 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2860 | regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&, | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 2861 | regex_constants::match_flag_type); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2862 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2863 | template <class _Ap, class _Cp, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2864 | friend | 
|  | 2865 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2866 | regex_search(const _Cp*, const _Cp*, match_results<const _Cp*, _Ap>&, | 
|  | 2867 | const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2868 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2869 | template <class _Bp, class _Cp, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2870 | friend | 
|  | 2871 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2872 | regex_search(_Bp, _Bp, const basic_regex<_Cp, _Tp>&, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2873 | regex_constants::match_flag_type); | 
|  | 2874 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2875 | template <class _Cp, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2876 | friend | 
|  | 2877 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2878 | regex_search(const _Cp*, const _Cp*, | 
|  | 2879 | const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2880 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2881 | template <class _Cp, class _Ap, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2882 | friend | 
|  | 2883 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2884 | regex_search(const _Cp*, match_results<const _Cp*, _Ap>&, const basic_regex<_Cp, _Tp>&, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2885 | regex_constants::match_flag_type); | 
|  | 2886 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2887 | template <class _ST, class _SA, class _Cp, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2888 | friend | 
|  | 2889 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2890 | regex_search(const basic_string<_Cp, _ST, _SA>& __s, | 
|  | 2891 | const basic_regex<_Cp, _Tp>& __e, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2892 | regex_constants::match_flag_type __flags); | 
|  | 2893 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2894 | template <class _ST, class _SA, class _Ap, class _Cp, class _Tp> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2895 | friend | 
|  | 2896 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 2897 | regex_search(const basic_string<_Cp, _ST, _SA>& __s, | 
|  | 2898 | match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&, | 
|  | 2899 | const basic_regex<_Cp, _Tp>& __e, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 2900 | regex_constants::match_flag_type __flags); | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2901 |  | 
| Howard Hinnant | a9602d5 | 2013-06-29 23:45:43 | [diff] [blame] | 2902 | template <class _Iter, class _Ap, class _Cp, class _Tp> | 
|  | 2903 | friend | 
|  | 2904 | bool | 
|  | 2905 | regex_search(__wrap_iter<_Iter> __first, | 
|  | 2906 | __wrap_iter<_Iter> __last, | 
|  | 2907 | match_results<__wrap_iter<_Iter>, _Ap>& __m, | 
|  | 2908 | const basic_regex<_Cp, _Tp>& __e, | 
|  | 2909 | regex_constants::match_flag_type __flags); | 
|  | 2910 |  | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2911 | template <class, class> friend class __lookahead; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 2912 | }; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2913 |  | 
|  | 2914 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 0a69fa1 | 2012-12-12 21:14:28 | [diff] [blame] | 2915 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase; | 
|  | 2916 | template <class _CharT, class _Traits> | 
|  | 2917 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::nosubs; | 
|  | 2918 | template <class _CharT, class _Traits> | 
|  | 2919 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::optimize; | 
|  | 2920 | template <class _CharT, class _Traits> | 
|  | 2921 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::collate; | 
|  | 2922 | template <class _CharT, class _Traits> | 
|  | 2923 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::ECMAScript; | 
|  | 2924 | template <class _CharT, class _Traits> | 
|  | 2925 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::basic; | 
|  | 2926 | template <class _CharT, class _Traits> | 
|  | 2927 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::extended; | 
|  | 2928 | template <class _CharT, class _Traits> | 
|  | 2929 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::awk; | 
|  | 2930 | template <class _CharT, class _Traits> | 
|  | 2931 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::grep; | 
|  | 2932 | template <class _CharT, class _Traits> | 
|  | 2933 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::egrep; | 
|  | 2934 |  | 
|  | 2935 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2936 | void | 
|  | 2937 | basic_regex<_CharT, _Traits>::swap(basic_regex& __r) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2938 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2939 | using _VSTD::swap; | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2940 | swap(__traits_, __r.__traits_); | 
|  | 2941 | swap(__flags_, __r.__flags_); | 
|  | 2942 | swap(__marked_count_, __r.__marked_count_); | 
|  | 2943 | swap(__loop_count_, __r.__loop_count_); | 
|  | 2944 | swap(__open_count_, __r.__open_count_); | 
|  | 2945 | swap(__start_, __r.__start_); | 
|  | 2946 | swap(__end_, __r.__end_); | 
| Howard Hinnant | 7026a17 | 2010-08-13 18:11:23 | [diff] [blame] | 2947 | } | 
|  | 2948 |  | 
|  | 2949 | template <class _CharT, class _Traits> | 
|  | 2950 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2951 | void | 
|  | 2952 | swap(basic_regex<_CharT, _Traits>& __x, basic_regex<_CharT, _Traits>& __y) | 
|  | 2953 | { | 
|  | 2954 | return __x.swap(__y); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2955 | } | 
|  | 2956 |  | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2957 | // __lookahead | 
|  | 2958 |  | 
|  | 2959 | template <class _CharT, class _Traits> | 
|  | 2960 | class __lookahead | 
|  | 2961 | : public __owns_one_state<_CharT> | 
|  | 2962 | { | 
|  | 2963 | typedef __owns_one_state<_CharT> base; | 
|  | 2964 |  | 
|  | 2965 | basic_regex<_CharT, _Traits> __exp_; | 
| Howard Hinnant | cd59acc | 2013-07-23 16:18:04 | [diff] [blame] | 2966 | unsigned __mexp_; | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2967 | bool __invert_; | 
|  | 2968 |  | 
|  | 2969 | __lookahead(const __lookahead&); | 
|  | 2970 | __lookahead& operator=(const __lookahead&); | 
|  | 2971 | public: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 2972 | typedef _VSTD::__state<_CharT> __state; | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2973 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 2974 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd59acc | 2013-07-23 16:18:04 | [diff] [blame] | 2975 | __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp) | 
| Eric Fiselier | 7cc7106 | 2015-07-22 01:29:41 | [diff] [blame] | 2976 | : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {} | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2977 |  | 
|  | 2978 | virtual void __exec(__state&) const; | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2979 | }; | 
|  | 2980 |  | 
|  | 2981 | template <class _CharT, class _Traits> | 
|  | 2982 | void | 
|  | 2983 | __lookahead<_CharT, _Traits>::__exec(__state& __s) const | 
|  | 2984 | { | 
|  | 2985 | match_results<const _CharT*> __m; | 
|  | 2986 | __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_); | 
|  | 2987 | bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 2988 | __m, | 
|  | 2989 | __s.__flags_ | regex_constants::match_continuous, | 
| Howard Hinnant | e57b7c4 | 2013-06-28 19:11:23 | [diff] [blame] | 2990 | __s.__at_first_ && __s.__current_ == __s.__first_); | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2991 | if (__matched != __invert_) | 
|  | 2992 | { | 
|  | 2993 | __s.__do_ = __state::__accept_but_not_consume; | 
|  | 2994 | __s.__node_ = this->first(); | 
| Howard Hinnant | cd59acc | 2013-07-23 16:18:04 | [diff] [blame] | 2995 | for (unsigned __i = 1; __i < __m.size(); ++__i) { | 
|  | 2996 | __s.__sub_matches_[__mexp_ + __i - 1] = __m.__matches_[__i]; | 
|  | 2997 | } | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 2998 | } | 
|  | 2999 | else | 
|  | 3000 | { | 
|  | 3001 | __s.__do_ = __state::__reject; | 
|  | 3002 | __s.__node_ = nullptr; | 
|  | 3003 | } | 
|  | 3004 | } | 
|  | 3005 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3006 | template <class _CharT, class _Traits> | 
|  | 3007 | template <class _ForwardIterator> | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 3008 | _ForwardIterator | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3009 | basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first, | 
|  | 3010 | _ForwardIterator __last) | 
|  | 3011 | { | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 3012 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 3013 | unique_ptr<__node> __h(new __end_state<_CharT>); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 3014 | __start_.reset(new __empty_state<_CharT>(__h.get())); | 
|  | 3015 | __h.release(); | 
|  | 3016 | __end_ = __start_.get(); | 
|  | 3017 | } | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 3018 | switch (__flags_ & 0x1F0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3019 | { | 
|  | 3020 | case ECMAScript: | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 3021 | __first = __parse_ecma_exp(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3022 | break; | 
|  | 3023 | case basic: | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 3024 | __first = __parse_basic_reg_exp(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3025 | break; | 
|  | 3026 | case extended: | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3027 | case awk: | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3028 | __first = __parse_extended_reg_exp(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3029 | break; | 
|  | 3030 | case grep: | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 3031 | __first = __parse_grep(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3032 | break; | 
|  | 3033 | case egrep: | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 3034 | __first = __parse_egrep(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3035 | break; | 
|  | 3036 | default: | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3037 | __throw_regex_error<regex_constants::__re_err_grammar>(); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3038 | } | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 3039 | return __first; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3040 | } | 
|  | 3041 |  | 
|  | 3042 | template <class _CharT, class _Traits> | 
|  | 3043 | template <class _ForwardIterator> | 
|  | 3044 | _ForwardIterator | 
|  | 3045 | basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first, | 
|  | 3046 | _ForwardIterator __last) | 
|  | 3047 | { | 
|  | 3048 | if (__first != __last) | 
|  | 3049 | { | 
|  | 3050 | if (*__first == '^') | 
|  | 3051 | { | 
|  | 3052 | __push_l_anchor(); | 
|  | 3053 | ++__first; | 
|  | 3054 | } | 
|  | 3055 | if (__first != __last) | 
|  | 3056 | { | 
|  | 3057 | __first = __parse_RE_expression(__first, __last); | 
|  | 3058 | if (__first != __last) | 
|  | 3059 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3060 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3061 | if (__temp == __last && *__first == '$') | 
|  | 3062 | { | 
|  | 3063 | __push_r_anchor(); | 
|  | 3064 | ++__first; | 
|  | 3065 | } | 
|  | 3066 | } | 
|  | 3067 | } | 
|  | 3068 | if (__first != __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3069 | __throw_regex_error<regex_constants::__re_err_empty>(); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3070 | } | 
|  | 3071 | return __first; | 
|  | 3072 | } | 
|  | 3073 |  | 
|  | 3074 | template <class _CharT, class _Traits> | 
|  | 3075 | template <class _ForwardIterator> | 
|  | 3076 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3077 | basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first, | 
|  | 3078 | _ForwardIterator __last) | 
|  | 3079 | { | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3080 | __owns_one_state<_CharT>* __sa = __end_; | 
|  | 3081 | _ForwardIterator __temp = __parse_ERE_branch(__first, __last); | 
|  | 3082 | if (__temp == __first) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3083 | __throw_regex_error<regex_constants::__re_err_empty>(); | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3084 | __first = __temp; | 
|  | 3085 | while (__first != __last && *__first == '|') | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3086 | { | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3087 | __owns_one_state<_CharT>* __sb = __end_; | 
|  | 3088 | __temp = __parse_ERE_branch(++__first, __last); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3089 | if (__temp == __first) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3090 | __throw_regex_error<regex_constants::__re_err_empty>(); | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3091 | __push_alternation(__sa, __sb); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3092 | __first = __temp; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3093 | } | 
|  | 3094 | return __first; | 
|  | 3095 | } | 
|  | 3096 |  | 
|  | 3097 | template <class _CharT, class _Traits> | 
|  | 3098 | template <class _ForwardIterator> | 
|  | 3099 | _ForwardIterator | 
|  | 3100 | basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first, | 
|  | 3101 | _ForwardIterator __last) | 
|  | 3102 | { | 
|  | 3103 | _ForwardIterator __temp = __parse_ERE_expression(__first, __last); | 
|  | 3104 | if (__temp == __first) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3105 | __throw_regex_error<regex_constants::__re_err_empty>(); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3106 | do | 
|  | 3107 | { | 
|  | 3108 | __first = __temp; | 
|  | 3109 | __temp = __parse_ERE_expression(__first, __last); | 
|  | 3110 | } while (__temp != __first); | 
|  | 3111 | return __first; | 
|  | 3112 | } | 
|  | 3113 |  | 
|  | 3114 | template <class _CharT, class _Traits> | 
|  | 3115 | template <class _ForwardIterator> | 
|  | 3116 | _ForwardIterator | 
|  | 3117 | basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first, | 
|  | 3118 | _ForwardIterator __last) | 
|  | 3119 | { | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3120 | __owns_one_state<_CharT>* __e = __end_; | 
|  | 3121 | unsigned __mexp_begin = __marked_count_; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3122 | _ForwardIterator __temp = __parse_one_char_or_coll_elem_ERE(__first, __last); | 
|  | 3123 | if (__temp == __first && __temp != __last) | 
|  | 3124 | { | 
|  | 3125 | switch (*__temp) | 
|  | 3126 | { | 
|  | 3127 | case '^': | 
|  | 3128 | __push_l_anchor(); | 
|  | 3129 | ++__temp; | 
|  | 3130 | break; | 
|  | 3131 | case '$': | 
|  | 3132 | __push_r_anchor(); | 
|  | 3133 | ++__temp; | 
|  | 3134 | break; | 
|  | 3135 | case '(': | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 3136 | __push_begin_marked_subexpression(); | 
|  | 3137 | unsigned __temp_count = __marked_count_; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3138 | ++__open_count_; | 
|  | 3139 | __temp = __parse_extended_reg_exp(++__temp, __last); | 
|  | 3140 | if (__temp == __last || *__temp != ')') | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3141 | __throw_regex_error<regex_constants::error_paren>(); | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 3142 | __push_end_marked_subexpression(__temp_count); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3143 | --__open_count_; | 
|  | 3144 | ++__temp; | 
|  | 3145 | break; | 
|  | 3146 | } | 
|  | 3147 | } | 
|  | 3148 | if (__temp != __first) | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3149 | __temp = __parse_ERE_dupl_symbol(__temp, __last, __e, __mexp_begin+1, | 
|  | 3150 | __marked_count_+1); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3151 | __first = __temp; | 
|  | 3152 | return __first; | 
|  | 3153 | } | 
|  | 3154 |  | 
|  | 3155 | template <class _CharT, class _Traits> | 
|  | 3156 | template <class _ForwardIterator> | 
|  | 3157 | _ForwardIterator | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3158 | basic_regex<_CharT, _Traits>::__parse_RE_expression(_ForwardIterator __first, | 
|  | 3159 | _ForwardIterator __last) | 
|  | 3160 | { | 
|  | 3161 | while (true) | 
|  | 3162 | { | 
|  | 3163 | _ForwardIterator __temp = __parse_simple_RE(__first, __last); | 
|  | 3164 | if (__temp == __first) | 
|  | 3165 | break; | 
|  | 3166 | __first = __temp; | 
|  | 3167 | } | 
|  | 3168 | return __first; | 
|  | 3169 | } | 
|  | 3170 |  | 
|  | 3171 | template <class _CharT, class _Traits> | 
|  | 3172 | template <class _ForwardIterator> | 
|  | 3173 | _ForwardIterator | 
|  | 3174 | basic_regex<_CharT, _Traits>::__parse_simple_RE(_ForwardIterator __first, | 
|  | 3175 | _ForwardIterator __last) | 
|  | 3176 | { | 
|  | 3177 | if (__first != __last) | 
|  | 3178 | { | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 3179 | __owns_one_state<_CharT>* __e = __end_; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 3180 | unsigned __mexp_begin = __marked_count_; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3181 | _ForwardIterator __temp = __parse_nondupl_RE(__first, __last); | 
|  | 3182 | if (__temp != __first) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 3183 | __first = __parse_RE_dupl_symbol(__temp, __last, __e, | 
|  | 3184 | __mexp_begin+1, __marked_count_+1); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3185 | } | 
|  | 3186 | return __first; | 
|  | 3187 | } | 
|  | 3188 |  | 
|  | 3189 | template <class _CharT, class _Traits> | 
|  | 3190 | template <class _ForwardIterator> | 
|  | 3191 | _ForwardIterator | 
|  | 3192 | basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first, | 
|  | 3193 | _ForwardIterator __last) | 
|  | 3194 | { | 
|  | 3195 | _ForwardIterator __temp = __first; | 
|  | 3196 | __first = __parse_one_char_or_coll_elem_RE(__first, __last); | 
|  | 3197 | if (__temp == __first) | 
|  | 3198 | { | 
|  | 3199 | __temp = __parse_Back_open_paren(__first, __last); | 
|  | 3200 | if (__temp != __first) | 
|  | 3201 | { | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 3202 | __push_begin_marked_subexpression(); | 
|  | 3203 | unsigned __temp_count = __marked_count_; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3204 | __first = __parse_RE_expression(__temp, __last); | 
|  | 3205 | __temp = __parse_Back_close_paren(__first, __last); | 
|  | 3206 | if (__temp == __first) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3207 | __throw_regex_error<regex_constants::error_paren>(); | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 3208 | __push_end_marked_subexpression(__temp_count); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3209 | __first = __temp; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3210 | } | 
|  | 3211 | else | 
|  | 3212 | __first = __parse_BACKREF(__first, __last); | 
|  | 3213 | } | 
|  | 3214 | return __first; | 
|  | 3215 | } | 
|  | 3216 |  | 
|  | 3217 | template <class _CharT, class _Traits> | 
|  | 3218 | template <class _ForwardIterator> | 
|  | 3219 | _ForwardIterator | 
|  | 3220 | basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_RE( | 
|  | 3221 | _ForwardIterator __first, | 
|  | 3222 | _ForwardIterator __last) | 
|  | 3223 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3224 | _ForwardIterator __temp = __parse_ORD_CHAR(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3225 | if (__temp == __first) | 
|  | 3226 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3227 | __temp = __parse_QUOTED_CHAR(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3228 | if (__temp == __first) | 
|  | 3229 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3230 | if (__temp != __last && *__temp == '.') | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3231 | { | 
|  | 3232 | __push_match_any(); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3233 | ++__temp; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3234 | } | 
|  | 3235 | else | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3236 | __temp = __parse_bracket_expression(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3237 | } | 
|  | 3238 | } | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3239 | __first = __temp; | 
|  | 3240 | return __first; | 
|  | 3241 | } | 
|  | 3242 |  | 
|  | 3243 | template <class _CharT, class _Traits> | 
|  | 3244 | template <class _ForwardIterator> | 
|  | 3245 | _ForwardIterator | 
|  | 3246 | basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_ERE( | 
|  | 3247 | _ForwardIterator __first, | 
|  | 3248 | _ForwardIterator __last) | 
|  | 3249 | { | 
|  | 3250 | _ForwardIterator __temp = __parse_ORD_CHAR_ERE(__first, __last); | 
|  | 3251 | if (__temp == __first) | 
|  | 3252 | { | 
|  | 3253 | __temp = __parse_QUOTED_CHAR_ERE(__first, __last); | 
|  | 3254 | if (__temp == __first) | 
|  | 3255 | { | 
|  | 3256 | if (__temp != __last && *__temp == '.') | 
|  | 3257 | { | 
|  | 3258 | __push_match_any(); | 
|  | 3259 | ++__temp; | 
|  | 3260 | } | 
|  | 3261 | else | 
|  | 3262 | __temp = __parse_bracket_expression(__first, __last); | 
|  | 3263 | } | 
|  | 3264 | } | 
|  | 3265 | __first = __temp; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3266 | return __first; | 
|  | 3267 | } | 
|  | 3268 |  | 
|  | 3269 | template <class _CharT, class _Traits> | 
|  | 3270 | template <class _ForwardIterator> | 
|  | 3271 | _ForwardIterator | 
|  | 3272 | basic_regex<_CharT, _Traits>::__parse_Back_open_paren(_ForwardIterator __first, | 
|  | 3273 | _ForwardIterator __last) | 
|  | 3274 | { | 
|  | 3275 | if (__first != __last) | 
|  | 3276 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3277 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3278 | if (__temp != __last) | 
|  | 3279 | { | 
|  | 3280 | if (*__first == '\\' && *__temp == '(') | 
|  | 3281 | __first = ++__temp; | 
|  | 3282 | } | 
|  | 3283 | } | 
|  | 3284 | return __first; | 
|  | 3285 | } | 
|  | 3286 |  | 
|  | 3287 | template <class _CharT, class _Traits> | 
|  | 3288 | template <class _ForwardIterator> | 
|  | 3289 | _ForwardIterator | 
|  | 3290 | basic_regex<_CharT, _Traits>::__parse_Back_close_paren(_ForwardIterator __first, | 
|  | 3291 | _ForwardIterator __last) | 
|  | 3292 | { | 
|  | 3293 | if (__first != __last) | 
|  | 3294 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3295 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3296 | if (__temp != __last) | 
|  | 3297 | { | 
|  | 3298 | if (*__first == '\\' && *__temp == ')') | 
|  | 3299 | __first = ++__temp; | 
|  | 3300 | } | 
|  | 3301 | } | 
|  | 3302 | return __first; | 
|  | 3303 | } | 
|  | 3304 |  | 
|  | 3305 | template <class _CharT, class _Traits> | 
|  | 3306 | template <class _ForwardIterator> | 
|  | 3307 | _ForwardIterator | 
|  | 3308 | basic_regex<_CharT, _Traits>::__parse_Back_open_brace(_ForwardIterator __first, | 
|  | 3309 | _ForwardIterator __last) | 
|  | 3310 | { | 
|  | 3311 | if (__first != __last) | 
|  | 3312 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3313 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3314 | if (__temp != __last) | 
|  | 3315 | { | 
|  | 3316 | if (*__first == '\\' && *__temp == '{') | 
|  | 3317 | __first = ++__temp; | 
|  | 3318 | } | 
|  | 3319 | } | 
|  | 3320 | return __first; | 
|  | 3321 | } | 
|  | 3322 |  | 
|  | 3323 | template <class _CharT, class _Traits> | 
|  | 3324 | template <class _ForwardIterator> | 
|  | 3325 | _ForwardIterator | 
|  | 3326 | basic_regex<_CharT, _Traits>::__parse_Back_close_brace(_ForwardIterator __first, | 
|  | 3327 | _ForwardIterator __last) | 
|  | 3328 | { | 
|  | 3329 | if (__first != __last) | 
|  | 3330 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3331 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3332 | if (__temp != __last) | 
|  | 3333 | { | 
|  | 3334 | if (*__first == '\\' && *__temp == '}') | 
|  | 3335 | __first = ++__temp; | 
|  | 3336 | } | 
|  | 3337 | } | 
|  | 3338 | return __first; | 
|  | 3339 | } | 
|  | 3340 |  | 
|  | 3341 | template <class _CharT, class _Traits> | 
|  | 3342 | template <class _ForwardIterator> | 
|  | 3343 | _ForwardIterator | 
|  | 3344 | basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first, | 
|  | 3345 | _ForwardIterator __last) | 
|  | 3346 | { | 
|  | 3347 | if (__first != __last) | 
|  | 3348 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3349 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3350 | if (__temp != __last) | 
|  | 3351 | { | 
| Marshall Clow | 97f50f6 | 2014-01-18 03:40:03 | [diff] [blame] | 3352 | if (*__first == '\\') | 
|  | 3353 | { | 
|  | 3354 | int __val = __traits_.value(*__temp, 10); | 
|  | 3355 | if (__val >= 1 && __val <= 9) | 
|  | 3356 | { | 
|  | 3357 | __push_back_ref(__val); | 
|  | 3358 | __first = ++__temp; | 
|  | 3359 | } | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3360 | } | 
|  | 3361 | } | 
|  | 3362 | } | 
|  | 3363 | return __first; | 
|  | 3364 | } | 
|  | 3365 |  | 
|  | 3366 | template <class _CharT, class _Traits> | 
|  | 3367 | template <class _ForwardIterator> | 
|  | 3368 | _ForwardIterator | 
|  | 3369 | basic_regex<_CharT, _Traits>::__parse_ORD_CHAR(_ForwardIterator __first, | 
|  | 3370 | _ForwardIterator __last) | 
|  | 3371 | { | 
|  | 3372 | if (__first != __last) | 
|  | 3373 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3374 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3375 | if (__temp == __last && *__first == '$') | 
|  | 3376 | return __first; | 
|  | 3377 | // Not called inside a bracket | 
|  | 3378 | if (*__first == '.' || *__first == '\\' || *__first == '[') | 
|  | 3379 | return __first; | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3380 | __push_char(*__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3381 | ++__first; | 
|  | 3382 | } | 
|  | 3383 | return __first; | 
|  | 3384 | } | 
|  | 3385 |  | 
|  | 3386 | template <class _CharT, class _Traits> | 
|  | 3387 | template <class _ForwardIterator> | 
|  | 3388 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3389 | basic_regex<_CharT, _Traits>::__parse_ORD_CHAR_ERE(_ForwardIterator __first, | 
|  | 3390 | _ForwardIterator __last) | 
|  | 3391 | { | 
|  | 3392 | if (__first != __last) | 
|  | 3393 | { | 
|  | 3394 | switch (*__first) | 
|  | 3395 | { | 
|  | 3396 | case '^': | 
|  | 3397 | case '.': | 
|  | 3398 | case '[': | 
|  | 3399 | case '$': | 
|  | 3400 | case '(': | 
|  | 3401 | case '|': | 
|  | 3402 | case '*': | 
|  | 3403 | case '+': | 
|  | 3404 | case '?': | 
|  | 3405 | case '{': | 
|  | 3406 | case '\\': | 
|  | 3407 | break; | 
|  | 3408 | case ')': | 
|  | 3409 | if (__open_count_ == 0) | 
|  | 3410 | { | 
|  | 3411 | __push_char(*__first); | 
|  | 3412 | ++__first; | 
|  | 3413 | } | 
|  | 3414 | break; | 
|  | 3415 | default: | 
|  | 3416 | __push_char(*__first); | 
|  | 3417 | ++__first; | 
|  | 3418 | break; | 
|  | 3419 | } | 
|  | 3420 | } | 
|  | 3421 | return __first; | 
|  | 3422 | } | 
|  | 3423 |  | 
|  | 3424 | template <class _CharT, class _Traits> | 
|  | 3425 | template <class _ForwardIterator> | 
|  | 3426 | _ForwardIterator | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3427 | basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR(_ForwardIterator __first, | 
|  | 3428 | _ForwardIterator __last) | 
|  | 3429 | { | 
|  | 3430 | if (__first != __last) | 
|  | 3431 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3432 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3433 | if (__temp != __last) | 
|  | 3434 | { | 
|  | 3435 | if (*__first == '\\') | 
|  | 3436 | { | 
|  | 3437 | switch (*__temp) | 
|  | 3438 | { | 
|  | 3439 | case '^': | 
|  | 3440 | case '.': | 
|  | 3441 | case '*': | 
|  | 3442 | case '[': | 
|  | 3443 | case '$': | 
|  | 3444 | case '\\': | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3445 | __push_char(*__temp); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3446 | __first = ++__temp; | 
|  | 3447 | break; | 
|  | 3448 | } | 
|  | 3449 | } | 
|  | 3450 | } | 
|  | 3451 | } | 
|  | 3452 | return __first; | 
|  | 3453 | } | 
|  | 3454 |  | 
|  | 3455 | template <class _CharT, class _Traits> | 
|  | 3456 | template <class _ForwardIterator> | 
|  | 3457 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3458 | basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first, | 
|  | 3459 | _ForwardIterator __last) | 
|  | 3460 | { | 
|  | 3461 | if (__first != __last) | 
|  | 3462 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3463 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3464 | if (__temp != __last) | 
|  | 3465 | { | 
|  | 3466 | if (*__first == '\\') | 
|  | 3467 | { | 
|  | 3468 | switch (*__temp) | 
|  | 3469 | { | 
|  | 3470 | case '^': | 
|  | 3471 | case '.': | 
|  | 3472 | case '*': | 
|  | 3473 | case '[': | 
|  | 3474 | case '$': | 
|  | 3475 | case '\\': | 
|  | 3476 | case '(': | 
|  | 3477 | case ')': | 
|  | 3478 | case '|': | 
|  | 3479 | case '+': | 
|  | 3480 | case '?': | 
|  | 3481 | case '{': | 
| Howard Hinnant | c1ecd97 | 2013-06-28 20:31:05 | [diff] [blame] | 3482 | case '}': | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3483 | __push_char(*__temp); | 
|  | 3484 | __first = ++__temp; | 
|  | 3485 | break; | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3486 | default: | 
|  | 3487 | if ((__flags_ & 0x1F0) == awk) | 
|  | 3488 | __first = __parse_awk_escape(++__first, __last); | 
|  | 3489 | break; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3490 | } | 
|  | 3491 | } | 
|  | 3492 | } | 
|  | 3493 | } | 
|  | 3494 | return __first; | 
|  | 3495 | } | 
|  | 3496 |  | 
|  | 3497 | template <class _CharT, class _Traits> | 
|  | 3498 | template <class _ForwardIterator> | 
|  | 3499 | _ForwardIterator | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3500 | basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first, | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 3501 | _ForwardIterator __last, | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 3502 | __owns_one_state<_CharT>* __s, | 
|  | 3503 | unsigned __mexp_begin, | 
|  | 3504 | unsigned __mexp_end) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3505 | { | 
|  | 3506 | if (__first != __last) | 
|  | 3507 | { | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3508 | if (*__first == '*') | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3509 | { | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 3510 | __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3511 | ++__first; | 
|  | 3512 | } | 
|  | 3513 | else | 
|  | 3514 | { | 
|  | 3515 | _ForwardIterator __temp = __parse_Back_open_brace(__first, __last); | 
|  | 3516 | if (__temp != __first) | 
|  | 3517 | { | 
|  | 3518 | int __min = 0; | 
|  | 3519 | __first = __temp; | 
|  | 3520 | __temp = __parse_DUP_COUNT(__first, __last, __min); | 
|  | 3521 | if (__temp == __first) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3522 | __throw_regex_error<regex_constants::error_badbrace>(); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3523 | __first = __temp; | 
|  | 3524 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3525 | __throw_regex_error<regex_constants::error_brace>(); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3526 | if (*__first != ',') | 
|  | 3527 | { | 
|  | 3528 | __temp = __parse_Back_close_brace(__first, __last); | 
|  | 3529 | if (__temp == __first) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3530 | __throw_regex_error<regex_constants::error_brace>(); | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 3531 | __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, | 
|  | 3532 | true); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3533 | __first = __temp; | 
|  | 3534 | } | 
|  | 3535 | else | 
|  | 3536 | { | 
|  | 3537 | ++__first; // consume ',' | 
|  | 3538 | int __max = -1; | 
|  | 3539 | __first = __parse_DUP_COUNT(__first, __last, __max); | 
|  | 3540 | __temp = __parse_Back_close_brace(__first, __last); | 
|  | 3541 | if (__temp == __first) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3542 | __throw_regex_error<regex_constants::error_brace>(); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3543 | if (__max == -1) | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3544 | __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3545 | else | 
|  | 3546 | { | 
|  | 3547 | if (__max < __min) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3548 | __throw_regex_error<regex_constants::error_badbrace>(); | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 3549 | __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, | 
|  | 3550 | true); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 3551 | } | 
|  | 3552 | __first = __temp; | 
|  | 3553 | } | 
|  | 3554 | } | 
|  | 3555 | } | 
|  | 3556 | } | 
|  | 3557 | return __first; | 
|  | 3558 | } | 
|  | 3559 |  | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3560 | template <class _CharT, class _Traits> | 
|  | 3561 | template <class _ForwardIterator> | 
|  | 3562 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3563 | basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first, | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3564 | _ForwardIterator __last, | 
|  | 3565 | __owns_one_state<_CharT>* __s, | 
|  | 3566 | unsigned __mexp_begin, | 
|  | 3567 | unsigned __mexp_end) | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3568 | { | 
|  | 3569 | if (__first != __last) | 
|  | 3570 | { | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3571 | unsigned __grammar = __flags_ & 0x1F0; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3572 | switch (*__first) | 
|  | 3573 | { | 
|  | 3574 | case '*': | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3575 | ++__first; | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3576 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3577 | { | 
|  | 3578 | ++__first; | 
|  | 3579 | __push_nongreedy_inf_repeat(0, __s, __mexp_begin, __mexp_end); | 
|  | 3580 | } | 
|  | 3581 | else | 
|  | 3582 | __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3583 | break; | 
|  | 3584 | case '+': | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3585 | ++__first; | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3586 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3587 | { | 
|  | 3588 | ++__first; | 
|  | 3589 | __push_nongreedy_inf_repeat(1, __s, __mexp_begin, __mexp_end); | 
|  | 3590 | } | 
|  | 3591 | else | 
|  | 3592 | __push_greedy_inf_repeat(1, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3593 | break; | 
|  | 3594 | case '?': | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3595 | ++__first; | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3596 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3597 | { | 
|  | 3598 | ++__first; | 
|  | 3599 | __push_loop(0, 1, __s, __mexp_begin, __mexp_end, false); | 
|  | 3600 | } | 
|  | 3601 | else | 
|  | 3602 | __push_loop(0, 1, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3603 | break; | 
|  | 3604 | case '{': | 
|  | 3605 | { | 
|  | 3606 | int __min; | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3607 | _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3608 | if (__temp == __first) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3609 | __throw_regex_error<regex_constants::error_badbrace>(); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3610 | __first = __temp; | 
|  | 3611 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3612 | __throw_regex_error<regex_constants::error_brace>(); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3613 | switch (*__first) | 
|  | 3614 | { | 
|  | 3615 | case '}': | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3616 | ++__first; | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3617 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3618 | { | 
|  | 3619 | ++__first; | 
|  | 3620 | __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, false); | 
|  | 3621 | } | 
|  | 3622 | else | 
|  | 3623 | __push_loop(__min, __min, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3624 | break; | 
|  | 3625 | case ',': | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3626 | ++__first; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3627 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3628 | __throw_regex_error<regex_constants::error_badbrace>(); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3629 | if (*__first == '}') | 
|  | 3630 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3631 | ++__first; | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3632 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3633 | { | 
|  | 3634 | ++__first; | 
|  | 3635 | __push_nongreedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); | 
|  | 3636 | } | 
|  | 3637 | else | 
|  | 3638 | __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3639 | } | 
|  | 3640 | else | 
|  | 3641 | { | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3642 | int __max = -1; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3643 | __temp = __parse_DUP_COUNT(__first, __last, __max); | 
|  | 3644 | if (__temp == __first) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3645 | __throw_regex_error<regex_constants::error_brace>(); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3646 | __first = __temp; | 
|  | 3647 | if (__first == __last || *__first != '}') | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3648 | __throw_regex_error<regex_constants::error_brace>(); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3649 | ++__first; | 
|  | 3650 | if (__max < __min) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3651 | __throw_regex_error<regex_constants::error_badbrace>(); | 
| Howard Hinnant | a0d045b | 2010-07-29 00:36:00 | [diff] [blame] | 3652 | if (__grammar == ECMAScript && __first != __last && *__first == '?') | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 3653 | { | 
|  | 3654 | ++__first; | 
|  | 3655 | __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false); | 
|  | 3656 | } | 
|  | 3657 | else | 
|  | 3658 | __push_loop(__min, __max, __s, __mexp_begin, __mexp_end); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3659 | } | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 3660 | break; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3661 | default: | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3662 | __throw_regex_error<regex_constants::error_badbrace>(); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 3663 | } | 
|  | 3664 | } | 
|  | 3665 | break; | 
|  | 3666 | } | 
|  | 3667 | } | 
|  | 3668 | return __first; | 
|  | 3669 | } | 
|  | 3670 |  | 
|  | 3671 | template <class _CharT, class _Traits> | 
|  | 3672 | template <class _ForwardIterator> | 
|  | 3673 | _ForwardIterator | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3674 | basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __first, | 
|  | 3675 | _ForwardIterator __last) | 
|  | 3676 | { | 
|  | 3677 | if (__first != __last && *__first == '[') | 
|  | 3678 | { | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3679 | ++__first; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 3680 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3681 | __throw_regex_error<regex_constants::error_brack>(); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3682 | bool __negate = false; | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3683 | if (*__first == '^') | 
|  | 3684 | { | 
|  | 3685 | ++__first; | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3686 | __negate = true; | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3687 | } | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3688 | __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate); | 
|  | 3689 | // __ml owned by *this | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3690 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3691 | __throw_regex_error<regex_constants::error_brack>(); | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3692 | if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']') | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3693 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3694 | __ml->__add_char(']'); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3695 | ++__first; | 
|  | 3696 | } | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3697 | __first = __parse_follow_list(__first, __last, __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3698 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3699 | __throw_regex_error<regex_constants::error_brack>(); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3700 | if (*__first == '-') | 
|  | 3701 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3702 | __ml->__add_char('-'); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3703 | ++__first; | 
|  | 3704 | } | 
|  | 3705 | if (__first == __last || *__first != ']') | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3706 | __throw_regex_error<regex_constants::error_brack>(); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3707 | ++__first; | 
|  | 3708 | } | 
|  | 3709 | return __first; | 
|  | 3710 | } | 
|  | 3711 |  | 
|  | 3712 | template <class _CharT, class _Traits> | 
|  | 3713 | template <class _ForwardIterator> | 
|  | 3714 | _ForwardIterator | 
|  | 3715 | basic_regex<_CharT, _Traits>::__parse_follow_list(_ForwardIterator __first, | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3716 | _ForwardIterator __last, | 
|  | 3717 | __bracket_expression<_CharT, _Traits>* __ml) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3718 | { | 
|  | 3719 | if (__first != __last) | 
|  | 3720 | { | 
|  | 3721 | while (true) | 
|  | 3722 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3723 | _ForwardIterator __temp = __parse_expression_term(__first, __last, | 
|  | 3724 | __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3725 | if (__temp == __first) | 
|  | 3726 | break; | 
|  | 3727 | __first = __temp; | 
|  | 3728 | } | 
|  | 3729 | } | 
|  | 3730 | return __first; | 
|  | 3731 | } | 
|  | 3732 |  | 
|  | 3733 | template <class _CharT, class _Traits> | 
|  | 3734 | template <class _ForwardIterator> | 
|  | 3735 | _ForwardIterator | 
|  | 3736 | basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first, | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3737 | _ForwardIterator __last, | 
|  | 3738 | __bracket_expression<_CharT, _Traits>* __ml) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3739 | { | 
|  | 3740 | if (__first != __last && *__first != ']') | 
|  | 3741 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3742 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3743 | basic_string<_CharT> __start_range; | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3744 | if (__temp != __last && *__first == '[') | 
|  | 3745 | { | 
|  | 3746 | if (*__temp == '=') | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3747 | return __parse_equivalence_class(++__temp, __last, __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3748 | else if (*__temp == ':') | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3749 | return __parse_character_class(++__temp, __last, __ml); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3750 | else if (*__temp == '.') | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3751 | __first = __parse_collating_symbol(++__temp, __last, __start_range); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3752 | } | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3753 | unsigned __grammar = __flags_ & 0x1F0; | 
|  | 3754 | if (__start_range.empty()) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3755 | { | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3756 | if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\') | 
|  | 3757 | { | 
|  | 3758 | if (__grammar == ECMAScript) | 
|  | 3759 | __first = __parse_class_escape(++__first, __last, __start_range, __ml); | 
|  | 3760 | else | 
|  | 3761 | __first = __parse_awk_escape(++__first, __last, &__start_range); | 
|  | 3762 | } | 
|  | 3763 | else | 
|  | 3764 | { | 
|  | 3765 | __start_range = *__first; | 
|  | 3766 | ++__first; | 
|  | 3767 | } | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3768 | } | 
|  | 3769 | if (__first != __last && *__first != ']') | 
|  | 3770 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3771 | __temp = _VSTD::next(__first); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3772 | if (__temp != __last && *__first == '-' && *__temp != ']') | 
|  | 3773 | { | 
|  | 3774 | // parse a range | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3775 | basic_string<_CharT> __end_range; | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3776 | __first = __temp; | 
|  | 3777 | ++__temp; | 
|  | 3778 | if (__temp != __last && *__first == '[' && *__temp == '.') | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3779 | __first = __parse_collating_symbol(++__temp, __last, __end_range); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3780 | else | 
|  | 3781 | { | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3782 | if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\') | 
|  | 3783 | { | 
|  | 3784 | if (__grammar == ECMAScript) | 
|  | 3785 | __first = __parse_class_escape(++__first, __last, | 
|  | 3786 | __end_range, __ml); | 
|  | 3787 | else | 
|  | 3788 | __first = __parse_awk_escape(++__first, __last, | 
|  | 3789 | &__end_range); | 
|  | 3790 | } | 
|  | 3791 | else | 
|  | 3792 | { | 
|  | 3793 | __end_range = *__first; | 
|  | 3794 | ++__first; | 
|  | 3795 | } | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3796 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3797 | __ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range)); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3798 | } | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 | [diff] [blame] | 3799 | else if (!__start_range.empty()) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3800 | { | 
|  | 3801 | if (__start_range.size() == 1) | 
|  | 3802 | __ml->__add_char(__start_range[0]); | 
|  | 3803 | else | 
|  | 3804 | __ml->__add_digraph(__start_range[0], __start_range[1]); | 
|  | 3805 | } | 
|  | 3806 | } | 
| Howard Hinnant | 499cea1 | 2013-08-23 17:37:05 | [diff] [blame] | 3807 | else if (!__start_range.empty()) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3808 | { | 
|  | 3809 | if (__start_range.size() == 1) | 
|  | 3810 | __ml->__add_char(__start_range[0]); | 
|  | 3811 | else | 
|  | 3812 | __ml->__add_digraph(__start_range[0], __start_range[1]); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3813 | } | 
|  | 3814 | } | 
|  | 3815 | return __first; | 
|  | 3816 | } | 
|  | 3817 |  | 
|  | 3818 | template <class _CharT, class _Traits> | 
|  | 3819 | template <class _ForwardIterator> | 
|  | 3820 | _ForwardIterator | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3821 | basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first, | 
|  | 3822 | _ForwardIterator __last, | 
|  | 3823 | basic_string<_CharT>& __str, | 
|  | 3824 | __bracket_expression<_CharT, _Traits>* __ml) | 
|  | 3825 | { | 
|  | 3826 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3827 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3828 | switch (*__first) | 
|  | 3829 | { | 
|  | 3830 | case 0: | 
|  | 3831 | __str = *__first; | 
|  | 3832 | return ++__first; | 
|  | 3833 | case 'b': | 
|  | 3834 | __str = _CharT(8); | 
|  | 3835 | return ++__first; | 
|  | 3836 | case 'd': | 
|  | 3837 | __ml->__add_class(ctype_base::digit); | 
|  | 3838 | return ++__first; | 
|  | 3839 | case 'D': | 
|  | 3840 | __ml->__add_neg_class(ctype_base::digit); | 
|  | 3841 | return ++__first; | 
|  | 3842 | case 's': | 
|  | 3843 | __ml->__add_class(ctype_base::space); | 
|  | 3844 | return ++__first; | 
|  | 3845 | case 'S': | 
|  | 3846 | __ml->__add_neg_class(ctype_base::space); | 
|  | 3847 | return ++__first; | 
|  | 3848 | case 'w': | 
|  | 3849 | __ml->__add_class(ctype_base::alnum); | 
|  | 3850 | __ml->__add_char('_'); | 
|  | 3851 | return ++__first; | 
|  | 3852 | case 'W': | 
|  | 3853 | __ml->__add_neg_class(ctype_base::alnum); | 
|  | 3854 | __ml->__add_neg_char('_'); | 
|  | 3855 | return ++__first; | 
|  | 3856 | } | 
|  | 3857 | __first = __parse_character_escape(__first, __last, &__str); | 
|  | 3858 | return __first; | 
|  | 3859 | } | 
|  | 3860 |  | 
|  | 3861 | template <class _CharT, class _Traits> | 
|  | 3862 | template <class _ForwardIterator> | 
|  | 3863 | _ForwardIterator | 
|  | 3864 | basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first, | 
|  | 3865 | _ForwardIterator __last, | 
|  | 3866 | basic_string<_CharT>* __str) | 
|  | 3867 | { | 
|  | 3868 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3869 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3870 | switch (*__first) | 
|  | 3871 | { | 
|  | 3872 | case '\\': | 
|  | 3873 | case '"': | 
|  | 3874 | case '/': | 
|  | 3875 | if (__str) | 
|  | 3876 | *__str = *__first; | 
|  | 3877 | else | 
|  | 3878 | __push_char(*__first); | 
|  | 3879 | return ++__first; | 
|  | 3880 | case 'a': | 
|  | 3881 | if (__str) | 
|  | 3882 | *__str = _CharT(7); | 
|  | 3883 | else | 
|  | 3884 | __push_char(_CharT(7)); | 
|  | 3885 | return ++__first; | 
|  | 3886 | case 'b': | 
|  | 3887 | if (__str) | 
|  | 3888 | *__str = _CharT(8); | 
|  | 3889 | else | 
|  | 3890 | __push_char(_CharT(8)); | 
|  | 3891 | return ++__first; | 
|  | 3892 | case 'f': | 
|  | 3893 | if (__str) | 
|  | 3894 | *__str = _CharT(0xC); | 
|  | 3895 | else | 
|  | 3896 | __push_char(_CharT(0xC)); | 
|  | 3897 | return ++__first; | 
|  | 3898 | case 'n': | 
|  | 3899 | if (__str) | 
|  | 3900 | *__str = _CharT(0xA); | 
|  | 3901 | else | 
|  | 3902 | __push_char(_CharT(0xA)); | 
|  | 3903 | return ++__first; | 
|  | 3904 | case 'r': | 
|  | 3905 | if (__str) | 
|  | 3906 | *__str = _CharT(0xD); | 
|  | 3907 | else | 
|  | 3908 | __push_char(_CharT(0xD)); | 
|  | 3909 | return ++__first; | 
|  | 3910 | case 't': | 
|  | 3911 | if (__str) | 
|  | 3912 | *__str = _CharT(0x9); | 
|  | 3913 | else | 
|  | 3914 | __push_char(_CharT(0x9)); | 
|  | 3915 | return ++__first; | 
|  | 3916 | case 'v': | 
|  | 3917 | if (__str) | 
|  | 3918 | *__str = _CharT(0xB); | 
|  | 3919 | else | 
|  | 3920 | __push_char(_CharT(0xB)); | 
|  | 3921 | return ++__first; | 
|  | 3922 | } | 
|  | 3923 | if ('0' <= *__first && *__first <= '7') | 
|  | 3924 | { | 
|  | 3925 | unsigned __val = *__first - '0'; | 
|  | 3926 | if (++__first != __last && ('0' <= *__first && *__first <= '7')) | 
|  | 3927 | { | 
|  | 3928 | __val = 8 * __val + *__first - '0'; | 
|  | 3929 | if (++__first != __last && ('0' <= *__first && *__first <= '7')) | 
| Howard Hinnant | dbc8cf0 | 2013-07-02 17:43:31 | [diff] [blame] | 3930 | __val = 8 * __val + *__first++ - '0'; | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3931 | } | 
|  | 3932 | if (__str) | 
|  | 3933 | *__str = _CharT(__val); | 
|  | 3934 | else | 
|  | 3935 | __push_char(_CharT(__val)); | 
|  | 3936 | } | 
|  | 3937 | else | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3938 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 3939 | return __first; | 
|  | 3940 | } | 
|  | 3941 |  | 
|  | 3942 | template <class _CharT, class _Traits> | 
|  | 3943 | template <class _ForwardIterator> | 
|  | 3944 | _ForwardIterator | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3945 | basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first, | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3946 | _ForwardIterator __last, | 
|  | 3947 | __bracket_expression<_CharT, _Traits>* __ml) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3948 | { | 
|  | 3949 | // Found [= | 
|  | 3950 | // This means =] must exist | 
|  | 3951 | value_type _Equal_close[2] = {'=', ']'}; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3952 | _ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close, | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3953 | _Equal_close+2); | 
|  | 3954 | if (__temp == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3955 | __throw_regex_error<regex_constants::error_brack>(); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3956 | // [__first, __temp) contains all text in [= ... =] | 
|  | 3957 | typedef typename _Traits::string_type string_type; | 
|  | 3958 | string_type __collate_name = | 
|  | 3959 | __traits_.lookup_collatename(__first, __temp); | 
|  | 3960 | if (__collate_name.empty()) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3961 | __throw_regex_error<regex_constants::error_collate>(); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3962 | string_type __equiv_name = | 
|  | 3963 | __traits_.transform_primary(__collate_name.begin(), | 
|  | 3964 | __collate_name.end()); | 
|  | 3965 | if (!__equiv_name.empty()) | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3966 | __ml->__add_equivalence(__equiv_name); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3967 | else | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3968 | { | 
|  | 3969 | switch (__collate_name.size()) | 
|  | 3970 | { | 
|  | 3971 | case 1: | 
|  | 3972 | __ml->__add_char(__collate_name[0]); | 
|  | 3973 | break; | 
|  | 3974 | case 2: | 
|  | 3975 | __ml->__add_digraph(__collate_name[0], __collate_name[1]); | 
|  | 3976 | break; | 
|  | 3977 | default: | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3978 | __throw_regex_error<regex_constants::error_collate>(); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3979 | } | 
|  | 3980 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3981 | __first = _VSTD::next(__temp, 2); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3982 | return __first; | 
|  | 3983 | } | 
|  | 3984 |  | 
|  | 3985 | template <class _CharT, class _Traits> | 
|  | 3986 | template <class _ForwardIterator> | 
|  | 3987 | _ForwardIterator | 
|  | 3988 | basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first, | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 3989 | _ForwardIterator __last, | 
|  | 3990 | __bracket_expression<_CharT, _Traits>* __ml) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3991 | { | 
|  | 3992 | // Found [: | 
|  | 3993 | // This means :] must exist | 
|  | 3994 | value_type _Colon_close[2] = {':', ']'}; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 3995 | _ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close, | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3996 | _Colon_close+2); | 
|  | 3997 | if (__temp == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 3998 | __throw_regex_error<regex_constants::error_brack>(); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 3999 | // [__first, __temp) contains all text in [: ... :] | 
|  | 4000 | typedef typename _Traits::char_class_type char_class_type; | 
|  | 4001 | char_class_type __class_type = | 
|  | 4002 | __traits_.lookup_classname(__first, __temp, __flags_ & icase); | 
|  | 4003 | if (__class_type == 0) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4004 | __throw_regex_error<regex_constants::error_brack>(); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4005 | __ml->__add_class(__class_type); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4006 | __first = _VSTD::next(__temp, 2); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 4007 | return __first; | 
|  | 4008 | } | 
|  | 4009 |  | 
|  | 4010 | template <class _CharT, class _Traits> | 
|  | 4011 | template <class _ForwardIterator> | 
|  | 4012 | _ForwardIterator | 
|  | 4013 | basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first, | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4014 | _ForwardIterator __last, | 
|  | 4015 | basic_string<_CharT>& __col_sym) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 4016 | { | 
|  | 4017 | // Found [. | 
|  | 4018 | // This means .] must exist | 
|  | 4019 | value_type _Dot_close[2] = {'.', ']'}; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4020 | _ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close, | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 4021 | _Dot_close+2); | 
|  | 4022 | if (__temp == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4023 | __throw_regex_error<regex_constants::error_brack>(); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 4024 | // [__first, __temp) contains all text in [. ... .] | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4025 | __col_sym = __traits_.lookup_collatename(__first, __temp); | 
|  | 4026 | switch (__col_sym.size()) | 
|  | 4027 | { | 
|  | 4028 | case 1: | 
|  | 4029 | case 2: | 
|  | 4030 | break; | 
|  | 4031 | default: | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4032 | __throw_regex_error<regex_constants::error_collate>(); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4033 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4034 | __first = _VSTD::next(__temp, 2); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 4035 | return __first; | 
|  | 4036 | } | 
|  | 4037 |  | 
|  | 4038 | template <class _CharT, class _Traits> | 
|  | 4039 | template <class _ForwardIterator> | 
|  | 4040 | _ForwardIterator | 
|  | 4041 | basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first, | 
|  | 4042 | _ForwardIterator __last, | 
|  | 4043 | int& __c) | 
|  | 4044 | { | 
| Marshall Clow | 97f50f6 | 2014-01-18 03:40:03 | [diff] [blame] | 4045 | if (__first != __last ) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 4046 | { | 
| Marshall Clow | 97f50f6 | 2014-01-18 03:40:03 | [diff] [blame] | 4047 | int __val = __traits_.value(*__first, 10); | 
|  | 4048 | if ( __val != -1 ) | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 4049 | { | 
| Marshall Clow | 97f50f6 | 2014-01-18 03:40:03 | [diff] [blame] | 4050 | __c = __val; | 
|  | 4051 | for (++__first; | 
|  | 4052 | __first != __last && ( __val = __traits_.value(*__first, 10)) != -1; | 
|  | 4053 | ++__first) | 
|  | 4054 | { | 
|  | 4055 | __c *= 10; | 
|  | 4056 | __c += __val; | 
|  | 4057 | } | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 4058 | } | 
|  | 4059 | } | 
|  | 4060 | return __first; | 
|  | 4061 | } | 
|  | 4062 |  | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4063 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4064 | template <class _ForwardIterator> | 
|  | 4065 | _ForwardIterator | 
|  | 4066 | basic_regex<_CharT, _Traits>::__parse_ecma_exp(_ForwardIterator __first, | 
|  | 4067 | _ForwardIterator __last) | 
|  | 4068 | { | 
|  | 4069 | __owns_one_state<_CharT>* __sa = __end_; | 
|  | 4070 | _ForwardIterator __temp = __parse_alternative(__first, __last); | 
|  | 4071 | if (__temp == __first) | 
|  | 4072 | __push_empty(); | 
|  | 4073 | __first = __temp; | 
|  | 4074 | while (__first != __last && *__first == '|') | 
|  | 4075 | { | 
|  | 4076 | __owns_one_state<_CharT>* __sb = __end_; | 
|  | 4077 | __temp = __parse_alternative(++__first, __last); | 
|  | 4078 | if (__temp == __first) | 
|  | 4079 | __push_empty(); | 
|  | 4080 | __push_alternation(__sa, __sb); | 
|  | 4081 | __first = __temp; | 
|  | 4082 | } | 
|  | 4083 | return __first; | 
|  | 4084 | } | 
|  | 4085 |  | 
|  | 4086 | template <class _CharT, class _Traits> | 
|  | 4087 | template <class _ForwardIterator> | 
|  | 4088 | _ForwardIterator | 
|  | 4089 | basic_regex<_CharT, _Traits>::__parse_alternative(_ForwardIterator __first, | 
|  | 4090 | _ForwardIterator __last) | 
|  | 4091 | { | 
|  | 4092 | while (true) | 
|  | 4093 | { | 
|  | 4094 | _ForwardIterator __temp = __parse_term(__first, __last); | 
|  | 4095 | if (__temp == __first) | 
|  | 4096 | break; | 
|  | 4097 | __first = __temp; | 
|  | 4098 | } | 
|  | 4099 | return __first; | 
|  | 4100 | } | 
|  | 4101 |  | 
|  | 4102 | template <class _CharT, class _Traits> | 
|  | 4103 | template <class _ForwardIterator> | 
|  | 4104 | _ForwardIterator | 
|  | 4105 | basic_regex<_CharT, _Traits>::__parse_term(_ForwardIterator __first, | 
|  | 4106 | _ForwardIterator __last) | 
|  | 4107 | { | 
|  | 4108 | _ForwardIterator __temp = __parse_assertion(__first, __last); | 
|  | 4109 | if (__temp == __first) | 
|  | 4110 | { | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4111 | __owns_one_state<_CharT>* __e = __end_; | 
|  | 4112 | unsigned __mexp_begin = __marked_count_; | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4113 | __temp = __parse_atom(__first, __last); | 
|  | 4114 | if (__temp != __first) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4115 | __first = __parse_ERE_dupl_symbol(__temp, __last, __e, | 
|  | 4116 | __mexp_begin+1, __marked_count_+1); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4117 | } | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4118 | else | 
|  | 4119 | __first = __temp; | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4120 | return __first; | 
|  | 4121 | } | 
|  | 4122 |  | 
|  | 4123 | template <class _CharT, class _Traits> | 
|  | 4124 | template <class _ForwardIterator> | 
|  | 4125 | _ForwardIterator | 
|  | 4126 | basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first, | 
|  | 4127 | _ForwardIterator __last) | 
|  | 4128 | { | 
|  | 4129 | if (__first != __last) | 
|  | 4130 | { | 
|  | 4131 | switch (*__first) | 
|  | 4132 | { | 
|  | 4133 | case '^': | 
|  | 4134 | __push_l_anchor(); | 
|  | 4135 | ++__first; | 
|  | 4136 | break; | 
|  | 4137 | case '$': | 
|  | 4138 | __push_r_anchor(); | 
|  | 4139 | ++__first; | 
|  | 4140 | break; | 
|  | 4141 | case '\\': | 
|  | 4142 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4143 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4144 | if (__temp != __last) | 
|  | 4145 | { | 
|  | 4146 | if (*__temp == 'b') | 
|  | 4147 | { | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4148 | __push_word_boundary(false); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4149 | __first = ++__temp; | 
|  | 4150 | } | 
|  | 4151 | else if (*__temp == 'B') | 
|  | 4152 | { | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4153 | __push_word_boundary(true); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4154 | __first = ++__temp; | 
|  | 4155 | } | 
|  | 4156 | } | 
|  | 4157 | } | 
|  | 4158 | break; | 
|  | 4159 | case '(': | 
|  | 4160 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4161 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4162 | if (__temp != __last && *__temp == '?') | 
|  | 4163 | { | 
|  | 4164 | if (++__temp != __last) | 
|  | 4165 | { | 
|  | 4166 | switch (*__temp) | 
|  | 4167 | { | 
|  | 4168 | case '=': | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4169 | { | 
|  | 4170 | basic_regex __exp; | 
|  | 4171 | __exp.__flags_ = __flags_; | 
|  | 4172 | __temp = __exp.__parse(++__temp, __last); | 
| Howard Hinnant | cd59acc | 2013-07-23 16:18:04 | [diff] [blame] | 4173 | unsigned __mexp = __exp.__marked_count_; | 
|  | 4174 | __push_lookahead(_VSTD::move(__exp), false, __marked_count_); | 
|  | 4175 | __marked_count_ += __mexp; | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4176 | if (__temp == __last || *__temp != ')') | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4177 | __throw_regex_error<regex_constants::error_paren>(); | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4178 | __first = ++__temp; | 
|  | 4179 | } | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4180 | break; | 
|  | 4181 | case '!': | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4182 | { | 
|  | 4183 | basic_regex __exp; | 
|  | 4184 | __exp.__flags_ = __flags_; | 
|  | 4185 | __temp = __exp.__parse(++__temp, __last); | 
| Howard Hinnant | cd59acc | 2013-07-23 16:18:04 | [diff] [blame] | 4186 | unsigned __mexp = __exp.__marked_count_; | 
|  | 4187 | __push_lookahead(_VSTD::move(__exp), true, __marked_count_); | 
|  | 4188 | __marked_count_ += __mexp; | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4189 | if (__temp == __last || *__temp != ')') | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4190 | __throw_regex_error<regex_constants::error_paren>(); | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4191 | __first = ++__temp; | 
|  | 4192 | } | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4193 | break; | 
|  | 4194 | } | 
|  | 4195 | } | 
|  | 4196 | } | 
|  | 4197 | } | 
|  | 4198 | break; | 
|  | 4199 | } | 
|  | 4200 | } | 
|  | 4201 | return __first; | 
|  | 4202 | } | 
|  | 4203 |  | 
|  | 4204 | template <class _CharT, class _Traits> | 
|  | 4205 | template <class _ForwardIterator> | 
|  | 4206 | _ForwardIterator | 
|  | 4207 | basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first, | 
|  | 4208 | _ForwardIterator __last) | 
|  | 4209 | { | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4210 | if (__first != __last) | 
|  | 4211 | { | 
|  | 4212 | switch (*__first) | 
|  | 4213 | { | 
|  | 4214 | case '.': | 
|  | 4215 | __push_match_any_but_newline(); | 
|  | 4216 | ++__first; | 
|  | 4217 | break; | 
|  | 4218 | case '\\': | 
|  | 4219 | __first = __parse_atom_escape(__first, __last); | 
|  | 4220 | break; | 
|  | 4221 | case '[': | 
|  | 4222 | __first = __parse_bracket_expression(__first, __last); | 
|  | 4223 | break; | 
|  | 4224 | case '(': | 
|  | 4225 | { | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4226 | ++__first; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4227 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4228 | __throw_regex_error<regex_constants::error_paren>(); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4229 | _ForwardIterator __temp = _VSTD::next(__first); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4230 | if (__temp != __last && *__first == '?' && *__temp == ':') | 
|  | 4231 | { | 
|  | 4232 | ++__open_count_; | 
|  | 4233 | __first = __parse_ecma_exp(++__temp, __last); | 
|  | 4234 | if (__first == __last || *__first != ')') | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4235 | __throw_regex_error<regex_constants::error_paren>(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4236 | --__open_count_; | 
|  | 4237 | ++__first; | 
|  | 4238 | } | 
|  | 4239 | else | 
|  | 4240 | { | 
|  | 4241 | __push_begin_marked_subexpression(); | 
|  | 4242 | unsigned __temp_count = __marked_count_; | 
|  | 4243 | ++__open_count_; | 
|  | 4244 | __first = __parse_ecma_exp(__first, __last); | 
|  | 4245 | if (__first == __last || *__first != ')') | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4246 | __throw_regex_error<regex_constants::error_paren>(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4247 | __push_end_marked_subexpression(__temp_count); | 
|  | 4248 | --__open_count_; | 
|  | 4249 | ++__first; | 
|  | 4250 | } | 
|  | 4251 | } | 
|  | 4252 | break; | 
| Marshall Clow | 568bd02 | 2015-07-23 18:27:51 | [diff] [blame] | 4253 | case '*': | 
|  | 4254 | case '+': | 
|  | 4255 | case '?': | 
|  | 4256 | case '{': | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4257 | __throw_regex_error<regex_constants::error_badrepeat>(); | 
| Marshall Clow | 568bd02 | 2015-07-23 18:27:51 | [diff] [blame] | 4258 | break; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4259 | default: | 
|  | 4260 | __first = __parse_pattern_character(__first, __last); | 
|  | 4261 | break; | 
|  | 4262 | } | 
|  | 4263 | } | 
|  | 4264 | return __first; | 
|  | 4265 | } | 
|  | 4266 |  | 
|  | 4267 | template <class _CharT, class _Traits> | 
|  | 4268 | template <class _ForwardIterator> | 
|  | 4269 | _ForwardIterator | 
|  | 4270 | basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first, | 
|  | 4271 | _ForwardIterator __last) | 
|  | 4272 | { | 
|  | 4273 | if (__first != __last && *__first == '\\') | 
|  | 4274 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4275 | _ForwardIterator __t1 = _VSTD::next(__first); | 
| Marshall Clow | 685cdca | 2016-01-19 00:50:37 | [diff] [blame] | 4276 | if (__t1 == __last) | 
|  | 4277 | __throw_regex_error<regex_constants::error_escape>(); | 
|  | 4278 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4279 | _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last); | 
|  | 4280 | if (__t2 != __t1) | 
|  | 4281 | __first = __t2; | 
|  | 4282 | else | 
|  | 4283 | { | 
|  | 4284 | __t2 = __parse_character_class_escape(__t1, __last); | 
|  | 4285 | if (__t2 != __t1) | 
|  | 4286 | __first = __t2; | 
|  | 4287 | else | 
|  | 4288 | { | 
|  | 4289 | __t2 = __parse_character_escape(__t1, __last); | 
|  | 4290 | if (__t2 != __t1) | 
|  | 4291 | __first = __t2; | 
|  | 4292 | } | 
|  | 4293 | } | 
|  | 4294 | } | 
|  | 4295 | return __first; | 
|  | 4296 | } | 
|  | 4297 |  | 
|  | 4298 | template <class _CharT, class _Traits> | 
|  | 4299 | template <class _ForwardIterator> | 
|  | 4300 | _ForwardIterator | 
|  | 4301 | basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first, | 
|  | 4302 | _ForwardIterator __last) | 
|  | 4303 | { | 
|  | 4304 | if (__first != __last) | 
|  | 4305 | { | 
|  | 4306 | if (*__first == '0') | 
|  | 4307 | { | 
|  | 4308 | __push_char(_CharT()); | 
|  | 4309 | ++__first; | 
|  | 4310 | } | 
|  | 4311 | else if ('1' <= *__first && *__first <= '9') | 
|  | 4312 | { | 
|  | 4313 | unsigned __v = *__first - '0'; | 
|  | 4314 | for (++__first; '0' <= *__first && *__first <= '9'; ++__first) | 
|  | 4315 | __v = 10 * __v + *__first - '0'; | 
|  | 4316 | if (__v > mark_count()) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4317 | __throw_regex_error<regex_constants::error_backref>(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4318 | __push_back_ref(__v); | 
|  | 4319 | } | 
|  | 4320 | } | 
|  | 4321 | return __first; | 
|  | 4322 | } | 
|  | 4323 |  | 
|  | 4324 | template <class _CharT, class _Traits> | 
|  | 4325 | template <class _ForwardIterator> | 
|  | 4326 | _ForwardIterator | 
|  | 4327 | basic_regex<_CharT, _Traits>::__parse_character_class_escape(_ForwardIterator __first, | 
|  | 4328 | _ForwardIterator __last) | 
|  | 4329 | { | 
|  | 4330 | if (__first != __last) | 
|  | 4331 | { | 
|  | 4332 | __bracket_expression<_CharT, _Traits>* __ml; | 
|  | 4333 | switch (*__first) | 
|  | 4334 | { | 
|  | 4335 | case 'd': | 
|  | 4336 | __ml = __start_matching_list(false); | 
|  | 4337 | __ml->__add_class(ctype_base::digit); | 
|  | 4338 | ++__first; | 
|  | 4339 | break; | 
|  | 4340 | case 'D': | 
|  | 4341 | __ml = __start_matching_list(true); | 
|  | 4342 | __ml->__add_class(ctype_base::digit); | 
|  | 4343 | ++__first; | 
|  | 4344 | break; | 
|  | 4345 | case 's': | 
|  | 4346 | __ml = __start_matching_list(false); | 
|  | 4347 | __ml->__add_class(ctype_base::space); | 
|  | 4348 | ++__first; | 
|  | 4349 | break; | 
|  | 4350 | case 'S': | 
|  | 4351 | __ml = __start_matching_list(true); | 
|  | 4352 | __ml->__add_class(ctype_base::space); | 
|  | 4353 | ++__first; | 
|  | 4354 | break; | 
|  | 4355 | case 'w': | 
|  | 4356 | __ml = __start_matching_list(false); | 
|  | 4357 | __ml->__add_class(ctype_base::alnum); | 
|  | 4358 | __ml->__add_char('_'); | 
|  | 4359 | ++__first; | 
|  | 4360 | break; | 
|  | 4361 | case 'W': | 
|  | 4362 | __ml = __start_matching_list(true); | 
|  | 4363 | __ml->__add_class(ctype_base::alnum); | 
|  | 4364 | __ml->__add_char('_'); | 
|  | 4365 | ++__first; | 
|  | 4366 | break; | 
|  | 4367 | } | 
|  | 4368 | } | 
|  | 4369 | return __first; | 
|  | 4370 | } | 
|  | 4371 |  | 
|  | 4372 | template <class _CharT, class _Traits> | 
|  | 4373 | template <class _ForwardIterator> | 
|  | 4374 | _ForwardIterator | 
|  | 4375 | basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4376 | _ForwardIterator __last, | 
|  | 4377 | basic_string<_CharT>* __str) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4378 | { | 
|  | 4379 | if (__first != __last) | 
|  | 4380 | { | 
|  | 4381 | _ForwardIterator __t; | 
|  | 4382 | unsigned __sum = 0; | 
|  | 4383 | int __hd; | 
|  | 4384 | switch (*__first) | 
|  | 4385 | { | 
|  | 4386 | case 'f': | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4387 | if (__str) | 
|  | 4388 | *__str = _CharT(0xC); | 
|  | 4389 | else | 
|  | 4390 | __push_char(_CharT(0xC)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4391 | ++__first; | 
|  | 4392 | break; | 
|  | 4393 | case 'n': | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4394 | if (__str) | 
|  | 4395 | *__str = _CharT(0xA); | 
|  | 4396 | else | 
|  | 4397 | __push_char(_CharT(0xA)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4398 | ++__first; | 
|  | 4399 | break; | 
|  | 4400 | case 'r': | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4401 | if (__str) | 
|  | 4402 | *__str = _CharT(0xD); | 
|  | 4403 | else | 
|  | 4404 | __push_char(_CharT(0xD)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4405 | ++__first; | 
|  | 4406 | break; | 
|  | 4407 | case 't': | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4408 | if (__str) | 
|  | 4409 | *__str = _CharT(0x9); | 
|  | 4410 | else | 
|  | 4411 | __push_char(_CharT(0x9)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4412 | ++__first; | 
|  | 4413 | break; | 
|  | 4414 | case 'v': | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4415 | if (__str) | 
|  | 4416 | *__str = _CharT(0xB); | 
|  | 4417 | else | 
|  | 4418 | __push_char(_CharT(0xB)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4419 | ++__first; | 
|  | 4420 | break; | 
|  | 4421 | case 'c': | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4422 | if ((__t = _VSTD::next(__first)) != __last) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4423 | { | 
| Howard Hinnant | 1e1d051 | 2013-07-15 18:21:11 | [diff] [blame] | 4424 | if (('A' <= *__t && *__t <= 'Z') || | 
|  | 4425 | ('a' <= *__t && *__t <= 'z')) | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4426 | { | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4427 | if (__str) | 
|  | 4428 | *__str = _CharT(*__t % 32); | 
|  | 4429 | else | 
|  | 4430 | __push_char(_CharT(*__t % 32)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4431 | __first = ++__t; | 
|  | 4432 | } | 
| Howard Hinnant | 1e1d051 | 2013-07-15 18:21:11 | [diff] [blame] | 4433 | else | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4434 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4435 | } | 
| Howard Hinnant | 1e1d051 | 2013-07-15 18:21:11 | [diff] [blame] | 4436 | else | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4437 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4438 | break; | 
|  | 4439 | case 'u': | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4440 | ++__first; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4441 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4442 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4443 | __hd = __traits_.value(*__first, 16); | 
|  | 4444 | if (__hd == -1) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4445 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 4446 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4447 | ++__first; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4448 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4449 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4450 | __hd = __traits_.value(*__first, 16); | 
|  | 4451 | if (__hd == -1) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4452 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 4453 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4454 | // drop through | 
|  | 4455 | case 'x': | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4456 | ++__first; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4457 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4458 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4459 | __hd = __traits_.value(*__first, 16); | 
|  | 4460 | if (__hd == -1) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4461 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 4462 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4463 | ++__first; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 4464 | if (__first == __last) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4465 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4466 | __hd = __traits_.value(*__first, 16); | 
|  | 4467 | if (__hd == -1) | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4468 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | ec3773c | 2011-12-01 20:21:04 | [diff] [blame] | 4469 | __sum = 16 * __sum + static_cast<unsigned>(__hd); | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4470 | if (__str) | 
|  | 4471 | *__str = _CharT(__sum); | 
|  | 4472 | else | 
|  | 4473 | __push_char(_CharT(__sum)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4474 | ++__first; | 
|  | 4475 | break; | 
| Marshall Clow | 6b7e692 | 2014-05-21 16:29:50 | [diff] [blame] | 4476 | case '0': | 
|  | 4477 | if (__str) | 
|  | 4478 | *__str = _CharT(0); | 
|  | 4479 | else | 
|  | 4480 | __push_char(_CharT(0)); | 
|  | 4481 | ++__first; | 
|  | 4482 | break; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4483 | default: | 
|  | 4484 | if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum)) | 
|  | 4485 | { | 
| Howard Hinnant | 15476f3 | 2010-07-28 17:35:27 | [diff] [blame] | 4486 | if (__str) | 
|  | 4487 | *__str = *__first; | 
|  | 4488 | else | 
|  | 4489 | __push_char(*__first); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4490 | ++__first; | 
|  | 4491 | } | 
| Howard Hinnant | 918f2a8 | 2013-06-28 18:57:30 | [diff] [blame] | 4492 | else | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 4493 | __throw_regex_error<regex_constants::error_escape>(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4494 | break; | 
|  | 4495 | } | 
|  | 4496 | } | 
|  | 4497 | return __first; | 
|  | 4498 | } | 
|  | 4499 |  | 
|  | 4500 | template <class _CharT, class _Traits> | 
|  | 4501 | template <class _ForwardIterator> | 
|  | 4502 | _ForwardIterator | 
|  | 4503 | basic_regex<_CharT, _Traits>::__parse_pattern_character(_ForwardIterator __first, | 
|  | 4504 | _ForwardIterator __last) | 
|  | 4505 | { | 
|  | 4506 | if (__first != __last) | 
|  | 4507 | { | 
|  | 4508 | switch (*__first) | 
|  | 4509 | { | 
|  | 4510 | case '^': | 
|  | 4511 | case '$': | 
|  | 4512 | case '\\': | 
|  | 4513 | case '.': | 
|  | 4514 | case '*': | 
|  | 4515 | case '+': | 
|  | 4516 | case '?': | 
|  | 4517 | case '(': | 
|  | 4518 | case ')': | 
|  | 4519 | case '[': | 
|  | 4520 | case ']': | 
|  | 4521 | case '{': | 
|  | 4522 | case '}': | 
|  | 4523 | case '|': | 
|  | 4524 | break; | 
|  | 4525 | default: | 
|  | 4526 | __push_char(*__first); | 
|  | 4527 | ++__first; | 
|  | 4528 | break; | 
|  | 4529 | } | 
|  | 4530 | } | 
|  | 4531 | return __first; | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4532 | } | 
|  | 4533 |  | 
|  | 4534 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 4535 | template <class _ForwardIterator> | 
|  | 4536 | _ForwardIterator | 
|  | 4537 | basic_regex<_CharT, _Traits>::__parse_grep(_ForwardIterator __first, | 
|  | 4538 | _ForwardIterator __last) | 
|  | 4539 | { | 
|  | 4540 | __owns_one_state<_CharT>* __sa = __end_; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4541 | _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n')); | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 4542 | if (__t1 != __first) | 
|  | 4543 | __parse_basic_reg_exp(__first, __t1); | 
|  | 4544 | else | 
|  | 4545 | __push_empty(); | 
|  | 4546 | __first = __t1; | 
|  | 4547 | if (__first != __last) | 
|  | 4548 | ++__first; | 
|  | 4549 | while (__first != __last) | 
|  | 4550 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4551 | __t1 = _VSTD::find(__first, __last, _CharT('\n')); | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 4552 | __owns_one_state<_CharT>* __sb = __end_; | 
|  | 4553 | if (__t1 != __first) | 
|  | 4554 | __parse_basic_reg_exp(__first, __t1); | 
|  | 4555 | else | 
|  | 4556 | __push_empty(); | 
|  | 4557 | __push_alternation(__sa, __sb); | 
|  | 4558 | __first = __t1; | 
|  | 4559 | if (__first != __last) | 
|  | 4560 | ++__first; | 
|  | 4561 | } | 
|  | 4562 | return __first; | 
|  | 4563 | } | 
|  | 4564 |  | 
|  | 4565 | template <class _CharT, class _Traits> | 
|  | 4566 | template <class _ForwardIterator> | 
|  | 4567 | _ForwardIterator | 
|  | 4568 | basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first, | 
|  | 4569 | _ForwardIterator __last) | 
|  | 4570 | { | 
|  | 4571 | __owns_one_state<_CharT>* __sa = __end_; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4572 | _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n')); | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 4573 | if (__t1 != __first) | 
|  | 4574 | __parse_extended_reg_exp(__first, __t1); | 
|  | 4575 | else | 
|  | 4576 | __push_empty(); | 
|  | 4577 | __first = __t1; | 
|  | 4578 | if (__first != __last) | 
|  | 4579 | ++__first; | 
|  | 4580 | while (__first != __last) | 
|  | 4581 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4582 | __t1 = _VSTD::find(__first, __last, _CharT('\n')); | 
| Howard Hinnant | 856846b | 2010-07-27 19:53:10 | [diff] [blame] | 4583 | __owns_one_state<_CharT>* __sb = __end_; | 
|  | 4584 | if (__t1 != __first) | 
|  | 4585 | __parse_extended_reg_exp(__first, __t1); | 
|  | 4586 | else | 
|  | 4587 | __push_empty(); | 
|  | 4588 | __push_alternation(__sa, __sb); | 
|  | 4589 | __first = __t1; | 
|  | 4590 | if (__first != __last) | 
|  | 4591 | ++__first; | 
|  | 4592 | } | 
|  | 4593 | return __first; | 
|  | 4594 | } | 
|  | 4595 |  | 
|  | 4596 | template <class _CharT, class _Traits> | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4597 | void | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 4598 | basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max, | 
|  | 4599 | __owns_one_state<_CharT>* __s, size_t __mexp_begin, size_t __mexp_end, | 
|  | 4600 | bool __greedy) | 
|  | 4601 | { | 
|  | 4602 | unique_ptr<__empty_state<_CharT> > __e1(new __empty_state<_CharT>(__end_->first())); | 
|  | 4603 | __end_->first() = nullptr; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 4604 | unique_ptr<__loop<_CharT> > __e2(new __loop<_CharT>(__loop_count_, | 
|  | 4605 | __s->first(), __e1.get(), __mexp_begin, __mexp_end, __greedy, | 
|  | 4606 | __min, __max)); | 
|  | 4607 | __s->first() = nullptr; | 
|  | 4608 | __e1.release(); | 
|  | 4609 | __end_->first() = new __repeat_one_loop<_CharT>(__e2.get()); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 4610 | __end_ = __e2->second(); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 4611 | __s->first() = __e2.release(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 4612 | ++__loop_count_; | 
|  | 4613 | } | 
|  | 4614 |  | 
|  | 4615 | template <class _CharT, class _Traits> | 
|  | 4616 | void | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4617 | basic_regex<_CharT, _Traits>::__push_char(value_type __c) | 
|  | 4618 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4619 | if (flags() & icase) | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 4620 | __end_->first() = new __match_char_icase<_CharT, _Traits> | 
|  | 4621 | (__traits_, __c, __end_->first()); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4622 | else if (flags() & collate) | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 4623 | __end_->first() = new __match_char_collate<_CharT, _Traits> | 
|  | 4624 | (__traits_, __c, __end_->first()); | 
|  | 4625 | else | 
|  | 4626 | __end_->first() = new __match_char<_CharT>(__c, __end_->first()); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 4627 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4628 | } | 
|  | 4629 |  | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 4630 | template <class _CharT, class _Traits> | 
|  | 4631 | void | 
|  | 4632 | basic_regex<_CharT, _Traits>::__push_begin_marked_subexpression() | 
|  | 4633 | { | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 4634 | if (!(__flags_ & nosubs)) | 
|  | 4635 | { | 
|  | 4636 | __end_->first() = | 
|  | 4637 | new __begin_marked_subexpression<_CharT>(++__marked_count_, | 
|  | 4638 | __end_->first()); | 
|  | 4639 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4640 | } | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 4641 | } | 
|  | 4642 |  | 
|  | 4643 | template <class _CharT, class _Traits> | 
|  | 4644 | void | 
|  | 4645 | basic_regex<_CharT, _Traits>::__push_end_marked_subexpression(unsigned __sub) | 
|  | 4646 | { | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 4647 | if (!(__flags_ & nosubs)) | 
|  | 4648 | { | 
|  | 4649 | __end_->first() = | 
|  | 4650 | new __end_marked_subexpression<_CharT>(__sub, __end_->first()); | 
|  | 4651 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4652 | } | 
| Howard Hinnant | 0dca5fc | 2010-06-30 20:30:19 | [diff] [blame] | 4653 | } | 
|  | 4654 |  | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 4655 | template <class _CharT, class _Traits> | 
|  | 4656 | void | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 4657 | basic_regex<_CharT, _Traits>::__push_l_anchor() | 
|  | 4658 | { | 
|  | 4659 | __end_->first() = new __l_anchor<_CharT>(__end_->first()); | 
|  | 4660 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4661 | } | 
|  | 4662 |  | 
|  | 4663 | template <class _CharT, class _Traits> | 
|  | 4664 | void | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 4665 | basic_regex<_CharT, _Traits>::__push_r_anchor() | 
|  | 4666 | { | 
|  | 4667 | __end_->first() = new __r_anchor<_CharT>(__end_->first()); | 
|  | 4668 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4669 | } | 
|  | 4670 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 4671 | template <class _CharT, class _Traits> | 
|  | 4672 | void | 
|  | 4673 | basic_regex<_CharT, _Traits>::__push_match_any() | 
|  | 4674 | { | 
|  | 4675 | __end_->first() = new __match_any<_CharT>(__end_->first()); | 
|  | 4676 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4677 | } | 
| Howard Hinnant | 37f9f9c | 2010-07-09 00:15:26 | [diff] [blame] | 4678 |  | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 4679 | template <class _CharT, class _Traits> | 
|  | 4680 | void | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4681 | basic_regex<_CharT, _Traits>::__push_match_any_but_newline() | 
|  | 4682 | { | 
|  | 4683 | __end_->first() = new __match_any_but_newline<_CharT>(__end_->first()); | 
|  | 4684 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4685 | } | 
|  | 4686 |  | 
|  | 4687 | template <class _CharT, class _Traits> | 
|  | 4688 | void | 
| Howard Hinnant | 2ade7c2 | 2010-07-22 17:53:24 | [diff] [blame] | 4689 | basic_regex<_CharT, _Traits>::__push_empty() | 
|  | 4690 | { | 
|  | 4691 | __end_->first() = new __empty_state<_CharT>(__end_->first()); | 
|  | 4692 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4693 | } | 
|  | 4694 |  | 
|  | 4695 | template <class _CharT, class _Traits> | 
|  | 4696 | void | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 4697 | basic_regex<_CharT, _Traits>::__push_word_boundary(bool __invert) | 
|  | 4698 | { | 
|  | 4699 | __end_->first() = new __word_boundary<_CharT, _Traits>(__traits_, __invert, | 
|  | 4700 | __end_->first()); | 
|  | 4701 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4702 | } | 
|  | 4703 |  | 
|  | 4704 | template <class _CharT, class _Traits> | 
|  | 4705 | void | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 4706 | basic_regex<_CharT, _Traits>::__push_back_ref(int __i) | 
|  | 4707 | { | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4708 | if (flags() & icase) | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 4709 | __end_->first() = new __back_ref_icase<_CharT, _Traits> | 
|  | 4710 | (__traits_, __i, __end_->first()); | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4711 | else if (flags() & collate) | 
| Howard Hinnant | e34f17d | 2010-07-12 19:11:27 | [diff] [blame] | 4712 | __end_->first() = new __back_ref_collate<_CharT, _Traits> | 
|  | 4713 | (__traits_, __i, __end_->first()); | 
|  | 4714 | else | 
|  | 4715 | __end_->first() = new __back_ref<_CharT>(__i, __end_->first()); | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 4716 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4717 | } | 
|  | 4718 |  | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4719 | template <class _CharT, class _Traits> | 
| Howard Hinnant | aa69808 | 2010-07-16 19:08:36 | [diff] [blame] | 4720 | void | 
|  | 4721 | basic_regex<_CharT, _Traits>::__push_alternation(__owns_one_state<_CharT>* __sa, | 
|  | 4722 | __owns_one_state<_CharT>* __ea) | 
|  | 4723 | { | 
|  | 4724 | __sa->first() = new __alternate<_CharT>( | 
|  | 4725 | static_cast<__owns_one_state<_CharT>*>(__sa->first()), | 
|  | 4726 | static_cast<__owns_one_state<_CharT>*>(__ea->first())); | 
|  | 4727 | __ea->first() = nullptr; | 
|  | 4728 | __ea->first() = new __empty_state<_CharT>(__end_->first()); | 
|  | 4729 | __end_->first() = nullptr; | 
|  | 4730 | __end_->first() = new __empty_non_own_state<_CharT>(__ea->first()); | 
|  | 4731 | __end_ = static_cast<__owns_one_state<_CharT>*>(__ea->first()); | 
|  | 4732 | } | 
|  | 4733 |  | 
|  | 4734 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 173968a | 2010-07-13 21:48:06 | [diff] [blame] | 4735 | __bracket_expression<_CharT, _Traits>* | 
|  | 4736 | basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate) | 
|  | 4737 | { | 
|  | 4738 | __bracket_expression<_CharT, _Traits>* __r = | 
|  | 4739 | new __bracket_expression<_CharT, _Traits>(__traits_, __end_->first(), | 
|  | 4740 | __negate, __flags_ & icase, | 
|  | 4741 | __flags_ & collate); | 
|  | 4742 | __end_->first() = __r; | 
|  | 4743 | __end_ = __r; | 
|  | 4744 | return __r; | 
|  | 4745 | } | 
|  | 4746 |  | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4747 | template <class _CharT, class _Traits> | 
|  | 4748 | void | 
|  | 4749 | basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, | 
| Howard Hinnant | cd59acc | 2013-07-23 16:18:04 | [diff] [blame] | 4750 | bool __invert, | 
|  | 4751 | unsigned __mexp) | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4752 | { | 
|  | 4753 | __end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert, | 
| Howard Hinnant | cd59acc | 2013-07-23 16:18:04 | [diff] [blame] | 4754 | __end_->first(), __mexp); | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 4755 | __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first()); | 
|  | 4756 | } | 
|  | 4757 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 4758 | typedef basic_regex<char> regex; | 
|  | 4759 | typedef basic_regex<wchar_t> wregex; | 
|  | 4760 |  | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4761 | // sub_match | 
|  | 4762 |  | 
|  | 4763 | template <class _BidirectionalIterator> | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 | [diff] [blame] | 4764 | class _LIBCPP_TYPE_VIS_ONLY sub_match | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4765 | : public pair<_BidirectionalIterator, _BidirectionalIterator> | 
|  | 4766 | { | 
|  | 4767 | public: | 
|  | 4768 | typedef _BidirectionalIterator iterator; | 
|  | 4769 | typedef typename iterator_traits<iterator>::value_type value_type; | 
|  | 4770 | typedef typename iterator_traits<iterator>::difference_type difference_type; | 
|  | 4771 | typedef basic_string<value_type> string_type; | 
|  | 4772 |  | 
|  | 4773 | bool matched; | 
|  | 4774 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4775 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 46623a0 | 2012-07-21 01:31:58 | [diff] [blame] | 4776 | _LIBCPP_CONSTEXPR sub_match() : matched() {} | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 4777 |  | 
|  | 4778 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4779 | difference_type length() const | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 4780 | {return matched ? _VSTD::distance(this->first, this->second) : 0;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4781 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4782 | string_type str() const | 
|  | 4783 | {return matched ? string_type(this->first, this->second) : string_type();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4784 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4785 | operator string_type() const | 
|  | 4786 | {return str();} | 
|  | 4787 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4788 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4789 | int compare(const sub_match& __s) const | 
|  | 4790 | {return str().compare(__s.str());} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4791 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4792 | int compare(const string_type& __s) const | 
|  | 4793 | {return str().compare(__s);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 4794 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4795 | int compare(const value_type* __s) const | 
|  | 4796 | {return str().compare(__s);} | 
|  | 4797 | }; | 
|  | 4798 |  | 
|  | 4799 | typedef sub_match<const char*> csub_match; | 
|  | 4800 | typedef sub_match<const wchar_t*> wcsub_match; | 
|  | 4801 | typedef sub_match<string::const_iterator> ssub_match; | 
|  | 4802 | typedef sub_match<wstring::const_iterator> wssub_match; | 
|  | 4803 |  | 
|  | 4804 | template <class _BiIter> | 
|  | 4805 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4806 | bool | 
|  | 4807 | operator==(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4808 | { | 
|  | 4809 | return __x.compare(__y) == 0; | 
|  | 4810 | } | 
|  | 4811 |  | 
|  | 4812 | template <class _BiIter> | 
|  | 4813 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4814 | bool | 
|  | 4815 | operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4816 | { | 
|  | 4817 | return !(__x == __y); | 
|  | 4818 | } | 
|  | 4819 |  | 
|  | 4820 | template <class _BiIter> | 
|  | 4821 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4822 | bool | 
|  | 4823 | operator<(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4824 | { | 
|  | 4825 | return __x.compare(__y) < 0; | 
|  | 4826 | } | 
|  | 4827 |  | 
|  | 4828 | template <class _BiIter> | 
|  | 4829 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4830 | bool | 
|  | 4831 | operator<=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4832 | { | 
|  | 4833 | return !(__y < __x); | 
|  | 4834 | } | 
|  | 4835 |  | 
|  | 4836 | template <class _BiIter> | 
|  | 4837 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4838 | bool | 
|  | 4839 | operator>=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4840 | { | 
|  | 4841 | return !(__x < __y); | 
|  | 4842 | } | 
|  | 4843 |  | 
|  | 4844 | template <class _BiIter> | 
|  | 4845 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4846 | bool | 
|  | 4847 | operator>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 4848 | { | 
|  | 4849 | return __y < __x; | 
|  | 4850 | } | 
|  | 4851 |  | 
|  | 4852 | template <class _BiIter, class _ST, class _SA> | 
|  | 4853 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4854 | bool | 
|  | 4855 | operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4856 | const sub_match<_BiIter>& __y) | 
|  | 4857 | { | 
| Marshall Clow | e3e7054 | 2014-12-15 23:57:56 | [diff] [blame] | 4858 | return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4859 | } | 
|  | 4860 |  | 
|  | 4861 | template <class _BiIter, class _ST, class _SA> | 
|  | 4862 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4863 | bool | 
|  | 4864 | operator!=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4865 | const sub_match<_BiIter>& __y) | 
|  | 4866 | { | 
|  | 4867 | return !(__x == __y); | 
|  | 4868 | } | 
|  | 4869 |  | 
|  | 4870 | template <class _BiIter, class _ST, class _SA> | 
|  | 4871 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4872 | bool | 
|  | 4873 | operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4874 | const sub_match<_BiIter>& __y) | 
|  | 4875 | { | 
| Marshall Clow | e3e7054 | 2014-12-15 23:57:56 | [diff] [blame] | 4876 | return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4877 | } | 
|  | 4878 |  | 
|  | 4879 | template <class _BiIter, class _ST, class _SA> | 
|  | 4880 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4881 | bool | 
|  | 4882 | operator>(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4883 | const sub_match<_BiIter>& __y) | 
|  | 4884 | { | 
|  | 4885 | return __y < __x; | 
|  | 4886 | } | 
|  | 4887 |  | 
|  | 4888 | template <class _BiIter, class _ST, class _SA> | 
|  | 4889 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4890 | bool operator>=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4891 | const sub_match<_BiIter>& __y) | 
|  | 4892 | { | 
|  | 4893 | return !(__x < __y); | 
|  | 4894 | } | 
|  | 4895 |  | 
|  | 4896 | template <class _BiIter, class _ST, class _SA> | 
|  | 4897 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4898 | bool | 
|  | 4899 | operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 4900 | const sub_match<_BiIter>& __y) | 
|  | 4901 | { | 
|  | 4902 | return !(__y < __x); | 
|  | 4903 | } | 
|  | 4904 |  | 
|  | 4905 | template <class _BiIter, class _ST, class _SA> | 
|  | 4906 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4907 | bool | 
|  | 4908 | operator==(const sub_match<_BiIter>& __x, | 
|  | 4909 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4910 | { | 
| Marshall Clow | e3e7054 | 2014-12-15 23:57:56 | [diff] [blame] | 4911 | return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4912 | } | 
|  | 4913 |  | 
|  | 4914 | template <class _BiIter, class _ST, class _SA> | 
|  | 4915 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4916 | bool | 
|  | 4917 | operator!=(const sub_match<_BiIter>& __x, | 
|  | 4918 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4919 | { | 
|  | 4920 | return !(__x == __y); | 
|  | 4921 | } | 
|  | 4922 |  | 
|  | 4923 | template <class _BiIter, class _ST, class _SA> | 
|  | 4924 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4925 | bool | 
|  | 4926 | operator<(const sub_match<_BiIter>& __x, | 
|  | 4927 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4928 | { | 
| Marshall Clow | e3e7054 | 2014-12-15 23:57:56 | [diff] [blame] | 4929 | return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame] | 4930 | } | 
|  | 4931 |  | 
|  | 4932 | template <class _BiIter, class _ST, class _SA> | 
|  | 4933 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4934 | bool operator>(const sub_match<_BiIter>& __x, | 
|  | 4935 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4936 | { | 
|  | 4937 | return __y < __x; | 
|  | 4938 | } | 
|  | 4939 |  | 
|  | 4940 | template <class _BiIter, class _ST, class _SA> | 
|  | 4941 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4942 | bool | 
|  | 4943 | operator>=(const sub_match<_BiIter>& __x, | 
|  | 4944 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4945 | { | 
|  | 4946 | return !(__x < __y); | 
|  | 4947 | } | 
|  | 4948 |  | 
|  | 4949 | template <class _BiIter, class _ST, class _SA> | 
|  | 4950 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4951 | bool | 
|  | 4952 | operator<=(const sub_match<_BiIter>& __x, | 
|  | 4953 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 4954 | { | 
|  | 4955 | return !(__y < __x); | 
|  | 4956 | } | 
|  | 4957 |  | 
|  | 4958 | template <class _BiIter> | 
|  | 4959 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4960 | bool | 
|  | 4961 | operator==(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 4962 | const sub_match<_BiIter>& __y) | 
|  | 4963 | { | 
|  | 4964 | return __y.compare(__x) == 0; | 
|  | 4965 | } | 
|  | 4966 |  | 
|  | 4967 | template <class _BiIter> | 
|  | 4968 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4969 | bool | 
|  | 4970 | operator!=(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 4971 | const sub_match<_BiIter>& __y) | 
|  | 4972 | { | 
|  | 4973 | return !(__x == __y); | 
|  | 4974 | } | 
|  | 4975 |  | 
|  | 4976 | template <class _BiIter> | 
|  | 4977 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4978 | bool | 
|  | 4979 | operator<(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 4980 | const sub_match<_BiIter>& __y) | 
|  | 4981 | { | 
|  | 4982 | return __y.compare(__x) > 0; | 
|  | 4983 | } | 
|  | 4984 |  | 
|  | 4985 | template <class _BiIter> | 
|  | 4986 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4987 | bool | 
|  | 4988 | operator>(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 4989 | const sub_match<_BiIter>& __y) | 
|  | 4990 | { | 
|  | 4991 | return __y < __x; | 
|  | 4992 | } | 
|  | 4993 |  | 
|  | 4994 | template <class _BiIter> | 
|  | 4995 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 4996 | bool | 
|  | 4997 | operator>=(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 4998 | const sub_match<_BiIter>& __y) | 
|  | 4999 | { | 
|  | 5000 | return !(__x < __y); | 
|  | 5001 | } | 
|  | 5002 |  | 
|  | 5003 | template <class _BiIter> | 
|  | 5004 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5005 | bool | 
|  | 5006 | operator<=(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 5007 | const sub_match<_BiIter>& __y) | 
|  | 5008 | { | 
|  | 5009 | return !(__y < __x); | 
|  | 5010 | } | 
|  | 5011 |  | 
|  | 5012 | template <class _BiIter> | 
|  | 5013 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5014 | bool | 
|  | 5015 | operator==(const sub_match<_BiIter>& __x, | 
|  | 5016 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 5017 | { | 
|  | 5018 | return __x.compare(__y) == 0; | 
|  | 5019 | } | 
|  | 5020 |  | 
|  | 5021 | template <class _BiIter> | 
|  | 5022 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5023 | bool | 
|  | 5024 | operator!=(const sub_match<_BiIter>& __x, | 
|  | 5025 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 5026 | { | 
|  | 5027 | return !(__x == __y); | 
|  | 5028 | } | 
|  | 5029 |  | 
|  | 5030 | template <class _BiIter> | 
|  | 5031 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5032 | bool | 
|  | 5033 | operator<(const sub_match<_BiIter>& __x, | 
|  | 5034 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 5035 | { | 
|  | 5036 | return __x.compare(__y) < 0; | 
|  | 5037 | } | 
|  | 5038 |  | 
|  | 5039 | template <class _BiIter> | 
|  | 5040 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5041 | bool | 
|  | 5042 | operator>(const sub_match<_BiIter>& __x, | 
|  | 5043 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 5044 | { | 
|  | 5045 | return __y < __x; | 
|  | 5046 | } | 
|  | 5047 |  | 
|  | 5048 | template <class _BiIter> | 
|  | 5049 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5050 | bool | 
|  | 5051 | operator>=(const sub_match<_BiIter>& __x, | 
|  | 5052 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 5053 | { | 
|  | 5054 | return !(__x < __y); | 
|  | 5055 | } | 
|  | 5056 |  | 
|  | 5057 | template <class _BiIter> | 
|  | 5058 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5059 | bool | 
|  | 5060 | operator<=(const sub_match<_BiIter>& __x, | 
|  | 5061 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 5062 | { | 
|  | 5063 | return !(__y < __x); | 
|  | 5064 | } | 
|  | 5065 |  | 
|  | 5066 | template <class _BiIter> | 
|  | 5067 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5068 | bool | 
|  | 5069 | operator==(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5070 | const sub_match<_BiIter>& __y) | 
|  | 5071 | { | 
|  | 5072 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 5073 | return __y.compare(string_type(1, __x)) == 0; | 
|  | 5074 | } | 
|  | 5075 |  | 
|  | 5076 | template <class _BiIter> | 
|  | 5077 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5078 | bool | 
|  | 5079 | operator!=(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5080 | const sub_match<_BiIter>& __y) | 
|  | 5081 | { | 
|  | 5082 | return !(__x == __y); | 
|  | 5083 | } | 
|  | 5084 |  | 
|  | 5085 | template <class _BiIter> | 
|  | 5086 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5087 | bool | 
|  | 5088 | operator<(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5089 | const sub_match<_BiIter>& __y) | 
|  | 5090 | { | 
|  | 5091 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 5092 | return __y.compare(string_type(1, __x)) > 0; | 
|  | 5093 | } | 
|  | 5094 |  | 
|  | 5095 | template <class _BiIter> | 
|  | 5096 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5097 | bool | 
|  | 5098 | operator>(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5099 | const sub_match<_BiIter>& __y) | 
|  | 5100 | { | 
|  | 5101 | return __y < __x; | 
|  | 5102 | } | 
|  | 5103 |  | 
|  | 5104 | template <class _BiIter> | 
|  | 5105 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5106 | bool | 
|  | 5107 | operator>=(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5108 | const sub_match<_BiIter>& __y) | 
|  | 5109 | { | 
|  | 5110 | return !(__x < __y); | 
|  | 5111 | } | 
|  | 5112 |  | 
|  | 5113 | template <class _BiIter> | 
|  | 5114 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5115 | bool | 
|  | 5116 | operator<=(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 5117 | const sub_match<_BiIter>& __y) | 
|  | 5118 | { | 
|  | 5119 | return !(__y < __x); | 
|  | 5120 | } | 
|  | 5121 |  | 
|  | 5122 | template <class _BiIter> | 
|  | 5123 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5124 | bool | 
|  | 5125 | operator==(const sub_match<_BiIter>& __x, | 
|  | 5126 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5127 | { | 
|  | 5128 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 5129 | return __x.compare(string_type(1, __y)) == 0; | 
|  | 5130 | } | 
|  | 5131 |  | 
|  | 5132 | template <class _BiIter> | 
|  | 5133 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5134 | bool | 
|  | 5135 | operator!=(const sub_match<_BiIter>& __x, | 
|  | 5136 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5137 | { | 
|  | 5138 | return !(__x == __y); | 
|  | 5139 | } | 
|  | 5140 |  | 
|  | 5141 | template <class _BiIter> | 
|  | 5142 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5143 | bool | 
|  | 5144 | operator<(const sub_match<_BiIter>& __x, | 
|  | 5145 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5146 | { | 
|  | 5147 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 5148 | return __x.compare(string_type(1, __y)) < 0; | 
|  | 5149 | } | 
|  | 5150 |  | 
|  | 5151 | template <class _BiIter> | 
|  | 5152 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5153 | bool | 
|  | 5154 | operator>(const sub_match<_BiIter>& __x, | 
|  | 5155 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5156 | { | 
|  | 5157 | return __y < __x; | 
|  | 5158 | } | 
|  | 5159 |  | 
|  | 5160 | template <class _BiIter> | 
|  | 5161 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5162 | bool | 
|  | 5163 | operator>=(const sub_match<_BiIter>& __x, | 
|  | 5164 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5165 | { | 
|  | 5166 | return !(__x < __y); | 
|  | 5167 | } | 
|  | 5168 |  | 
|  | 5169 | template <class _BiIter> | 
|  | 5170 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5171 | bool | 
|  | 5172 | operator<=(const sub_match<_BiIter>& __x, | 
|  | 5173 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 5174 | { | 
|  | 5175 | return !(__y < __x); | 
|  | 5176 | } | 
|  | 5177 |  | 
|  | 5178 | template <class _CharT, class _ST, class _BiIter> | 
|  | 5179 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5180 | basic_ostream<_CharT, _ST>& | 
|  | 5181 | operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) | 
|  | 5182 | { | 
|  | 5183 | return __os << __m.str(); | 
|  | 5184 | } | 
|  | 5185 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5186 | template <class _BidirectionalIterator, class _Allocator> | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 | [diff] [blame] | 5187 | class _LIBCPP_TYPE_VIS_ONLY match_results | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5188 | { | 
|  | 5189 | public: | 
|  | 5190 | typedef _Allocator allocator_type; | 
|  | 5191 | typedef sub_match<_BidirectionalIterator> value_type; | 
|  | 5192 | private: | 
|  | 5193 | typedef vector<value_type, allocator_type> __container_type; | 
|  | 5194 |  | 
|  | 5195 | __container_type __matches_; | 
|  | 5196 | value_type __unmatched_; | 
|  | 5197 | value_type __prefix_; | 
|  | 5198 | value_type __suffix_; | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5199 | bool __ready_; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5200 | public: | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5201 | _BidirectionalIterator __position_start_; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5202 | typedef const value_type& const_reference; | 
| Marshall Clow | 103af34 | 2014-02-26 01:56:31 | [diff] [blame] | 5203 | typedef value_type& reference; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5204 | typedef typename __container_type::const_iterator const_iterator; | 
|  | 5205 | typedef const_iterator iterator; | 
|  | 5206 | typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; | 
|  | 5207 | typedef typename allocator_traits<allocator_type>::size_type size_type; | 
|  | 5208 | typedef typename iterator_traits<_BidirectionalIterator>::value_type char_type; | 
|  | 5209 | typedef basic_string<char_type> string_type; | 
|  | 5210 |  | 
|  | 5211 | // construct/copy/destroy: | 
|  | 5212 | explicit match_results(const allocator_type& __a = allocator_type()); | 
|  | 5213 | // match_results(const match_results&) = default; | 
|  | 5214 | // match_results& operator=(const match_results&) = default; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5215 | // match_results(match_results&& __m) = default; | 
|  | 5216 | // match_results& operator=(match_results&& __m) = default; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5217 | // ~match_results() = default; | 
|  | 5218 |  | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5219 | _LIBCPP_INLINE_VISIBILITY | 
|  | 5220 | bool ready() const {return __ready_;} | 
|  | 5221 |  | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5222 | // size: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5223 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5224 | size_type size() const {return __matches_.size();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5225 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5226 | size_type max_size() const {return __matches_.max_size();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5227 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5228 | bool empty() const {return size() == 0;} | 
|  | 5229 |  | 
|  | 5230 | // element access: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5231 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5232 | difference_type length(size_type __sub = 0) const | 
|  | 5233 | {return (*this)[__sub].length();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5234 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5235 | difference_type position(size_type __sub = 0) const | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5236 | {return _VSTD::distance(__position_start_, (*this)[__sub].first);} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5237 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5238 | string_type str(size_type __sub = 0) const | 
|  | 5239 | {return (*this)[__sub].str();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5240 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5241 | const_reference operator[](size_type __n) const | 
|  | 5242 | {return __n < __matches_.size() ? __matches_[__n] : __unmatched_;} | 
|  | 5243 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5244 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5245 | const_reference prefix() const {return __prefix_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5246 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5247 | const_reference suffix() const {return __suffix_;} | 
|  | 5248 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5249 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | c6fe8ca | 2011-10-08 14:36:16 | [diff] [blame] | 5250 | const_iterator begin() const {return empty() ? __matches_.end() : __matches_.begin();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5251 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5252 | const_iterator end() const {return __matches_.end();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5253 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | c6fe8ca | 2011-10-08 14:36:16 | [diff] [blame] | 5254 | const_iterator cbegin() const {return empty() ? __matches_.end() : __matches_.begin();} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5255 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5256 | const_iterator cend() const {return __matches_.end();} | 
|  | 5257 |  | 
|  | 5258 | // format: | 
|  | 5259 | template <class _OutputIter> | 
|  | 5260 | _OutputIter | 
|  | 5261 | format(_OutputIter __out, const char_type* __fmt_first, | 
|  | 5262 | const char_type* __fmt_last, | 
|  | 5263 | regex_constants::match_flag_type __flags = regex_constants::format_default) const; | 
|  | 5264 | template <class _OutputIter, class _ST, class _SA> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5265 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5266 | _OutputIter | 
|  | 5267 | format(_OutputIter __out, const basic_string<char_type, _ST, _SA>& __fmt, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5268 | regex_constants::match_flag_type __flags = regex_constants::format_default) const | 
|  | 5269 | {return format(__out, __fmt.data(), __fmt.data() + __fmt.size(), __flags);} | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5270 | template <class _ST, class _SA> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5271 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5272 | basic_string<char_type, _ST, _SA> | 
|  | 5273 | format(const basic_string<char_type, _ST, _SA>& __fmt, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5274 | regex_constants::match_flag_type __flags = regex_constants::format_default) const | 
|  | 5275 | { | 
|  | 5276 | basic_string<char_type, _ST, _SA> __r; | 
|  | 5277 | format(back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(), | 
|  | 5278 | __flags); | 
|  | 5279 | return __r; | 
|  | 5280 | } | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5281 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5282 | string_type | 
|  | 5283 | format(const char_type* __fmt, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5284 | regex_constants::match_flag_type __flags = regex_constants::format_default) const | 
|  | 5285 | { | 
|  | 5286 | string_type __r; | 
|  | 5287 | format(back_inserter(__r), __fmt, | 
|  | 5288 | __fmt + char_traits<char_type>::length(__fmt), __flags); | 
|  | 5289 | return __r; | 
|  | 5290 | } | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5291 |  | 
|  | 5292 | // allocator: | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5293 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5294 | allocator_type get_allocator() const {return __matches_.get_allocator();} | 
|  | 5295 |  | 
|  | 5296 | // swap: | 
|  | 5297 | void swap(match_results& __m); | 
|  | 5298 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5299 | template <class _Bp, class _Ap> | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 5300 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5301 | void __assign(_BidirectionalIterator __f, _BidirectionalIterator __l, | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5302 | const match_results<_Bp, _Ap>& __m, bool __no_update_pos) | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5303 | { | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5304 | _Bp __mf = __m.prefix().first; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5305 | __matches_.resize(__m.size()); | 
|  | 5306 | for (size_type __i = 0; __i < __matches_.size(); ++__i) | 
|  | 5307 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5308 | __matches_[__i].first = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].first)); | 
|  | 5309 | __matches_[__i].second = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].second)); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5310 | __matches_[__i].matched = __m[__i].matched; | 
|  | 5311 | } | 
|  | 5312 | __unmatched_.first = __l; | 
|  | 5313 | __unmatched_.second = __l; | 
|  | 5314 | __unmatched_.matched = false; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5315 | __prefix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().first)); | 
|  | 5316 | __prefix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().second)); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5317 | __prefix_.matched = __m.prefix().matched; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5318 | __suffix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().first)); | 
|  | 5319 | __suffix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().second)); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5320 | __suffix_.matched = __m.suffix().matched; | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5321 | if (!__no_update_pos) | 
|  | 5322 | __position_start_ = __prefix_.first; | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5323 | __ready_ = __m.ready(); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5324 | } | 
|  | 5325 |  | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5326 | private: | 
|  | 5327 | void __init(unsigned __s, | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5328 | _BidirectionalIterator __f, _BidirectionalIterator __l, | 
|  | 5329 | bool __no_update_pos = false); | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5330 |  | 
|  | 5331 | template <class, class> friend class basic_regex; | 
|  | 5332 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5333 | template <class _Bp, class _Ap, class _Cp, class _Tp> | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5334 | friend | 
|  | 5335 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5336 | regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&, | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5337 | regex_constants::match_flag_type); | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 5338 |  | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5339 | template <class _Bp, class _Ap> | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5340 | friend | 
|  | 5341 | bool | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5342 | operator==(const match_results<_Bp, _Ap>&, const match_results<_Bp, _Ap>&); | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5343 |  | 
| Howard Hinnant | e9de5ff | 2010-07-27 22:20:32 | [diff] [blame] | 5344 | template <class, class> friend class __lookahead; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5345 | }; | 
|  | 5346 |  | 
|  | 5347 | template <class _BidirectionalIterator, class _Allocator> | 
|  | 5348 | match_results<_BidirectionalIterator, _Allocator>::match_results( | 
|  | 5349 | const allocator_type& __a) | 
|  | 5350 | : __matches_(__a), | 
|  | 5351 | __unmatched_(), | 
|  | 5352 | __prefix_(), | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5353 | __suffix_(), | 
| Eric Fiselier | 7cc7106 | 2015-07-22 01:29:41 | [diff] [blame] | 5354 | __ready_(false), | 
|  | 5355 | __position_start_() | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5356 | { | 
|  | 5357 | } | 
|  | 5358 |  | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5359 | template <class _BidirectionalIterator, class _Allocator> | 
|  | 5360 | void | 
|  | 5361 | match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s, | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5362 | _BidirectionalIterator __f, _BidirectionalIterator __l, | 
|  | 5363 | bool __no_update_pos) | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5364 | { | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5365 | __unmatched_.first = __l; | 
|  | 5366 | __unmatched_.second = __l; | 
|  | 5367 | __unmatched_.matched = false; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5368 | __matches_.assign(__s, __unmatched_); | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5369 | __prefix_.first = __f; | 
|  | 5370 | __prefix_.second = __f; | 
|  | 5371 | __prefix_.matched = false; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5372 | __suffix_ = __unmatched_; | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5373 | if (!__no_update_pos) | 
|  | 5374 | __position_start_ = __prefix_.first; | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5375 | __ready_ = true; | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5376 | } | 
|  | 5377 |  | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5378 | template <class _BidirectionalIterator, class _Allocator> | 
|  | 5379 | template <class _OutputIter> | 
|  | 5380 | _OutputIter | 
|  | 5381 | match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out, | 
|  | 5382 | const char_type* __fmt_first, const char_type* __fmt_last, | 
|  | 5383 | regex_constants::match_flag_type __flags) const | 
|  | 5384 | { | 
|  | 5385 | if (__flags & regex_constants::format_sed) | 
|  | 5386 | { | 
|  | 5387 | for (; __fmt_first != __fmt_last; ++__fmt_first) | 
|  | 5388 | { | 
|  | 5389 | if (*__fmt_first == '&') | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5390 | __out = _VSTD::copy(__matches_[0].first, __matches_[0].second, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5391 | __out); | 
|  | 5392 | else if (*__fmt_first == '\\' && __fmt_first + 1 != __fmt_last) | 
|  | 5393 | { | 
|  | 5394 | ++__fmt_first; | 
|  | 5395 | if ('0' <= *__fmt_first && *__fmt_first <= '9') | 
|  | 5396 | { | 
|  | 5397 | size_t __i = *__fmt_first - '0'; | 
| Duncan P. N. Exon Smith | e784f57 | 2016-02-03 19:30:20 | [diff] [blame] | 5398 | __out = _VSTD::copy((*this)[__i].first, | 
|  | 5399 | (*this)[__i].second, __out); | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5400 | } | 
|  | 5401 | else | 
|  | 5402 | { | 
|  | 5403 | *__out = *__fmt_first; | 
|  | 5404 | ++__out; | 
|  | 5405 | } | 
|  | 5406 | } | 
|  | 5407 | else | 
|  | 5408 | { | 
|  | 5409 | *__out = *__fmt_first; | 
|  | 5410 | ++__out; | 
|  | 5411 | } | 
|  | 5412 | } | 
|  | 5413 | } | 
|  | 5414 | else | 
|  | 5415 | { | 
|  | 5416 | for (; __fmt_first != __fmt_last; ++__fmt_first) | 
|  | 5417 | { | 
|  | 5418 | if (*__fmt_first == '$' && __fmt_first + 1 != __fmt_last) | 
|  | 5419 | { | 
|  | 5420 | switch (__fmt_first[1]) | 
|  | 5421 | { | 
|  | 5422 | case '$': | 
|  | 5423 | *__out = *++__fmt_first; | 
|  | 5424 | ++__out; | 
|  | 5425 | break; | 
|  | 5426 | case '&': | 
|  | 5427 | ++__fmt_first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5428 | __out = _VSTD::copy(__matches_[0].first, __matches_[0].second, | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5429 | __out); | 
|  | 5430 | break; | 
|  | 5431 | case '`': | 
|  | 5432 | ++__fmt_first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5433 | __out = _VSTD::copy(__prefix_.first, __prefix_.second, __out); | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5434 | break; | 
|  | 5435 | case '\'': | 
|  | 5436 | ++__fmt_first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5437 | __out = _VSTD::copy(__suffix_.first, __suffix_.second, __out); | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5438 | break; | 
|  | 5439 | default: | 
|  | 5440 | if ('0' <= __fmt_first[1] && __fmt_first[1] <= '9') | 
|  | 5441 | { | 
|  | 5442 | ++__fmt_first; | 
|  | 5443 | size_t __i = *__fmt_first - '0'; | 
|  | 5444 | if (__fmt_first + 1 != __fmt_last && | 
|  | 5445 | '0' <= __fmt_first[1] && __fmt_first[1] <= '9') | 
|  | 5446 | { | 
|  | 5447 | ++__fmt_first; | 
|  | 5448 | __i = 10 * __i + *__fmt_first - '0'; | 
|  | 5449 | } | 
| Duncan P. N. Exon Smith | e784f57 | 2016-02-03 19:30:20 | [diff] [blame] | 5450 | __out = _VSTD::copy((*this)[__i].first, | 
|  | 5451 | (*this)[__i].second, __out); | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5452 | } | 
|  | 5453 | else | 
|  | 5454 | { | 
|  | 5455 | *__out = *__fmt_first; | 
|  | 5456 | ++__out; | 
|  | 5457 | } | 
|  | 5458 | break; | 
|  | 5459 | } | 
|  | 5460 | } | 
|  | 5461 | else | 
|  | 5462 | { | 
|  | 5463 | *__out = *__fmt_first; | 
|  | 5464 | ++__out; | 
|  | 5465 | } | 
|  | 5466 | } | 
|  | 5467 | } | 
|  | 5468 | return __out; | 
|  | 5469 | } | 
|  | 5470 |  | 
|  | 5471 | template <class _BidirectionalIterator, class _Allocator> | 
|  | 5472 | void | 
|  | 5473 | match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m) | 
|  | 5474 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5475 | using _VSTD::swap; | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5476 | swap(__matches_, __m.__matches_); | 
|  | 5477 | swap(__unmatched_, __m.__unmatched_); | 
|  | 5478 | swap(__prefix_, __m.__prefix_); | 
|  | 5479 | swap(__suffix_, __m.__suffix_); | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5480 | swap(__position_start_, __m.__position_start_); | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5481 | swap(__ready_, __m.__ready_); | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5482 | } | 
|  | 5483 |  | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5484 | typedef match_results<const char*> cmatch; | 
|  | 5485 | typedef match_results<const wchar_t*> wcmatch; | 
|  | 5486 | typedef match_results<string::const_iterator> smatch; | 
|  | 5487 | typedef match_results<wstring::const_iterator> wsmatch; | 
|  | 5488 |  | 
|  | 5489 | template <class _BidirectionalIterator, class _Allocator> | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5490 | bool | 
|  | 5491 | operator==(const match_results<_BidirectionalIterator, _Allocator>& __x, | 
|  | 5492 | const match_results<_BidirectionalIterator, _Allocator>& __y) | 
|  | 5493 | { | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5494 | if (__x.__ready_ != __y.__ready_) | 
|  | 5495 | return false; | 
|  | 5496 | if (!__x.__ready_) | 
|  | 5497 | return true; | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5498 | return __x.__matches_ == __y.__matches_ && | 
|  | 5499 | __x.__prefix_ == __y.__prefix_ && | 
| Howard Hinnant | 31aaf55 | 2010-12-08 21:07:55 | [diff] [blame] | 5500 | __x.__suffix_ == __y.__suffix_; | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5501 | } | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5502 |  | 
|  | 5503 | template <class _BidirectionalIterator, class _Allocator> | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5504 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5505 | bool | 
|  | 5506 | operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x, | 
|  | 5507 | const match_results<_BidirectionalIterator, _Allocator>& __y) | 
|  | 5508 | { | 
|  | 5509 | return !(__x == __y); | 
|  | 5510 | } | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5511 |  | 
|  | 5512 | template <class _BidirectionalIterator, class _Allocator> | 
| Howard Hinnant | 27405f9 | 2010-08-14 18:14:02 | [diff] [blame] | 5513 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5514 | void | 
|  | 5515 | swap(match_results<_BidirectionalIterator, _Allocator>& __x, | 
|  | 5516 | match_results<_BidirectionalIterator, _Allocator>& __y) | 
|  | 5517 | { | 
|  | 5518 | __x.swap(__y); | 
|  | 5519 | } | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5520 |  | 
|  | 5521 | // regex_search | 
|  | 5522 |  | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5523 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5524 | template <class _Allocator> | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5525 | bool | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5526 | basic_regex<_CharT, _Traits>::__match_at_start_ecma( | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5527 | const _CharT* __first, const _CharT* __last, | 
|  | 5528 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5529 | regex_constants::match_flag_type __flags, bool __at_first) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5530 | { | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5531 | vector<__state> __states; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5532 | __node* __st = __start_.get(); | 
|  | 5533 | if (__st) | 
|  | 5534 | { | 
| Marshall Clow | 5e56c30 | 2015-01-28 22:22:35 | [diff] [blame] | 5535 | sub_match<const _CharT*> __unmatched; | 
|  | 5536 | __unmatched.first = __last; | 
|  | 5537 | __unmatched.second = __last; | 
|  | 5538 | __unmatched.matched = false; | 
|  | 5539 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5540 | __states.push_back(__state()); | 
|  | 5541 | __states.back().__do_ = 0; | 
|  | 5542 | __states.back().__first_ = __first; | 
|  | 5543 | __states.back().__current_ = __first; | 
|  | 5544 | __states.back().__last_ = __last; | 
| Marshall Clow | 5e56c30 | 2015-01-28 22:22:35 | [diff] [blame] | 5545 | __states.back().__sub_matches_.resize(mark_count(), __unmatched); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5546 | __states.back().__loop_data_.resize(__loop_count()); | 
|  | 5547 | __states.back().__node_ = __st; | 
|  | 5548 | __states.back().__flags_ = __flags; | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5549 | __states.back().__at_first_ = __at_first; | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5550 | do | 
|  | 5551 | { | 
|  | 5552 | __state& __s = __states.back(); | 
|  | 5553 | if (__s.__node_) | 
|  | 5554 | __s.__node_->__exec(__s); | 
|  | 5555 | switch (__s.__do_) | 
|  | 5556 | { | 
|  | 5557 | case __state::__end_state: | 
|  | 5558 | __m.__matches_[0].first = __first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5559 | __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5560 | __m.__matches_[0].matched = true; | 
|  | 5561 | for (unsigned __i = 0; __i < __s.__sub_matches_.size(); ++__i) | 
|  | 5562 | __m.__matches_[__i+1] = __s.__sub_matches_[__i]; | 
|  | 5563 | return true; | 
|  | 5564 | case __state::__accept_and_consume: | 
|  | 5565 | case __state::__repeat: | 
|  | 5566 | case __state::__accept_but_not_consume: | 
|  | 5567 | break; | 
|  | 5568 | case __state::__split: | 
|  | 5569 | { | 
|  | 5570 | __state __snext = __s; | 
|  | 5571 | __s.__node_->__exec_split(true, __s); | 
|  | 5572 | __snext.__node_->__exec_split(false, __snext); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5573 | __states.push_back(_VSTD::move(__snext)); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5574 | } | 
|  | 5575 | break; | 
|  | 5576 | case __state::__reject: | 
|  | 5577 | __states.pop_back(); | 
|  | 5578 | break; | 
|  | 5579 | default: | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 5580 | __throw_regex_error<regex_constants::__re_err_unknown>(); | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5581 | break; | 
| Howard Hinnant | d444470 | 2010-08-11 17:04:31 | [diff] [blame] | 5582 |  | 
| Howard Hinnant | 17615b0 | 2010-07-27 01:25:38 | [diff] [blame] | 5583 | } | 
|  | 5584 | } while (!__states.empty()); | 
|  | 5585 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5586 | return false; | 
|  | 5587 | } | 
|  | 5588 |  | 
|  | 5589 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5590 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5591 | bool | 
|  | 5592 | basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs( | 
|  | 5593 | const _CharT* __first, const _CharT* __last, | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5594 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5595 | regex_constants::match_flag_type __flags, bool __at_first) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5596 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5597 | deque<__state> __states; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5598 | ptrdiff_t __highest_j = 0; | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5599 | ptrdiff_t _Np = _VSTD::distance(__first, __last); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5600 | __node* __st = __start_.get(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5601 | if (__st) | 
|  | 5602 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5603 | __states.push_back(__state()); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5604 | __states.back().__do_ = 0; | 
|  | 5605 | __states.back().__first_ = __first; | 
|  | 5606 | __states.back().__current_ = __first; | 
|  | 5607 | __states.back().__last_ = __last; | 
|  | 5608 | __states.back().__loop_data_.resize(__loop_count()); | 
|  | 5609 | __states.back().__node_ = __st; | 
|  | 5610 | __states.back().__flags_ = __flags; | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5611 | __states.back().__at_first_ = __at_first; | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 5612 | bool __matched = false; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5613 | do | 
|  | 5614 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5615 | __state& __s = __states.back(); | 
|  | 5616 | if (__s.__node_) | 
|  | 5617 | __s.__node_->__exec(__s); | 
|  | 5618 | switch (__s.__do_) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5619 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5620 | case __state::__end_state: | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5621 | if (!__matched || __highest_j < __s.__current_ - __s.__first_) | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 5622 | __highest_j = __s.__current_ - __s.__first_; | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5623 | __matched = true; | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5624 | if (__highest_j == _Np) | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5625 | __states.clear(); | 
|  | 5626 | else | 
|  | 5627 | __states.pop_back(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5628 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5629 | case __state::__consume_input: | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5630 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5631 | case __state::__accept_and_consume: | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5632 | __states.push_front(_VSTD::move(__s)); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5633 | __states.pop_back(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5634 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5635 | case __state::__repeat: | 
|  | 5636 | case __state::__accept_but_not_consume: | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5637 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5638 | case __state::__split: | 
|  | 5639 | { | 
|  | 5640 | __state __snext = __s; | 
|  | 5641 | __s.__node_->__exec_split(true, __s); | 
|  | 5642 | __snext.__node_->__exec_split(false, __snext); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5643 | __states.push_back(_VSTD::move(__snext)); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5644 | } | 
|  | 5645 | break; | 
|  | 5646 | case __state::__reject: | 
|  | 5647 | __states.pop_back(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5648 | break; | 
|  | 5649 | default: | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 5650 | __throw_regex_error<regex_constants::__re_err_unknown>(); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5651 | break; | 
|  | 5652 | } | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5653 | } while (!__states.empty()); | 
| Howard Hinnant | 68025ed | 2010-07-14 15:45:11 | [diff] [blame] | 5654 | if (__matched) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5655 | { | 
|  | 5656 | __m.__matches_[0].first = __first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5657 | __m.__matches_[0].second = _VSTD::next(__first, __highest_j); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5658 | __m.__matches_[0].matched = true; | 
|  | 5659 | return true; | 
|  | 5660 | } | 
|  | 5661 | } | 
|  | 5662 | return false; | 
|  | 5663 | } | 
|  | 5664 |  | 
|  | 5665 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5666 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5667 | bool | 
|  | 5668 | basic_regex<_CharT, _Traits>::__match_at_start_posix_subs( | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5669 | const _CharT* __first, const _CharT* __last, | 
|  | 5670 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5671 | regex_constants::match_flag_type __flags, bool __at_first) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5672 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5673 | vector<__state> __states; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5674 | __state __best_state; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5675 | ptrdiff_t __j = 0; | 
|  | 5676 | ptrdiff_t __highest_j = 0; | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5677 | ptrdiff_t _Np = _VSTD::distance(__first, __last); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5678 | __node* __st = __start_.get(); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5679 | if (__st) | 
|  | 5680 | { | 
| Marshall Clow | 5e56c30 | 2015-01-28 22:22:35 | [diff] [blame] | 5681 | sub_match<const _CharT*> __unmatched; | 
|  | 5682 | __unmatched.first = __last; | 
|  | 5683 | __unmatched.second = __last; | 
|  | 5684 | __unmatched.matched = false; | 
|  | 5685 |  | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5686 | __states.push_back(__state()); | 
|  | 5687 | __states.back().__do_ = 0; | 
|  | 5688 | __states.back().__first_ = __first; | 
|  | 5689 | __states.back().__current_ = __first; | 
|  | 5690 | __states.back().__last_ = __last; | 
| Marshall Clow | 5e56c30 | 2015-01-28 22:22:35 | [diff] [blame] | 5691 | __states.back().__sub_matches_.resize(mark_count(), __unmatched); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5692 | __states.back().__loop_data_.resize(__loop_count()); | 
|  | 5693 | __states.back().__node_ = __st; | 
|  | 5694 | __states.back().__flags_ = __flags; | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5695 | __states.back().__at_first_ = __at_first; | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5696 | const _CharT* __current = __first; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5697 | bool __matched = false; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5698 | do | 
|  | 5699 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5700 | __state& __s = __states.back(); | 
|  | 5701 | if (__s.__node_) | 
|  | 5702 | __s.__node_->__exec(__s); | 
|  | 5703 | switch (__s.__do_) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5704 | { | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5705 | case __state::__end_state: | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5706 | if (!__matched || __highest_j < __s.__current_ - __s.__first_) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5707 | { | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5708 | __highest_j = __s.__current_ - __s.__first_; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5709 | __best_state = __s; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5710 | } | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5711 | __matched = true; | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 5712 | if (__highest_j == _Np) | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5713 | __states.clear(); | 
|  | 5714 | else | 
|  | 5715 | __states.pop_back(); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5716 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5717 | case __state::__accept_and_consume: | 
| Howard Hinnant | cba352d | 2010-07-12 18:16:05 | [diff] [blame] | 5718 | __j += __s.__current_ - __current; | 
|  | 5719 | __current = __s.__current_; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5720 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5721 | case __state::__repeat: | 
|  | 5722 | case __state::__accept_but_not_consume: | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5723 | break; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5724 | case __state::__split: | 
|  | 5725 | { | 
|  | 5726 | __state __snext = __s; | 
|  | 5727 | __s.__node_->__exec_split(true, __s); | 
|  | 5728 | __snext.__node_->__exec_split(false, __snext); | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5729 | __states.push_back(_VSTD::move(__snext)); | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5730 | } | 
|  | 5731 | break; | 
|  | 5732 | case __state::__reject: | 
|  | 5733 | __states.pop_back(); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5734 | break; | 
|  | 5735 | default: | 
| Marshall Clow | 2576c29 | 2015-07-28 13:30:47 | [diff] [blame] | 5736 | __throw_regex_error<regex_constants::__re_err_unknown>(); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5737 | break; | 
|  | 5738 | } | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5739 | } while (!__states.empty()); | 
|  | 5740 | if (__matched) | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5741 | { | 
|  | 5742 | __m.__matches_[0].first = __first; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5743 | __m.__matches_[0].second = _VSTD::next(__first, __highest_j); | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5744 | __m.__matches_[0].matched = true; | 
| Howard Hinnant | ac30386 | 2010-07-12 15:51:17 | [diff] [blame] | 5745 | for (unsigned __i = 0; __i < __best_state.__sub_matches_.size(); ++__i) | 
|  | 5746 | __m.__matches_[__i+1] = __best_state.__sub_matches_[__i]; | 
| Howard Hinnant | e77aa5e | 2010-07-08 17:43:58 | [diff] [blame] | 5747 | return true; | 
|  | 5748 | } | 
|  | 5749 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5750 | return false; | 
|  | 5751 | } | 
|  | 5752 |  | 
|  | 5753 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5754 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5755 | bool | 
|  | 5756 | basic_regex<_CharT, _Traits>::__match_at_start( | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5757 | const _CharT* __first, const _CharT* __last, | 
|  | 5758 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5759 | regex_constants::match_flag_type __flags, bool __at_first) const | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5760 | { | 
| Howard Hinnant | ad2a7ab | 2010-07-27 17:24:17 | [diff] [blame] | 5761 | if ((__flags_ & 0x1F0) == ECMAScript) | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5762 | return __match_at_start_ecma(__first, __last, __m, __flags, __at_first); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5763 | if (mark_count() == 0) | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5764 | return __match_at_start_posix_nosubs(__first, __last, __m, __flags, __at_first); | 
|  | 5765 | return __match_at_start_posix_subs(__first, __last, __m, __flags, __at_first); | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5766 | } | 
|  | 5767 |  | 
|  | 5768 | template <class _CharT, class _Traits> | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5769 | template <class _Allocator> | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5770 | bool | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5771 | basic_regex<_CharT, _Traits>::__search( | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5772 | const _CharT* __first, const _CharT* __last, | 
|  | 5773 | match_results<const _CharT*, _Allocator>& __m, | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5774 | regex_constants::match_flag_type __flags) const | 
|  | 5775 | { | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5776 | __m.__init(1 + mark_count(), __first, __last, | 
|  | 5777 | __flags & regex_constants::__no_update_pos); | 
| Howard Hinnant | 7670f7d | 2013-07-09 17:29:09 | [diff] [blame] | 5778 | if (__match_at_start(__first, __last, __m, __flags, | 
|  | 5779 | !(__flags & regex_constants::__no_update_pos))) | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5780 | { | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5781 | __m.__prefix_.second = __m[0].first; | 
|  | 5782 | __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second; | 
|  | 5783 | __m.__suffix_.first = __m[0].second; | 
|  | 5784 | __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second; | 
|  | 5785 | return true; | 
|  | 5786 | } | 
| Howard Hinnant | 8daa733 | 2010-07-29 01:15:27 | [diff] [blame] | 5787 | if (__first != __last && !(__flags & regex_constants::match_continuous)) | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5788 | { | 
| Howard Hinnant | f3dcca0 | 2010-07-29 15:17:28 | [diff] [blame] | 5789 | __flags |= regex_constants::match_prev_avail; | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5790 | for (++__first; __first != __last; ++__first) | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5791 | { | 
| Howard Hinnant | f3dcca0 | 2010-07-29 15:17:28 | [diff] [blame] | 5792 | __m.__matches_.assign(__m.size(), __m.__unmatched_); | 
| Howard Hinnant | 41fb6e1 | 2011-03-26 20:02:27 | [diff] [blame] | 5793 | if (__match_at_start(__first, __last, __m, __flags, false)) | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5794 | { | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5795 | __m.__prefix_.second = __m[0].first; | 
|  | 5796 | __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second; | 
|  | 5797 | __m.__suffix_.first = __m[0].second; | 
|  | 5798 | __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second; | 
|  | 5799 | return true; | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5800 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5801 | __m.__matches_.assign(__m.size(), __m.__unmatched_); | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5802 | } | 
|  | 5803 | } | 
| Howard Hinnant | f8ce459 | 2010-07-07 19:14:52 | [diff] [blame] | 5804 | __m.__matches_.clear(); | 
|  | 5805 | return false; | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5806 | } | 
|  | 5807 |  | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5808 | template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits> | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5809 | inline _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5810 | bool | 
|  | 5811 | regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 5812 | match_results<_BidirectionalIterator, _Allocator>& __m, | 
|  | 5813 | const basic_regex<_CharT, _Traits>& __e, | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5814 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5815 | { | 
| Howard Hinnant | e840208 | 2013-07-11 15:32:55 | [diff] [blame] | 5816 | int __offset = (__flags & regex_constants::match_prev_avail) ? 1 : 0; | 
|  | 5817 | basic_string<_CharT> __s(_VSTD::prev(__first, __offset), __last); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5818 | match_results<const _CharT*> __mc; | 
| Howard Hinnant | e840208 | 2013-07-11 15:32:55 | [diff] [blame] | 5819 | bool __r = __e.__search(__s.data() + __offset, __s.data() + __s.size(), __mc, __flags); | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5820 | __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5821 | return __r; | 
|  | 5822 | } | 
|  | 5823 |  | 
| Howard Hinnant | a9602d5 | 2013-06-29 23:45:43 | [diff] [blame] | 5824 | template <class _Iter, class _Allocator, class _CharT, class _Traits> | 
|  | 5825 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5826 | bool | 
|  | 5827 | regex_search(__wrap_iter<_Iter> __first, | 
|  | 5828 | __wrap_iter<_Iter> __last, | 
|  | 5829 | match_results<__wrap_iter<_Iter>, _Allocator>& __m, | 
|  | 5830 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5831 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5832 | { | 
|  | 5833 | match_results<const _CharT*> __mc; | 
|  | 5834 | bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags); | 
|  | 5835 | __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos); | 
|  | 5836 | return __r; | 
|  | 5837 | } | 
|  | 5838 |  | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5839 | template <class _Allocator, class _CharT, class _Traits> | 
|  | 5840 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5841 | bool | 
|  | 5842 | regex_search(const _CharT* __first, const _CharT* __last, | 
|  | 5843 | match_results<const _CharT*, _Allocator>& __m, | 
|  | 5844 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5845 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5846 | { | 
| Howard Hinnant | 9b80f2b | 2010-06-30 17:22:19 | [diff] [blame] | 5847 | return __e.__search(__first, __last, __m, __flags); | 
|  | 5848 | } | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5849 |  | 
|  | 5850 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 5851 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5852 | bool | 
|  | 5853 | regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 5854 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5855 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5856 | { | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5857 | basic_string<_CharT> __s(__first, __last); | 
|  | 5858 | match_results<const _CharT*> __mc; | 
|  | 5859 | return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags); | 
|  | 5860 | } | 
|  | 5861 |  | 
|  | 5862 | template <class _CharT, class _Traits> | 
|  | 5863 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5864 | bool | 
|  | 5865 | regex_search(const _CharT* __first, const _CharT* __last, | 
|  | 5866 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5867 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5868 | { | 
|  | 5869 | match_results<const _CharT*> __mc; | 
|  | 5870 | return __e.__search(__first, __last, __mc, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5871 | } | 
|  | 5872 |  | 
|  | 5873 | template <class _CharT, class _Allocator, class _Traits> | 
|  | 5874 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5875 | bool | 
|  | 5876 | regex_search(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m, | 
|  | 5877 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5878 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5879 | { | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5880 | return __e.__search(__str, __str + _Traits::length(__str), __m, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5881 | } | 
|  | 5882 |  | 
|  | 5883 | template <class _CharT, class _Traits> | 
|  | 5884 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5885 | bool | 
|  | 5886 | regex_search(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e, | 
|  | 5887 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5888 | { | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5889 | match_results<const _CharT*> __m; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5890 | return _VSTD::regex_search(__str, __m, __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5891 | } | 
|  | 5892 |  | 
|  | 5893 | template <class _ST, class _SA, class _CharT, class _Traits> | 
|  | 5894 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5895 | bool | 
|  | 5896 | regex_search(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 5897 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5898 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5899 | { | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5900 | match_results<const _CharT*> __mc; | 
|  | 5901 | return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5902 | } | 
|  | 5903 |  | 
|  | 5904 | template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits> | 
|  | 5905 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5906 | bool | 
|  | 5907 | regex_search(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 5908 | match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m, | 
|  | 5909 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5910 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5911 | { | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5912 | match_results<const _CharT*> __mc; | 
|  | 5913 | bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags); | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 5914 | __m.__assign(__s.begin(), __s.end(), __mc, __flags & regex_constants::__no_update_pos); | 
| Howard Hinnant | 22ce0b4 | 2010-07-14 21:14:52 | [diff] [blame] | 5915 | return __r; | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5916 | } | 
|  | 5917 |  | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 5918 | #if _LIBCPP_STD_VER > 11 | 
|  | 5919 | template <class _ST, class _SA, class _Ap, class _Cp, class _Tp> | 
|  | 5920 | bool | 
|  | 5921 | regex_search(const basic_string<_Cp, _ST, _SA>&& __s, | 
|  | 5922 | match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&, | 
|  | 5923 | const basic_regex<_Cp, _Tp>& __e, | 
|  | 5924 | regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; | 
|  | 5925 | #endif | 
|  | 5926 |  | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5927 | // regex_match | 
|  | 5928 |  | 
|  | 5929 | template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits> | 
|  | 5930 | bool | 
|  | 5931 | regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 5932 | match_results<_BidirectionalIterator, _Allocator>& __m, | 
|  | 5933 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5934 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5935 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5936 | bool __r = _VSTD::regex_search(__first, __last, __m, __e, | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5937 | __flags | regex_constants::match_continuous); | 
|  | 5938 | if (__r) | 
|  | 5939 | { | 
|  | 5940 | __r = !__m.suffix().matched; | 
|  | 5941 | if (!__r) | 
|  | 5942 | __m.__matches_.clear(); | 
|  | 5943 | } | 
|  | 5944 | return __r; | 
|  | 5945 | } | 
|  | 5946 |  | 
|  | 5947 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 5948 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5949 | bool | 
|  | 5950 | regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 5951 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5952 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5953 | { | 
|  | 5954 | match_results<_BidirectionalIterator> __m; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5955 | return _VSTD::regex_match(__first, __last, __m, __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5956 | } | 
|  | 5957 |  | 
|  | 5958 | template <class _CharT, class _Allocator, class _Traits> | 
|  | 5959 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5960 | bool | 
|  | 5961 | regex_match(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m, | 
|  | 5962 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5963 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5964 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5965 | return _VSTD::regex_match(__str, __str + _Traits::length(__str), __m, __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5966 | } | 
|  | 5967 |  | 
|  | 5968 | template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits> | 
|  | 5969 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5970 | bool | 
|  | 5971 | regex_match(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 5972 | match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m, | 
|  | 5973 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5974 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5975 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5976 | return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5977 | } | 
|  | 5978 |  | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 5979 | #if _LIBCPP_STD_VER > 11 | 
|  | 5980 | template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits> | 
|  | 5981 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5982 | bool | 
|  | 5983 | regex_match(const basic_string<_CharT, _ST, _SA>&& __s, | 
|  | 5984 | match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m, | 
|  | 5985 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 5986 | regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; | 
|  | 5987 | #endif | 
|  | 5988 |  | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5989 | template <class _CharT, class _Traits> | 
|  | 5990 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 5991 | bool | 
|  | 5992 | regex_match(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e, | 
|  | 5993 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 5994 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 5995 | return _VSTD::regex_match(__str, __str + _Traits::length(__str), __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 5996 | } | 
|  | 5997 |  | 
|  | 5998 | template <class _ST, class _SA, class _CharT, class _Traits> | 
|  | 5999 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 6000 | bool | 
|  | 6001 | regex_match(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 6002 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 6003 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6004 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6005 | return _VSTD::regex_match(__s.begin(), __s.end(), __e, __flags); | 
| Howard Hinnant | 7e9d84b | 2010-06-30 00:21:42 | [diff] [blame] | 6006 | } | 
|  | 6007 |  | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6008 | // regex_iterator | 
|  | 6009 |  | 
|  | 6010 | template <class _BidirectionalIterator, | 
|  | 6011 | class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, | 
|  | 6012 | class _Traits = regex_traits<_CharT> > | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 | [diff] [blame] | 6013 | class _LIBCPP_TYPE_VIS_ONLY regex_iterator | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6014 | { | 
|  | 6015 | public: | 
|  | 6016 | typedef basic_regex<_CharT, _Traits> regex_type; | 
|  | 6017 | typedef match_results<_BidirectionalIterator> value_type; | 
|  | 6018 | typedef ptrdiff_t difference_type; | 
|  | 6019 | typedef const value_type* pointer; | 
|  | 6020 | typedef const value_type& reference; | 
|  | 6021 | typedef forward_iterator_tag iterator_category; | 
|  | 6022 |  | 
|  | 6023 | private: | 
|  | 6024 | _BidirectionalIterator __begin_; | 
|  | 6025 | _BidirectionalIterator __end_; | 
|  | 6026 | const regex_type* __pregex_; | 
|  | 6027 | regex_constants::match_flag_type __flags_; | 
|  | 6028 | value_type __match_; | 
|  | 6029 |  | 
|  | 6030 | public: | 
|  | 6031 | regex_iterator(); | 
|  | 6032 | regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6033 | const regex_type& __re, | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 6034 | regex_constants::match_flag_type __m | 
|  | 6035 | = regex_constants::match_default); | 
|  | 6036 | #if _LIBCPP_STD_VER > 11 | 
|  | 6037 | regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6038 | const regex_type&& __re, | 
|  | 6039 | regex_constants::match_flag_type __m | 
|  | 6040 | = regex_constants::match_default) = delete; | 
|  | 6041 | #endif | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6042 |  | 
|  | 6043 | bool operator==(const regex_iterator& __x) const; | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6044 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6045 | bool operator!=(const regex_iterator& __x) const {return !(*this == __x);} | 
|  | 6046 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6047 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6048 | reference operator*() const {return __match_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6049 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6050 | pointer operator->() const {return &__match_;} | 
|  | 6051 |  | 
|  | 6052 | regex_iterator& operator++(); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6053 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6054 | regex_iterator operator++(int) | 
|  | 6055 | { | 
|  | 6056 | regex_iterator __t(*this); | 
|  | 6057 | ++(*this); | 
|  | 6058 | return __t; | 
|  | 6059 | } | 
|  | 6060 | }; | 
|  | 6061 |  | 
|  | 6062 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6063 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_iterator() | 
|  | 6064 | : __begin_(), __end_(), __pregex_(nullptr), __flags_(), __match_() | 
|  | 6065 | { | 
|  | 6066 | } | 
|  | 6067 |  | 
|  | 6068 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6069 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6070 | regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6071 | const regex_type& __re, regex_constants::match_flag_type __m) | 
|  | 6072 | : __begin_(__a), | 
|  | 6073 | __end_(__b), | 
|  | 6074 | __pregex_(&__re), | 
|  | 6075 | __flags_(__m) | 
|  | 6076 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6077 | _VSTD::regex_search(__begin_, __end_, __match_, *__pregex_, __flags_); | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6078 | } | 
|  | 6079 |  | 
|  | 6080 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6081 | bool | 
|  | 6082 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6083 | operator==(const regex_iterator& __x) const | 
|  | 6084 | { | 
|  | 6085 | if (__match_.empty() && __x.__match_.empty()) | 
|  | 6086 | return true; | 
|  | 6087 | if (__match_.empty() || __x.__match_.empty()) | 
|  | 6088 | return false; | 
|  | 6089 | return __begin_ == __x.__begin_ && | 
|  | 6090 | __end_ == __x.__end_ && | 
|  | 6091 | __pregex_ == __x.__pregex_ && | 
|  | 6092 | __flags_ == __x.__flags_ && | 
|  | 6093 | __match_[0] == __x.__match_[0]; | 
|  | 6094 | } | 
|  | 6095 |  | 
|  | 6096 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6097 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>& | 
|  | 6098 | regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() | 
|  | 6099 | { | 
|  | 6100 | __flags_ |= regex_constants::__no_update_pos; | 
|  | 6101 | _BidirectionalIterator __start = __match_[0].second; | 
| Howard Hinnant | a9602d5 | 2013-06-29 23:45:43 | [diff] [blame] | 6102 | if (__match_.empty()) | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6103 | { | 
|  | 6104 | if (__start == __end_) | 
|  | 6105 | { | 
|  | 6106 | __match_ = value_type(); | 
|  | 6107 | return *this; | 
|  | 6108 | } | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6109 | else if (_VSTD::regex_search(__start, __end_, __match_, *__pregex_, | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6110 | __flags_ | regex_constants::match_not_null | | 
|  | 6111 | regex_constants::match_continuous)) | 
|  | 6112 | return *this; | 
|  | 6113 | else | 
|  | 6114 | ++__start; | 
|  | 6115 | } | 
|  | 6116 | __flags_ |= regex_constants::match_prev_avail; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6117 | if (!_VSTD::regex_search(__start, __end_, __match_, *__pregex_, __flags_)) | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6118 | __match_ = value_type(); | 
|  | 6119 | return *this; | 
|  | 6120 | } | 
|  | 6121 |  | 
|  | 6122 | typedef regex_iterator<const char*> cregex_iterator; | 
|  | 6123 | typedef regex_iterator<const wchar_t*> wcregex_iterator; | 
|  | 6124 | typedef regex_iterator<string::const_iterator> sregex_iterator; | 
|  | 6125 | typedef regex_iterator<wstring::const_iterator> wsregex_iterator; | 
|  | 6126 |  | 
|  | 6127 | // regex_token_iterator | 
|  | 6128 |  | 
|  | 6129 | template <class _BidirectionalIterator, | 
|  | 6130 | class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, | 
|  | 6131 | class _Traits = regex_traits<_CharT> > | 
| Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 | [diff] [blame] | 6132 | class _LIBCPP_TYPE_VIS_ONLY regex_token_iterator | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6133 | { | 
|  | 6134 | public: | 
|  | 6135 | typedef basic_regex<_CharT, _Traits> regex_type; | 
|  | 6136 | typedef sub_match<_BidirectionalIterator> value_type; | 
|  | 6137 | typedef ptrdiff_t difference_type; | 
|  | 6138 | typedef const value_type* pointer; | 
|  | 6139 | typedef const value_type& reference; | 
|  | 6140 | typedef forward_iterator_tag iterator_category; | 
|  | 6141 |  | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6142 | private: | 
|  | 6143 | typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position; | 
|  | 6144 |  | 
|  | 6145 | _Position __position_; | 
|  | 6146 | const value_type* __result_; | 
|  | 6147 | value_type __suffix_; | 
|  | 6148 | ptrdiff_t _N_; | 
|  | 6149 | vector<int> __subs_; | 
|  | 6150 |  | 
|  | 6151 | public: | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6152 | regex_token_iterator(); | 
|  | 6153 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6154 | const regex_type& __re, int __submatch = 0, | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6155 | regex_constants::match_flag_type __m = | 
|  | 6156 | regex_constants::match_default); | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 6157 | #if _LIBCPP_STD_VER > 11 | 
|  | 6158 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6159 | const regex_type&& __re, int __submatch = 0, | 
|  | 6160 | regex_constants::match_flag_type __m = | 
|  | 6161 | regex_constants::match_default) = delete; | 
|  | 6162 | #endif | 
|  | 6163 |  | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6164 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6165 | const regex_type& __re, const vector<int>& __submatches, | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6166 | regex_constants::match_flag_type __m = | 
|  | 6167 | regex_constants::match_default); | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 6168 | #if _LIBCPP_STD_VER > 11 | 
|  | 6169 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6170 | const regex_type&& __re, const vector<int>& __submatches, | 
|  | 6171 | regex_constants::match_flag_type __m = | 
|  | 6172 | regex_constants::match_default) = delete; | 
|  | 6173 | #endif | 
|  | 6174 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 6175 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6176 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6177 | const regex_type& __re, | 
|  | 6178 | initializer_list<int> __submatches, | 
|  | 6179 | regex_constants::match_flag_type __m = | 
|  | 6180 | regex_constants::match_default); | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 6181 |  | 
|  | 6182 | #if _LIBCPP_STD_VER > 11 | 
|  | 6183 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6184 | const regex_type&& __re, | 
|  | 6185 | initializer_list<int> __submatches, | 
|  | 6186 | regex_constants::match_flag_type __m = | 
|  | 6187 | regex_constants::match_default) = delete; | 
|  | 6188 | #endif | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 6189 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 6190 | template <size_t _Np> | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6191 | regex_token_iterator(_BidirectionalIterator __a, | 
|  | 6192 | _BidirectionalIterator __b, | 
|  | 6193 | const regex_type& __re, | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 6194 | const int (&__submatches)[_Np], | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6195 | regex_constants::match_flag_type __m = | 
|  | 6196 | regex_constants::match_default); | 
| Marshall Clow | e0f8672 | 2014-02-19 21:21:11 | [diff] [blame] | 6197 | #if _LIBCPP_STD_VER > 11 | 
|  | 6198 | template <std::size_t _Np> | 
|  | 6199 | regex_token_iterator(_BidirectionalIterator __a, | 
|  | 6200 | _BidirectionalIterator __b, | 
|  | 6201 | const regex_type&& __re, | 
|  | 6202 | const int (&__submatches)[_Np], | 
|  | 6203 | regex_constants::match_flag_type __m = | 
|  | 6204 | regex_constants::match_default) = delete; | 
|  | 6205 | #endif | 
|  | 6206 |  | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6207 | regex_token_iterator(const regex_token_iterator&); | 
|  | 6208 | regex_token_iterator& operator=(const regex_token_iterator&); | 
|  | 6209 |  | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6210 | bool operator==(const regex_token_iterator& __x) const; | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6211 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6212 | bool operator!=(const regex_token_iterator& __x) const {return !(*this == __x);} | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6213 |  | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6214 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6215 | const value_type& operator*() const {return *__result_;} | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6216 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6217 | const value_type* operator->() const {return __result_;} | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6218 |  | 
|  | 6219 | regex_token_iterator& operator++(); | 
| Howard Hinnant | aef07cb | 2010-09-23 15:13:20 | [diff] [blame] | 6220 | _LIBCPP_INLINE_VISIBILITY | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6221 | regex_token_iterator operator++(int) | 
|  | 6222 | { | 
|  | 6223 | regex_token_iterator __t(*this); | 
|  | 6224 | ++(*this); | 
|  | 6225 | return __t; | 
|  | 6226 | } | 
|  | 6227 |  | 
|  | 6228 | private: | 
|  | 6229 | void __init(_BidirectionalIterator __a, _BidirectionalIterator __b); | 
| Marshall Clow | 0efd9dc | 2014-01-09 18:25:57 | [diff] [blame] | 6230 | void __establish_result () { | 
|  | 6231 | if (__subs_[_N_] == -1) | 
|  | 6232 | __result_ = &__position_->prefix(); | 
|  | 6233 | else | 
|  | 6234 | __result_ = &(*__position_)[__subs_[_N_]]; | 
|  | 6235 | } | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6236 | }; | 
|  | 6237 |  | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6238 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6239 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6240 | regex_token_iterator() | 
|  | 6241 | : __result_(nullptr), | 
|  | 6242 | __suffix_(), | 
|  | 6243 | _N_(0) | 
|  | 6244 | { | 
|  | 6245 | } | 
|  | 6246 |  | 
|  | 6247 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6248 | void | 
|  | 6249 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6250 | __init(_BidirectionalIterator __a, _BidirectionalIterator __b) | 
|  | 6251 | { | 
|  | 6252 | if (__position_ != _Position()) | 
| Marshall Clow | 0efd9dc | 2014-01-09 18:25:57 | [diff] [blame] | 6253 | __establish_result (); | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6254 | else if (__subs_[_N_] == -1) | 
|  | 6255 | { | 
|  | 6256 | __suffix_.matched = true; | 
|  | 6257 | __suffix_.first = __a; | 
|  | 6258 | __suffix_.second = __b; | 
|  | 6259 | __result_ = &__suffix_; | 
|  | 6260 | } | 
|  | 6261 | else | 
|  | 6262 | __result_ = nullptr; | 
|  | 6263 | } | 
|  | 6264 |  | 
|  | 6265 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6266 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6267 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6268 | const regex_type& __re, int __submatch, | 
|  | 6269 | regex_constants::match_flag_type __m) | 
|  | 6270 | : __position_(__a, __b, __re, __m), | 
|  | 6271 | _N_(0), | 
|  | 6272 | __subs_(1, __submatch) | 
|  | 6273 | { | 
|  | 6274 | __init(__a, __b); | 
|  | 6275 | } | 
|  | 6276 |  | 
|  | 6277 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6278 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6279 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6280 | const regex_type& __re, const vector<int>& __submatches, | 
|  | 6281 | regex_constants::match_flag_type __m) | 
|  | 6282 | : __position_(__a, __b, __re, __m), | 
|  | 6283 | _N_(0), | 
|  | 6284 | __subs_(__submatches) | 
|  | 6285 | { | 
|  | 6286 | __init(__a, __b); | 
|  | 6287 | } | 
|  | 6288 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 6289 | #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 6290 |  | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6291 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6292 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6293 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6294 | const regex_type& __re, | 
|  | 6295 | initializer_list<int> __submatches, | 
|  | 6296 | regex_constants::match_flag_type __m) | 
|  | 6297 | : __position_(__a, __b, __re, __m), | 
|  | 6298 | _N_(0), | 
|  | 6299 | __subs_(__submatches) | 
|  | 6300 | { | 
|  | 6301 | __init(__a, __b); | 
|  | 6302 | } | 
|  | 6303 |  | 
| Howard Hinnant | e3e3291 | 2011-08-12 21:56:02 | [diff] [blame] | 6304 | #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS | 
|  | 6305 |  | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6306 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 6307 | template <size_t _Np> | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6308 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6309 | regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b, | 
|  | 6310 | const regex_type& __re, | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 6311 | const int (&__submatches)[_Np], | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6312 | regex_constants::match_flag_type __m) | 
|  | 6313 | : __position_(__a, __b, __re, __m), | 
|  | 6314 | _N_(0), | 
| Howard Hinnant | 9996844 | 2011-11-29 18:15:50 | [diff] [blame] | 6315 | __subs_(__submatches, __submatches + _Np) | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6316 | { | 
|  | 6317 | __init(__a, __b); | 
|  | 6318 | } | 
|  | 6319 |  | 
|  | 6320 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6321 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6322 | regex_token_iterator(const regex_token_iterator& __x) | 
|  | 6323 | : __position_(__x.__position_), | 
|  | 6324 | __result_(__x.__result_), | 
|  | 6325 | __suffix_(__x.__suffix_), | 
|  | 6326 | _N_(__x._N_), | 
|  | 6327 | __subs_(__x.__subs_) | 
|  | 6328 | { | 
|  | 6329 | if (__x.__result_ == &__x.__suffix_) | 
| Marshall Clow | 72fe0ae | 2014-01-13 17:47:08 | [diff] [blame] | 6330 | __result_ = &__suffix_; | 
| Marshall Clow | 0efd9dc | 2014-01-09 18:25:57 | [diff] [blame] | 6331 | else if ( __result_ != nullptr ) | 
|  | 6332 | __establish_result (); | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6333 | } | 
|  | 6334 |  | 
|  | 6335 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6336 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>& | 
|  | 6337 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6338 | operator=(const regex_token_iterator& __x) | 
|  | 6339 | { | 
|  | 6340 | if (this != &__x) | 
|  | 6341 | { | 
|  | 6342 | __position_ = __x.__position_; | 
|  | 6343 | if (__x.__result_ == &__x.__suffix_) | 
| Marshall Clow | 0efd9dc | 2014-01-09 18:25:57 | [diff] [blame] | 6344 | __result_ = &__suffix_; | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6345 | else | 
|  | 6346 | __result_ = __x.__result_; | 
|  | 6347 | __suffix_ = __x.__suffix_; | 
|  | 6348 | _N_ = __x._N_; | 
|  | 6349 | __subs_ = __x.__subs_; | 
| Marshall Clow | 0efd9dc | 2014-01-09 18:25:57 | [diff] [blame] | 6350 |  | 
|  | 6351 | if ( __result_ != nullptr && __result_ != &__suffix_ ) | 
|  | 6352 | __establish_result(); | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6353 | } | 
|  | 6354 | return *this; | 
|  | 6355 | } | 
|  | 6356 |  | 
|  | 6357 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6358 | bool | 
|  | 6359 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>:: | 
|  | 6360 | operator==(const regex_token_iterator& __x) const | 
|  | 6361 | { | 
|  | 6362 | if (__result_ == nullptr && __x.__result_ == nullptr) | 
|  | 6363 | return true; | 
|  | 6364 | if (__result_ == &__suffix_ && __x.__result_ == &__x.__suffix_ && | 
|  | 6365 | __suffix_ == __x.__suffix_) | 
|  | 6366 | return true; | 
|  | 6367 | if (__result_ == nullptr || __x.__result_ == nullptr) | 
|  | 6368 | return false; | 
|  | 6369 | if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_) | 
|  | 6370 | return false; | 
|  | 6371 | return __position_ == __x.__position_ && _N_ == __x._N_ && | 
|  | 6372 | __subs_ == __x.__subs_; | 
|  | 6373 | } | 
|  | 6374 |  | 
|  | 6375 | template <class _BidirectionalIterator, class _CharT, class _Traits> | 
|  | 6376 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>& | 
|  | 6377 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() | 
|  | 6378 | { | 
|  | 6379 | _Position __prev = __position_; | 
|  | 6380 | if (__result_ == &__suffix_) | 
|  | 6381 | __result_ = nullptr; | 
|  | 6382 | else if (_N_ + 1 < __subs_.size()) | 
|  | 6383 | { | 
|  | 6384 | ++_N_; | 
| Marshall Clow | 0efd9dc | 2014-01-09 18:25:57 | [diff] [blame] | 6385 | __establish_result(); | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6386 | } | 
|  | 6387 | else | 
|  | 6388 | { | 
|  | 6389 | _N_ = 0; | 
|  | 6390 | ++__position_; | 
|  | 6391 | if (__position_ != _Position()) | 
| Marshall Clow | 0efd9dc | 2014-01-09 18:25:57 | [diff] [blame] | 6392 | __establish_result(); | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6393 | else | 
|  | 6394 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6395 | if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end() | 
| Howard Hinnant | 262b779 | 2010-08-17 20:42:03 | [diff] [blame] | 6396 | && __prev->suffix().length() != 0) | 
|  | 6397 | { | 
|  | 6398 | __suffix_.matched = true; | 
|  | 6399 | __suffix_.first = __prev->suffix().first; | 
|  | 6400 | __suffix_.second = __prev->suffix().second; | 
|  | 6401 | __result_ = &__suffix_; | 
|  | 6402 | } | 
|  | 6403 | else | 
|  | 6404 | __result_ = nullptr; | 
|  | 6405 | } | 
|  | 6406 | } | 
|  | 6407 | return *this; | 
|  | 6408 | } | 
|  | 6409 |  | 
| Howard Hinnant | a712c72 | 2010-08-16 20:21:16 | [diff] [blame] | 6410 | typedef regex_token_iterator<const char*> cregex_token_iterator; | 
|  | 6411 | typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; | 
|  | 6412 | typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; | 
|  | 6413 | typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; | 
|  | 6414 |  | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6415 | // regex_replace | 
|  | 6416 |  | 
|  | 6417 | template <class _OutputIterator, class _BidirectionalIterator, | 
|  | 6418 | class _Traits, class _CharT> | 
|  | 6419 | _OutputIterator | 
|  | 6420 | regex_replace(_OutputIterator __out, | 
|  | 6421 | _BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 6422 | const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt, | 
|  | 6423 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6424 | { | 
|  | 6425 | typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Iter; | 
|  | 6426 | _Iter __i(__first, __last, __e, __flags); | 
|  | 6427 | _Iter __eof; | 
|  | 6428 | if (__i == __eof) | 
|  | 6429 | { | 
|  | 6430 | if (!(__flags & regex_constants::format_no_copy)) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6431 | __out = _VSTD::copy(__first, __last, __out); | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6432 | } | 
|  | 6433 | else | 
|  | 6434 | { | 
|  | 6435 | sub_match<_BidirectionalIterator> __lm; | 
|  | 6436 | for (size_t __len = char_traits<_CharT>::length(__fmt); __i != __eof; ++__i) | 
|  | 6437 | { | 
|  | 6438 | if (!(__flags & regex_constants::format_no_copy)) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6439 | __out = _VSTD::copy(__i->prefix().first, __i->prefix().second, __out); | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6440 | __out = __i->format(__out, __fmt, __fmt + __len, __flags); | 
|  | 6441 | __lm = __i->suffix(); | 
|  | 6442 | if (__flags & regex_constants::format_first_only) | 
|  | 6443 | break; | 
|  | 6444 | } | 
|  | 6445 | if (!(__flags & regex_constants::format_no_copy)) | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6446 | __out = _VSTD::copy(__lm.first, __lm.second, __out); | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6447 | } | 
|  | 6448 | return __out; | 
|  | 6449 | } | 
|  | 6450 |  | 
|  | 6451 | template <class _OutputIterator, class _BidirectionalIterator, | 
|  | 6452 | class _Traits, class _CharT, class _ST, class _SA> | 
|  | 6453 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 6454 | _OutputIterator | 
|  | 6455 | regex_replace(_OutputIterator __out, | 
|  | 6456 | _BidirectionalIterator __first, _BidirectionalIterator __last, | 
|  | 6457 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 6458 | const basic_string<_CharT, _ST, _SA>& __fmt, | 
|  | 6459 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6460 | { | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6461 | return _VSTD::regex_replace(__out, __first, __last, __e, __fmt.c_str(), __flags); | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6462 | } | 
|  | 6463 |  | 
|  | 6464 | template <class _Traits, class _CharT, class _ST, class _SA, class _FST, | 
|  | 6465 | class _FSA> | 
|  | 6466 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 6467 | basic_string<_CharT, _ST, _SA> | 
|  | 6468 | regex_replace(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 6469 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 6470 | const basic_string<_CharT, _FST, _FSA>& __fmt, | 
|  | 6471 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6472 | { | 
|  | 6473 | basic_string<_CharT, _ST, _SA> __r; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6474 | _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e, | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6475 | __fmt.c_str(), __flags); | 
|  | 6476 | return __r; | 
|  | 6477 | } | 
|  | 6478 |  | 
|  | 6479 | template <class _Traits, class _CharT, class _ST, class _SA> | 
|  | 6480 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 6481 | basic_string<_CharT, _ST, _SA> | 
|  | 6482 | regex_replace(const basic_string<_CharT, _ST, _SA>& __s, | 
|  | 6483 | const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt, | 
|  | 6484 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6485 | { | 
|  | 6486 | basic_string<_CharT, _ST, _SA> __r; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6487 | _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e, | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6488 | __fmt, __flags); | 
|  | 6489 | return __r; | 
|  | 6490 | } | 
|  | 6491 |  | 
|  | 6492 | template <class _Traits, class _CharT, class _ST, class _SA> | 
|  | 6493 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 6494 | basic_string<_CharT> | 
|  | 6495 | regex_replace(const _CharT* __s, | 
|  | 6496 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 6497 | const basic_string<_CharT, _ST, _SA>& __fmt, | 
|  | 6498 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6499 | { | 
|  | 6500 | basic_string<_CharT> __r; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6501 | _VSTD::regex_replace(back_inserter(__r), __s, | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6502 | __s + char_traits<_CharT>::length(__s), __e, | 
|  | 6503 | __fmt.c_str(), __flags); | 
|  | 6504 | return __r; | 
|  | 6505 | } | 
|  | 6506 |  | 
|  | 6507 | template <class _Traits, class _CharT> | 
|  | 6508 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 6509 | basic_string<_CharT> | 
|  | 6510 | regex_replace(const _CharT* __s, | 
|  | 6511 | const basic_regex<_CharT, _Traits>& __e, | 
|  | 6512 | const _CharT* __fmt, | 
|  | 6513 | regex_constants::match_flag_type __flags = regex_constants::match_default) | 
|  | 6514 | { | 
|  | 6515 | basic_string<_CharT> __r; | 
| Howard Hinnant | 0949eed | 2011-06-30 21:18:19 | [diff] [blame] | 6516 | _VSTD::regex_replace(back_inserter(__r), __s, | 
| Howard Hinnant | a8d7759 | 2010-08-18 00:13:08 | [diff] [blame] | 6517 | __s + char_traits<_CharT>::length(__s), __e, | 
|  | 6518 | __fmt, __flags); | 
|  | 6519 | return __r; | 
|  | 6520 | } | 
|  | 6521 |  | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 6522 | _LIBCPP_END_NAMESPACE_STD | 
|  | 6523 |  | 
|  | 6524 | #endif // _LIBCPP_REGEX |