2 //===--------------------------- regex ------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
17 #include <initializer_list>
22 namespace regex_constants
25 emum syntax_option_type
29 optimize = unspecified,
30 collate = unspecified,
31 ECMAScript = unspecified,
33 extended = unspecified,
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);
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,
55 format_sed = unspecified,
56 format_no_copy = unspecified,
57 format_first_only = unspecified
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);
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
84 : public runtime_error
87 explicit regex_error(regex_constants::error_type ecode);
88 regex_constants::error_type code() const;
91 template <class charT>
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;
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>
107 transform(ForwardIterator first, ForwardIterator last) const;
108 template <class ForwardIterator>
110 transform_primary( ForwardIterator first, ForwardIterator last) const;
111 template <class ForwardIterator>
113 lookup_collatename(ForwardIterator first, ForwardIterator last) const;
114 template <class ForwardIterator>
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;
124 template <class charT, class traits = regex_traits<charT>>
129 typedef charT value_type;
130 typedef traits traits_type;
131 typedef typename traits::string_type string_type;
132 typedef regex_constants::syntax_option_type flag_type;
133 typedef typename traits::locale_type locale_type;
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;
147 // construct/copy/destroy:
149 explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
150 basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
151 basic_regex(const basic_regex&);
152 basic_regex(basic_regex&&) noexcept;
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);
163 basic_regex& operator=(const basic_regex&);
164 basic_regex& operator=(basic_regex&&) noexcept;
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);
171 basic_regex& assign(const basic_regex& that);
172 basic_regex& assign(basic_regex&& that) noexcept;
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);
184 unsigned mark_count() const;
185 flag_type flags() const;
188 locale_type imbue(locale_type loc);
189 locale_type getloc() const;
192 void swap(basic_regex&);
195 template<class ForwardIterator>
196 basic_regex(ForwardIterator, ForwardIterator,
197 regex_constants::syntax_option_type = regex_constants::ECMAScript)
198 -> basic_regex<typename iterator_traits<ForwardIterator>::value_type>; // C++17
200 typedef basic_regex<char> regex;
201 typedef basic_regex<wchar_t> wregex;
203 template <class charT, class traits>
204 void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2);
206 template <class BidirectionalIterator>
208 : public pair<BidirectionalIterator, BidirectionalIterator>
211 typedef typename iterator_traits<BidirectionalIterator>::value_type value_type;
212 typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
213 typedef BidirectionalIterator iterator;
214 typedef basic_string<value_type> string_type;
218 constexpr sub_match();
220 difference_type length() const;
221 operator string_type() const;
222 string_type str() const;
224 int compare(const sub_match& s) const;
225 int compare(const string_type& s) const;
226 int compare(const value_type* s) const;
229 typedef sub_match<const char*> csub_match;
230 typedef sub_match<const wchar_t*> wcsub_match;
231 typedef sub_match<string::const_iterator> ssub_match;
232 typedef sub_match<wstring::const_iterator> wssub_match;
234 template <class BiIter>
236 operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
238 template <class BiIter>
240 operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
242 template <class BiIter>
244 operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
246 template <class BiIter>
248 operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
250 template <class BiIter>
252 operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
254 template <class BiIter>
256 operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
258 template <class BiIter, class ST, class SA>
260 operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
261 const sub_match<BiIter>& rhs);
263 template <class BiIter, class ST, class SA>
265 operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
266 const sub_match<BiIter>& rhs);
268 template <class BiIter, class ST, class SA>
270 operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
271 const sub_match<BiIter>& rhs);
273 template <class BiIter, class ST, class SA>
275 operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
276 const sub_match<BiIter>& rhs);
278 template <class BiIter, class ST, class SA>
279 bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
280 const sub_match<BiIter>& rhs);
282 template <class BiIter, class ST, class SA>
284 operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
285 const sub_match<BiIter>& rhs);
287 template <class BiIter, class ST, class SA>
289 operator==(const sub_match<BiIter>& lhs,
290 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
292 template <class BiIter, class ST, class SA>
294 operator!=(const sub_match<BiIter>& lhs,
295 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
297 template <class BiIter, class ST, class SA>
299 operator<(const sub_match<BiIter>& lhs,
300 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
302 template <class BiIter, class ST, class SA>
303 bool operator>(const sub_match<BiIter>& lhs,
304 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
306 template <class BiIter, class ST, class SA>
308 operator>=(const sub_match<BiIter>& lhs,
309 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
311 template <class BiIter, class ST, class SA>
313 operator<=(const sub_match<BiIter>& lhs,
314 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
316 template <class BiIter>
318 operator==(typename iterator_traits<BiIter>::value_type const* lhs,
319 const sub_match<BiIter>& rhs);
321 template <class BiIter>
323 operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
324 const sub_match<BiIter>& rhs);
326 template <class BiIter>
328 operator<(typename iterator_traits<BiIter>::value_type const* lhs,
329 const sub_match<BiIter>& rhs);
331 template <class BiIter>
333 operator>(typename iterator_traits<BiIter>::value_type const* lhs,
334 const sub_match<BiIter>& rhs);
336 template <class BiIter>
338 operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
339 const sub_match<BiIter>& rhs);
341 template <class BiIter>
343 operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
344 const sub_match<BiIter>& rhs);
346 template <class BiIter>
348 operator==(const sub_match<BiIter>& lhs,
349 typename iterator_traits<BiIter>::value_type const* rhs);
351 template <class BiIter>
353 operator!=(const sub_match<BiIter>& lhs,
354 typename iterator_traits<BiIter>::value_type const* rhs);
356 template <class BiIter>
358 operator<(const sub_match<BiIter>& lhs,
359 typename iterator_traits<BiIter>::value_type const* rhs);
361 template <class BiIter>
363 operator>(const sub_match<BiIter>& lhs,
364 typename iterator_traits<BiIter>::value_type const* rhs);
366 template <class BiIter>
368 operator>=(const sub_match<BiIter>& lhs,
369 typename iterator_traits<BiIter>::value_type const* rhs);
371 template <class BiIter>
373 operator<=(const sub_match<BiIter>& lhs,
374 typename iterator_traits<BiIter>::value_type const* rhs);
376 template <class BiIter>
378 operator==(typename iterator_traits<BiIter>::value_type const& lhs,
379 const sub_match<BiIter>& rhs);
381 template <class BiIter>
383 operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
384 const sub_match<BiIter>& rhs);
386 template <class BiIter>
388 operator<(typename iterator_traits<BiIter>::value_type const& lhs,
389 const sub_match<BiIter>& rhs);
391 template <class BiIter>
393 operator>(typename iterator_traits<BiIter>::value_type const& lhs,
394 const sub_match<BiIter>& rhs);
396 template <class BiIter>
398 operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
399 const sub_match<BiIter>& rhs);
401 template <class BiIter>
403 operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
404 const sub_match<BiIter>& rhs);
406 template <class BiIter>
408 operator==(const sub_match<BiIter>& lhs,
409 typename iterator_traits<BiIter>::value_type const& rhs);
411 template <class BiIter>
413 operator!=(const sub_match<BiIter>& lhs,
414 typename iterator_traits<BiIter>::value_type const& rhs);
416 template <class BiIter>
418 operator<(const sub_match<BiIter>& lhs,
419 typename iterator_traits<BiIter>::value_type const& rhs);
421 template <class BiIter>
423 operator>(const sub_match<BiIter>& lhs,
424 typename iterator_traits<BiIter>::value_type const& rhs);
426 template <class BiIter>
428 operator>=(const sub_match<BiIter>& lhs,
429 typename iterator_traits<BiIter>::value_type const& rhs);
431 template <class BiIter>
433 operator<=(const sub_match<BiIter>& lhs,
434 typename iterator_traits<BiIter>::value_type const& rhs);
436 template <class charT, class ST, class BiIter>
437 basic_ostream<charT, ST>&
438 operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
440 template <class BidirectionalIterator,
441 class Allocator = allocator<sub_match<BidirectionalIterator>>>
445 typedef sub_match<BidirectionalIterator> value_type;
446 typedef const value_type& const_reference;
447 typedef value_type& reference;
448 typedef /implementation-defined/ const_iterator;
449 typedef const_iterator iterator;
450 typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
451 typedef typename allocator_traits<Allocator>::size_type size_type;
452 typedef Allocator allocator_type;
453 typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;
454 typedef basic_string<char_type> string_type;
456 // construct/copy/destroy:
457 explicit match_results(const Allocator& a = Allocator());
458 match_results(const match_results& m);
459 match_results(match_results&& m) noexcept;
460 match_results& operator=(const match_results& m);
461 match_results& operator=(match_results&& m);
467 size_type size() const;
468 size_type max_size() const;
472 difference_type length(size_type sub = 0) const;
473 difference_type position(size_type sub = 0) const;
474 string_type str(size_type sub = 0) const;
475 const_reference operator[](size_type n) const;
477 const_reference prefix() const;
478 const_reference suffix() const;
480 const_iterator begin() const;
481 const_iterator end() const;
482 const_iterator cbegin() const;
483 const_iterator cend() const;
486 template <class OutputIter>
488 format(OutputIter out, const char_type* fmt_first,
489 const char_type* fmt_last,
490 regex_constants::match_flag_type flags = regex_constants::format_default) const;
491 template <class OutputIter, class ST, class SA>
493 format(OutputIter out, const basic_string<char_type, ST, SA>& fmt,
494 regex_constants::match_flag_type flags = regex_constants::format_default) const;
495 template <class ST, class SA>
496 basic_string<char_type, ST, SA>
497 format(const basic_string<char_type, ST, SA>& fmt,
498 regex_constants::match_flag_type flags = regex_constants::format_default) const;
500 format(const char_type* fmt,
501 regex_constants::match_flag_type flags = regex_constants::format_default) const;
504 allocator_type get_allocator() const;
507 void swap(match_results& that);
510 typedef match_results<const char*> cmatch;
511 typedef match_results<const wchar_t*> wcmatch;
512 typedef match_results<string::const_iterator> smatch;
513 typedef match_results<wstring::const_iterator> wsmatch;
515 template <class BidirectionalIterator, class Allocator>
517 operator==(const match_results<BidirectionalIterator, Allocator>& m1,
518 const match_results<BidirectionalIterator, Allocator>& m2);
520 template <class BidirectionalIterator, class Allocator>
522 operator!=(const match_results<BidirectionalIterator, Allocator>& m1,
523 const match_results<BidirectionalIterator, Allocator>& m2);
525 template <class BidirectionalIterator, class Allocator>
527 swap(match_results<BidirectionalIterator, Allocator>& m1,
528 match_results<BidirectionalIterator, Allocator>& m2);
530 template <class BidirectionalIterator, class Allocator, class charT, class traits>
532 regex_match(BidirectionalIterator first, BidirectionalIterator last,
533 match_results<BidirectionalIterator, Allocator>& m,
534 const basic_regex<charT, traits>& e,
535 regex_constants::match_flag_type flags = regex_constants::match_default);
537 template <class BidirectionalIterator, class charT, class traits>
539 regex_match(BidirectionalIterator first, BidirectionalIterator last,
540 const basic_regex<charT, traits>& e,
541 regex_constants::match_flag_type flags = regex_constants::match_default);
543 template <class charT, class Allocator, class traits>
545 regex_match(const charT* str, match_results<const charT*, Allocator>& m,
546 const basic_regex<charT, traits>& e,
547 regex_constants::match_flag_type flags = regex_constants::match_default);
549 template <class ST, class SA, class Allocator, class charT, class traits>
551 regex_match(const basic_string<charT, ST, SA>& s,
552 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
553 const basic_regex<charT, traits>& e,
554 regex_constants::match_flag_type flags = regex_constants::match_default);
556 template <class ST, class SA, class Allocator, class charT, class traits>
558 regex_match(const basic_string<charT, ST, SA>&& s,
559 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
560 const basic_regex<charT, traits>& e,
561 regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
563 template <class charT, class traits>
565 regex_match(const charT* str, const basic_regex<charT, traits>& e,
566 regex_constants::match_flag_type flags = regex_constants::match_default);
568 template <class ST, class SA, class charT, class traits>
570 regex_match(const basic_string<charT, ST, SA>& s,
571 const basic_regex<charT, traits>& e,
572 regex_constants::match_flag_type flags = regex_constants::match_default);
574 template <class BidirectionalIterator, class Allocator, class charT, class traits>
576 regex_search(BidirectionalIterator first, BidirectionalIterator last,
577 match_results<BidirectionalIterator, Allocator>& m,
578 const basic_regex<charT, traits>& e,
579 regex_constants::match_flag_type flags = regex_constants::match_default);
581 template <class BidirectionalIterator, class charT, class traits>
583 regex_search(BidirectionalIterator first, BidirectionalIterator last,
584 const basic_regex<charT, traits>& e,
585 regex_constants::match_flag_type flags = regex_constants::match_default);
587 template <class charT, class Allocator, class traits>
589 regex_search(const charT* str, match_results<const charT*, Allocator>& m,
590 const basic_regex<charT, traits>& e,
591 regex_constants::match_flag_type flags = regex_constants::match_default);
593 template <class charT, class traits>
595 regex_search(const charT* str, const basic_regex<charT, traits>& e,
596 regex_constants::match_flag_type flags = regex_constants::match_default);
598 template <class ST, class SA, class charT, class traits>
600 regex_search(const basic_string<charT, ST, SA>& s,
601 const basic_regex<charT, traits>& e,
602 regex_constants::match_flag_type flags = regex_constants::match_default);
604 template <class ST, class SA, class Allocator, class charT, class traits>
606 regex_search(const basic_string<charT, ST, SA>& s,
607 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
608 const basic_regex<charT, traits>& e,
609 regex_constants::match_flag_type flags = regex_constants::match_default);
611 template <class ST, class SA, class Allocator, class charT, class traits>
613 regex_search(const basic_string<charT, ST, SA>&& s,
614 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
615 const basic_regex<charT, traits>& e,
616 regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
618 template <class OutputIterator, class BidirectionalIterator,
619 class traits, class charT, class ST, class SA>
621 regex_replace(OutputIterator out,
622 BidirectionalIterator first, BidirectionalIterator last,
623 const basic_regex<charT, traits>& e,
624 const basic_string<charT, ST, SA>& fmt,
625 regex_constants::match_flag_type flags = regex_constants::match_default);
627 template <class OutputIterator, class BidirectionalIterator,
628 class traits, class charT>
630 regex_replace(OutputIterator out,
631 BidirectionalIterator first, BidirectionalIterator last,
632 const basic_regex<charT, traits>& e, const charT* fmt,
633 regex_constants::match_flag_type flags = regex_constants::match_default);
635 template <class traits, class charT, class ST, class SA, class FST, class FSA>>
636 basic_string<charT, ST, SA>
637 regex_replace(const basic_string<charT, ST, SA>& s,
638 const basic_regex<charT, traits>& e,
639 const basic_string<charT, FST, FSA>& fmt,
640 regex_constants::match_flag_type flags = regex_constants::match_default);
642 template <class traits, class charT, class ST, class SA>
643 basic_string<charT, ST, SA>
644 regex_replace(const basic_string<charT, ST, SA>& s,
645 const basic_regex<charT, traits>& e, const charT* fmt,
646 regex_constants::match_flag_type flags = regex_constants::match_default);
648 template <class traits, class charT, class ST, class SA>
650 regex_replace(const charT* s,
651 const basic_regex<charT, traits>& e,
652 const basic_string<charT, ST, SA>& fmt,
653 regex_constants::match_flag_type flags = regex_constants::match_default);
655 template <class traits, class charT>
657 regex_replace(const charT* s,
658 const basic_regex<charT, traits>& e,
660 regex_constants::match_flag_type flags = regex_constants::match_default);
662 template <class BidirectionalIterator,
663 class charT = typename iterator_traits< BidirectionalIterator>::value_type,
664 class traits = regex_traits<charT>>
668 typedef basic_regex<charT, traits> regex_type;
669 typedef match_results<BidirectionalIterator> value_type;
670 typedef ptrdiff_t difference_type;
671 typedef const value_type* pointer;
672 typedef const value_type& reference;
673 typedef forward_iterator_tag iterator_category;
676 regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
677 const regex_type& re,
678 regex_constants::match_flag_type m = regex_constants::match_default);
679 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
680 const regex_type&& __re,
681 regex_constants::match_flag_type __m
682 = regex_constants::match_default) = delete; // C++14
683 regex_iterator(const regex_iterator&);
684 regex_iterator& operator=(const regex_iterator&);
686 bool operator==(const regex_iterator&) const;
687 bool operator!=(const regex_iterator&) const;
689 const value_type& operator*() const;
690 const value_type* operator->() const;
692 regex_iterator& operator++();
693 regex_iterator operator++(int);
696 typedef regex_iterator<const char*> cregex_iterator;
697 typedef regex_iterator<const wchar_t*> wcregex_iterator;
698 typedef regex_iterator<string::const_iterator> sregex_iterator;
699 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
701 template <class BidirectionalIterator,
702 class charT = typename iterator_traits< BidirectionalIterator>::value_type,
703 class traits = regex_traits<charT>>
704 class regex_token_iterator
707 typedef basic_regex<charT, traits> regex_type;
708 typedef sub_match<BidirectionalIterator> value_type;
709 typedef ptrdiff_t difference_type;
710 typedef const value_type* pointer;
711 typedef const value_type& reference;
712 typedef forward_iterator_tag iterator_category;
714 regex_token_iterator();
715 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
716 const regex_type& re, int submatch = 0,
717 regex_constants::match_flag_type m = regex_constants::match_default);
718 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
719 const regex_type&& re, int submatch = 0,
720 regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
721 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
722 const regex_type& re, const vector<int>& submatches,
723 regex_constants::match_flag_type m = regex_constants::match_default);
724 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
725 const regex_type&& re, const vector<int>& submatches,
726 regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
727 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
728 const regex_type& re, initializer_list<int> submatches,
729 regex_constants::match_flag_type m = regex_constants::match_default);
730 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
731 const regex_type&& re, initializer_list<int> submatches,
732 regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
734 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
735 const regex_type& re, const int (&submatches)[N],
736 regex_constants::match_flag_type m = regex_constants::match_default);
738 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
739 const regex_type& re, const int (&submatches)[N],
740 regex_constants::match_flag_type m = regex_constants::match_default) = delete // C++14;
741 regex_token_iterator(const regex_token_iterator&);
742 regex_token_iterator& operator=(const regex_token_iterator&);
744 bool operator==(const regex_token_iterator&) const;
745 bool operator!=(const regex_token_iterator&) const;
747 const value_type& operator*() const;
748 const value_type* operator->() const;
750 regex_token_iterator& operator++();
751 regex_token_iterator operator++(int);
754 typedef regex_token_iterator<const char*> cregex_token_iterator;
755 typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
756 typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
757 typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
765 #include <initializer_list>
774 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
775 #pragma GCC system_header
779 #include <__undef_macros>
782 #define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096
784 _LIBCPP_BEGIN_NAMESPACE_STD
786 namespace regex_constants
789 // syntax_option_type
791 enum syntax_option_type
805 inline _LIBCPP_INLINE_VISIBILITY
808 operator~(syntax_option_type __x)
810 return syntax_option_type(~int(__x) & 0x1FF);
813 inline _LIBCPP_INLINE_VISIBILITY
816 operator&(syntax_option_type __x, syntax_option_type __y)
818 return syntax_option_type(int(__x) & int(__y));
821 inline _LIBCPP_INLINE_VISIBILITY
824 operator|(syntax_option_type __x, syntax_option_type __y)
826 return syntax_option_type(int(__x) | int(__y));
829 inline _LIBCPP_INLINE_VISIBILITY
832 operator^(syntax_option_type __x, syntax_option_type __y)
834 return syntax_option_type(int(__x) ^ int(__y));
837 inline _LIBCPP_INLINE_VISIBILITY
839 operator&=(syntax_option_type& __x, syntax_option_type __y)
845 inline _LIBCPP_INLINE_VISIBILITY
847 operator|=(syntax_option_type& __x, syntax_option_type __y)
853 inline _LIBCPP_INLINE_VISIBILITY
855 operator^=(syntax_option_type& __x, syntax_option_type __y)
866 match_not_bol = 1 << 0,
867 match_not_eol = 1 << 1,
868 match_not_bow = 1 << 2,
869 match_not_eow = 1 << 3,
871 match_not_null = 1 << 5,
872 match_continuous = 1 << 6,
873 match_prev_avail = 1 << 7,
876 format_no_copy = 1 << 9,
877 format_first_only = 1 << 10,
878 __no_update_pos = 1 << 11,
879 __full_match = 1 << 12
882 inline _LIBCPP_INLINE_VISIBILITY
885 operator~(match_flag_type __x)
887 return match_flag_type(~int(__x) & 0x0FFF);
890 inline _LIBCPP_INLINE_VISIBILITY
893 operator&(match_flag_type __x, match_flag_type __y)
895 return match_flag_type(int(__x) & int(__y));
898 inline _LIBCPP_INLINE_VISIBILITY
901 operator|(match_flag_type __x, match_flag_type __y)
903 return match_flag_type(int(__x) | int(__y));
906 inline _LIBCPP_INLINE_VISIBILITY
909 operator^(match_flag_type __x, match_flag_type __y)
911 return match_flag_type(int(__x) ^ int(__y));
914 inline _LIBCPP_INLINE_VISIBILITY
916 operator&=(match_flag_type& __x, match_flag_type __y)
922 inline _LIBCPP_INLINE_VISIBILITY
924 operator|=(match_flag_type& __x, match_flag_type __y)
930 inline _LIBCPP_INLINE_VISIBILITY
932 operator^=(match_flag_type& __x, match_flag_type __y)
960 class _LIBCPP_EXCEPTION_ABI regex_error
961 : public runtime_error
963 regex_constants::error_type __code_;
965 explicit regex_error(regex_constants::error_type __ecode);
966 virtual ~regex_error() throw();
967 _LIBCPP_INLINE_VISIBILITY
968 regex_constants::error_type code() const {return __code_;}
971 template <regex_constants::error_type _Ev>
972 _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
973 void __throw_regex_error()
975 #ifndef _LIBCPP_NO_EXCEPTIONS
976 throw regex_error(_Ev);
982 template <class _CharT>
983 struct _LIBCPP_TEMPLATE_VIS regex_traits
986 typedef _CharT char_type;
987 typedef basic_string<char_type> string_type;
988 typedef locale locale_type;
989 typedef ctype_base::mask char_class_type;
991 #if defined(__mips__) && defined(__GLIBC__)
992 static const char_class_type __regex_word = static_cast<char_class_type>(_ISbit(15));
993 #elif defined(__NetBSD__)
994 // NetBSD defines classes up to 0x2000
995 // see sys/ctype_bits.h, _CTYPE_Q
996 static const char_class_type __regex_word = 0x8000;
998 static const char_class_type __regex_word = 0x80;
1003 const ctype<char_type>* __ct_;
1004 const collate<char_type>* __col_;
1009 _LIBCPP_INLINE_VISIBILITY
1010 static size_t length(const char_type* __p)
1011 {return char_traits<char_type>::length(__p);}
1012 _LIBCPP_INLINE_VISIBILITY
1013 char_type translate(char_type __c) const {return __c;}
1014 char_type translate_nocase(char_type __c) const;
1015 template <class _ForwardIterator>
1017 transform(_ForwardIterator __f, _ForwardIterator __l) const;
1018 template <class _ForwardIterator>
1019 _LIBCPP_INLINE_VISIBILITY
1021 transform_primary( _ForwardIterator __f, _ForwardIterator __l) const
1022 {return __transform_primary(__f, __l, char_type());}
1023 template <class _ForwardIterator>
1024 _LIBCPP_INLINE_VISIBILITY
1026 lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const
1027 {return __lookup_collatename(__f, __l, char_type());}
1028 template <class _ForwardIterator>
1029 _LIBCPP_INLINE_VISIBILITY
1031 lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1032 bool __icase = false) const
1033 {return __lookup_classname(__f, __l, __icase, char_type());}
1034 bool isctype(char_type __c, char_class_type __m) const;
1035 _LIBCPP_INLINE_VISIBILITY
1036 int value(char_type __ch, int __radix) const
1037 {return __regex_traits_value(__ch, __radix);}
1038 locale_type imbue(locale_type __l);
1039 _LIBCPP_INLINE_VISIBILITY
1040 locale_type getloc()const {return __loc_;}
1045 template <class _ForwardIterator>
1047 __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;
1048 template <class _ForwardIterator>
1050 __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1052 template <class _ForwardIterator>
1054 __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;
1055 template <class _ForwardIterator>
1057 __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1059 template <class _ForwardIterator>
1061 __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1062 bool __icase, char) const;
1063 template <class _ForwardIterator>
1065 __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1066 bool __icase, wchar_t) const;
1068 static int __regex_traits_value(unsigned char __ch, int __radix);
1069 _LIBCPP_INLINE_VISIBILITY
1070 int __regex_traits_value(char __ch, int __radix) const
1071 {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);}
1072 _LIBCPP_INLINE_VISIBILITY
1073 int __regex_traits_value(wchar_t __ch, int __radix) const;
1076 template <class _CharT>
1077 const typename regex_traits<_CharT>::char_class_type
1078 regex_traits<_CharT>::__regex_word;
1080 template <class _CharT>
1081 regex_traits<_CharT>::regex_traits()
1086 template <class _CharT>
1087 typename regex_traits<_CharT>::char_type
1088 regex_traits<_CharT>::translate_nocase(char_type __c) const
1090 return __ct_->tolower(__c);
1093 template <class _CharT>
1094 template <class _ForwardIterator>
1095 typename regex_traits<_CharT>::string_type
1096 regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const
1098 string_type __s(__f, __l);
1099 return __col_->transform(__s.data(), __s.data() + __s.size());
1102 template <class _CharT>
1104 regex_traits<_CharT>::__init()
1106 __ct_ = &use_facet<ctype<char_type> >(__loc_);
1107 __col_ = &use_facet<collate<char_type> >(__loc_);
1110 template <class _CharT>
1111 typename regex_traits<_CharT>::locale_type
1112 regex_traits<_CharT>::imbue(locale_type __l)
1114 locale __r = __loc_;
1120 // transform_primary is very FreeBSD-specific
1122 template <class _CharT>
1123 template <class _ForwardIterator>
1124 typename regex_traits<_CharT>::string_type
1125 regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
1126 _ForwardIterator __l, char) const
1128 const string_type __s(__f, __l);
1129 string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
1144 template <class _CharT>
1145 template <class _ForwardIterator>
1146 typename regex_traits<_CharT>::string_type
1147 regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
1148 _ForwardIterator __l, wchar_t) const
1150 const string_type __s(__f, __l);
1151 string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
1166 // lookup_collatename is very FreeBSD-specific
1168 _LIBCPP_FUNC_VIS string __get_collation_name(const char* __s);
1170 template <class _CharT>
1171 template <class _ForwardIterator>
1172 typename regex_traits<_CharT>::string_type
1173 regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
1174 _ForwardIterator __l, char) const
1176 string_type __s(__f, __l);
1180 __r = __get_collation_name(__s.c_str());
1181 if (__r.empty() && __s.size() <= 2)
1183 __r = __col_->transform(__s.data(), __s.data() + __s.size());
1184 if (__r.size() == 1 || __r.size() == 12)
1193 template <class _CharT>
1194 template <class _ForwardIterator>
1195 typename regex_traits<_CharT>::string_type
1196 regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
1197 _ForwardIterator __l, wchar_t) const
1199 string_type __s(__f, __l);
1201 __n.reserve(__s.size());
1202 for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
1205 if (static_cast<unsigned>(*__i) >= 127)
1206 return string_type();
1207 __n.push_back(char(*__i));
1212 __n = __get_collation_name(__n.c_str());
1214 __r.assign(__n.begin(), __n.end());
1215 else if (__s.size() <= 2)
1217 __r = __col_->transform(__s.data(), __s.data() + __s.size());
1218 if (__r.size() == 1 || __r.size() == 3)
1229 regex_traits<char>::char_class_type _LIBCPP_FUNC_VIS
1230 __get_classname(const char* __s, bool __icase);
1232 template <class _CharT>
1233 template <class _ForwardIterator>
1234 typename regex_traits<_CharT>::char_class_type
1235 regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
1236 _ForwardIterator __l,
1237 bool __icase, char) const
1239 string_type __s(__f, __l);
1240 __ct_->tolower(&__s[0], &__s[0] + __s.size());
1241 return __get_classname(__s.c_str(), __icase);
1244 template <class _CharT>
1245 template <class _ForwardIterator>
1246 typename regex_traits<_CharT>::char_class_type
1247 regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
1248 _ForwardIterator __l,
1249 bool __icase, wchar_t) const
1251 string_type __s(__f, __l);
1252 __ct_->tolower(&__s[0], &__s[0] + __s.size());
1254 __n.reserve(__s.size());
1255 for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
1258 if (static_cast<unsigned>(*__i) >= 127)
1259 return char_class_type();
1260 __n.push_back(char(*__i));
1262 return __get_classname(__n.c_str(), __icase);
1265 template <class _CharT>
1267 regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const
1269 if (__ct_->is(__m, __c))
1271 return (__c == '_' && (__m & __regex_word));
1274 template <class _CharT>
1276 regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix)
1278 if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7'
1282 if ((__ch & 0xFEu) == 0x38) // '8' <= __ch && __ch <= '9'
1286 __ch |= 0x20; // tolower
1287 if ('a' <= __ch && __ch <= 'f')
1288 return __ch - ('a' - 10);
1294 template <class _CharT>
1297 regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const
1299 return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix);
1302 template <class _CharT> class __node;
1304 template <class _BidirectionalIterator> class _LIBCPP_TEMPLATE_VIS sub_match;
1306 template <class _BidirectionalIterator,
1307 class _Allocator = allocator<sub_match<_BidirectionalIterator> > >
1308 class _LIBCPP_TEMPLATE_VIS match_results;
1310 template <class _CharT>
1315 __end_state = -1000,
1316 __consume_input, // -999
1317 __begin_marked_expr, // -998
1318 __end_marked_expr, // -997
1319 __pop_state, // -996
1320 __accept_and_consume, // -995
1321 __accept_but_not_consume, // -994
1328 const _CharT* __first_;
1329 const _CharT* __current_;
1330 const _CharT* __last_;
1331 vector<sub_match<const _CharT*> > __sub_matches_;
1332 vector<pair<size_t, const _CharT*> > __loop_data_;
1333 const __node<_CharT>* __node_;
1334 regex_constants::match_flag_type __flags_;
1337 _LIBCPP_INLINE_VISIBILITY
1339 : __do_(0), __first_(nullptr), __current_(nullptr), __last_(nullptr),
1340 __node_(nullptr), __flags_() {}
1345 template <class _CharT>
1348 __node(const __node&);
1349 __node& operator=(const __node&);
1351 typedef _VSTD::__state<_CharT> __state;
1353 _LIBCPP_INLINE_VISIBILITY
1355 _LIBCPP_INLINE_VISIBILITY
1356 virtual ~__node() {}
1358 _LIBCPP_INLINE_VISIBILITY
1359 virtual void __exec(__state&) const {}
1360 _LIBCPP_INLINE_VISIBILITY
1361 virtual void __exec_split(bool, __state&) const {}
1366 template <class _CharT>
1368 : public __node<_CharT>
1371 typedef _VSTD::__state<_CharT> __state;
1373 _LIBCPP_INLINE_VISIBILITY
1376 virtual void __exec(__state&) const;
1379 template <class _CharT>
1381 __end_state<_CharT>::__exec(__state& __s) const
1383 __s.__do_ = __state::__end_state;
1388 template <class _CharT>
1389 class __has_one_state
1390 : public __node<_CharT>
1392 __node<_CharT>* __first_;
1395 _LIBCPP_INLINE_VISIBILITY
1396 explicit __has_one_state(__node<_CharT>* __s)
1399 _LIBCPP_INLINE_VISIBILITY
1400 __node<_CharT>* first() const {return __first_;}
1401 _LIBCPP_INLINE_VISIBILITY
1402 __node<_CharT>*& first() {return __first_;}
1407 template <class _CharT>
1408 class __owns_one_state
1409 : public __has_one_state<_CharT>
1411 typedef __has_one_state<_CharT> base;
1414 _LIBCPP_INLINE_VISIBILITY
1415 explicit __owns_one_state(__node<_CharT>* __s)
1418 virtual ~__owns_one_state();
1421 template <class _CharT>
1422 __owns_one_state<_CharT>::~__owns_one_state()
1424 delete this->first();
1429 template <class _CharT>
1431 : public __owns_one_state<_CharT>
1433 typedef __owns_one_state<_CharT> base;
1436 typedef _VSTD::__state<_CharT> __state;
1438 _LIBCPP_INLINE_VISIBILITY
1439 explicit __empty_state(__node<_CharT>* __s)
1442 virtual void __exec(__state&) const;
1445 template <class _CharT>
1447 __empty_state<_CharT>::__exec(__state& __s) const
1449 __s.__do_ = __state::__accept_but_not_consume;
1450 __s.__node_ = this->first();
1453 // __empty_non_own_state
1455 template <class _CharT>
1456 class __empty_non_own_state
1457 : public __has_one_state<_CharT>
1459 typedef __has_one_state<_CharT> base;
1462 typedef _VSTD::__state<_CharT> __state;
1464 _LIBCPP_INLINE_VISIBILITY
1465 explicit __empty_non_own_state(__node<_CharT>* __s)
1468 virtual void __exec(__state&) const;
1471 template <class _CharT>
1473 __empty_non_own_state<_CharT>::__exec(__state& __s) const
1475 __s.__do_ = __state::__accept_but_not_consume;
1476 __s.__node_ = this->first();
1479 // __repeat_one_loop
1481 template <class _CharT>
1482 class __repeat_one_loop
1483 : public __has_one_state<_CharT>
1485 typedef __has_one_state<_CharT> base;
1488 typedef _VSTD::__state<_CharT> __state;
1490 _LIBCPP_INLINE_VISIBILITY
1491 explicit __repeat_one_loop(__node<_CharT>* __s)
1494 virtual void __exec(__state&) const;
1497 template <class _CharT>
1499 __repeat_one_loop<_CharT>::__exec(__state& __s) const
1501 __s.__do_ = __state::__repeat;
1502 __s.__node_ = this->first();
1505 // __owns_two_states
1507 template <class _CharT>
1508 class __owns_two_states
1509 : public __owns_one_state<_CharT>
1511 typedef __owns_one_state<_CharT> base;
1516 _LIBCPP_INLINE_VISIBILITY
1517 explicit __owns_two_states(__node<_CharT>* __s1, base* __s2)
1518 : base(__s1), __second_(__s2) {}
1520 virtual ~__owns_two_states();
1522 _LIBCPP_INLINE_VISIBILITY
1523 base* second() const {return __second_;}
1524 _LIBCPP_INLINE_VISIBILITY
1525 base*& second() {return __second_;}
1528 template <class _CharT>
1529 __owns_two_states<_CharT>::~__owns_two_states()
1536 template <class _CharT>
1538 : public __owns_two_states<_CharT>
1540 typedef __owns_two_states<_CharT> base;
1544 unsigned __loop_id_;
1545 unsigned __mexp_begin_;
1546 unsigned __mexp_end_;
1550 typedef _VSTD::__state<_CharT> __state;
1552 _LIBCPP_INLINE_VISIBILITY
1553 explicit __loop(unsigned __loop_id,
1554 __node<_CharT>* __s1, __owns_one_state<_CharT>* __s2,
1555 unsigned __mexp_begin, unsigned __mexp_end,
1556 bool __greedy = true,
1558 size_t __max = numeric_limits<size_t>::max())
1559 : base(__s1, __s2), __min_(__min), __max_(__max), __loop_id_(__loop_id),
1560 __mexp_begin_(__mexp_begin), __mexp_end_(__mexp_end),
1561 __greedy_(__greedy) {}
1563 virtual void __exec(__state& __s) const;
1564 virtual void __exec_split(bool __second, __state& __s) const;
1567 _LIBCPP_INLINE_VISIBILITY
1568 void __init_repeat(__state& __s) const
1570 __s.__loop_data_[__loop_id_].second = __s.__current_;
1571 for (size_t __i = __mexp_begin_-1; __i != __mexp_end_-1; ++__i)
1573 __s.__sub_matches_[__i].first = __s.__last_;
1574 __s.__sub_matches_[__i].second = __s.__last_;
1575 __s.__sub_matches_[__i].matched = false;
1580 template <class _CharT>
1582 __loop<_CharT>::__exec(__state& __s) const
1584 if (__s.__do_ == __state::__repeat)
1586 bool __do_repeat = ++__s.__loop_data_[__loop_id_].first < __max_;
1587 bool __do_alt = __s.__loop_data_[__loop_id_].first >= __min_;
1588 if (__do_repeat && __do_alt &&
1589 __s.__loop_data_[__loop_id_].second == __s.__current_)
1590 __do_repeat = false;
1591 if (__do_repeat && __do_alt)
1592 __s.__do_ = __state::__split;
1593 else if (__do_repeat)
1595 __s.__do_ = __state::__accept_but_not_consume;
1596 __s.__node_ = this->first();
1601 __s.__do_ = __state::__accept_but_not_consume;
1602 __s.__node_ = this->second();
1607 __s.__loop_data_[__loop_id_].first = 0;
1608 bool __do_repeat = 0 < __max_;
1609 bool __do_alt = 0 >= __min_;
1610 if (__do_repeat && __do_alt)
1611 __s.__do_ = __state::__split;
1612 else if (__do_repeat)
1614 __s.__do_ = __state::__accept_but_not_consume;
1615 __s.__node_ = this->first();
1620 __s.__do_ = __state::__accept_but_not_consume;
1621 __s.__node_ = this->second();
1626 template <class _CharT>
1628 __loop<_CharT>::__exec_split(bool __second, __state& __s) const
1630 __s.__do_ = __state::__accept_but_not_consume;
1631 if (__greedy_ != __second)
1633 __s.__node_ = this->first();
1637 __s.__node_ = this->second();
1642 template <class _CharT>
1644 : public __owns_two_states<_CharT>
1646 typedef __owns_two_states<_CharT> base;
1649 typedef _VSTD::__state<_CharT> __state;
1651 _LIBCPP_INLINE_VISIBILITY
1652 explicit __alternate(__owns_one_state<_CharT>* __s1,
1653 __owns_one_state<_CharT>* __s2)
1654 : base(__s1, __s2) {}
1656 virtual void __exec(__state& __s) const;
1657 virtual void __exec_split(bool __second, __state& __s) const;
1660 template <class _CharT>
1662 __alternate<_CharT>::__exec(__state& __s) const
1664 __s.__do_ = __state::__split;
1667 template <class _CharT>
1669 __alternate<_CharT>::__exec_split(bool __second, __state& __s) const
1671 __s.__do_ = __state::__accept_but_not_consume;
1673 __s.__node_ = this->second();
1675 __s.__node_ = this->first();
1678 // __begin_marked_subexpression
1680 template <class _CharT>
1681 class __begin_marked_subexpression
1682 : public __owns_one_state<_CharT>
1684 typedef __owns_one_state<_CharT> base;
1688 typedef _VSTD::__state<_CharT> __state;
1690 _LIBCPP_INLINE_VISIBILITY
1691 explicit __begin_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
1692 : base(__s), __mexp_(__mexp) {}
1694 virtual void __exec(__state&) const;
1697 template <class _CharT>
1699 __begin_marked_subexpression<_CharT>::__exec(__state& __s) const
1701 __s.__do_ = __state::__accept_but_not_consume;
1702 __s.__sub_matches_[__mexp_-1].first = __s.__current_;
1703 __s.__node_ = this->first();
1706 // __end_marked_subexpression
1708 template <class _CharT>
1709 class __end_marked_subexpression
1710 : public __owns_one_state<_CharT>
1712 typedef __owns_one_state<_CharT> base;
1716 typedef _VSTD::__state<_CharT> __state;
1718 _LIBCPP_INLINE_VISIBILITY
1719 explicit __end_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
1720 : base(__s), __mexp_(__mexp) {}
1722 virtual void __exec(__state&) const;
1725 template <class _CharT>
1727 __end_marked_subexpression<_CharT>::__exec(__state& __s) const
1729 __s.__do_ = __state::__accept_but_not_consume;
1730 __s.__sub_matches_[__mexp_-1].second = __s.__current_;
1731 __s.__sub_matches_[__mexp_-1].matched = true;
1732 __s.__node_ = this->first();
1737 template <class _CharT>
1739 : public __owns_one_state<_CharT>
1741 typedef __owns_one_state<_CharT> base;
1745 typedef _VSTD::__state<_CharT> __state;
1747 _LIBCPP_INLINE_VISIBILITY
1748 explicit __back_ref(unsigned __mexp, __node<_CharT>* __s)
1749 : base(__s), __mexp_(__mexp) {}
1751 virtual void __exec(__state&) const;
1754 template <class _CharT>
1756 __back_ref<_CharT>::__exec(__state& __s) const
1758 if (__mexp_ > __s.__sub_matches_.size())
1759 __throw_regex_error<regex_constants::error_backref>();
1760 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1763 ptrdiff_t __len = __sm.second - __sm.first;
1764 if (__s.__last_ - __s.__current_ >= __len &&
1765 _VSTD::equal(__sm.first, __sm.second, __s.__current_))
1767 __s.__do_ = __state::__accept_but_not_consume;
1768 __s.__current_ += __len;
1769 __s.__node_ = this->first();
1773 __s.__do_ = __state::__reject;
1774 __s.__node_ = nullptr;
1779 __s.__do_ = __state::__reject;
1780 __s.__node_ = nullptr;
1786 template <class _CharT, class _Traits>
1787 class __back_ref_icase
1788 : public __owns_one_state<_CharT>
1790 typedef __owns_one_state<_CharT> base;
1795 typedef _VSTD::__state<_CharT> __state;
1797 _LIBCPP_INLINE_VISIBILITY
1798 explicit __back_ref_icase(const _Traits& __traits, unsigned __mexp,
1799 __node<_CharT>* __s)
1800 : base(__s), __traits_(__traits), __mexp_(__mexp) {}
1802 virtual void __exec(__state&) const;
1805 template <class _CharT, class _Traits>
1807 __back_ref_icase<_CharT, _Traits>::__exec(__state& __s) const
1809 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1812 ptrdiff_t __len = __sm.second - __sm.first;
1813 if (__s.__last_ - __s.__current_ >= __len)
1815 for (ptrdiff_t __i = 0; __i < __len; ++__i)
1817 if (__traits_.translate_nocase(__sm.first[__i]) !=
1818 __traits_.translate_nocase(__s.__current_[__i]))
1821 __s.__do_ = __state::__accept_but_not_consume;
1822 __s.__current_ += __len;
1823 __s.__node_ = this->first();
1827 __s.__do_ = __state::__reject;
1828 __s.__node_ = nullptr;
1834 __s.__do_ = __state::__reject;
1835 __s.__node_ = nullptr;
1839 // __back_ref_collate
1841 template <class _CharT, class _Traits>
1842 class __back_ref_collate
1843 : public __owns_one_state<_CharT>
1845 typedef __owns_one_state<_CharT> base;
1850 typedef _VSTD::__state<_CharT> __state;
1852 _LIBCPP_INLINE_VISIBILITY
1853 explicit __back_ref_collate(const _Traits& __traits, unsigned __mexp,
1854 __node<_CharT>* __s)
1855 : base(__s), __traits_(__traits), __mexp_(__mexp) {}
1857 virtual void __exec(__state&) const;
1860 template <class _CharT, class _Traits>
1862 __back_ref_collate<_CharT, _Traits>::__exec(__state& __s) const
1864 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1867 ptrdiff_t __len = __sm.second - __sm.first;
1868 if (__s.__last_ - __s.__current_ >= __len)
1870 for (ptrdiff_t __i = 0; __i < __len; ++__i)
1872 if (__traits_.translate(__sm.first[__i]) !=
1873 __traits_.translate(__s.__current_[__i]))
1876 __s.__do_ = __state::__accept_but_not_consume;
1877 __s.__current_ += __len;
1878 __s.__node_ = this->first();
1882 __s.__do_ = __state::__reject;
1883 __s.__node_ = nullptr;
1889 __s.__do_ = __state::__reject;
1890 __s.__node_ = nullptr;
1896 template <class _CharT, class _Traits>
1897 class __word_boundary
1898 : public __owns_one_state<_CharT>
1900 typedef __owns_one_state<_CharT> base;
1905 typedef _VSTD::__state<_CharT> __state;
1907 _LIBCPP_INLINE_VISIBILITY
1908 explicit __word_boundary(const _Traits& __traits, bool __invert,
1909 __node<_CharT>* __s)
1910 : base(__s), __traits_(__traits), __invert_(__invert) {}
1912 virtual void __exec(__state&) const;
1915 template <class _CharT, class _Traits>
1917 __word_boundary<_CharT, _Traits>::__exec(__state& __s) const
1919 bool __is_word_b = false;
1920 if (__s.__first_ != __s.__last_)
1922 if (__s.__current_ == __s.__last_)
1924 if (!(__s.__flags_ & regex_constants::match_not_eow))
1926 _CharT __c = __s.__current_[-1];
1927 __is_word_b = __c == '_' ||
1928 __traits_.isctype(__c, ctype_base::alnum);
1931 else if (__s.__current_ == __s.__first_ &&
1932 !(__s.__flags_ & regex_constants::match_prev_avail))
1934 if (!(__s.__flags_ & regex_constants::match_not_bow))
1936 _CharT __c = *__s.__current_;
1937 __is_word_b = __c == '_' ||
1938 __traits_.isctype(__c, ctype_base::alnum);
1943 _CharT __c1 = __s.__current_[-1];
1944 _CharT __c2 = *__s.__current_;
1945 bool __is_c1_b = __c1 == '_' ||
1946 __traits_.isctype(__c1, ctype_base::alnum);
1947 bool __is_c2_b = __c2 == '_' ||
1948 __traits_.isctype(__c2, ctype_base::alnum);
1949 __is_word_b = __is_c1_b != __is_c2_b;
1952 if (__is_word_b != __invert_)
1954 __s.__do_ = __state::__accept_but_not_consume;
1955 __s.__node_ = this->first();
1959 __s.__do_ = __state::__reject;
1960 __s.__node_ = nullptr;
1966 template <class _CharT>
1968 : public __owns_one_state<_CharT>
1970 typedef __owns_one_state<_CharT> base;
1973 typedef _VSTD::__state<_CharT> __state;
1975 _LIBCPP_INLINE_VISIBILITY
1976 __l_anchor(__node<_CharT>* __s)
1979 virtual void __exec(__state&) const;
1982 template <class _CharT>
1984 __l_anchor<_CharT>::__exec(__state& __s) const
1986 if (__s.__at_first_ && __s.__current_ == __s.__first_ &&
1987 !(__s.__flags_ & regex_constants::match_not_bol))
1989 __s.__do_ = __state::__accept_but_not_consume;
1990 __s.__node_ = this->first();
1994 __s.__do_ = __state::__reject;
1995 __s.__node_ = nullptr;
2001 template <class _CharT>
2003 : public __owns_one_state<_CharT>
2005 typedef __owns_one_state<_CharT> base;
2008 typedef _VSTD::__state<_CharT> __state;
2010 _LIBCPP_INLINE_VISIBILITY
2011 __r_anchor(__node<_CharT>* __s)
2014 virtual void __exec(__state&) const;
2017 template <class _CharT>
2019 __r_anchor<_CharT>::__exec(__state& __s) const
2021 if (__s.__current_ == __s.__last_ &&
2022 !(__s.__flags_ & regex_constants::match_not_eol))
2024 __s.__do_ = __state::__accept_but_not_consume;
2025 __s.__node_ = this->first();
2029 __s.__do_ = __state::__reject;
2030 __s.__node_ = nullptr;
2036 template <class _CharT>
2038 : public __owns_one_state<_CharT>
2040 typedef __owns_one_state<_CharT> base;
2043 typedef _VSTD::__state<_CharT> __state;
2045 _LIBCPP_INLINE_VISIBILITY
2046 __match_any(__node<_CharT>* __s)
2049 virtual void __exec(__state&) const;
2052 template <class _CharT>
2054 __match_any<_CharT>::__exec(__state& __s) const
2056 if (__s.__current_ != __s.__last_ && *__s.__current_ != 0)
2058 __s.__do_ = __state::__accept_and_consume;
2060 __s.__node_ = this->first();
2064 __s.__do_ = __state::__reject;
2065 __s.__node_ = nullptr;
2069 // __match_any_but_newline
2071 template <class _CharT>
2072 class __match_any_but_newline
2073 : public __owns_one_state<_CharT>
2075 typedef __owns_one_state<_CharT> base;
2078 typedef _VSTD::__state<_CharT> __state;
2080 _LIBCPP_INLINE_VISIBILITY
2081 __match_any_but_newline(__node<_CharT>* __s)
2084 virtual void __exec(__state&) const;
2087 template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const;
2088 template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<wchar_t>::__exec(__state&) const;
2092 template <class _CharT>
2094 : public __owns_one_state<_CharT>
2096 typedef __owns_one_state<_CharT> base;
2100 __match_char(const __match_char&);
2101 __match_char& operator=(const __match_char&);
2103 typedef _VSTD::__state<_CharT> __state;
2105 _LIBCPP_INLINE_VISIBILITY
2106 __match_char(_CharT __c, __node<_CharT>* __s)
2107 : base(__s), __c_(__c) {}
2109 virtual void __exec(__state&) const;
2112 template <class _CharT>
2114 __match_char<_CharT>::__exec(__state& __s) const
2116 if (__s.__current_ != __s.__last_ && *__s.__current_ == __c_)
2118 __s.__do_ = __state::__accept_and_consume;
2120 __s.__node_ = this->first();
2124 __s.__do_ = __state::__reject;
2125 __s.__node_ = nullptr;
2129 // __match_char_icase
2131 template <class _CharT, class _Traits>
2132 class __match_char_icase
2133 : public __owns_one_state<_CharT>
2135 typedef __owns_one_state<_CharT> base;
2140 __match_char_icase(const __match_char_icase&);
2141 __match_char_icase& operator=(const __match_char_icase&);
2143 typedef _VSTD::__state<_CharT> __state;
2145 _LIBCPP_INLINE_VISIBILITY
2146 __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
2147 : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {}
2149 virtual void __exec(__state&) const;
2152 template <class _CharT, class _Traits>
2154 __match_char_icase<_CharT, _Traits>::__exec(__state& __s) const
2156 if (__s.__current_ != __s.__last_ &&
2157 __traits_.translate_nocase(*__s.__current_) == __c_)
2159 __s.__do_ = __state::__accept_and_consume;
2161 __s.__node_ = this->first();
2165 __s.__do_ = __state::__reject;
2166 __s.__node_ = nullptr;
2170 // __match_char_collate
2172 template <class _CharT, class _Traits>
2173 class __match_char_collate
2174 : public __owns_one_state<_CharT>
2176 typedef __owns_one_state<_CharT> base;
2181 __match_char_collate(const __match_char_collate&);
2182 __match_char_collate& operator=(const __match_char_collate&);
2184 typedef _VSTD::__state<_CharT> __state;
2186 _LIBCPP_INLINE_VISIBILITY
2187 __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
2188 : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {}
2190 virtual void __exec(__state&) const;
2193 template <class _CharT, class _Traits>
2195 __match_char_collate<_CharT, _Traits>::__exec(__state& __s) const
2197 if (__s.__current_ != __s.__last_ &&
2198 __traits_.translate(*__s.__current_) == __c_)
2200 __s.__do_ = __state::__accept_and_consume;
2202 __s.__node_ = this->first();
2206 __s.__do_ = __state::__reject;
2207 __s.__node_ = nullptr;
2211 // __bracket_expression
2213 template <class _CharT, class _Traits>
2214 class __bracket_expression
2215 : public __owns_one_state<_CharT>
2217 typedef __owns_one_state<_CharT> base;
2218 typedef typename _Traits::string_type string_type;
2221 vector<_CharT> __chars_;
2222 vector<_CharT> __neg_chars_;
2223 vector<pair<string_type, string_type> > __ranges_;
2224 vector<pair<_CharT, _CharT> > __digraphs_;
2225 vector<string_type> __equivalences_;
2226 typename regex_traits<_CharT>::char_class_type __mask_;
2227 typename regex_traits<_CharT>::char_class_type __neg_mask_;
2231 bool __might_have_digraph_;
2233 __bracket_expression(const __bracket_expression&);
2234 __bracket_expression& operator=(const __bracket_expression&);
2236 typedef _VSTD::__state<_CharT> __state;
2238 _LIBCPP_INLINE_VISIBILITY
2239 __bracket_expression(const _Traits& __traits, __node<_CharT>* __s,
2240 bool __negate, bool __icase, bool __collate)
2241 : base(__s), __traits_(__traits), __mask_(), __neg_mask_(),
2242 __negate_(__negate), __icase_(__icase), __collate_(__collate),
2243 __might_have_digraph_(__traits_.getloc().name() != "C") {}
2245 virtual void __exec(__state&) const;
2247 _LIBCPP_INLINE_VISIBILITY
2248 bool __negated() const {return __negate_;}
2250 _LIBCPP_INLINE_VISIBILITY
2251 void __add_char(_CharT __c)
2254 __chars_.push_back(__traits_.translate_nocase(__c));
2255 else if (__collate_)
2256 __chars_.push_back(__traits_.translate(__c));
2258 __chars_.push_back(__c);
2260 _LIBCPP_INLINE_VISIBILITY
2261 void __add_neg_char(_CharT __c)
2264 __neg_chars_.push_back(__traits_.translate_nocase(__c));
2265 else if (__collate_)
2266 __neg_chars_.push_back(__traits_.translate(__c));
2268 __neg_chars_.push_back(__c);
2270 _LIBCPP_INLINE_VISIBILITY
2271 void __add_range(string_type __b, string_type __e)
2277 for (size_t __i = 0; __i < __b.size(); ++__i)
2278 __b[__i] = __traits_.translate_nocase(__b[__i]);
2279 for (size_t __i = 0; __i < __e.size(); ++__i)
2280 __e[__i] = __traits_.translate_nocase(__e[__i]);
2284 for (size_t __i = 0; __i < __b.size(); ++__i)
2285 __b[__i] = __traits_.translate(__b[__i]);
2286 for (size_t __i = 0; __i < __e.size(); ++__i)
2287 __e[__i] = __traits_.translate(__e[__i]);
2289 __ranges_.push_back(make_pair(
2290 __traits_.transform(__b.begin(), __b.end()),
2291 __traits_.transform(__e.begin(), __e.end())));
2295 if (__b.size() != 1 || __e.size() != 1)
2296 __throw_regex_error<regex_constants::error_collate>();
2299 __b[0] = __traits_.translate_nocase(__b[0]);
2300 __e[0] = __traits_.translate_nocase(__e[0]);
2302 __ranges_.push_back(make_pair(_VSTD::move(__b), _VSTD::move(__e)));
2305 _LIBCPP_INLINE_VISIBILITY
2306 void __add_digraph(_CharT __c1, _CharT __c2)
2309 __digraphs_.push_back(make_pair(__traits_.translate_nocase(__c1),
2310 __traits_.translate_nocase(__c2)));
2311 else if (__collate_)
2312 __digraphs_.push_back(make_pair(__traits_.translate(__c1),
2313 __traits_.translate(__c2)));
2315 __digraphs_.push_back(make_pair(__c1, __c2));
2317 _LIBCPP_INLINE_VISIBILITY
2318 void __add_equivalence(const string_type& __s)
2319 {__equivalences_.push_back(__s);}
2320 _LIBCPP_INLINE_VISIBILITY
2321 void __add_class(typename regex_traits<_CharT>::char_class_type __mask)
2322 {__mask_ |= __mask;}
2323 _LIBCPP_INLINE_VISIBILITY
2324 void __add_neg_class(typename regex_traits<_CharT>::char_class_type __mask)
2325 {__neg_mask_ |= __mask;}
2328 template <class _CharT, class _Traits>
2330 __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const
2332 bool __found = false;
2333 unsigned __consumed = 0;
2334 if (__s.__current_ != __s.__last_)
2337 if (__might_have_digraph_)
2339 const _CharT* __next = _VSTD::next(__s.__current_);
2340 if (__next != __s.__last_)
2342 pair<_CharT, _CharT> __ch2(*__s.__current_, *__next);
2345 __ch2.first = __traits_.translate_nocase(__ch2.first);
2346 __ch2.second = __traits_.translate_nocase(__ch2.second);
2348 else if (__collate_)
2350 __ch2.first = __traits_.translate(__ch2.first);
2351 __ch2.second = __traits_.translate(__ch2.second);
2353 if (!__traits_.lookup_collatename(&__ch2.first, &__ch2.first+2).empty())
2355 // __ch2 is a digraph in this locale
2357 for (size_t __i = 0; __i < __digraphs_.size(); ++__i)
2359 if (__ch2 == __digraphs_[__i])
2365 if (__collate_ && !__ranges_.empty())
2367 string_type __s2 = __traits_.transform(&__ch2.first,
2369 for (size_t __i = 0; __i < __ranges_.size(); ++__i)
2371 if (__ranges_[__i].first <= __s2 &&
2372 __s2 <= __ranges_[__i].second)
2379 if (!__equivalences_.empty())
2381 string_type __s2 = __traits_.transform_primary(&__ch2.first,
2383 for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
2385 if (__s2 == __equivalences_[__i])
2392 if (__traits_.isctype(__ch2.first, __mask_) &&
2393 __traits_.isctype(__ch2.second, __mask_))
2398 if (!__traits_.isctype(__ch2.first, __neg_mask_) &&
2399 !__traits_.isctype(__ch2.second, __neg_mask_))
2408 // test *__s.__current_ as not a digraph
2409 _CharT __ch = *__s.__current_;
2411 __ch = __traits_.translate_nocase(__ch);
2412 else if (__collate_)
2413 __ch = __traits_.translate(__ch);
2414 for (size_t __i = 0; __i < __chars_.size(); ++__i)
2416 if (__ch == __chars_[__i])
2422 // When there's at least one of __neg_chars_ and __neg_mask_, the set
2423 // of "__found" chars is
2424 // union(complement(union(__neg_chars_, __neg_mask_)),
2427 // It doesn't make sense to check this when there are no __neg_chars_
2428 // and no __neg_mask_.
2429 if (!(__neg_mask_ == 0 && __neg_chars_.empty()))
2431 const bool __in_neg_mask = __traits_.isctype(__ch, __neg_mask_);
2432 const bool __in_neg_chars =
2433 std::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) !=
2435 if (!(__in_neg_mask || __in_neg_chars))
2441 if (!__ranges_.empty())
2443 string_type __s2 = __collate_ ?
2444 __traits_.transform(&__ch, &__ch + 1) :
2445 string_type(1, __ch);
2446 for (size_t __i = 0; __i < __ranges_.size(); ++__i)
2448 if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second)
2455 if (!__equivalences_.empty())
2457 string_type __s2 = __traits_.transform_primary(&__ch, &__ch + 1);
2458 for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
2460 if (__s2 == __equivalences_[__i])
2467 if (__traits_.isctype(__ch, __mask_))
2474 __found = __negate_; // force reject
2476 if (__found != __negate_)
2478 __s.__do_ = __state::__accept_and_consume;
2479 __s.__current_ += __consumed;
2480 __s.__node_ = this->first();
2484 __s.__do_ = __state::__reject;
2485 __s.__node_ = nullptr;
2489 template <class _CharT, class _Traits> class __lookahead;
2491 template <class _CharT, class _Traits = regex_traits<_CharT> >
2492 class _LIBCPP_TEMPLATE_VIS basic_regex
2496 typedef _CharT value_type;
2497 typedef _Traits traits_type;
2498 typedef typename _Traits::string_type string_type;
2499 typedef regex_constants::syntax_option_type flag_type;
2500 typedef typename _Traits::locale_type locale_type;
2505 unsigned __marked_count_;
2506 unsigned __loop_count_;
2508 shared_ptr<__empty_state<_CharT> > __start_;
2509 __owns_one_state<_CharT>* __end_;
2511 typedef _VSTD::__state<_CharT> __state;
2512 typedef _VSTD::__node<_CharT> __node;
2516 static const regex_constants::syntax_option_type icase = regex_constants::icase;
2517 static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
2518 static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
2519 static const regex_constants::syntax_option_type collate = regex_constants::collate;
2520 static const regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
2521 static const regex_constants::syntax_option_type basic = regex_constants::basic;
2522 static const regex_constants::syntax_option_type extended = regex_constants::extended;
2523 static const regex_constants::syntax_option_type awk = regex_constants::awk;
2524 static const regex_constants::syntax_option_type grep = regex_constants::grep;
2525 static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
2527 // construct/copy/destroy:
2528 _LIBCPP_INLINE_VISIBILITY
2530 : __flags_(), __marked_count_(0), __loop_count_(0), __open_count_(0),
2533 _LIBCPP_INLINE_VISIBILITY
2534 explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
2535 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2537 {__parse(__p, __p + __traits_.length(__p));}
2538 _LIBCPP_INLINE_VISIBILITY
2539 basic_regex(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
2540 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2542 {__parse(__p, __p + __len);}
2543 // basic_regex(const basic_regex&) = default;
2544 // basic_regex(basic_regex&&) = default;
2545 template <class _ST, class _SA>
2546 _LIBCPP_INLINE_VISIBILITY
2547 explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p,
2548 flag_type __f = regex_constants::ECMAScript)
2549 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2551 {__parse(__p.begin(), __p.end());}
2552 template <class _ForwardIterator>
2553 _LIBCPP_INLINE_VISIBILITY
2554 basic_regex(_ForwardIterator __first, _ForwardIterator __last,
2555 flag_type __f = regex_constants::ECMAScript)
2556 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2558 {__parse(__first, __last);}
2559 #ifndef _LIBCPP_CXX03_LANG
2560 _LIBCPP_INLINE_VISIBILITY
2561 basic_regex(initializer_list<value_type> __il,
2562 flag_type __f = regex_constants::ECMAScript)
2563 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2565 {__parse(__il.begin(), __il.end());}
2566 #endif // _LIBCPP_CXX03_LANG
2568 // ~basic_regex() = default;
2570 // basic_regex& operator=(const basic_regex&) = default;
2571 // basic_regex& operator=(basic_regex&&) = default;
2572 _LIBCPP_INLINE_VISIBILITY
2573 basic_regex& operator=(const value_type* __p)
2574 {return assign(__p);}
2575 #ifndef _LIBCPP_CXX03_LANG
2576 _LIBCPP_INLINE_VISIBILITY
2577 basic_regex& operator=(initializer_list<value_type> __il)
2578 {return assign(__il);}
2579 #endif // _LIBCPP_CXX03_LANG
2580 template <class _ST, class _SA>
2581 _LIBCPP_INLINE_VISIBILITY
2582 basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p)
2583 {return assign(__p);}
2586 _LIBCPP_INLINE_VISIBILITY
2587 basic_regex& assign(const basic_regex& __that)
2588 {return *this = __that;}
2589 #ifndef _LIBCPP_CXX03_LANG
2590 _LIBCPP_INLINE_VISIBILITY
2591 basic_regex& assign(basic_regex&& __that) _NOEXCEPT
2592 {return *this = _VSTD::move(__that);}
2594 _LIBCPP_INLINE_VISIBILITY
2595 basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
2596 {return assign(__p, __p + __traits_.length(__p), __f);}
2597 _LIBCPP_INLINE_VISIBILITY
2598 basic_regex& assign(const value_type* __p, size_t __len, flag_type __f)
2599 {return assign(__p, __p + __len, __f);}
2600 template <class _ST, class _SA>
2601 _LIBCPP_INLINE_VISIBILITY
2602 basic_regex& assign(const basic_string<value_type, _ST, _SA>& __s,
2603 flag_type __f = regex_constants::ECMAScript)
2604 {return assign(__s.begin(), __s.end(), __f);}
2606 template <class _InputIterator>
2607 _LIBCPP_INLINE_VISIBILITY
2610 __is_input_iterator <_InputIterator>::value &&
2611 !__is_forward_iterator<_InputIterator>::value,
2614 assign(_InputIterator __first, _InputIterator __last,
2615 flag_type __f = regex_constants::ECMAScript)
2617 basic_string<_CharT> __t(__first, __last);
2618 return assign(__t.begin(), __t.end(), __f);
2622 _LIBCPP_INLINE_VISIBILITY
2623 void __member_init(flag_type __f)
2626 __marked_count_ = 0;
2633 template <class _ForwardIterator>
2634 _LIBCPP_INLINE_VISIBILITY
2637 __is_forward_iterator<_ForwardIterator>::value,
2640 assign(_ForwardIterator __first, _ForwardIterator __last,
2641 flag_type __f = regex_constants::ECMAScript)
2643 return assign(basic_regex(__first, __last, __f));
2646 #ifndef _LIBCPP_CXX03_LANG
2648 _LIBCPP_INLINE_VISIBILITY
2649 basic_regex& assign(initializer_list<value_type> __il,
2650 flag_type __f = regex_constants::ECMAScript)
2651 {return assign(__il.begin(), __il.end(), __f);}
2653 #endif // _LIBCPP_CXX03_LANG
2655 // const operations:
2656 _LIBCPP_INLINE_VISIBILITY
2657 unsigned mark_count() const {return __marked_count_;}
2658 _LIBCPP_INLINE_VISIBILITY
2659 flag_type flags() const {return __flags_;}
2662 _LIBCPP_INLINE_VISIBILITY
2663 locale_type imbue(locale_type __loc)
2665 __member_init(ECMAScript);
2667 return __traits_.imbue(__loc);
2669 _LIBCPP_INLINE_VISIBILITY
2670 locale_type getloc() const {return __traits_.getloc();}
2673 void swap(basic_regex& __r);
2676 _LIBCPP_INLINE_VISIBILITY
2677 unsigned __loop_count() const {return __loop_count_;}
2679 template <class _ForwardIterator>
2681 __parse(_ForwardIterator __first, _ForwardIterator __last);
2682 template <class _ForwardIterator>
2684 __parse_basic_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
2685 template <class _ForwardIterator>
2687 __parse_RE_expression(_ForwardIterator __first, _ForwardIterator __last);
2688 template <class _ForwardIterator>
2690 __parse_simple_RE(_ForwardIterator __first, _ForwardIterator __last);
2691 template <class _ForwardIterator>
2693 __parse_nondupl_RE(_ForwardIterator __first, _ForwardIterator __last);
2694 template <class _ForwardIterator>
2696 __parse_one_char_or_coll_elem_RE(_ForwardIterator __first, _ForwardIterator __last);
2697 template <class _ForwardIterator>
2699 __parse_Back_open_paren(_ForwardIterator __first, _ForwardIterator __last);
2700 template <class _ForwardIterator>
2702 __parse_Back_close_paren(_ForwardIterator __first, _ForwardIterator __last);
2703 template <class _ForwardIterator>
2705 __parse_Back_open_brace(_ForwardIterator __first, _ForwardIterator __last);
2706 template <class _ForwardIterator>
2708 __parse_Back_close_brace(_ForwardIterator __first, _ForwardIterator __last);
2709 template <class _ForwardIterator>
2711 __parse_BACKREF(_ForwardIterator __first, _ForwardIterator __last);
2712 template <class _ForwardIterator>
2714 __parse_ORD_CHAR(_ForwardIterator __first, _ForwardIterator __last);
2715 template <class _ForwardIterator>
2717 __parse_QUOTED_CHAR(_ForwardIterator __first, _ForwardIterator __last);
2718 template <class _ForwardIterator>
2720 __parse_RE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
2721 __owns_one_state<_CharT>* __s,
2722 unsigned __mexp_begin, unsigned __mexp_end);
2723 template <class _ForwardIterator>
2725 __parse_ERE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
2726 __owns_one_state<_CharT>* __s,
2727 unsigned __mexp_begin, unsigned __mexp_end);
2728 template <class _ForwardIterator>
2730 __parse_bracket_expression(_ForwardIterator __first, _ForwardIterator __last);
2731 template <class _ForwardIterator>
2733 __parse_follow_list(_ForwardIterator __first, _ForwardIterator __last,
2734 __bracket_expression<_CharT, _Traits>* __ml);
2735 template <class _ForwardIterator>
2737 __parse_expression_term(_ForwardIterator __first, _ForwardIterator __last,
2738 __bracket_expression<_CharT, _Traits>* __ml);
2739 template <class _ForwardIterator>
2741 __parse_equivalence_class(_ForwardIterator __first, _ForwardIterator __last,
2742 __bracket_expression<_CharT, _Traits>* __ml);
2743 template <class _ForwardIterator>
2745 __parse_character_class(_ForwardIterator __first, _ForwardIterator __last,
2746 __bracket_expression<_CharT, _Traits>* __ml);
2747 template <class _ForwardIterator>
2749 __parse_collating_symbol(_ForwardIterator __first, _ForwardIterator __last,
2750 basic_string<_CharT>& __col_sym);
2751 template <class _ForwardIterator>
2753 __parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c);
2754 template <class _ForwardIterator>
2756 __parse_extended_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
2757 template <class _ForwardIterator>
2759 __parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last);
2760 template <class _ForwardIterator>
2762 __parse_ERE_expression(_ForwardIterator __first, _ForwardIterator __last);
2763 template <class _ForwardIterator>
2765 __parse_one_char_or_coll_elem_ERE(_ForwardIterator __first, _ForwardIterator __last);
2766 template <class _ForwardIterator>
2768 __parse_ORD_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
2769 template <class _ForwardIterator>
2771 __parse_QUOTED_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
2772 template <class _ForwardIterator>
2774 __parse_ecma_exp(_ForwardIterator __first, _ForwardIterator __last);
2775 template <class _ForwardIterator>
2777 __parse_alternative(_ForwardIterator __first, _ForwardIterator __last);
2778 template <class _ForwardIterator>
2780 __parse_term(_ForwardIterator __first, _ForwardIterator __last);
2781 template <class _ForwardIterator>
2783 __parse_assertion(_ForwardIterator __first, _ForwardIterator __last);
2784 template <class _ForwardIterator>
2786 __parse_atom(_ForwardIterator __first, _ForwardIterator __last);
2787 template <class _ForwardIterator>
2789 __parse_atom_escape(_ForwardIterator __first, _ForwardIterator __last);
2790 template <class _ForwardIterator>
2792 __parse_decimal_escape(_ForwardIterator __first, _ForwardIterator __last);
2793 template <class _ForwardIterator>
2795 __parse_character_class_escape(_ForwardIterator __first, _ForwardIterator __last);
2796 template <class _ForwardIterator>
2798 __parse_character_escape(_ForwardIterator __first, _ForwardIterator __last,
2799 basic_string<_CharT>* __str = nullptr);
2800 template <class _ForwardIterator>
2802 __parse_pattern_character(_ForwardIterator __first, _ForwardIterator __last);
2803 template <class _ForwardIterator>
2805 __parse_grep(_ForwardIterator __first, _ForwardIterator __last);
2806 template <class _ForwardIterator>
2808 __parse_egrep(_ForwardIterator __first, _ForwardIterator __last);
2809 template <class _ForwardIterator>
2811 __parse_class_escape(_ForwardIterator __first, _ForwardIterator __last,
2812 basic_string<_CharT>& __str,
2813 __bracket_expression<_CharT, _Traits>* __ml);
2814 template <class _ForwardIterator>
2816 __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last,
2817 basic_string<_CharT>* __str = nullptr);
2819 _LIBCPP_INLINE_VISIBILITY
2820 void __push_l_anchor();
2821 void __push_r_anchor();
2822 void __push_match_any();
2823 void __push_match_any_but_newline();
2824 _LIBCPP_INLINE_VISIBILITY
2825 void __push_greedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
2826 unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
2827 {__push_loop(__min, numeric_limits<size_t>::max(), __s,
2828 __mexp_begin, __mexp_end);}
2829 _LIBCPP_INLINE_VISIBILITY
2830 void __push_nongreedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
2831 unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
2832 {__push_loop(__min, numeric_limits<size_t>::max(), __s,
2833 __mexp_begin, __mexp_end, false);}
2834 void __push_loop(size_t __min, size_t __max, __owns_one_state<_CharT>* __s,
2835 size_t __mexp_begin = 0, size_t __mexp_end = 0,
2836 bool __greedy = true);
2837 __bracket_expression<_CharT, _Traits>* __start_matching_list(bool __negate);
2838 void __push_char(value_type __c);
2839 void __push_back_ref(int __i);
2840 void __push_alternation(__owns_one_state<_CharT>* __sa,
2841 __owns_one_state<_CharT>* __sb);
2842 void __push_begin_marked_subexpression();
2843 void __push_end_marked_subexpression(unsigned);
2844 void __push_empty();
2845 void __push_word_boundary(bool);
2846 void __push_lookahead(const basic_regex&, bool, unsigned);
2848 template <class _Allocator>
2850 __search(const _CharT* __first, const _CharT* __last,
2851 match_results<const _CharT*, _Allocator>& __m,
2852 regex_constants::match_flag_type __flags) const;
2854 template <class _Allocator>
2856 __match_at_start(const _CharT* __first, const _CharT* __last,
2857 match_results<const _CharT*, _Allocator>& __m,
2858 regex_constants::match_flag_type __flags, bool) const;
2859 template <class _Allocator>
2861 __match_at_start_ecma(const _CharT* __first, const _CharT* __last,
2862 match_results<const _CharT*, _Allocator>& __m,
2863 regex_constants::match_flag_type __flags, bool) const;
2864 template <class _Allocator>
2866 __match_at_start_posix_nosubs(const _CharT* __first, const _CharT* __last,
2867 match_results<const _CharT*, _Allocator>& __m,
2868 regex_constants::match_flag_type __flags, bool) const;
2869 template <class _Allocator>
2871 __match_at_start_posix_subs(const _CharT* __first, const _CharT* __last,
2872 match_results<const _CharT*, _Allocator>& __m,
2873 regex_constants::match_flag_type __flags, bool) const;
2875 template <class _Bp, class _Ap, class _Cp, class _Tp>
2878 regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
2879 regex_constants::match_flag_type);
2881 template <class _Ap, class _Cp, class _Tp>
2884 regex_search(const _Cp*, const _Cp*, match_results<const _Cp*, _Ap>&,
2885 const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
2887 template <class _Bp, class _Cp, class _Tp>
2890 regex_search(_Bp, _Bp, const basic_regex<_Cp, _Tp>&,
2891 regex_constants::match_flag_type);
2893 template <class _Cp, class _Tp>
2896 regex_search(const _Cp*, const _Cp*,
2897 const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
2899 template <class _Cp, class _Ap, class _Tp>
2902 regex_search(const _Cp*, match_results<const _Cp*, _Ap>&, const basic_regex<_Cp, _Tp>&,
2903 regex_constants::match_flag_type);
2905 template <class _ST, class _SA, class _Cp, class _Tp>
2908 regex_search(const basic_string<_Cp, _ST, _SA>& __s,
2909 const basic_regex<_Cp, _Tp>& __e,
2910 regex_constants::match_flag_type __flags);
2912 template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
2915 regex_search(const basic_string<_Cp, _ST, _SA>& __s,
2916 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
2917 const basic_regex<_Cp, _Tp>& __e,
2918 regex_constants::match_flag_type __flags);
2920 template <class _Iter, class _Ap, class _Cp, class _Tp>
2923 regex_search(__wrap_iter<_Iter> __first,
2924 __wrap_iter<_Iter> __last,
2925 match_results<__wrap_iter<_Iter>, _Ap>& __m,
2926 const basic_regex<_Cp, _Tp>& __e,
2927 regex_constants::match_flag_type __flags);
2929 template <class, class> friend class __lookahead;
2932 #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
2933 template <class _ForwardIterator,
2934 class = typename enable_if<__is_forward_iterator<_ForwardIterator>::value, nullptr_t>::type
2936 basic_regex(_ForwardIterator, _ForwardIterator,
2937 regex_constants::syntax_option_type = regex_constants::ECMAScript)
2938 -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>;
2941 template <class _CharT, class _Traits>
2942 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;
2943 template <class _CharT, class _Traits>
2944 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::nosubs;
2945 template <class _CharT, class _Traits>
2946 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::optimize;
2947 template <class _CharT, class _Traits>
2948 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::collate;
2949 template <class _CharT, class _Traits>
2950 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::ECMAScript;
2951 template <class _CharT, class _Traits>
2952 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::basic;
2953 template <class _CharT, class _Traits>
2954 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::extended;
2955 template <class _CharT, class _Traits>
2956 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::awk;
2957 template <class _CharT, class _Traits>
2958 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::grep;
2959 template <class _CharT, class _Traits>
2960 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::egrep;
2962 template <class _CharT, class _Traits>
2964 basic_regex<_CharT, _Traits>::swap(basic_regex& __r)
2967 swap(__traits_, __r.__traits_);
2968 swap(__flags_, __r.__flags_);
2969 swap(__marked_count_, __r.__marked_count_);
2970 swap(__loop_count_, __r.__loop_count_);
2971 swap(__open_count_, __r.__open_count_);
2972 swap(__start_, __r.__start_);
2973 swap(__end_, __r.__end_);
2976 template <class _CharT, class _Traits>
2977 inline _LIBCPP_INLINE_VISIBILITY
2979 swap(basic_regex<_CharT, _Traits>& __x, basic_regex<_CharT, _Traits>& __y)
2981 return __x.swap(__y);
2986 template <class _CharT, class _Traits>
2988 : public __owns_one_state<_CharT>
2990 typedef __owns_one_state<_CharT> base;
2992 basic_regex<_CharT, _Traits> __exp_;
2996 __lookahead(const __lookahead&);
2997 __lookahead& operator=(const __lookahead&);
2999 typedef _VSTD::__state<_CharT> __state;
3001 _LIBCPP_INLINE_VISIBILITY
3002 __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp)
3003 : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {}
3005 virtual void __exec(__state&) const;
3008 template <class _CharT, class _Traits>
3010 __lookahead<_CharT, _Traits>::__exec(__state& __s) const
3012 match_results<const _CharT*> __m;
3013 __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
3014 bool __matched = __exp_.__match_at_start_ecma(
3015 __s.__current_, __s.__last_,
3017 (__s.__flags_ | regex_constants::match_continuous) &
3018 ~regex_constants::__full_match,
3019 __s.__at_first_ && __s.__current_ == __s.__first_);
3020 if (__matched != __invert_)
3022 __s.__do_ = __state::__accept_but_not_consume;
3023 __s.__node_ = this->first();
3024 for (unsigned __i = 1; __i < __m.size(); ++__i) {
3025 __s.__sub_matches_[__mexp_ + __i - 1] = __m.__matches_[__i];
3030 __s.__do_ = __state::__reject;
3031 __s.__node_ = nullptr;
3035 template <class _CharT, class _Traits>
3036 template <class _ForwardIterator>
3038 basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
3039 _ForwardIterator __last)
3042 unique_ptr<__node> __h(new __end_state<_CharT>);
3043 __start_.reset(new __empty_state<_CharT>(__h.get()));
3045 __end_ = __start_.get();
3047 switch (__flags_ & 0x1F0)
3050 __first = __parse_ecma_exp(__first, __last);
3053 __first = __parse_basic_reg_exp(__first, __last);
3057 __first = __parse_extended_reg_exp(__first, __last);
3060 __first = __parse_grep(__first, __last);
3063 __first = __parse_egrep(__first, __last);
3066 __throw_regex_error<regex_constants::__re_err_grammar>();
3071 template <class _CharT, class _Traits>
3072 template <class _ForwardIterator>
3074 basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first,
3075 _ForwardIterator __last)
3077 if (__first != __last)
3079 if (*__first == '^')
3084 if (__first != __last)
3086 __first = __parse_RE_expression(__first, __last);
3087 if (__first != __last)
3089 _ForwardIterator __temp = _VSTD::next(__first);
3090 if (__temp == __last && *__first == '$')
3097 if (__first != __last)
3098 __throw_regex_error<regex_constants::__re_err_empty>();
3103 template <class _CharT, class _Traits>
3104 template <class _ForwardIterator>
3106 basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
3107 _ForwardIterator __last)
3109 __owns_one_state<_CharT>* __sa = __end_;
3110 _ForwardIterator __temp = __parse_ERE_branch(__first, __last);
3111 if (__temp == __first)
3112 __throw_regex_error<regex_constants::__re_err_empty>();
3114 while (__first != __last && *__first == '|')
3116 __owns_one_state<_CharT>* __sb = __end_;
3117 __temp = __parse_ERE_branch(++__first, __last);
3118 if (__temp == __first)
3119 __throw_regex_error<regex_constants::__re_err_empty>();
3120 __push_alternation(__sa, __sb);
3126 template <class _CharT, class _Traits>
3127 template <class _ForwardIterator>
3129 basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first,
3130 _ForwardIterator __last)
3132 _ForwardIterator __temp = __parse_ERE_expression(__first, __last);
3133 if (__temp == __first)
3134 __throw_regex_error<regex_constants::__re_err_empty>();
3138 __temp = __parse_ERE_expression(__first, __last);
3139 } while (__temp != __first);
3143 template <class _CharT, class _Traits>
3144 template <class _ForwardIterator>
3146 basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first,
3147 _ForwardIterator __last)
3149 __owns_one_state<_CharT>* __e = __end_;
3150 unsigned __mexp_begin = __marked_count_;
3151 _ForwardIterator __temp = __parse_one_char_or_coll_elem_ERE(__first, __last);
3152 if (__temp == __first && __temp != __last)
3165 __push_begin_marked_subexpression();
3166 unsigned __temp_count = __marked_count_;
3168 __temp = __parse_extended_reg_exp(++__temp, __last);
3169 if (__temp == __last || *__temp != ')')
3170 __throw_regex_error<regex_constants::error_paren>();
3171 __push_end_marked_subexpression(__temp_count);
3177 if (__temp != __first)
3178 __temp = __parse_ERE_dupl_symbol(__temp, __last, __e, __mexp_begin+1,
3184 template <class _CharT, class _Traits>
3185 template <class _ForwardIterator>
3187 basic_regex<_CharT, _Traits>::__parse_RE_expression(_ForwardIterator __first,
3188 _ForwardIterator __last)
3192 _ForwardIterator __temp = __parse_simple_RE(__first, __last);
3193 if (__temp == __first)
3200 template <class _CharT, class _Traits>
3201 template <class _ForwardIterator>
3203 basic_regex<_CharT, _Traits>::__parse_simple_RE(_ForwardIterator __first,
3204 _ForwardIterator __last)
3206 if (__first != __last)
3208 __owns_one_state<_CharT>* __e = __end_;
3209 unsigned __mexp_begin = __marked_count_;
3210 _ForwardIterator __temp = __parse_nondupl_RE(__first, __last);
3211 if (__temp != __first)
3212 __first = __parse_RE_dupl_symbol(__temp, __last, __e,
3213 __mexp_begin+1, __marked_count_+1);
3218 template <class _CharT, class _Traits>
3219 template <class _ForwardIterator>
3221 basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first,
3222 _ForwardIterator __last)
3224 _ForwardIterator __temp = __first;
3225 __first = __parse_one_char_or_coll_elem_RE(__first, __last);
3226 if (__temp == __first)
3228 __temp = __parse_Back_open_paren(__first, __last);
3229 if (__temp != __first)
3231 __push_begin_marked_subexpression();
3232 unsigned __temp_count = __marked_count_;
3233 __first = __parse_RE_expression(__temp, __last);
3234 __temp = __parse_Back_close_paren(__first, __last);
3235 if (__temp == __first)
3236 __throw_regex_error<regex_constants::error_paren>();
3237 __push_end_marked_subexpression(__temp_count);
3241 __first = __parse_BACKREF(__first, __last);
3246 template <class _CharT, class _Traits>
3247 template <class _ForwardIterator>
3249 basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_RE(
3250 _ForwardIterator __first,
3251 _ForwardIterator __last)
3253 _ForwardIterator __temp = __parse_ORD_CHAR(__first, __last);
3254 if (__temp == __first)
3256 __temp = __parse_QUOTED_CHAR(__first, __last);
3257 if (__temp == __first)
3259 if (__temp != __last && *__temp == '.')
3265 __temp = __parse_bracket_expression(__first, __last);
3272 template <class _CharT, class _Traits>
3273 template <class _ForwardIterator>
3275 basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_ERE(
3276 _ForwardIterator __first,
3277 _ForwardIterator __last)
3279 _ForwardIterator __temp = __parse_ORD_CHAR_ERE(__first, __last);
3280 if (__temp == __first)
3282 __temp = __parse_QUOTED_CHAR_ERE(__first, __last);
3283 if (__temp == __first)
3285 if (__temp != __last && *__temp == '.')
3291 __temp = __parse_bracket_expression(__first, __last);
3298 template <class _CharT, class _Traits>
3299 template <class _ForwardIterator>
3301 basic_regex<_CharT, _Traits>::__parse_Back_open_paren(_ForwardIterator __first,
3302 _ForwardIterator __last)
3304 if (__first != __last)
3306 _ForwardIterator __temp = _VSTD::next(__first);
3307 if (__temp != __last)
3309 if (*__first == '\\' && *__temp == '(')
3316 template <class _CharT, class _Traits>
3317 template <class _ForwardIterator>
3319 basic_regex<_CharT, _Traits>::__parse_Back_close_paren(_ForwardIterator __first,
3320 _ForwardIterator __last)
3322 if (__first != __last)
3324 _ForwardIterator __temp = _VSTD::next(__first);
3325 if (__temp != __last)
3327 if (*__first == '\\' && *__temp == ')')
3334 template <class _CharT, class _Traits>
3335 template <class _ForwardIterator>
3337 basic_regex<_CharT, _Traits>::__parse_Back_open_brace(_ForwardIterator __first,
3338 _ForwardIterator __last)
3340 if (__first != __last)
3342 _ForwardIterator __temp = _VSTD::next(__first);
3343 if (__temp != __last)
3345 if (*__first == '\\' && *__temp == '{')
3352 template <class _CharT, class _Traits>
3353 template <class _ForwardIterator>
3355 basic_regex<_CharT, _Traits>::__parse_Back_close_brace(_ForwardIterator __first,
3356 _ForwardIterator __last)
3358 if (__first != __last)
3360 _ForwardIterator __temp = _VSTD::next(__first);
3361 if (__temp != __last)
3363 if (*__first == '\\' && *__temp == '}')
3370 template <class _CharT, class _Traits>
3371 template <class _ForwardIterator>
3373 basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first,
3374 _ForwardIterator __last)
3376 if (__first != __last)
3378 _ForwardIterator __temp = _VSTD::next(__first);
3379 if (__temp != __last)
3381 if (*__first == '\\')
3383 int __val = __traits_.value(*__temp, 10);
3384 if (__val >= 1 && __val <= 9)
3386 __push_back_ref(__val);
3395 template <class _CharT, class _Traits>
3396 template <class _ForwardIterator>
3398 basic_regex<_CharT, _Traits>::__parse_ORD_CHAR(_ForwardIterator __first,
3399 _ForwardIterator __last)
3401 if (__first != __last)
3403 _ForwardIterator __temp = _VSTD::next(__first);
3404 if (__temp == __last && *__first == '$')
3406 // Not called inside a bracket
3407 if (*__first == '.' || *__first == '\\' || *__first == '[')
3409 __push_char(*__first);
3415 template <class _CharT, class _Traits>
3416 template <class _ForwardIterator>
3418 basic_regex<_CharT, _Traits>::__parse_ORD_CHAR_ERE(_ForwardIterator __first,
3419 _ForwardIterator __last)
3421 if (__first != __last)
3438 if (__open_count_ == 0)
3440 __push_char(*__first);
3445 __push_char(*__first);
3453 template <class _CharT, class _Traits>
3454 template <class _ForwardIterator>
3456 basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR(_ForwardIterator __first,
3457 _ForwardIterator __last)
3459 if (__first != __last)
3461 _ForwardIterator __temp = _VSTD::next(__first);
3462 if (__temp != __last)
3464 if (*__first == '\\')
3474 __push_char(*__temp);
3484 template <class _CharT, class _Traits>
3485 template <class _ForwardIterator>
3487 basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first,
3488 _ForwardIterator __last)
3490 if (__first != __last)
3492 _ForwardIterator __temp = _VSTD::next(__first);
3493 if (__temp != __last)
3495 if (*__first == '\\')
3512 __push_char(*__temp);
3516 if ((__flags_ & 0x1F0) == awk)
3517 __first = __parse_awk_escape(++__first, __last);
3526 template <class _CharT, class _Traits>
3527 template <class _ForwardIterator>
3529 basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
3530 _ForwardIterator __last,
3531 __owns_one_state<_CharT>* __s,
3532 unsigned __mexp_begin,
3533 unsigned __mexp_end)
3535 if (__first != __last)
3537 if (*__first == '*')
3539 __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3544 _ForwardIterator __temp = __parse_Back_open_brace(__first, __last);
3545 if (__temp != __first)
3549 __temp = __parse_DUP_COUNT(__first, __last, __min);
3550 if (__temp == __first)
3551 __throw_regex_error<regex_constants::error_badbrace>();
3553 if (__first == __last)
3554 __throw_regex_error<regex_constants::error_brace>();
3555 if (*__first != ',')
3557 __temp = __parse_Back_close_brace(__first, __last);
3558 if (__temp == __first)
3559 __throw_regex_error<regex_constants::error_brace>();
3560 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end,
3566 ++__first; // consume ','
3568 __first = __parse_DUP_COUNT(__first, __last, __max);
3569 __temp = __parse_Back_close_brace(__first, __last);
3570 if (__temp == __first)
3571 __throw_regex_error<regex_constants::error_brace>();
3573 __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3577 __throw_regex_error<regex_constants::error_badbrace>();
3578 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end,
3589 template <class _CharT, class _Traits>
3590 template <class _ForwardIterator>
3592 basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
3593 _ForwardIterator __last,
3594 __owns_one_state<_CharT>* __s,
3595 unsigned __mexp_begin,
3596 unsigned __mexp_end)
3598 if (__first != __last)
3600 unsigned __grammar = __flags_ & 0x1F0;
3605 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3608 __push_nongreedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3611 __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3615 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3618 __push_nongreedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
3621 __push_greedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
3625 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3628 __push_loop(0, 1, __s, __mexp_begin, __mexp_end, false);
3631 __push_loop(0, 1, __s, __mexp_begin, __mexp_end);
3636 _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);
3637 if (__temp == __first)
3638 __throw_regex_error<regex_constants::error_badbrace>();
3640 if (__first == __last)
3641 __throw_regex_error<regex_constants::error_brace>();
3646 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3649 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, false);
3652 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end);
3656 if (__first == __last)
3657 __throw_regex_error<regex_constants::error_badbrace>();
3658 if (*__first == '}')
3661 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3664 __push_nongreedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3667 __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3672 __temp = __parse_DUP_COUNT(__first, __last, __max);
3673 if (__temp == __first)
3674 __throw_regex_error<regex_constants::error_brace>();
3676 if (__first == __last || *__first != '}')
3677 __throw_regex_error<regex_constants::error_brace>();
3680 __throw_regex_error<regex_constants::error_badbrace>();
3681 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3684 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false);
3687 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end);
3691 __throw_regex_error<regex_constants::error_badbrace>();
3700 template <class _CharT, class _Traits>
3701 template <class _ForwardIterator>
3703 basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __first,
3704 _ForwardIterator __last)
3706 if (__first != __last && *__first == '[')
3709 if (__first == __last)
3710 __throw_regex_error<regex_constants::error_brack>();
3711 bool __negate = false;
3712 if (*__first == '^')
3717 __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);
3718 // __ml owned by *this
3719 if (__first == __last)
3720 __throw_regex_error<regex_constants::error_brack>();
3721 if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']')
3723 __ml->__add_char(']');
3726 __first = __parse_follow_list(__first, __last, __ml);
3727 if (__first == __last)
3728 __throw_regex_error<regex_constants::error_brack>();
3729 if (*__first == '-')
3731 __ml->__add_char('-');
3734 if (__first == __last || *__first != ']')
3735 __throw_regex_error<regex_constants::error_brack>();
3741 template <class _CharT, class _Traits>
3742 template <class _ForwardIterator>
3744 basic_regex<_CharT, _Traits>::__parse_follow_list(_ForwardIterator __first,
3745 _ForwardIterator __last,
3746 __bracket_expression<_CharT, _Traits>* __ml)
3748 if (__first != __last)
3752 _ForwardIterator __temp = __parse_expression_term(__first, __last,
3754 if (__temp == __first)
3762 template <class _CharT, class _Traits>
3763 template <class _ForwardIterator>
3765 basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first,
3766 _ForwardIterator __last,
3767 __bracket_expression<_CharT, _Traits>* __ml)
3769 if (__first != __last && *__first != ']')
3771 _ForwardIterator __temp = _VSTD::next(__first);
3772 basic_string<_CharT> __start_range;
3773 if (__temp != __last && *__first == '[')
3776 return __parse_equivalence_class(++__temp, __last, __ml);
3777 else if (*__temp == ':')
3778 return __parse_character_class(++__temp, __last, __ml);
3779 else if (*__temp == '.')
3780 __first = __parse_collating_symbol(++__temp, __last, __start_range);
3782 unsigned __grammar = __flags_ & 0x1F0;
3783 if (__start_range.empty())
3785 if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
3787 if (__grammar == ECMAScript)
3788 __first = __parse_class_escape(++__first, __last, __start_range, __ml);
3790 __first = __parse_awk_escape(++__first, __last, &__start_range);
3794 __start_range = *__first;
3798 if (__first != __last && *__first != ']')
3800 __temp = _VSTD::next(__first);
3801 if (__temp != __last && *__first == '-' && *__temp != ']')
3804 basic_string<_CharT> __end_range;
3807 if (__temp != __last && *__first == '[' && *__temp == '.')
3808 __first = __parse_collating_symbol(++__temp, __last, __end_range);
3811 if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
3813 if (__grammar == ECMAScript)
3814 __first = __parse_class_escape(++__first, __last,
3817 __first = __parse_awk_escape(++__first, __last,
3822 __end_range = *__first;
3826 __ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range));
3828 else if (!__start_range.empty())
3830 if (__start_range.size() == 1)
3831 __ml->__add_char(__start_range[0]);
3833 __ml->__add_digraph(__start_range[0], __start_range[1]);
3836 else if (!__start_range.empty())
3838 if (__start_range.size() == 1)
3839 __ml->__add_char(__start_range[0]);
3841 __ml->__add_digraph(__start_range[0], __start_range[1]);
3847 template <class _CharT, class _Traits>
3848 template <class _ForwardIterator>
3850 basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first,
3851 _ForwardIterator __last,
3852 basic_string<_CharT>& __str,
3853 __bracket_expression<_CharT, _Traits>* __ml)
3855 if (__first == __last)
3856 __throw_regex_error<regex_constants::error_escape>();
3866 __ml->__add_class(ctype_base::digit);
3869 __ml->__add_neg_class(ctype_base::digit);
3872 __ml->__add_class(ctype_base::space);
3875 __ml->__add_neg_class(ctype_base::space);
3878 __ml->__add_class(ctype_base::alnum);
3879 __ml->__add_char('_');
3882 __ml->__add_neg_class(ctype_base::alnum);
3883 __ml->__add_neg_char('_');
3886 __first = __parse_character_escape(__first, __last, &__str);
3890 template <class _CharT, class _Traits>
3891 template <class _ForwardIterator>
3893 basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
3894 _ForwardIterator __last,
3895 basic_string<_CharT>* __str)
3897 if (__first == __last)
3898 __throw_regex_error<regex_constants::error_escape>();
3907 __push_char(*__first);
3913 __push_char(_CharT(7));
3919 __push_char(_CharT(8));
3923 *__str = _CharT(0xC);
3925 __push_char(_CharT(0xC));
3929 *__str = _CharT(0xA);
3931 __push_char(_CharT(0xA));
3935 *__str = _CharT(0xD);
3937 __push_char(_CharT(0xD));
3941 *__str = _CharT(0x9);
3943 __push_char(_CharT(0x9));
3947 *__str = _CharT(0xB);
3949 __push_char(_CharT(0xB));
3952 if ('0' <= *__first && *__first <= '7')
3954 unsigned __val = *__first - '0';
3955 if (++__first != __last && ('0' <= *__first && *__first <= '7'))
3957 __val = 8 * __val + *__first - '0';
3958 if (++__first != __last && ('0' <= *__first && *__first <= '7'))
3959 __val = 8 * __val + *__first++ - '0';
3962 *__str = _CharT(__val);
3964 __push_char(_CharT(__val));
3967 __throw_regex_error<regex_constants::error_escape>();
3971 template <class _CharT, class _Traits>
3972 template <class _ForwardIterator>
3974 basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first,
3975 _ForwardIterator __last,
3976 __bracket_expression<_CharT, _Traits>* __ml)
3979 // This means =] must exist
3980 value_type _Equal_close[2] = {'=', ']'};
3981 _ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close,
3983 if (__temp == __last)
3984 __throw_regex_error<regex_constants::error_brack>();
3985 // [__first, __temp) contains all text in [= ... =]
3986 string_type __collate_name =
3987 __traits_.lookup_collatename(__first, __temp);
3988 if (__collate_name.empty())
3989 __throw_regex_error<regex_constants::error_collate>();
3990 string_type __equiv_name =
3991 __traits_.transform_primary(__collate_name.begin(),
3992 __collate_name.end());
3993 if (!__equiv_name.empty())
3994 __ml->__add_equivalence(__equiv_name);
3997 switch (__collate_name.size())
4000 __ml->__add_char(__collate_name[0]);
4003 __ml->__add_digraph(__collate_name[0], __collate_name[1]);
4006 __throw_regex_error<regex_constants::error_collate>();
4009 __first = _VSTD::next(__temp, 2);
4013 template <class _CharT, class _Traits>
4014 template <class _ForwardIterator>
4016 basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
4017 _ForwardIterator __last,
4018 __bracket_expression<_CharT, _Traits>* __ml)
4021 // This means :] must exist
4022 value_type _Colon_close[2] = {':', ']'};
4023 _ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close,
4025 if (__temp == __last)
4026 __throw_regex_error<regex_constants::error_brack>();
4027 // [__first, __temp) contains all text in [: ... :]
4028 typedef typename _Traits::char_class_type char_class_type;
4029 char_class_type __class_type =
4030 __traits_.lookup_classname(__first, __temp, __flags_ & icase);
4031 if (__class_type == 0)
4032 __throw_regex_error<regex_constants::error_ctype>();
4033 __ml->__add_class(__class_type);
4034 __first = _VSTD::next(__temp, 2);
4038 template <class _CharT, class _Traits>
4039 template <class _ForwardIterator>
4041 basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
4042 _ForwardIterator __last,
4043 basic_string<_CharT>& __col_sym)
4046 // This means .] must exist
4047 value_type _Dot_close[2] = {'.', ']'};
4048 _ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close,
4050 if (__temp == __last)
4051 __throw_regex_error<regex_constants::error_brack>();
4052 // [__first, __temp) contains all text in [. ... .]
4053 __col_sym = __traits_.lookup_collatename(__first, __temp);
4054 switch (__col_sym.size())
4060 __throw_regex_error<regex_constants::error_collate>();
4062 __first = _VSTD::next(__temp, 2);
4066 template <class _CharT, class _Traits>
4067 template <class _ForwardIterator>
4069 basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
4070 _ForwardIterator __last,
4073 if (__first != __last )
4075 int __val = __traits_.value(*__first, 10);
4080 __first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
4083 if (__c >= std::numeric_limits<int>::max() / 10)
4084 __throw_regex_error<regex_constants::error_badbrace>();
4093 template <class _CharT, class _Traits>
4094 template <class _ForwardIterator>
4096 basic_regex<_CharT, _Traits>::__parse_ecma_exp(_ForwardIterator __first,
4097 _ForwardIterator __last)
4099 __owns_one_state<_CharT>* __sa = __end_;
4100 _ForwardIterator __temp = __parse_alternative(__first, __last);
4101 if (__temp == __first)
4104 while (__first != __last && *__first == '|')
4106 __owns_one_state<_CharT>* __sb = __end_;
4107 __temp = __parse_alternative(++__first, __last);
4108 if (__temp == __first)
4110 __push_alternation(__sa, __sb);
4116 template <class _CharT, class _Traits>
4117 template <class _ForwardIterator>
4119 basic_regex<_CharT, _Traits>::__parse_alternative(_ForwardIterator __first,
4120 _ForwardIterator __last)
4124 _ForwardIterator __temp = __parse_term(__first, __last);
4125 if (__temp == __first)
4132 template <class _CharT, class _Traits>
4133 template <class _ForwardIterator>
4135 basic_regex<_CharT, _Traits>::__parse_term(_ForwardIterator __first,
4136 _ForwardIterator __last)
4138 _ForwardIterator __temp = __parse_assertion(__first, __last);
4139 if (__temp == __first)
4141 __owns_one_state<_CharT>* __e = __end_;
4142 unsigned __mexp_begin = __marked_count_;
4143 __temp = __parse_atom(__first, __last);
4144 if (__temp != __first)
4145 __first = __parse_ERE_dupl_symbol(__temp, __last, __e,
4146 __mexp_begin+1, __marked_count_+1);
4153 template <class _CharT, class _Traits>
4154 template <class _ForwardIterator>
4156 basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
4157 _ForwardIterator __last)
4159 if (__first != __last)
4173 _ForwardIterator __temp = _VSTD::next(__first);
4174 if (__temp != __last)
4178 __push_word_boundary(false);
4181 else if (*__temp == 'B')
4183 __push_word_boundary(true);
4191 _ForwardIterator __temp = _VSTD::next(__first);
4192 if (__temp != __last && *__temp == '?')
4194 if (++__temp != __last)
4201 __exp.__flags_ = __flags_;
4202 __temp = __exp.__parse(++__temp, __last);
4203 unsigned __mexp = __exp.__marked_count_;
4204 __push_lookahead(_VSTD::move(__exp), false, __marked_count_);
4205 __marked_count_ += __mexp;
4206 if (__temp == __last || *__temp != ')')
4207 __throw_regex_error<regex_constants::error_paren>();
4214 __exp.__flags_ = __flags_;
4215 __temp = __exp.__parse(++__temp, __last);
4216 unsigned __mexp = __exp.__marked_count_;
4217 __push_lookahead(_VSTD::move(__exp), true, __marked_count_);
4218 __marked_count_ += __mexp;
4219 if (__temp == __last || *__temp != ')')
4220 __throw_regex_error<regex_constants::error_paren>();
4234 template <class _CharT, class _Traits>
4235 template <class _ForwardIterator>
4237 basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
4238 _ForwardIterator __last)
4240 if (__first != __last)
4245 __push_match_any_but_newline();
4249 __first = __parse_atom_escape(__first, __last);
4252 __first = __parse_bracket_expression(__first, __last);
4257 if (__first == __last)
4258 __throw_regex_error<regex_constants::error_paren>();
4259 _ForwardIterator __temp = _VSTD::next(__first);
4260 if (__temp != __last && *__first == '?' && *__temp == ':')
4263 __first = __parse_ecma_exp(++__temp, __last);
4264 if (__first == __last || *__first != ')')
4265 __throw_regex_error<regex_constants::error_paren>();
4271 __push_begin_marked_subexpression();
4272 unsigned __temp_count = __marked_count_;
4274 __first = __parse_ecma_exp(__first, __last);
4275 if (__first == __last || *__first != ')')
4276 __throw_regex_error<regex_constants::error_paren>();
4277 __push_end_marked_subexpression(__temp_count);
4287 __throw_regex_error<regex_constants::error_badrepeat>();
4290 __first = __parse_pattern_character(__first, __last);
4297 template <class _CharT, class _Traits>
4298 template <class _ForwardIterator>
4300 basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first,
4301 _ForwardIterator __last)
4303 if (__first != __last && *__first == '\\')
4305 _ForwardIterator __t1 = _VSTD::next(__first);
4307 __throw_regex_error<regex_constants::error_escape>();
4309 _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
4314 __t2 = __parse_character_class_escape(__t1, __last);
4319 __t2 = __parse_character_escape(__t1, __last);
4328 template <class _CharT, class _Traits>
4329 template <class _ForwardIterator>
4331 basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
4332 _ForwardIterator __last)
4334 if (__first != __last)
4336 if (*__first == '0')
4338 __push_char(_CharT());
4341 else if ('1' <= *__first && *__first <= '9')
4343 unsigned __v = *__first - '0';
4345 __first != __last && '0' <= *__first && *__first <= '9'; ++__first)
4347 if (__v >= std::numeric_limits<unsigned>::max() / 10)
4348 __throw_regex_error<regex_constants::error_backref>();
4349 __v = 10 * __v + *__first - '0';
4351 if (__v == 0 || __v > mark_count())
4352 __throw_regex_error<regex_constants::error_backref>();
4353 __push_back_ref(__v);
4359 template <class _CharT, class _Traits>
4360 template <class _ForwardIterator>
4362 basic_regex<_CharT, _Traits>::__parse_character_class_escape(_ForwardIterator __first,
4363 _ForwardIterator __last)
4365 if (__first != __last)
4367 __bracket_expression<_CharT, _Traits>* __ml;
4371 __ml = __start_matching_list(false);
4372 __ml->__add_class(ctype_base::digit);
4376 __ml = __start_matching_list(true);
4377 __ml->__add_class(ctype_base::digit);
4381 __ml = __start_matching_list(false);
4382 __ml->__add_class(ctype_base::space);
4386 __ml = __start_matching_list(true);
4387 __ml->__add_class(ctype_base::space);
4391 __ml = __start_matching_list(false);
4392 __ml->__add_class(ctype_base::alnum);
4393 __ml->__add_char('_');
4397 __ml = __start_matching_list(true);
4398 __ml->__add_class(ctype_base::alnum);
4399 __ml->__add_char('_');
4407 template <class _CharT, class _Traits>
4408 template <class _ForwardIterator>
4410 basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
4411 _ForwardIterator __last,
4412 basic_string<_CharT>* __str)
4414 if (__first != __last)
4416 _ForwardIterator __t;
4423 *__str = _CharT(0xC);
4425 __push_char(_CharT(0xC));
4430 *__str = _CharT(0xA);
4432 __push_char(_CharT(0xA));
4437 *__str = _CharT(0xD);
4439 __push_char(_CharT(0xD));
4444 *__str = _CharT(0x9);
4446 __push_char(_CharT(0x9));
4451 *__str = _CharT(0xB);
4453 __push_char(_CharT(0xB));
4457 if ((__t = _VSTD::next(__first)) != __last)
4459 if (('A' <= *__t && *__t <= 'Z') ||
4460 ('a' <= *__t && *__t <= 'z'))
4463 *__str = _CharT(*__t % 32);
4465 __push_char(_CharT(*__t % 32));
4469 __throw_regex_error<regex_constants::error_escape>();
4472 __throw_regex_error<regex_constants::error_escape>();
4476 if (__first == __last)
4477 __throw_regex_error<regex_constants::error_escape>();
4478 __hd = __traits_.value(*__first, 16);
4480 __throw_regex_error<regex_constants::error_escape>();
4481 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4483 if (__first == __last)
4484 __throw_regex_error<regex_constants::error_escape>();
4485 __hd = __traits_.value(*__first, 16);
4487 __throw_regex_error<regex_constants::error_escape>();
4488 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4492 if (__first == __last)
4493 __throw_regex_error<regex_constants::error_escape>();
4494 __hd = __traits_.value(*__first, 16);
4496 __throw_regex_error<regex_constants::error_escape>();
4497 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4499 if (__first == __last)
4500 __throw_regex_error<regex_constants::error_escape>();
4501 __hd = __traits_.value(*__first, 16);
4503 __throw_regex_error<regex_constants::error_escape>();
4504 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4506 *__str = _CharT(__sum);
4508 __push_char(_CharT(__sum));
4515 __push_char(_CharT(0));
4519 if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum))
4524 __push_char(*__first);
4528 __throw_regex_error<regex_constants::error_escape>();
4535 template <class _CharT, class _Traits>
4536 template <class _ForwardIterator>
4538 basic_regex<_CharT, _Traits>::__parse_pattern_character(_ForwardIterator __first,
4539 _ForwardIterator __last)
4541 if (__first != __last)
4561 __push_char(*__first);
4569 template <class _CharT, class _Traits>
4570 template <class _ForwardIterator>
4572 basic_regex<_CharT, _Traits>::__parse_grep(_ForwardIterator __first,
4573 _ForwardIterator __last)
4575 __owns_one_state<_CharT>* __sa = __end_;
4576 _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4577 if (__t1 != __first)
4578 __parse_basic_reg_exp(__first, __t1);
4582 if (__first != __last)
4584 while (__first != __last)
4586 __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4587 __owns_one_state<_CharT>* __sb = __end_;
4588 if (__t1 != __first)
4589 __parse_basic_reg_exp(__first, __t1);
4592 __push_alternation(__sa, __sb);
4594 if (__first != __last)
4600 template <class _CharT, class _Traits>
4601 template <class _ForwardIterator>
4603 basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first,
4604 _ForwardIterator __last)
4606 __owns_one_state<_CharT>* __sa = __end_;
4607 _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4608 if (__t1 != __first)
4609 __parse_extended_reg_exp(__first, __t1);
4613 if (__first != __last)
4615 while (__first != __last)
4617 __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4618 __owns_one_state<_CharT>* __sb = __end_;
4619 if (__t1 != __first)
4620 __parse_extended_reg_exp(__first, __t1);
4623 __push_alternation(__sa, __sb);
4625 if (__first != __last)
4631 template <class _CharT, class _Traits>
4633 basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max,
4634 __owns_one_state<_CharT>* __s, size_t __mexp_begin, size_t __mexp_end,
4637 unique_ptr<__empty_state<_CharT> > __e1(new __empty_state<_CharT>(__end_->first()));
4638 __end_->first() = nullptr;
4639 unique_ptr<__loop<_CharT> > __e2(new __loop<_CharT>(__loop_count_,
4640 __s->first(), __e1.get(), __mexp_begin, __mexp_end, __greedy,
4642 __s->first() = nullptr;
4644 __end_->first() = new __repeat_one_loop<_CharT>(__e2.get());
4645 __end_ = __e2->second();
4646 __s->first() = __e2.release();
4650 template <class _CharT, class _Traits>
4652 basic_regex<_CharT, _Traits>::__push_char(value_type __c)
4654 if (flags() & icase)
4655 __end_->first() = new __match_char_icase<_CharT, _Traits>
4656 (__traits_, __c, __end_->first());
4657 else if (flags() & collate)
4658 __end_->first() = new __match_char_collate<_CharT, _Traits>
4659 (__traits_, __c, __end_->first());
4661 __end_->first() = new __match_char<_CharT>(__c, __end_->first());
4662 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4665 template <class _CharT, class _Traits>
4667 basic_regex<_CharT, _Traits>::__push_begin_marked_subexpression()
4669 if (!(__flags_ & nosubs))
4672 new __begin_marked_subexpression<_CharT>(++__marked_count_,
4674 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4678 template <class _CharT, class _Traits>
4680 basic_regex<_CharT, _Traits>::__push_end_marked_subexpression(unsigned __sub)
4682 if (!(__flags_ & nosubs))
4685 new __end_marked_subexpression<_CharT>(__sub, __end_->first());
4686 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4690 template <class _CharT, class _Traits>
4692 basic_regex<_CharT, _Traits>::__push_l_anchor()
4694 __end_->first() = new __l_anchor<_CharT>(__end_->first());
4695 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4698 template <class _CharT, class _Traits>
4700 basic_regex<_CharT, _Traits>::__push_r_anchor()
4702 __end_->first() = new __r_anchor<_CharT>(__end_->first());
4703 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4706 template <class _CharT, class _Traits>
4708 basic_regex<_CharT, _Traits>::__push_match_any()
4710 __end_->first() = new __match_any<_CharT>(__end_->first());
4711 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4714 template <class _CharT, class _Traits>
4716 basic_regex<_CharT, _Traits>::__push_match_any_but_newline()
4718 __end_->first() = new __match_any_but_newline<_CharT>(__end_->first());
4719 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4722 template <class _CharT, class _Traits>
4724 basic_regex<_CharT, _Traits>::__push_empty()
4726 __end_->first() = new __empty_state<_CharT>(__end_->first());
4727 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4730 template <class _CharT, class _Traits>
4732 basic_regex<_CharT, _Traits>::__push_word_boundary(bool __invert)
4734 __end_->first() = new __word_boundary<_CharT, _Traits>(__traits_, __invert,
4736 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4739 template <class _CharT, class _Traits>
4741 basic_regex<_CharT, _Traits>::__push_back_ref(int __i)
4743 if (flags() & icase)
4744 __end_->first() = new __back_ref_icase<_CharT, _Traits>
4745 (__traits_, __i, __end_->first());
4746 else if (flags() & collate)
4747 __end_->first() = new __back_ref_collate<_CharT, _Traits>
4748 (__traits_, __i, __end_->first());
4750 __end_->first() = new __back_ref<_CharT>(__i, __end_->first());
4751 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4754 template <class _CharT, class _Traits>
4756 basic_regex<_CharT, _Traits>::__push_alternation(__owns_one_state<_CharT>* __sa,
4757 __owns_one_state<_CharT>* __ea)
4759 __sa->first() = new __alternate<_CharT>(
4760 static_cast<__owns_one_state<_CharT>*>(__sa->first()),
4761 static_cast<__owns_one_state<_CharT>*>(__ea->first()));
4762 __ea->first() = nullptr;
4763 __ea->first() = new __empty_state<_CharT>(__end_->first());
4764 __end_->first() = nullptr;
4765 __end_->first() = new __empty_non_own_state<_CharT>(__ea->first());
4766 __end_ = static_cast<__owns_one_state<_CharT>*>(__ea->first());
4769 template <class _CharT, class _Traits>
4770 __bracket_expression<_CharT, _Traits>*
4771 basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate)
4773 __bracket_expression<_CharT, _Traits>* __r =
4774 new __bracket_expression<_CharT, _Traits>(__traits_, __end_->first(),
4775 __negate, __flags_ & icase,
4776 __flags_ & collate);
4777 __end_->first() = __r;
4782 template <class _CharT, class _Traits>
4784 basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp,
4788 __end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert,
4789 __end_->first(), __mexp);
4790 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4793 typedef basic_regex<char> regex;
4794 typedef basic_regex<wchar_t> wregex;
4798 template <class _BidirectionalIterator>
4799 class _LIBCPP_TEMPLATE_VIS sub_match
4800 : public pair<_BidirectionalIterator, _BidirectionalIterator>
4803 typedef _BidirectionalIterator iterator;
4804 typedef typename iterator_traits<iterator>::value_type value_type;
4805 typedef typename iterator_traits<iterator>::difference_type difference_type;
4806 typedef basic_string<value_type> string_type;
4810 _LIBCPP_INLINE_VISIBILITY
4811 _LIBCPP_CONSTEXPR sub_match() : matched() {}
4813 _LIBCPP_INLINE_VISIBILITY
4814 difference_type length() const
4815 {return matched ? _VSTD::distance(this->first, this->second) : 0;}
4816 _LIBCPP_INLINE_VISIBILITY
4817 string_type str() const
4818 {return matched ? string_type(this->first, this->second) : string_type();}
4819 _LIBCPP_INLINE_VISIBILITY
4820 operator string_type() const
4823 _LIBCPP_INLINE_VISIBILITY
4824 int compare(const sub_match& __s) const
4825 {return str().compare(__s.str());}
4826 _LIBCPP_INLINE_VISIBILITY
4827 int compare(const string_type& __s) const
4828 {return str().compare(__s);}
4829 _LIBCPP_INLINE_VISIBILITY
4830 int compare(const value_type* __s) const
4831 {return str().compare(__s);}
4834 typedef sub_match<const char*> csub_match;
4835 typedef sub_match<const wchar_t*> wcsub_match;
4836 typedef sub_match<string::const_iterator> ssub_match;
4837 typedef sub_match<wstring::const_iterator> wssub_match;
4839 template <class _BiIter>
4840 inline _LIBCPP_INLINE_VISIBILITY
4842 operator==(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4844 return __x.compare(__y) == 0;
4847 template <class _BiIter>
4848 inline _LIBCPP_INLINE_VISIBILITY
4850 operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4852 return !(__x == __y);
4855 template <class _BiIter>
4856 inline _LIBCPP_INLINE_VISIBILITY
4858 operator<(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4860 return __x.compare(__y) < 0;
4863 template <class _BiIter>
4864 inline _LIBCPP_INLINE_VISIBILITY
4866 operator<=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4868 return !(__y < __x);
4871 template <class _BiIter>
4872 inline _LIBCPP_INLINE_VISIBILITY
4874 operator>=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4876 return !(__x < __y);
4879 template <class _BiIter>
4880 inline _LIBCPP_INLINE_VISIBILITY
4882 operator>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4887 template <class _BiIter, class _ST, class _SA>
4888 inline _LIBCPP_INLINE_VISIBILITY
4890 operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4891 const sub_match<_BiIter>& __y)
4893 return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0;
4896 template <class _BiIter, class _ST, class _SA>
4897 inline _LIBCPP_INLINE_VISIBILITY
4899 operator!=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4900 const sub_match<_BiIter>& __y)
4902 return !(__x == __y);
4905 template <class _BiIter, class _ST, class _SA>
4906 inline _LIBCPP_INLINE_VISIBILITY
4908 operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4909 const sub_match<_BiIter>& __y)
4911 return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0;
4914 template <class _BiIter, class _ST, class _SA>
4915 inline _LIBCPP_INLINE_VISIBILITY
4917 operator>(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4918 const sub_match<_BiIter>& __y)
4923 template <class _BiIter, class _ST, class _SA>
4924 inline _LIBCPP_INLINE_VISIBILITY
4925 bool operator>=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4926 const sub_match<_BiIter>& __y)
4928 return !(__x < __y);
4931 template <class _BiIter, class _ST, class _SA>
4932 inline _LIBCPP_INLINE_VISIBILITY
4934 operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4935 const sub_match<_BiIter>& __y)
4937 return !(__y < __x);
4940 template <class _BiIter, class _ST, class _SA>
4941 inline _LIBCPP_INLINE_VISIBILITY
4943 operator==(const sub_match<_BiIter>& __x,
4944 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4946 return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;
4949 template <class _BiIter, class _ST, class _SA>
4950 inline _LIBCPP_INLINE_VISIBILITY
4952 operator!=(const sub_match<_BiIter>& __x,
4953 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4955 return !(__x == __y);
4958 template <class _BiIter, class _ST, class _SA>
4959 inline _LIBCPP_INLINE_VISIBILITY
4961 operator<(const sub_match<_BiIter>& __x,
4962 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4964 return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0;
4967 template <class _BiIter, class _ST, class _SA>
4968 inline _LIBCPP_INLINE_VISIBILITY
4969 bool operator>(const sub_match<_BiIter>& __x,
4970 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4975 template <class _BiIter, class _ST, class _SA>
4976 inline _LIBCPP_INLINE_VISIBILITY
4978 operator>=(const sub_match<_BiIter>& __x,
4979 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4981 return !(__x < __y);
4984 template <class _BiIter, class _ST, class _SA>
4985 inline _LIBCPP_INLINE_VISIBILITY
4987 operator<=(const sub_match<_BiIter>& __x,
4988 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4990 return !(__y < __x);
4993 template <class _BiIter>
4994 inline _LIBCPP_INLINE_VISIBILITY
4996 operator==(typename iterator_traits<_BiIter>::value_type const* __x,
4997 const sub_match<_BiIter>& __y)
4999 return __y.compare(__x) == 0;
5002 template <class _BiIter>
5003 inline _LIBCPP_INLINE_VISIBILITY
5005 operator!=(typename iterator_traits<_BiIter>::value_type const* __x,
5006 const sub_match<_BiIter>& __y)
5008 return !(__x == __y);
5011 template <class _BiIter>
5012 inline _LIBCPP_INLINE_VISIBILITY
5014 operator<(typename iterator_traits<_BiIter>::value_type const* __x,
5015 const sub_match<_BiIter>& __y)
5017 return __y.compare(__x) > 0;
5020 template <class _BiIter>
5021 inline _LIBCPP_INLINE_VISIBILITY
5023 operator>(typename iterator_traits<_BiIter>::value_type const* __x,
5024 const sub_match<_BiIter>& __y)
5029 template <class _BiIter>
5030 inline _LIBCPP_INLINE_VISIBILITY
5032 operator>=(typename iterator_traits<_BiIter>::value_type const* __x,
5033 const sub_match<_BiIter>& __y)
5035 return !(__x < __y);
5038 template <class _BiIter>
5039 inline _LIBCPP_INLINE_VISIBILITY
5041 operator<=(typename iterator_traits<_BiIter>::value_type const* __x,
5042 const sub_match<_BiIter>& __y)
5044 return !(__y < __x);
5047 template <class _BiIter>
5048 inline _LIBCPP_INLINE_VISIBILITY
5050 operator==(const sub_match<_BiIter>& __x,
5051 typename iterator_traits<_BiIter>::value_type const* __y)
5053 return __x.compare(__y) == 0;
5056 template <class _BiIter>
5057 inline _LIBCPP_INLINE_VISIBILITY
5059 operator!=(const sub_match<_BiIter>& __x,
5060 typename iterator_traits<_BiIter>::value_type const* __y)
5062 return !(__x == __y);
5065 template <class _BiIter>
5066 inline _LIBCPP_INLINE_VISIBILITY
5068 operator<(const sub_match<_BiIter>& __x,
5069 typename iterator_traits<_BiIter>::value_type const* __y)
5071 return __x.compare(__y) < 0;
5074 template <class _BiIter>
5075 inline _LIBCPP_INLINE_VISIBILITY
5077 operator>(const sub_match<_BiIter>& __x,
5078 typename iterator_traits<_BiIter>::value_type const* __y)
5083 template <class _BiIter>
5084 inline _LIBCPP_INLINE_VISIBILITY
5086 operator>=(const sub_match<_BiIter>& __x,
5087 typename iterator_traits<_BiIter>::value_type const* __y)
5089 return !(__x < __y);
5092 template <class _BiIter>
5093 inline _LIBCPP_INLINE_VISIBILITY
5095 operator<=(const sub_match<_BiIter>& __x,
5096 typename iterator_traits<_BiIter>::value_type const* __y)
5098 return !(__y < __x);
5101 template <class _BiIter>
5102 inline _LIBCPP_INLINE_VISIBILITY
5104 operator==(typename iterator_traits<_BiIter>::value_type const& __x,
5105 const sub_match<_BiIter>& __y)
5107 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5108 return __y.compare(string_type(1, __x)) == 0;
5111 template <class _BiIter>
5112 inline _LIBCPP_INLINE_VISIBILITY
5114 operator!=(typename iterator_traits<_BiIter>::value_type const& __x,
5115 const sub_match<_BiIter>& __y)
5117 return !(__x == __y);
5120 template <class _BiIter>
5121 inline _LIBCPP_INLINE_VISIBILITY
5123 operator<(typename iterator_traits<_BiIter>::value_type const& __x,
5124 const sub_match<_BiIter>& __y)
5126 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5127 return __y.compare(string_type(1, __x)) > 0;
5130 template <class _BiIter>
5131 inline _LIBCPP_INLINE_VISIBILITY
5133 operator>(typename iterator_traits<_BiIter>::value_type const& __x,
5134 const sub_match<_BiIter>& __y)
5139 template <class _BiIter>
5140 inline _LIBCPP_INLINE_VISIBILITY
5142 operator>=(typename iterator_traits<_BiIter>::value_type const& __x,
5143 const sub_match<_BiIter>& __y)
5145 return !(__x < __y);
5148 template <class _BiIter>
5149 inline _LIBCPP_INLINE_VISIBILITY
5151 operator<=(typename iterator_traits<_BiIter>::value_type const& __x,
5152 const sub_match<_BiIter>& __y)
5154 return !(__y < __x);
5157 template <class _BiIter>
5158 inline _LIBCPP_INLINE_VISIBILITY
5160 operator==(const sub_match<_BiIter>& __x,
5161 typename iterator_traits<_BiIter>::value_type const& __y)
5163 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5164 return __x.compare(string_type(1, __y)) == 0;
5167 template <class _BiIter>
5168 inline _LIBCPP_INLINE_VISIBILITY
5170 operator!=(const sub_match<_BiIter>& __x,
5171 typename iterator_traits<_BiIter>::value_type const& __y)
5173 return !(__x == __y);
5176 template <class _BiIter>
5177 inline _LIBCPP_INLINE_VISIBILITY
5179 operator<(const sub_match<_BiIter>& __x,
5180 typename iterator_traits<_BiIter>::value_type const& __y)
5182 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5183 return __x.compare(string_type(1, __y)) < 0;
5186 template <class _BiIter>
5187 inline _LIBCPP_INLINE_VISIBILITY
5189 operator>(const sub_match<_BiIter>& __x,
5190 typename iterator_traits<_BiIter>::value_type const& __y)
5195 template <class _BiIter>
5196 inline _LIBCPP_INLINE_VISIBILITY
5198 operator>=(const sub_match<_BiIter>& __x,
5199 typename iterator_traits<_BiIter>::value_type const& __y)
5201 return !(__x < __y);
5204 template <class _BiIter>
5205 inline _LIBCPP_INLINE_VISIBILITY
5207 operator<=(const sub_match<_BiIter>& __x,
5208 typename iterator_traits<_BiIter>::value_type const& __y)
5210 return !(__y < __x);
5213 template <class _CharT, class _ST, class _BiIter>
5214 inline _LIBCPP_INLINE_VISIBILITY
5215 basic_ostream<_CharT, _ST>&
5216 operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m)
5218 return __os << __m.str();
5221 template <class _BidirectionalIterator, class _Allocator>
5222 class _LIBCPP_TEMPLATE_VIS match_results
5225 typedef _Allocator allocator_type;
5226 typedef sub_match<_BidirectionalIterator> value_type;
5228 typedef vector<value_type, allocator_type> __container_type;
5230 __container_type __matches_;
5231 value_type __unmatched_;
5232 value_type __prefix_;
5233 value_type __suffix_;
5236 _BidirectionalIterator __position_start_;
5237 typedef const value_type& const_reference;
5238 typedef value_type& reference;
5239 typedef typename __container_type::const_iterator const_iterator;
5240 typedef const_iterator iterator;
5241 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
5242 typedef typename allocator_traits<allocator_type>::size_type size_type;
5243 typedef typename iterator_traits<_BidirectionalIterator>::value_type char_type;
5244 typedef basic_string<char_type> string_type;
5246 // construct/copy/destroy:
5247 explicit match_results(const allocator_type& __a = allocator_type());
5248 // match_results(const match_results&) = default;
5249 // match_results& operator=(const match_results&) = default;
5250 // match_results(match_results&& __m) = default;
5251 // match_results& operator=(match_results&& __m) = default;
5252 // ~match_results() = default;
5254 _LIBCPP_INLINE_VISIBILITY
5255 bool ready() const {return __ready_;}
5258 _LIBCPP_INLINE_VISIBILITY
5259 size_type size() const _NOEXCEPT {return __matches_.size();}
5260 _LIBCPP_INLINE_VISIBILITY
5261 size_type max_size() const _NOEXCEPT {return __matches_.max_size();}
5262 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
5263 bool empty() const _NOEXCEPT {return size() == 0;}
5266 _LIBCPP_INLINE_VISIBILITY
5267 difference_type length(size_type __sub = 0) const
5268 {return (*this)[__sub].length();}
5269 _LIBCPP_INLINE_VISIBILITY
5270 difference_type position(size_type __sub = 0) const
5271 {return _VSTD::distance(__position_start_, (*this)[__sub].first);}
5272 _LIBCPP_INLINE_VISIBILITY
5273 string_type str(size_type __sub = 0) const
5274 {return (*this)[__sub].str();}
5275 _LIBCPP_INLINE_VISIBILITY
5276 const_reference operator[](size_type __n) const
5277 {return __n < __matches_.size() ? __matches_[__n] : __unmatched_;}
5279 _LIBCPP_INLINE_VISIBILITY
5280 const_reference prefix() const {return __prefix_;}
5281 _LIBCPP_INLINE_VISIBILITY
5282 const_reference suffix() const {return __suffix_;}
5284 _LIBCPP_INLINE_VISIBILITY
5285 const_iterator begin() const {return empty() ? __matches_.end() : __matches_.begin();}
5286 _LIBCPP_INLINE_VISIBILITY
5287 const_iterator end() const {return __matches_.end();}
5288 _LIBCPP_INLINE_VISIBILITY
5289 const_iterator cbegin() const {return empty() ? __matches_.end() : __matches_.begin();}
5290 _LIBCPP_INLINE_VISIBILITY
5291 const_iterator cend() const {return __matches_.end();}
5294 template <class _OutputIter>
5296 format(_OutputIter __output_iter, const char_type* __fmt_first,
5297 const char_type* __fmt_last,
5298 regex_constants::match_flag_type __flags = regex_constants::format_default) const;
5299 template <class _OutputIter, class _ST, class _SA>
5300 _LIBCPP_INLINE_VISIBILITY
5302 format(_OutputIter __output_iter, const basic_string<char_type, _ST, _SA>& __fmt,
5303 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5304 {return format(__output_iter, __fmt.data(), __fmt.data() + __fmt.size(), __flags);}
5305 template <class _ST, class _SA>
5306 _LIBCPP_INLINE_VISIBILITY
5307 basic_string<char_type, _ST, _SA>
5308 format(const basic_string<char_type, _ST, _SA>& __fmt,
5309 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5311 basic_string<char_type, _ST, _SA> __r;
5312 format(back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(),
5316 _LIBCPP_INLINE_VISIBILITY
5318 format(const char_type* __fmt,
5319 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5322 format(back_inserter(__r), __fmt,
5323 __fmt + char_traits<char_type>::length(__fmt), __flags);
5328 _LIBCPP_INLINE_VISIBILITY
5329 allocator_type get_allocator() const {return __matches_.get_allocator();}
5332 void swap(match_results& __m);
5334 template <class _Bp, class _Ap>
5335 _LIBCPP_INLINE_VISIBILITY
5336 void __assign(_BidirectionalIterator __f, _BidirectionalIterator __l,
5337 const match_results<_Bp, _Ap>& __m, bool __no_update_pos)
5339 _Bp __mf = __m.prefix().first;
5340 __matches_.resize(__m.size());
5341 for (size_type __i = 0; __i < __matches_.size(); ++__i)
5343 __matches_[__i].first = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].first));
5344 __matches_[__i].second = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].second));
5345 __matches_[__i].matched = __m[__i].matched;
5347 __unmatched_.first = __l;
5348 __unmatched_.second = __l;
5349 __unmatched_.matched = false;
5350 __prefix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().first));
5351 __prefix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().second));
5352 __prefix_.matched = __m.prefix().matched;
5353 __suffix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().first));
5354 __suffix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().second));
5355 __suffix_.matched = __m.suffix().matched;
5356 if (!__no_update_pos)
5357 __position_start_ = __prefix_.first;
5358 __ready_ = __m.ready();
5362 void __init(unsigned __s,
5363 _BidirectionalIterator __f, _BidirectionalIterator __l,
5364 bool __no_update_pos = false);
5366 template <class, class> friend class basic_regex;
5368 template <class _Bp, class _Ap, class _Cp, class _Tp>
5371 regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
5372 regex_constants::match_flag_type);
5374 template <class _Bp, class _Ap>
5377 operator==(const match_results<_Bp, _Ap>&, const match_results<_Bp, _Ap>&);
5379 template <class, class> friend class __lookahead;
5382 template <class _BidirectionalIterator, class _Allocator>
5383 match_results<_BidirectionalIterator, _Allocator>::match_results(
5384 const allocator_type& __a)
5394 template <class _BidirectionalIterator, class _Allocator>
5396 match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s,
5397 _BidirectionalIterator __f, _BidirectionalIterator __l,
5398 bool __no_update_pos)
5400 __unmatched_.first = __l;
5401 __unmatched_.second = __l;
5402 __unmatched_.matched = false;
5403 __matches_.assign(__s, __unmatched_);
5404 __prefix_.first = __f;
5405 __prefix_.second = __f;
5406 __prefix_.matched = false;
5407 __suffix_ = __unmatched_;
5408 if (!__no_update_pos)
5409 __position_start_ = __prefix_.first;
5413 template <class _BidirectionalIterator, class _Allocator>
5414 template <class _OutputIter>
5416 match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output_iter,
5417 const char_type* __fmt_first, const char_type* __fmt_last,
5418 regex_constants::match_flag_type __flags) const
5420 if (__flags & regex_constants::format_sed)
5422 for (; __fmt_first != __fmt_last; ++__fmt_first)
5424 if (*__fmt_first == '&')
5425 __output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second,
5427 else if (*__fmt_first == '\\' && __fmt_first + 1 != __fmt_last)
5430 if ('0' <= *__fmt_first && *__fmt_first <= '9')
5432 size_t __i = *__fmt_first - '0';
5433 __output_iter = _VSTD::copy((*this)[__i].first,
5434 (*this)[__i].second, __output_iter);
5438 *__output_iter = *__fmt_first;
5444 *__output_iter = *__fmt_first;
5451 for (; __fmt_first != __fmt_last; ++__fmt_first)
5453 if (*__fmt_first == '$' && __fmt_first + 1 != __fmt_last)
5455 switch (__fmt_first[1])
5458 *__output_iter = *++__fmt_first;
5463 __output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second,
5468 __output_iter = _VSTD::copy(__prefix_.first, __prefix_.second, __output_iter);
5472 __output_iter = _VSTD::copy(__suffix_.first, __suffix_.second, __output_iter);
5475 if ('0' <= __fmt_first[1] && __fmt_first[1] <= '9')
5478 size_t __idx = *__fmt_first - '0';
5479 if (__fmt_first + 1 != __fmt_last &&
5480 '0' <= __fmt_first[1] && __fmt_first[1] <= '9')
5483 if (__idx >= std::numeric_limits<size_t>::max() / 10)
5484 __throw_regex_error<regex_constants::error_escape>();
5485 __idx = 10 * __idx + *__fmt_first - '0';
5487 __output_iter = _VSTD::copy((*this)[__idx].first,
5488 (*this)[__idx].second, __output_iter);
5492 *__output_iter = *__fmt_first;
5500 *__output_iter = *__fmt_first;
5505 return __output_iter;
5508 template <class _BidirectionalIterator, class _Allocator>
5510 match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
5513 swap(__matches_, __m.__matches_);
5514 swap(__unmatched_, __m.__unmatched_);
5515 swap(__prefix_, __m.__prefix_);
5516 swap(__suffix_, __m.__suffix_);
5517 swap(__position_start_, __m.__position_start_);
5518 swap(__ready_, __m.__ready_);
5521 typedef match_results<const char*> cmatch;
5522 typedef match_results<const wchar_t*> wcmatch;
5523 typedef match_results<string::const_iterator> smatch;
5524 typedef match_results<wstring::const_iterator> wsmatch;
5526 template <class _BidirectionalIterator, class _Allocator>
5528 operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
5529 const match_results<_BidirectionalIterator, _Allocator>& __y)
5531 if (__x.__ready_ != __y.__ready_)
5535 return __x.__matches_ == __y.__matches_ &&
5536 __x.__prefix_ == __y.__prefix_ &&
5537 __x.__suffix_ == __y.__suffix_;
5540 template <class _BidirectionalIterator, class _Allocator>
5541 inline _LIBCPP_INLINE_VISIBILITY
5543 operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,
5544 const match_results<_BidirectionalIterator, _Allocator>& __y)
5546 return !(__x == __y);
5549 template <class _BidirectionalIterator, class _Allocator>
5550 inline _LIBCPP_INLINE_VISIBILITY
5552 swap(match_results<_BidirectionalIterator, _Allocator>& __x,
5553 match_results<_BidirectionalIterator, _Allocator>& __y)
5560 template <class _CharT, class _Traits>
5561 template <class _Allocator>
5563 basic_regex<_CharT, _Traits>::__match_at_start_ecma(
5564 const _CharT* __first, const _CharT* __last,
5565 match_results<const _CharT*, _Allocator>& __m,
5566 regex_constants::match_flag_type __flags, bool __at_first) const
5568 vector<__state> __states;
5569 __node* __st = __start_.get();
5572 sub_match<const _CharT*> __unmatched;
5573 __unmatched.first = __last;
5574 __unmatched.second = __last;
5575 __unmatched.matched = false;
5577 __states.push_back(__state());
5578 __states.back().__do_ = 0;
5579 __states.back().__first_ = __first;
5580 __states.back().__current_ = __first;
5581 __states.back().__last_ = __last;
5582 __states.back().__sub_matches_.resize(mark_count(), __unmatched);
5583 __states.back().__loop_data_.resize(__loop_count());
5584 __states.back().__node_ = __st;
5585 __states.back().__flags_ = __flags;
5586 __states.back().__at_first_ = __at_first;
5588 int __length = __last - __first;
5592 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
5593 __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
5594 __throw_regex_error<regex_constants::error_complexity>();
5595 __state& __s = __states.back();
5597 __s.__node_->__exec(__s);
5600 case __state::__end_state:
5601 if ((__flags & regex_constants::match_not_null) &&
5602 __s.__current_ == __first)
5604 __states.pop_back();
5607 if ((__flags & regex_constants::__full_match) &&
5608 __s.__current_ != __last)
5610 __states.pop_back();
5613 __m.__matches_[0].first = __first;
5614 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first);
5615 __m.__matches_[0].matched = true;
5616 for (unsigned __i = 0; __i < __s.__sub_matches_.size(); ++__i)
5617 __m.__matches_[__i+1] = __s.__sub_matches_[__i];
5619 case __state::__accept_and_consume:
5620 case __state::__repeat:
5621 case __state::__accept_but_not_consume:
5623 case __state::__split:
5625 __state __snext = __s;
5626 __s.__node_->__exec_split(true, __s);
5627 __snext.__node_->__exec_split(false, __snext);
5628 __states.push_back(_VSTD::move(__snext));
5631 case __state::__reject:
5632 __states.pop_back();
5635 __throw_regex_error<regex_constants::__re_err_unknown>();
5639 } while (!__states.empty());
5644 template <class _CharT, class _Traits>
5645 template <class _Allocator>
5647 basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
5648 const _CharT* __first, const _CharT* __last,
5649 match_results<const _CharT*, _Allocator>& __m,
5650 regex_constants::match_flag_type __flags, bool __at_first) const
5652 deque<__state> __states;
5653 ptrdiff_t __highest_j = 0;
5654 ptrdiff_t _Np = _VSTD::distance(__first, __last);
5655 __node* __st = __start_.get();
5658 __states.push_back(__state());
5659 __states.back().__do_ = 0;
5660 __states.back().__first_ = __first;
5661 __states.back().__current_ = __first;
5662 __states.back().__last_ = __last;
5663 __states.back().__loop_data_.resize(__loop_count());
5664 __states.back().__node_ = __st;
5665 __states.back().__flags_ = __flags;
5666 __states.back().__at_first_ = __at_first;
5667 bool __matched = false;
5669 int __length = __last - __first;
5673 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
5674 __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
5675 __throw_regex_error<regex_constants::error_complexity>();
5676 __state& __s = __states.back();
5678 __s.__node_->__exec(__s);
5681 case __state::__end_state:
5682 if ((__flags & regex_constants::match_not_null) &&
5683 __s.__current_ == __first)
5685 __states.pop_back();
5688 if ((__flags & regex_constants::__full_match) &&
5689 __s.__current_ != __last)
5691 __states.pop_back();
5694 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
5695 __highest_j = __s.__current_ - __s.__first_;
5697 if (__highest_j == _Np)
5700 __states.pop_back();
5702 case __state::__consume_input:
5704 case __state::__accept_and_consume:
5705 __states.push_front(_VSTD::move(__s));
5706 __states.pop_back();
5708 case __state::__repeat:
5709 case __state::__accept_but_not_consume:
5711 case __state::__split:
5713 __state __snext = __s;
5714 __s.__node_->__exec_split(true, __s);
5715 __snext.__node_->__exec_split(false, __snext);
5716 __states.push_back(_VSTD::move(__snext));
5719 case __state::__reject:
5720 __states.pop_back();
5723 __throw_regex_error<regex_constants::__re_err_unknown>();
5726 } while (!__states.empty());
5729 __m.__matches_[0].first = __first;
5730 __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
5731 __m.__matches_[0].matched = true;
5738 template <class _CharT, class _Traits>
5739 template <class _Allocator>
5741 basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
5742 const _CharT* __first, const _CharT* __last,
5743 match_results<const _CharT*, _Allocator>& __m,
5744 regex_constants::match_flag_type __flags, bool __at_first) const
5746 vector<__state> __states;
5747 __state __best_state;
5749 ptrdiff_t __highest_j = 0;
5750 ptrdiff_t _Np = _VSTD::distance(__first, __last);
5751 __node* __st = __start_.get();
5754 sub_match<const _CharT*> __unmatched;
5755 __unmatched.first = __last;
5756 __unmatched.second = __last;
5757 __unmatched.matched = false;
5759 __states.push_back(__state());
5760 __states.back().__do_ = 0;
5761 __states.back().__first_ = __first;
5762 __states.back().__current_ = __first;
5763 __states.back().__last_ = __last;
5764 __states.back().__sub_matches_.resize(mark_count(), __unmatched);
5765 __states.back().__loop_data_.resize(__loop_count());
5766 __states.back().__node_ = __st;
5767 __states.back().__flags_ = __flags;
5768 __states.back().__at_first_ = __at_first;
5769 const _CharT* __current = __first;
5770 bool __matched = false;
5772 int __length = __last - __first;
5776 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
5777 __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
5778 __throw_regex_error<regex_constants::error_complexity>();
5779 __state& __s = __states.back();
5781 __s.__node_->__exec(__s);
5784 case __state::__end_state:
5785 if ((__flags & regex_constants::match_not_null) &&
5786 __s.__current_ == __first)
5788 __states.pop_back();
5791 if ((__flags & regex_constants::__full_match) &&
5792 __s.__current_ != __last)
5794 __states.pop_back();
5797 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
5799 __highest_j = __s.__current_ - __s.__first_;
5803 if (__highest_j == _Np)
5806 __states.pop_back();
5808 case __state::__accept_and_consume:
5809 __j += __s.__current_ - __current;
5810 __current = __s.__current_;
5812 case __state::__repeat:
5813 case __state::__accept_but_not_consume:
5815 case __state::__split:
5817 __state __snext = __s;
5818 __s.__node_->__exec_split(true, __s);
5819 __snext.__node_->__exec_split(false, __snext);
5820 __states.push_back(_VSTD::move(__snext));
5823 case __state::__reject:
5824 __states.pop_back();
5827 __throw_regex_error<regex_constants::__re_err_unknown>();
5830 } while (!__states.empty());
5833 __m.__matches_[0].first = __first;
5834 __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
5835 __m.__matches_[0].matched = true;
5836 for (unsigned __i = 0; __i < __best_state.__sub_matches_.size(); ++__i)
5837 __m.__matches_[__i+1] = __best_state.__sub_matches_[__i];
5844 template <class _CharT, class _Traits>
5845 template <class _Allocator>
5847 basic_regex<_CharT, _Traits>::__match_at_start(
5848 const _CharT* __first, const _CharT* __last,
5849 match_results<const _CharT*, _Allocator>& __m,
5850 regex_constants::match_flag_type __flags, bool __at_first) const
5852 if ((__flags_ & 0x1F0) == ECMAScript)
5853 return __match_at_start_ecma(__first, __last, __m, __flags, __at_first);
5854 if (mark_count() == 0)
5855 return __match_at_start_posix_nosubs(__first, __last, __m, __flags, __at_first);
5856 return __match_at_start_posix_subs(__first, __last, __m, __flags, __at_first);
5859 template <class _CharT, class _Traits>
5860 template <class _Allocator>
5862 basic_regex<_CharT, _Traits>::__search(
5863 const _CharT* __first, const _CharT* __last,
5864 match_results<const _CharT*, _Allocator>& __m,
5865 regex_constants::match_flag_type __flags) const
5867 __m.__init(1 + mark_count(), __first, __last,
5868 __flags & regex_constants::__no_update_pos);
5869 if (__match_at_start(__first, __last, __m, __flags,
5870 !(__flags & regex_constants::__no_update_pos)))
5872 __m.__prefix_.second = __m[0].first;
5873 __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
5874 __m.__suffix_.first = __m[0].second;
5875 __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
5878 if (__first != __last && !(__flags & regex_constants::match_continuous))
5880 __flags |= regex_constants::match_prev_avail;
5881 for (++__first; __first != __last; ++__first)
5883 __m.__matches_.assign(__m.size(), __m.__unmatched_);
5884 if (__match_at_start(__first, __last, __m, __flags, false))
5886 __m.__prefix_.second = __m[0].first;
5887 __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
5888 __m.__suffix_.first = __m[0].second;
5889 __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
5892 __m.__matches_.assign(__m.size(), __m.__unmatched_);
5895 __m.__matches_.clear();
5899 template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
5900 inline _LIBCPP_INLINE_VISIBILITY
5902 regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
5903 match_results<_BidirectionalIterator, _Allocator>& __m,
5904 const basic_regex<_CharT, _Traits>& __e,
5905 regex_constants::match_flag_type __flags = regex_constants::match_default)
5907 int __offset = (__flags & regex_constants::match_prev_avail) ? 1 : 0;
5908 basic_string<_CharT> __s(_VSTD::prev(__first, __offset), __last);
5909 match_results<const _CharT*> __mc;
5910 bool __r = __e.__search(__s.data() + __offset, __s.data() + __s.size(), __mc, __flags);
5911 __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
5915 template <class _Iter, class _Allocator, class _CharT, class _Traits>
5916 inline _LIBCPP_INLINE_VISIBILITY
5918 regex_search(__wrap_iter<_Iter> __first,
5919 __wrap_iter<_Iter> __last,
5920 match_results<__wrap_iter<_Iter>, _Allocator>& __m,
5921 const basic_regex<_CharT, _Traits>& __e,
5922 regex_constants::match_flag_type __flags = regex_constants::match_default)
5924 match_results<const _CharT*> __mc;
5925 bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags);
5926 __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
5930 template <class _Allocator, class _CharT, class _Traits>
5931 inline _LIBCPP_INLINE_VISIBILITY
5933 regex_search(const _CharT* __first, const _CharT* __last,
5934 match_results<const _CharT*, _Allocator>& __m,
5935 const basic_regex<_CharT, _Traits>& __e,
5936 regex_constants::match_flag_type __flags = regex_constants::match_default)
5938 return __e.__search(__first, __last, __m, __flags);
5941 template <class _BidirectionalIterator, class _CharT, class _Traits>
5942 inline _LIBCPP_INLINE_VISIBILITY
5944 regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
5945 const basic_regex<_CharT, _Traits>& __e,
5946 regex_constants::match_flag_type __flags = regex_constants::match_default)
5948 basic_string<_CharT> __s(__first, __last);
5949 match_results<const _CharT*> __mc;
5950 return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
5953 template <class _CharT, class _Traits>
5954 inline _LIBCPP_INLINE_VISIBILITY
5956 regex_search(const _CharT* __first, const _CharT* __last,
5957 const basic_regex<_CharT, _Traits>& __e,
5958 regex_constants::match_flag_type __flags = regex_constants::match_default)
5960 match_results<const _CharT*> __mc;
5961 return __e.__search(__first, __last, __mc, __flags);
5964 template <class _CharT, class _Allocator, class _Traits>
5965 inline _LIBCPP_INLINE_VISIBILITY
5967 regex_search(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
5968 const basic_regex<_CharT, _Traits>& __e,
5969 regex_constants::match_flag_type __flags = regex_constants::match_default)
5971 return __e.__search(__str, __str + _Traits::length(__str), __m, __flags);
5974 template <class _CharT, class _Traits>
5975 inline _LIBCPP_INLINE_VISIBILITY
5977 regex_search(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
5978 regex_constants::match_flag_type __flags = regex_constants::match_default)
5980 match_results<const _CharT*> __m;
5981 return _VSTD::regex_search(__str, __m, __e, __flags);
5984 template <class _ST, class _SA, class _CharT, class _Traits>
5985 inline _LIBCPP_INLINE_VISIBILITY
5987 regex_search(const basic_string<_CharT, _ST, _SA>& __s,
5988 const basic_regex<_CharT, _Traits>& __e,
5989 regex_constants::match_flag_type __flags = regex_constants::match_default)
5991 match_results<const _CharT*> __mc;
5992 return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
5995 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
5996 inline _LIBCPP_INLINE_VISIBILITY
5998 regex_search(const basic_string<_CharT, _ST, _SA>& __s,
5999 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
6000 const basic_regex<_CharT, _Traits>& __e,
6001 regex_constants::match_flag_type __flags = regex_constants::match_default)
6003 match_results<const _CharT*> __mc;
6004 bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
6005 __m.__assign(__s.begin(), __s.end(), __mc, __flags & regex_constants::__no_update_pos);
6009 #if _LIBCPP_STD_VER > 11
6010 template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
6012 regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
6013 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
6014 const basic_regex<_Cp, _Tp>& __e,
6015 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
6020 template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
6022 regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
6023 match_results<_BidirectionalIterator, _Allocator>& __m,
6024 const basic_regex<_CharT, _Traits>& __e,
6025 regex_constants::match_flag_type __flags = regex_constants::match_default)
6027 bool __r = _VSTD::regex_search(
6028 __first, __last, __m, __e,
6029 __flags | regex_constants::match_continuous |
6030 regex_constants::__full_match);
6033 __r = !__m.suffix().matched;
6035 __m.__matches_.clear();
6040 template <class _BidirectionalIterator, class _CharT, class _Traits>
6041 inline _LIBCPP_INLINE_VISIBILITY
6043 regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
6044 const basic_regex<_CharT, _Traits>& __e,
6045 regex_constants::match_flag_type __flags = regex_constants::match_default)
6047 match_results<_BidirectionalIterator> __m;
6048 return _VSTD::regex_match(__first, __last, __m, __e, __flags);
6051 template <class _CharT, class _Allocator, class _Traits>
6052 inline _LIBCPP_INLINE_VISIBILITY
6054 regex_match(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
6055 const basic_regex<_CharT, _Traits>& __e,
6056 regex_constants::match_flag_type __flags = regex_constants::match_default)
6058 return _VSTD::regex_match(__str, __str + _Traits::length(__str), __m, __e, __flags);
6061 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
6062 inline _LIBCPP_INLINE_VISIBILITY
6064 regex_match(const basic_string<_CharT, _ST, _SA>& __s,
6065 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
6066 const basic_regex<_CharT, _Traits>& __e,
6067 regex_constants::match_flag_type __flags = regex_constants::match_default)
6069 return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags);
6072 #if _LIBCPP_STD_VER > 11
6073 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
6074 inline _LIBCPP_INLINE_VISIBILITY
6076 regex_match(const basic_string<_CharT, _ST, _SA>&& __s,
6077 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
6078 const basic_regex<_CharT, _Traits>& __e,
6079 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
6082 template <class _CharT, class _Traits>
6083 inline _LIBCPP_INLINE_VISIBILITY
6085 regex_match(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
6086 regex_constants::match_flag_type __flags = regex_constants::match_default)
6088 return _VSTD::regex_match(__str, __str + _Traits::length(__str), __e, __flags);
6091 template <class _ST, class _SA, class _CharT, class _Traits>
6092 inline _LIBCPP_INLINE_VISIBILITY
6094 regex_match(const basic_string<_CharT, _ST, _SA>& __s,
6095 const basic_regex<_CharT, _Traits>& __e,
6096 regex_constants::match_flag_type __flags = regex_constants::match_default)
6098 return _VSTD::regex_match(__s.begin(), __s.end(), __e, __flags);
6103 template <class _BidirectionalIterator,
6104 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
6105 class _Traits = regex_traits<_CharT> >
6106 class _LIBCPP_TEMPLATE_VIS regex_iterator
6109 typedef basic_regex<_CharT, _Traits> regex_type;
6110 typedef match_results<_BidirectionalIterator> value_type;
6111 typedef ptrdiff_t difference_type;
6112 typedef const value_type* pointer;
6113 typedef const value_type& reference;
6114 typedef forward_iterator_tag iterator_category;
6117 _BidirectionalIterator __begin_;
6118 _BidirectionalIterator __end_;
6119 const regex_type* __pregex_;
6120 regex_constants::match_flag_type __flags_;
6121 value_type __match_;
6125 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6126 const regex_type& __re,
6127 regex_constants::match_flag_type __m
6128 = regex_constants::match_default);
6129 #if _LIBCPP_STD_VER > 11
6130 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6131 const regex_type&& __re,
6132 regex_constants::match_flag_type __m
6133 = regex_constants::match_default) = delete;
6136 bool operator==(const regex_iterator& __x) const;
6137 _LIBCPP_INLINE_VISIBILITY
6138 bool operator!=(const regex_iterator& __x) const {return !(*this == __x);}
6140 _LIBCPP_INLINE_VISIBILITY
6141 reference operator*() const {return __match_;}
6142 _LIBCPP_INLINE_VISIBILITY
6143 pointer operator->() const {return &__match_;}
6145 regex_iterator& operator++();
6146 _LIBCPP_INLINE_VISIBILITY
6147 regex_iterator operator++(int)
6149 regex_iterator __t(*this);
6155 template <class _BidirectionalIterator, class _CharT, class _Traits>
6156 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_iterator()
6157 : __begin_(), __end_(), __pregex_(nullptr), __flags_(), __match_()
6161 template <class _BidirectionalIterator, class _CharT, class _Traits>
6162 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
6163 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6164 const regex_type& __re, regex_constants::match_flag_type __m)
6170 _VSTD::regex_search(__begin_, __end_, __match_, *__pregex_, __flags_);
6173 template <class _BidirectionalIterator, class _CharT, class _Traits>
6175 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
6176 operator==(const regex_iterator& __x) const
6178 if (__match_.empty() && __x.__match_.empty())
6180 if (__match_.empty() || __x.__match_.empty())
6182 return __begin_ == __x.__begin_ &&
6183 __end_ == __x.__end_ &&
6184 __pregex_ == __x.__pregex_ &&
6185 __flags_ == __x.__flags_ &&
6186 __match_[0] == __x.__match_[0];
6189 template <class _BidirectionalIterator, class _CharT, class _Traits>
6190 regex_iterator<_BidirectionalIterator, _CharT, _Traits>&
6191 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6193 __flags_ |= regex_constants::__no_update_pos;
6194 _BidirectionalIterator __start = __match_[0].second;
6195 if (__match_[0].first == __match_[0].second)
6197 if (__start == __end_)
6199 __match_ = value_type();
6202 else if (_VSTD::regex_search(__start, __end_, __match_, *__pregex_,
6203 __flags_ | regex_constants::match_not_null |
6204 regex_constants::match_continuous))
6209 __flags_ |= regex_constants::match_prev_avail;
6210 if (!_VSTD::regex_search(__start, __end_, __match_, *__pregex_, __flags_))
6211 __match_ = value_type();
6215 typedef regex_iterator<const char*> cregex_iterator;
6216 typedef regex_iterator<const wchar_t*> wcregex_iterator;
6217 typedef regex_iterator<string::const_iterator> sregex_iterator;
6218 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
6220 // regex_token_iterator
6222 template <class _BidirectionalIterator,
6223 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
6224 class _Traits = regex_traits<_CharT> >
6225 class _LIBCPP_TEMPLATE_VIS regex_token_iterator
6228 typedef basic_regex<_CharT, _Traits> regex_type;
6229 typedef sub_match<_BidirectionalIterator> value_type;
6230 typedef ptrdiff_t difference_type;
6231 typedef const value_type* pointer;
6232 typedef const value_type& reference;
6233 typedef forward_iterator_tag iterator_category;
6236 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position;
6238 _Position __position_;
6239 const value_type* __result_;
6240 value_type __suffix_;
6242 vector<int> __subs_;
6245 regex_token_iterator();
6246 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6247 const regex_type& __re, int __submatch = 0,
6248 regex_constants::match_flag_type __m =
6249 regex_constants::match_default);
6250 #if _LIBCPP_STD_VER > 11
6251 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6252 const regex_type&& __re, int __submatch = 0,
6253 regex_constants::match_flag_type __m =
6254 regex_constants::match_default) = delete;
6257 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6258 const regex_type& __re, const vector<int>& __submatches,
6259 regex_constants::match_flag_type __m =
6260 regex_constants::match_default);
6261 #if _LIBCPP_STD_VER > 11
6262 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6263 const regex_type&& __re, const vector<int>& __submatches,
6264 regex_constants::match_flag_type __m =
6265 regex_constants::match_default) = delete;
6268 #ifndef _LIBCPP_CXX03_LANG
6269 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6270 const regex_type& __re,
6271 initializer_list<int> __submatches,
6272 regex_constants::match_flag_type __m =
6273 regex_constants::match_default);
6275 #if _LIBCPP_STD_VER > 11
6276 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6277 const regex_type&& __re,
6278 initializer_list<int> __submatches,
6279 regex_constants::match_flag_type __m =
6280 regex_constants::match_default) = delete;
6282 #endif // _LIBCPP_CXX03_LANG
6283 template <size_t _Np>
6284 regex_token_iterator(_BidirectionalIterator __a,
6285 _BidirectionalIterator __b,
6286 const regex_type& __re,
6287 const int (&__submatches)[_Np],
6288 regex_constants::match_flag_type __m =
6289 regex_constants::match_default);
6290 #if _LIBCPP_STD_VER > 11
6291 template <std::size_t _Np>
6292 regex_token_iterator(_BidirectionalIterator __a,
6293 _BidirectionalIterator __b,
6294 const regex_type&& __re,
6295 const int (&__submatches)[_Np],
6296 regex_constants::match_flag_type __m =
6297 regex_constants::match_default) = delete;
6300 regex_token_iterator(const regex_token_iterator&);
6301 regex_token_iterator& operator=(const regex_token_iterator&);
6303 bool operator==(const regex_token_iterator& __x) const;
6304 _LIBCPP_INLINE_VISIBILITY
6305 bool operator!=(const regex_token_iterator& __x) const {return !(*this == __x);}
6307 _LIBCPP_INLINE_VISIBILITY
6308 const value_type& operator*() const {return *__result_;}
6309 _LIBCPP_INLINE_VISIBILITY
6310 const value_type* operator->() const {return __result_;}
6312 regex_token_iterator& operator++();
6313 _LIBCPP_INLINE_VISIBILITY
6314 regex_token_iterator operator++(int)
6316 regex_token_iterator __t(*this);
6322 void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
6323 void __establish_result () {
6324 if (__subs_[__n_] == -1)
6325 __result_ = &__position_->prefix();
6327 __result_ = &(*__position_)[__subs_[__n_]];
6331 template <class _BidirectionalIterator, class _CharT, class _Traits>
6332 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6333 regex_token_iterator()
6334 : __result_(nullptr),
6340 template <class _BidirectionalIterator, class _CharT, class _Traits>
6342 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6343 __init(_BidirectionalIterator __a, _BidirectionalIterator __b)
6345 if (__position_ != _Position())
6346 __establish_result ();
6347 else if (__subs_[__n_] == -1)
6349 __suffix_.matched = true;
6350 __suffix_.first = __a;
6351 __suffix_.second = __b;
6352 __result_ = &__suffix_;
6355 __result_ = nullptr;
6358 template <class _BidirectionalIterator, class _CharT, class _Traits>
6359 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6360 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6361 const regex_type& __re, int __submatch,
6362 regex_constants::match_flag_type __m)
6363 : __position_(__a, __b, __re, __m),
6365 __subs_(1, __submatch)
6370 template <class _BidirectionalIterator, class _CharT, class _Traits>
6371 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6372 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6373 const regex_type& __re, const vector<int>& __submatches,
6374 regex_constants::match_flag_type __m)
6375 : __position_(__a, __b, __re, __m),
6377 __subs_(__submatches)
6382 #ifndef _LIBCPP_CXX03_LANG
6384 template <class _BidirectionalIterator, class _CharT, class _Traits>
6385 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6386 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6387 const regex_type& __re,
6388 initializer_list<int> __submatches,
6389 regex_constants::match_flag_type __m)
6390 : __position_(__a, __b, __re, __m),
6392 __subs_(__submatches)
6397 #endif // _LIBCPP_CXX03_LANG
6399 template <class _BidirectionalIterator, class _CharT, class _Traits>
6400 template <size_t _Np>
6401 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6402 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6403 const regex_type& __re,
6404 const int (&__submatches)[_Np],
6405 regex_constants::match_flag_type __m)
6406 : __position_(__a, __b, __re, __m),
6408 __subs_(__submatches, __submatches + _Np)
6413 template <class _BidirectionalIterator, class _CharT, class _Traits>
6414 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6415 regex_token_iterator(const regex_token_iterator& __x)
6416 : __position_(__x.__position_),
6417 __result_(__x.__result_),
6418 __suffix_(__x.__suffix_),
6420 __subs_(__x.__subs_)
6422 if (__x.__result_ == &__x.__suffix_)
6423 __result_ = &__suffix_;
6424 else if ( __result_ != nullptr )
6425 __establish_result ();
6428 template <class _BidirectionalIterator, class _CharT, class _Traits>
6429 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
6430 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6431 operator=(const regex_token_iterator& __x)
6435 __position_ = __x.__position_;
6436 if (__x.__result_ == &__x.__suffix_)
6437 __result_ = &__suffix_;
6439 __result_ = __x.__result_;
6440 __suffix_ = __x.__suffix_;
6442 __subs_ = __x.__subs_;
6444 if ( __result_ != nullptr && __result_ != &__suffix_ )
6445 __establish_result();
6450 template <class _BidirectionalIterator, class _CharT, class _Traits>
6452 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6453 operator==(const regex_token_iterator& __x) const
6455 if (__result_ == nullptr && __x.__result_ == nullptr)
6457 if (__result_ == &__suffix_ && __x.__result_ == &__x.__suffix_ &&
6458 __suffix_ == __x.__suffix_)
6460 if (__result_ == nullptr || __x.__result_ == nullptr)
6462 if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_)
6464 return __position_ == __x.__position_ && __n_ == __x.__n_ &&
6465 __subs_ == __x.__subs_;
6468 template <class _BidirectionalIterator, class _CharT, class _Traits>
6469 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
6470 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6472 _Position __prev = __position_;
6473 if (__result_ == &__suffix_)
6474 __result_ = nullptr;
6475 else if (static_cast<size_t>(__n_ + 1) < __subs_.size())
6478 __establish_result();
6484 if (__position_ != _Position())
6485 __establish_result();
6488 if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end()
6489 && __prev->suffix().length() != 0)
6491 __suffix_.matched = true;
6492 __suffix_.first = __prev->suffix().first;
6493 __suffix_.second = __prev->suffix().second;
6494 __result_ = &__suffix_;
6497 __result_ = nullptr;
6503 typedef regex_token_iterator<const char*> cregex_token_iterator;
6504 typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
6505 typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
6506 typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
6510 template <class _OutputIterator, class _BidirectionalIterator,
6511 class _Traits, class _CharT>
6513 regex_replace(_OutputIterator __output_iter,
6514 _BidirectionalIterator __first, _BidirectionalIterator __last,
6515 const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
6516 regex_constants::match_flag_type __flags = regex_constants::match_default)
6518 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Iter;
6519 _Iter __i(__first, __last, __e, __flags);
6523 if (!(__flags & regex_constants::format_no_copy))
6524 __output_iter = _VSTD::copy(__first, __last, __output_iter);
6528 sub_match<_BidirectionalIterator> __lm;
6529 for (size_t __len = char_traits<_CharT>::length(__fmt); __i != __eof; ++__i)
6531 if (!(__flags & regex_constants::format_no_copy))
6532 __output_iter = _VSTD::copy(__i->prefix().first, __i->prefix().second, __output_iter);
6533 __output_iter = __i->format(__output_iter, __fmt, __fmt + __len, __flags);
6534 __lm = __i->suffix();
6535 if (__flags & regex_constants::format_first_only)
6538 if (!(__flags & regex_constants::format_no_copy))
6539 __output_iter = _VSTD::copy(__lm.first, __lm.second, __output_iter);
6541 return __output_iter;
6544 template <class _OutputIterator, class _BidirectionalIterator,
6545 class _Traits, class _CharT, class _ST, class _SA>
6546 inline _LIBCPP_INLINE_VISIBILITY
6548 regex_replace(_OutputIterator __output_iter,
6549 _BidirectionalIterator __first, _BidirectionalIterator __last,
6550 const basic_regex<_CharT, _Traits>& __e,
6551 const basic_string<_CharT, _ST, _SA>& __fmt,
6552 regex_constants::match_flag_type __flags = regex_constants::match_default)
6554 return _VSTD::regex_replace(__output_iter, __first, __last, __e, __fmt.c_str(), __flags);
6557 template <class _Traits, class _CharT, class _ST, class _SA, class _FST,
6559 inline _LIBCPP_INLINE_VISIBILITY
6560 basic_string<_CharT, _ST, _SA>
6561 regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6562 const basic_regex<_CharT, _Traits>& __e,
6563 const basic_string<_CharT, _FST, _FSA>& __fmt,
6564 regex_constants::match_flag_type __flags = regex_constants::match_default)
6566 basic_string<_CharT, _ST, _SA> __r;
6567 _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6568 __fmt.c_str(), __flags);
6572 template <class _Traits, class _CharT, class _ST, class _SA>
6573 inline _LIBCPP_INLINE_VISIBILITY
6574 basic_string<_CharT, _ST, _SA>
6575 regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6576 const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
6577 regex_constants::match_flag_type __flags = regex_constants::match_default)
6579 basic_string<_CharT, _ST, _SA> __r;
6580 _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6585 template <class _Traits, class _CharT, class _ST, class _SA>
6586 inline _LIBCPP_INLINE_VISIBILITY
6587 basic_string<_CharT>
6588 regex_replace(const _CharT* __s,
6589 const basic_regex<_CharT, _Traits>& __e,
6590 const basic_string<_CharT, _ST, _SA>& __fmt,
6591 regex_constants::match_flag_type __flags = regex_constants::match_default)
6593 basic_string<_CharT> __r;
6594 _VSTD::regex_replace(back_inserter(__r), __s,
6595 __s + char_traits<_CharT>::length(__s), __e,
6596 __fmt.c_str(), __flags);
6600 template <class _Traits, class _CharT>
6601 inline _LIBCPP_INLINE_VISIBILITY
6602 basic_string<_CharT>
6603 regex_replace(const _CharT* __s,
6604 const basic_regex<_CharT, _Traits>& __e,
6605 const _CharT* __fmt,
6606 regex_constants::match_flag_type __flags = regex_constants::match_default)
6608 basic_string<_CharT> __r;
6609 _VSTD::regex_replace(back_inserter(__r), __s,
6610 __s + char_traits<_CharT>::length(__s), __e,
6615 _LIBCPP_END_NAMESPACE_STD
6619 #endif // _LIBCPP_REGEX