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>
773 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
774 #pragma GCC system_header
778 #include <__undef_macros>
781 #define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096
783 _LIBCPP_BEGIN_NAMESPACE_STD
785 namespace regex_constants
788 // syntax_option_type
790 enum syntax_option_type
804 inline _LIBCPP_INLINE_VISIBILITY
807 operator~(syntax_option_type __x)
809 return syntax_option_type(~int(__x) & 0x1FF);
812 inline _LIBCPP_INLINE_VISIBILITY
815 operator&(syntax_option_type __x, syntax_option_type __y)
817 return syntax_option_type(int(__x) & int(__y));
820 inline _LIBCPP_INLINE_VISIBILITY
823 operator|(syntax_option_type __x, syntax_option_type __y)
825 return syntax_option_type(int(__x) | int(__y));
828 inline _LIBCPP_INLINE_VISIBILITY
831 operator^(syntax_option_type __x, syntax_option_type __y)
833 return syntax_option_type(int(__x) ^ int(__y));
836 inline _LIBCPP_INLINE_VISIBILITY
838 operator&=(syntax_option_type& __x, syntax_option_type __y)
844 inline _LIBCPP_INLINE_VISIBILITY
846 operator|=(syntax_option_type& __x, syntax_option_type __y)
852 inline _LIBCPP_INLINE_VISIBILITY
854 operator^=(syntax_option_type& __x, syntax_option_type __y)
865 match_not_bol = 1 << 0,
866 match_not_eol = 1 << 1,
867 match_not_bow = 1 << 2,
868 match_not_eow = 1 << 3,
870 match_not_null = 1 << 5,
871 match_continuous = 1 << 6,
872 match_prev_avail = 1 << 7,
875 format_no_copy = 1 << 9,
876 format_first_only = 1 << 10,
877 __no_update_pos = 1 << 11,
878 __full_match = 1 << 12
881 inline _LIBCPP_INLINE_VISIBILITY
884 operator~(match_flag_type __x)
886 return match_flag_type(~int(__x) & 0x0FFF);
889 inline _LIBCPP_INLINE_VISIBILITY
892 operator&(match_flag_type __x, match_flag_type __y)
894 return match_flag_type(int(__x) & int(__y));
897 inline _LIBCPP_INLINE_VISIBILITY
900 operator|(match_flag_type __x, match_flag_type __y)
902 return match_flag_type(int(__x) | int(__y));
905 inline _LIBCPP_INLINE_VISIBILITY
908 operator^(match_flag_type __x, match_flag_type __y)
910 return match_flag_type(int(__x) ^ int(__y));
913 inline _LIBCPP_INLINE_VISIBILITY
915 operator&=(match_flag_type& __x, match_flag_type __y)
921 inline _LIBCPP_INLINE_VISIBILITY
923 operator|=(match_flag_type& __x, match_flag_type __y)
929 inline _LIBCPP_INLINE_VISIBILITY
931 operator^=(match_flag_type& __x, match_flag_type __y)
959 class _LIBCPP_EXCEPTION_ABI regex_error
960 : public runtime_error
962 regex_constants::error_type __code_;
964 explicit regex_error(regex_constants::error_type __ecode);
965 virtual ~regex_error() throw();
966 _LIBCPP_INLINE_VISIBILITY
967 regex_constants::error_type code() const {return __code_;}
970 template <regex_constants::error_type _Ev>
971 _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
972 void __throw_regex_error()
974 #ifndef _LIBCPP_NO_EXCEPTIONS
975 throw regex_error(_Ev);
981 template <class _CharT>
982 struct _LIBCPP_TEMPLATE_VIS regex_traits
985 typedef _CharT char_type;
986 typedef basic_string<char_type> string_type;
987 typedef locale locale_type;
988 typedef ctype_base::mask char_class_type;
990 #if defined(__mips__) && defined(__GLIBC__)
991 static const char_class_type __regex_word = static_cast<char_class_type>(_ISbit(15));
993 static const char_class_type __regex_word = 0x80;
998 const ctype<char_type>* __ct_;
999 const collate<char_type>* __col_;
1004 _LIBCPP_INLINE_VISIBILITY
1005 static size_t length(const char_type* __p)
1006 {return char_traits<char_type>::length(__p);}
1007 _LIBCPP_INLINE_VISIBILITY
1008 char_type translate(char_type __c) const {return __c;}
1009 char_type translate_nocase(char_type __c) const;
1010 template <class _ForwardIterator>
1012 transform(_ForwardIterator __f, _ForwardIterator __l) const;
1013 template <class _ForwardIterator>
1014 _LIBCPP_INLINE_VISIBILITY
1016 transform_primary( _ForwardIterator __f, _ForwardIterator __l) const
1017 {return __transform_primary(__f, __l, char_type());}
1018 template <class _ForwardIterator>
1019 _LIBCPP_INLINE_VISIBILITY
1021 lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const
1022 {return __lookup_collatename(__f, __l, char_type());}
1023 template <class _ForwardIterator>
1024 _LIBCPP_INLINE_VISIBILITY
1026 lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1027 bool __icase = false) const
1028 {return __lookup_classname(__f, __l, __icase, char_type());}
1029 bool isctype(char_type __c, char_class_type __m) const;
1030 _LIBCPP_INLINE_VISIBILITY
1031 int value(char_type __ch, int __radix) const
1032 {return __regex_traits_value(__ch, __radix);}
1033 locale_type imbue(locale_type __l);
1034 _LIBCPP_INLINE_VISIBILITY
1035 locale_type getloc()const {return __loc_;}
1040 template <class _ForwardIterator>
1042 __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;
1043 template <class _ForwardIterator>
1045 __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1047 template <class _ForwardIterator>
1049 __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;
1050 template <class _ForwardIterator>
1052 __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1054 template <class _ForwardIterator>
1056 __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1057 bool __icase, char) const;
1058 template <class _ForwardIterator>
1060 __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1061 bool __icase, wchar_t) const;
1063 static int __regex_traits_value(unsigned char __ch, int __radix);
1064 _LIBCPP_INLINE_VISIBILITY
1065 int __regex_traits_value(char __ch, int __radix) const
1066 {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);}
1067 _LIBCPP_INLINE_VISIBILITY
1068 int __regex_traits_value(wchar_t __ch, int __radix) const;
1071 template <class _CharT>
1072 const typename regex_traits<_CharT>::char_class_type
1073 regex_traits<_CharT>::__regex_word;
1075 template <class _CharT>
1076 regex_traits<_CharT>::regex_traits()
1081 template <class _CharT>
1082 typename regex_traits<_CharT>::char_type
1083 regex_traits<_CharT>::translate_nocase(char_type __c) const
1085 return __ct_->tolower(__c);
1088 template <class _CharT>
1089 template <class _ForwardIterator>
1090 typename regex_traits<_CharT>::string_type
1091 regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const
1093 string_type __s(__f, __l);
1094 return __col_->transform(__s.data(), __s.data() + __s.size());
1097 template <class _CharT>
1099 regex_traits<_CharT>::__init()
1101 __ct_ = &use_facet<ctype<char_type> >(__loc_);
1102 __col_ = &use_facet<collate<char_type> >(__loc_);
1105 template <class _CharT>
1106 typename regex_traits<_CharT>::locale_type
1107 regex_traits<_CharT>::imbue(locale_type __l)
1109 locale __r = __loc_;
1115 // transform_primary is very FreeBSD-specific
1117 template <class _CharT>
1118 template <class _ForwardIterator>
1119 typename regex_traits<_CharT>::string_type
1120 regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
1121 _ForwardIterator __l, char) const
1123 const string_type __s(__f, __l);
1124 string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
1139 template <class _CharT>
1140 template <class _ForwardIterator>
1141 typename regex_traits<_CharT>::string_type
1142 regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
1143 _ForwardIterator __l, wchar_t) const
1145 const string_type __s(__f, __l);
1146 string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
1161 // lookup_collatename is very FreeBSD-specific
1163 _LIBCPP_FUNC_VIS string __get_collation_name(const char* __s);
1165 template <class _CharT>
1166 template <class _ForwardIterator>
1167 typename regex_traits<_CharT>::string_type
1168 regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
1169 _ForwardIterator __l, char) const
1171 string_type __s(__f, __l);
1175 __r = __get_collation_name(__s.c_str());
1176 if (__r.empty() && __s.size() <= 2)
1178 __r = __col_->transform(__s.data(), __s.data() + __s.size());
1179 if (__r.size() == 1 || __r.size() == 12)
1188 template <class _CharT>
1189 template <class _ForwardIterator>
1190 typename regex_traits<_CharT>::string_type
1191 regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
1192 _ForwardIterator __l, wchar_t) const
1194 string_type __s(__f, __l);
1196 __n.reserve(__s.size());
1197 for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
1200 if (static_cast<unsigned>(*__i) >= 127)
1201 return string_type();
1202 __n.push_back(char(*__i));
1207 __n = __get_collation_name(__n.c_str());
1209 __r.assign(__n.begin(), __n.end());
1210 else if (__s.size() <= 2)
1212 __r = __col_->transform(__s.data(), __s.data() + __s.size());
1213 if (__r.size() == 1 || __r.size() == 3)
1224 regex_traits<char>::char_class_type _LIBCPP_FUNC_VIS
1225 __get_classname(const char* __s, bool __icase);
1227 template <class _CharT>
1228 template <class _ForwardIterator>
1229 typename regex_traits<_CharT>::char_class_type
1230 regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
1231 _ForwardIterator __l,
1232 bool __icase, char) const
1234 string_type __s(__f, __l);
1235 __ct_->tolower(&__s[0], &__s[0] + __s.size());
1236 return __get_classname(__s.c_str(), __icase);
1239 template <class _CharT>
1240 template <class _ForwardIterator>
1241 typename regex_traits<_CharT>::char_class_type
1242 regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
1243 _ForwardIterator __l,
1244 bool __icase, wchar_t) const
1246 string_type __s(__f, __l);
1247 __ct_->tolower(&__s[0], &__s[0] + __s.size());
1249 __n.reserve(__s.size());
1250 for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
1253 if (static_cast<unsigned>(*__i) >= 127)
1254 return char_class_type();
1255 __n.push_back(char(*__i));
1257 return __get_classname(__n.c_str(), __icase);
1260 template <class _CharT>
1262 regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const
1264 if (__ct_->is(__m, __c))
1266 return (__c == '_' && (__m & __regex_word));
1269 template <class _CharT>
1271 regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix)
1273 if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7'
1277 if ((__ch & 0xFEu) == 0x38) // '8' <= __ch && __ch <= '9'
1281 __ch |= 0x20; // tolower
1282 if ('a' <= __ch && __ch <= 'f')
1283 return __ch - ('a' - 10);
1289 template <class _CharT>
1292 regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const
1294 return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix);
1297 template <class _CharT> class __node;
1299 template <class _BidirectionalIterator> class _LIBCPP_TEMPLATE_VIS sub_match;
1301 template <class _BidirectionalIterator,
1302 class _Allocator = allocator<sub_match<_BidirectionalIterator> > >
1303 class _LIBCPP_TEMPLATE_VIS match_results;
1305 template <class _CharT>
1310 __end_state = -1000,
1311 __consume_input, // -999
1312 __begin_marked_expr, // -998
1313 __end_marked_expr, // -997
1314 __pop_state, // -996
1315 __accept_and_consume, // -995
1316 __accept_but_not_consume, // -994
1323 const _CharT* __first_;
1324 const _CharT* __current_;
1325 const _CharT* __last_;
1326 vector<sub_match<const _CharT*> > __sub_matches_;
1327 vector<pair<size_t, const _CharT*> > __loop_data_;
1328 const __node<_CharT>* __node_;
1329 regex_constants::match_flag_type __flags_;
1332 _LIBCPP_INLINE_VISIBILITY
1334 : __do_(0), __first_(nullptr), __current_(nullptr), __last_(nullptr),
1335 __node_(nullptr), __flags_() {}
1340 template <class _CharT>
1343 __node(const __node&);
1344 __node& operator=(const __node&);
1346 typedef _VSTD::__state<_CharT> __state;
1348 _LIBCPP_INLINE_VISIBILITY
1350 _LIBCPP_INLINE_VISIBILITY
1351 virtual ~__node() {}
1353 _LIBCPP_INLINE_VISIBILITY
1354 virtual void __exec(__state&) const {};
1355 _LIBCPP_INLINE_VISIBILITY
1356 virtual void __exec_split(bool, __state&) const {};
1361 template <class _CharT>
1363 : public __node<_CharT>
1366 typedef _VSTD::__state<_CharT> __state;
1368 _LIBCPP_INLINE_VISIBILITY
1371 virtual void __exec(__state&) const;
1374 template <class _CharT>
1376 __end_state<_CharT>::__exec(__state& __s) const
1378 __s.__do_ = __state::__end_state;
1383 template <class _CharT>
1384 class __has_one_state
1385 : public __node<_CharT>
1387 __node<_CharT>* __first_;
1390 _LIBCPP_INLINE_VISIBILITY
1391 explicit __has_one_state(__node<_CharT>* __s)
1394 _LIBCPP_INLINE_VISIBILITY
1395 __node<_CharT>* first() const {return __first_;}
1396 _LIBCPP_INLINE_VISIBILITY
1397 __node<_CharT>*& first() {return __first_;}
1402 template <class _CharT>
1403 class __owns_one_state
1404 : public __has_one_state<_CharT>
1406 typedef __has_one_state<_CharT> base;
1409 _LIBCPP_INLINE_VISIBILITY
1410 explicit __owns_one_state(__node<_CharT>* __s)
1413 virtual ~__owns_one_state();
1416 template <class _CharT>
1417 __owns_one_state<_CharT>::~__owns_one_state()
1419 delete this->first();
1424 template <class _CharT>
1426 : public __owns_one_state<_CharT>
1428 typedef __owns_one_state<_CharT> base;
1431 typedef _VSTD::__state<_CharT> __state;
1433 _LIBCPP_INLINE_VISIBILITY
1434 explicit __empty_state(__node<_CharT>* __s)
1437 virtual void __exec(__state&) const;
1440 template <class _CharT>
1442 __empty_state<_CharT>::__exec(__state& __s) const
1444 __s.__do_ = __state::__accept_but_not_consume;
1445 __s.__node_ = this->first();
1448 // __empty_non_own_state
1450 template <class _CharT>
1451 class __empty_non_own_state
1452 : public __has_one_state<_CharT>
1454 typedef __has_one_state<_CharT> base;
1457 typedef _VSTD::__state<_CharT> __state;
1459 _LIBCPP_INLINE_VISIBILITY
1460 explicit __empty_non_own_state(__node<_CharT>* __s)
1463 virtual void __exec(__state&) const;
1466 template <class _CharT>
1468 __empty_non_own_state<_CharT>::__exec(__state& __s) const
1470 __s.__do_ = __state::__accept_but_not_consume;
1471 __s.__node_ = this->first();
1474 // __repeat_one_loop
1476 template <class _CharT>
1477 class __repeat_one_loop
1478 : public __has_one_state<_CharT>
1480 typedef __has_one_state<_CharT> base;
1483 typedef _VSTD::__state<_CharT> __state;
1485 _LIBCPP_INLINE_VISIBILITY
1486 explicit __repeat_one_loop(__node<_CharT>* __s)
1489 virtual void __exec(__state&) const;
1492 template <class _CharT>
1494 __repeat_one_loop<_CharT>::__exec(__state& __s) const
1496 __s.__do_ = __state::__repeat;
1497 __s.__node_ = this->first();
1500 // __owns_two_states
1502 template <class _CharT>
1503 class __owns_two_states
1504 : public __owns_one_state<_CharT>
1506 typedef __owns_one_state<_CharT> base;
1511 _LIBCPP_INLINE_VISIBILITY
1512 explicit __owns_two_states(__node<_CharT>* __s1, base* __s2)
1513 : base(__s1), __second_(__s2) {}
1515 virtual ~__owns_two_states();
1517 _LIBCPP_INLINE_VISIBILITY
1518 base* second() const {return __second_;}
1519 _LIBCPP_INLINE_VISIBILITY
1520 base*& second() {return __second_;}
1523 template <class _CharT>
1524 __owns_two_states<_CharT>::~__owns_two_states()
1531 template <class _CharT>
1533 : public __owns_two_states<_CharT>
1535 typedef __owns_two_states<_CharT> base;
1539 unsigned __loop_id_;
1540 unsigned __mexp_begin_;
1541 unsigned __mexp_end_;
1545 typedef _VSTD::__state<_CharT> __state;
1547 _LIBCPP_INLINE_VISIBILITY
1548 explicit __loop(unsigned __loop_id,
1549 __node<_CharT>* __s1, __owns_one_state<_CharT>* __s2,
1550 unsigned __mexp_begin, unsigned __mexp_end,
1551 bool __greedy = true,
1553 size_t __max = numeric_limits<size_t>::max())
1554 : base(__s1, __s2), __min_(__min), __max_(__max), __loop_id_(__loop_id),
1555 __mexp_begin_(__mexp_begin), __mexp_end_(__mexp_end),
1556 __greedy_(__greedy) {}
1558 virtual void __exec(__state& __s) const;
1559 virtual void __exec_split(bool __second, __state& __s) const;
1562 _LIBCPP_INLINE_VISIBILITY
1563 void __init_repeat(__state& __s) const
1565 __s.__loop_data_[__loop_id_].second = __s.__current_;
1566 for (size_t __i = __mexp_begin_-1; __i != __mexp_end_-1; ++__i)
1568 __s.__sub_matches_[__i].first = __s.__last_;
1569 __s.__sub_matches_[__i].second = __s.__last_;
1570 __s.__sub_matches_[__i].matched = false;
1575 template <class _CharT>
1577 __loop<_CharT>::__exec(__state& __s) const
1579 if (__s.__do_ == __state::__repeat)
1581 bool __do_repeat = ++__s.__loop_data_[__loop_id_].first < __max_;
1582 bool __do_alt = __s.__loop_data_[__loop_id_].first >= __min_;
1583 if (__do_repeat && __do_alt &&
1584 __s.__loop_data_[__loop_id_].second == __s.__current_)
1585 __do_repeat = false;
1586 if (__do_repeat && __do_alt)
1587 __s.__do_ = __state::__split;
1588 else if (__do_repeat)
1590 __s.__do_ = __state::__accept_but_not_consume;
1591 __s.__node_ = this->first();
1596 __s.__do_ = __state::__accept_but_not_consume;
1597 __s.__node_ = this->second();
1602 __s.__loop_data_[__loop_id_].first = 0;
1603 bool __do_repeat = 0 < __max_;
1604 bool __do_alt = 0 >= __min_;
1605 if (__do_repeat && __do_alt)
1606 __s.__do_ = __state::__split;
1607 else if (__do_repeat)
1609 __s.__do_ = __state::__accept_but_not_consume;
1610 __s.__node_ = this->first();
1615 __s.__do_ = __state::__accept_but_not_consume;
1616 __s.__node_ = this->second();
1621 template <class _CharT>
1623 __loop<_CharT>::__exec_split(bool __second, __state& __s) const
1625 __s.__do_ = __state::__accept_but_not_consume;
1626 if (__greedy_ != __second)
1628 __s.__node_ = this->first();
1632 __s.__node_ = this->second();
1637 template <class _CharT>
1639 : public __owns_two_states<_CharT>
1641 typedef __owns_two_states<_CharT> base;
1644 typedef _VSTD::__state<_CharT> __state;
1646 _LIBCPP_INLINE_VISIBILITY
1647 explicit __alternate(__owns_one_state<_CharT>* __s1,
1648 __owns_one_state<_CharT>* __s2)
1649 : base(__s1, __s2) {}
1651 virtual void __exec(__state& __s) const;
1652 virtual void __exec_split(bool __second, __state& __s) const;
1655 template <class _CharT>
1657 __alternate<_CharT>::__exec(__state& __s) const
1659 __s.__do_ = __state::__split;
1662 template <class _CharT>
1664 __alternate<_CharT>::__exec_split(bool __second, __state& __s) const
1666 __s.__do_ = __state::__accept_but_not_consume;
1668 __s.__node_ = this->second();
1670 __s.__node_ = this->first();
1673 // __begin_marked_subexpression
1675 template <class _CharT>
1676 class __begin_marked_subexpression
1677 : public __owns_one_state<_CharT>
1679 typedef __owns_one_state<_CharT> base;
1683 typedef _VSTD::__state<_CharT> __state;
1685 _LIBCPP_INLINE_VISIBILITY
1686 explicit __begin_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
1687 : base(__s), __mexp_(__mexp) {}
1689 virtual void __exec(__state&) const;
1692 template <class _CharT>
1694 __begin_marked_subexpression<_CharT>::__exec(__state& __s) const
1696 __s.__do_ = __state::__accept_but_not_consume;
1697 __s.__sub_matches_[__mexp_-1].first = __s.__current_;
1698 __s.__node_ = this->first();
1701 // __end_marked_subexpression
1703 template <class _CharT>
1704 class __end_marked_subexpression
1705 : public __owns_one_state<_CharT>
1707 typedef __owns_one_state<_CharT> base;
1711 typedef _VSTD::__state<_CharT> __state;
1713 _LIBCPP_INLINE_VISIBILITY
1714 explicit __end_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
1715 : base(__s), __mexp_(__mexp) {}
1717 virtual void __exec(__state&) const;
1720 template <class _CharT>
1722 __end_marked_subexpression<_CharT>::__exec(__state& __s) const
1724 __s.__do_ = __state::__accept_but_not_consume;
1725 __s.__sub_matches_[__mexp_-1].second = __s.__current_;
1726 __s.__sub_matches_[__mexp_-1].matched = true;
1727 __s.__node_ = this->first();
1732 template <class _CharT>
1734 : public __owns_one_state<_CharT>
1736 typedef __owns_one_state<_CharT> base;
1740 typedef _VSTD::__state<_CharT> __state;
1742 _LIBCPP_INLINE_VISIBILITY
1743 explicit __back_ref(unsigned __mexp, __node<_CharT>* __s)
1744 : base(__s), __mexp_(__mexp) {}
1746 virtual void __exec(__state&) const;
1749 template <class _CharT>
1751 __back_ref<_CharT>::__exec(__state& __s) const
1753 if (__mexp_ > __s.__sub_matches_.size())
1754 __throw_regex_error<regex_constants::error_backref>();
1755 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1758 ptrdiff_t __len = __sm.second - __sm.first;
1759 if (__s.__last_ - __s.__current_ >= __len &&
1760 _VSTD::equal(__sm.first, __sm.second, __s.__current_))
1762 __s.__do_ = __state::__accept_but_not_consume;
1763 __s.__current_ += __len;
1764 __s.__node_ = this->first();
1768 __s.__do_ = __state::__reject;
1769 __s.__node_ = nullptr;
1774 __s.__do_ = __state::__reject;
1775 __s.__node_ = nullptr;
1781 template <class _CharT, class _Traits>
1782 class __back_ref_icase
1783 : public __owns_one_state<_CharT>
1785 typedef __owns_one_state<_CharT> base;
1790 typedef _VSTD::__state<_CharT> __state;
1792 _LIBCPP_INLINE_VISIBILITY
1793 explicit __back_ref_icase(const _Traits& __traits, unsigned __mexp,
1794 __node<_CharT>* __s)
1795 : base(__s), __traits_(__traits), __mexp_(__mexp) {}
1797 virtual void __exec(__state&) const;
1800 template <class _CharT, class _Traits>
1802 __back_ref_icase<_CharT, _Traits>::__exec(__state& __s) const
1804 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1807 ptrdiff_t __len = __sm.second - __sm.first;
1808 if (__s.__last_ - __s.__current_ >= __len)
1810 for (ptrdiff_t __i = 0; __i < __len; ++__i)
1812 if (__traits_.translate_nocase(__sm.first[__i]) !=
1813 __traits_.translate_nocase(__s.__current_[__i]))
1816 __s.__do_ = __state::__accept_but_not_consume;
1817 __s.__current_ += __len;
1818 __s.__node_ = this->first();
1822 __s.__do_ = __state::__reject;
1823 __s.__node_ = nullptr;
1829 __s.__do_ = __state::__reject;
1830 __s.__node_ = nullptr;
1834 // __back_ref_collate
1836 template <class _CharT, class _Traits>
1837 class __back_ref_collate
1838 : public __owns_one_state<_CharT>
1840 typedef __owns_one_state<_CharT> base;
1845 typedef _VSTD::__state<_CharT> __state;
1847 _LIBCPP_INLINE_VISIBILITY
1848 explicit __back_ref_collate(const _Traits& __traits, unsigned __mexp,
1849 __node<_CharT>* __s)
1850 : base(__s), __traits_(__traits), __mexp_(__mexp) {}
1852 virtual void __exec(__state&) const;
1855 template <class _CharT, class _Traits>
1857 __back_ref_collate<_CharT, _Traits>::__exec(__state& __s) const
1859 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1862 ptrdiff_t __len = __sm.second - __sm.first;
1863 if (__s.__last_ - __s.__current_ >= __len)
1865 for (ptrdiff_t __i = 0; __i < __len; ++__i)
1867 if (__traits_.translate(__sm.first[__i]) !=
1868 __traits_.translate(__s.__current_[__i]))
1871 __s.__do_ = __state::__accept_but_not_consume;
1872 __s.__current_ += __len;
1873 __s.__node_ = this->first();
1877 __s.__do_ = __state::__reject;
1878 __s.__node_ = nullptr;
1884 __s.__do_ = __state::__reject;
1885 __s.__node_ = nullptr;
1891 template <class _CharT, class _Traits>
1892 class __word_boundary
1893 : public __owns_one_state<_CharT>
1895 typedef __owns_one_state<_CharT> base;
1900 typedef _VSTD::__state<_CharT> __state;
1902 _LIBCPP_INLINE_VISIBILITY
1903 explicit __word_boundary(const _Traits& __traits, bool __invert,
1904 __node<_CharT>* __s)
1905 : base(__s), __traits_(__traits), __invert_(__invert) {}
1907 virtual void __exec(__state&) const;
1910 template <class _CharT, class _Traits>
1912 __word_boundary<_CharT, _Traits>::__exec(__state& __s) const
1914 bool __is_word_b = false;
1915 if (__s.__first_ != __s.__last_)
1917 if (__s.__current_ == __s.__last_)
1919 if (!(__s.__flags_ & regex_constants::match_not_eow))
1921 _CharT __c = __s.__current_[-1];
1922 __is_word_b = __c == '_' ||
1923 __traits_.isctype(__c, ctype_base::alnum);
1926 else if (__s.__current_ == __s.__first_ &&
1927 !(__s.__flags_ & regex_constants::match_prev_avail))
1929 if (!(__s.__flags_ & regex_constants::match_not_bow))
1931 _CharT __c = *__s.__current_;
1932 __is_word_b = __c == '_' ||
1933 __traits_.isctype(__c, ctype_base::alnum);
1938 _CharT __c1 = __s.__current_[-1];
1939 _CharT __c2 = *__s.__current_;
1940 bool __is_c1_b = __c1 == '_' ||
1941 __traits_.isctype(__c1, ctype_base::alnum);
1942 bool __is_c2_b = __c2 == '_' ||
1943 __traits_.isctype(__c2, ctype_base::alnum);
1944 __is_word_b = __is_c1_b != __is_c2_b;
1947 if (__is_word_b != __invert_)
1949 __s.__do_ = __state::__accept_but_not_consume;
1950 __s.__node_ = this->first();
1954 __s.__do_ = __state::__reject;
1955 __s.__node_ = nullptr;
1961 template <class _CharT>
1963 : public __owns_one_state<_CharT>
1965 typedef __owns_one_state<_CharT> base;
1968 typedef _VSTD::__state<_CharT> __state;
1970 _LIBCPP_INLINE_VISIBILITY
1971 __l_anchor(__node<_CharT>* __s)
1974 virtual void __exec(__state&) const;
1977 template <class _CharT>
1979 __l_anchor<_CharT>::__exec(__state& __s) const
1981 if (__s.__at_first_ && __s.__current_ == __s.__first_ &&
1982 !(__s.__flags_ & regex_constants::match_not_bol))
1984 __s.__do_ = __state::__accept_but_not_consume;
1985 __s.__node_ = this->first();
1989 __s.__do_ = __state::__reject;
1990 __s.__node_ = nullptr;
1996 template <class _CharT>
1998 : public __owns_one_state<_CharT>
2000 typedef __owns_one_state<_CharT> base;
2003 typedef _VSTD::__state<_CharT> __state;
2005 _LIBCPP_INLINE_VISIBILITY
2006 __r_anchor(__node<_CharT>* __s)
2009 virtual void __exec(__state&) const;
2012 template <class _CharT>
2014 __r_anchor<_CharT>::__exec(__state& __s) const
2016 if (__s.__current_ == __s.__last_ &&
2017 !(__s.__flags_ & regex_constants::match_not_eol))
2019 __s.__do_ = __state::__accept_but_not_consume;
2020 __s.__node_ = this->first();
2024 __s.__do_ = __state::__reject;
2025 __s.__node_ = nullptr;
2031 template <class _CharT>
2033 : public __owns_one_state<_CharT>
2035 typedef __owns_one_state<_CharT> base;
2038 typedef _VSTD::__state<_CharT> __state;
2040 _LIBCPP_INLINE_VISIBILITY
2041 __match_any(__node<_CharT>* __s)
2044 virtual void __exec(__state&) const;
2047 template <class _CharT>
2049 __match_any<_CharT>::__exec(__state& __s) const
2051 if (__s.__current_ != __s.__last_ && *__s.__current_ != 0)
2053 __s.__do_ = __state::__accept_and_consume;
2055 __s.__node_ = this->first();
2059 __s.__do_ = __state::__reject;
2060 __s.__node_ = nullptr;
2064 // __match_any_but_newline
2066 template <class _CharT>
2067 class __match_any_but_newline
2068 : public __owns_one_state<_CharT>
2070 typedef __owns_one_state<_CharT> base;
2073 typedef _VSTD::__state<_CharT> __state;
2075 _LIBCPP_INLINE_VISIBILITY
2076 __match_any_but_newline(__node<_CharT>* __s)
2079 virtual void __exec(__state&) const;
2082 template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const;
2083 template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<wchar_t>::__exec(__state&) const;
2087 template <class _CharT>
2089 : public __owns_one_state<_CharT>
2091 typedef __owns_one_state<_CharT> base;
2095 __match_char(const __match_char&);
2096 __match_char& operator=(const __match_char&);
2098 typedef _VSTD::__state<_CharT> __state;
2100 _LIBCPP_INLINE_VISIBILITY
2101 __match_char(_CharT __c, __node<_CharT>* __s)
2102 : base(__s), __c_(__c) {}
2104 virtual void __exec(__state&) const;
2107 template <class _CharT>
2109 __match_char<_CharT>::__exec(__state& __s) const
2111 if (__s.__current_ != __s.__last_ && *__s.__current_ == __c_)
2113 __s.__do_ = __state::__accept_and_consume;
2115 __s.__node_ = this->first();
2119 __s.__do_ = __state::__reject;
2120 __s.__node_ = nullptr;
2124 // __match_char_icase
2126 template <class _CharT, class _Traits>
2127 class __match_char_icase
2128 : public __owns_one_state<_CharT>
2130 typedef __owns_one_state<_CharT> base;
2135 __match_char_icase(const __match_char_icase&);
2136 __match_char_icase& operator=(const __match_char_icase&);
2138 typedef _VSTD::__state<_CharT> __state;
2140 _LIBCPP_INLINE_VISIBILITY
2141 __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
2142 : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {}
2144 virtual void __exec(__state&) const;
2147 template <class _CharT, class _Traits>
2149 __match_char_icase<_CharT, _Traits>::__exec(__state& __s) const
2151 if (__s.__current_ != __s.__last_ &&
2152 __traits_.translate_nocase(*__s.__current_) == __c_)
2154 __s.__do_ = __state::__accept_and_consume;
2156 __s.__node_ = this->first();
2160 __s.__do_ = __state::__reject;
2161 __s.__node_ = nullptr;
2165 // __match_char_collate
2167 template <class _CharT, class _Traits>
2168 class __match_char_collate
2169 : public __owns_one_state<_CharT>
2171 typedef __owns_one_state<_CharT> base;
2176 __match_char_collate(const __match_char_collate&);
2177 __match_char_collate& operator=(const __match_char_collate&);
2179 typedef _VSTD::__state<_CharT> __state;
2181 _LIBCPP_INLINE_VISIBILITY
2182 __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
2183 : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {}
2185 virtual void __exec(__state&) const;
2188 template <class _CharT, class _Traits>
2190 __match_char_collate<_CharT, _Traits>::__exec(__state& __s) const
2192 if (__s.__current_ != __s.__last_ &&
2193 __traits_.translate(*__s.__current_) == __c_)
2195 __s.__do_ = __state::__accept_and_consume;
2197 __s.__node_ = this->first();
2201 __s.__do_ = __state::__reject;
2202 __s.__node_ = nullptr;
2206 // __bracket_expression
2208 template <class _CharT, class _Traits>
2209 class __bracket_expression
2210 : public __owns_one_state<_CharT>
2212 typedef __owns_one_state<_CharT> base;
2213 typedef typename _Traits::string_type string_type;
2216 vector<_CharT> __chars_;
2217 vector<_CharT> __neg_chars_;
2218 vector<pair<string_type, string_type> > __ranges_;
2219 vector<pair<_CharT, _CharT> > __digraphs_;
2220 vector<string_type> __equivalences_;
2221 typename regex_traits<_CharT>::char_class_type __mask_;
2222 typename regex_traits<_CharT>::char_class_type __neg_mask_;
2226 bool __might_have_digraph_;
2228 __bracket_expression(const __bracket_expression&);
2229 __bracket_expression& operator=(const __bracket_expression&);
2231 typedef _VSTD::__state<_CharT> __state;
2233 _LIBCPP_INLINE_VISIBILITY
2234 __bracket_expression(const _Traits& __traits, __node<_CharT>* __s,
2235 bool __negate, bool __icase, bool __collate)
2236 : base(__s), __traits_(__traits), __mask_(), __neg_mask_(),
2237 __negate_(__negate), __icase_(__icase), __collate_(__collate),
2238 __might_have_digraph_(__traits_.getloc().name() != "C") {}
2240 virtual void __exec(__state&) const;
2242 _LIBCPP_INLINE_VISIBILITY
2243 bool __negated() const {return __negate_;}
2245 _LIBCPP_INLINE_VISIBILITY
2246 void __add_char(_CharT __c)
2249 __chars_.push_back(__traits_.translate_nocase(__c));
2250 else if (__collate_)
2251 __chars_.push_back(__traits_.translate(__c));
2253 __chars_.push_back(__c);
2255 _LIBCPP_INLINE_VISIBILITY
2256 void __add_neg_char(_CharT __c)
2259 __neg_chars_.push_back(__traits_.translate_nocase(__c));
2260 else if (__collate_)
2261 __neg_chars_.push_back(__traits_.translate(__c));
2263 __neg_chars_.push_back(__c);
2265 _LIBCPP_INLINE_VISIBILITY
2266 void __add_range(string_type __b, string_type __e)
2272 for (size_t __i = 0; __i < __b.size(); ++__i)
2273 __b[__i] = __traits_.translate_nocase(__b[__i]);
2274 for (size_t __i = 0; __i < __e.size(); ++__i)
2275 __e[__i] = __traits_.translate_nocase(__e[__i]);
2279 for (size_t __i = 0; __i < __b.size(); ++__i)
2280 __b[__i] = __traits_.translate(__b[__i]);
2281 for (size_t __i = 0; __i < __e.size(); ++__i)
2282 __e[__i] = __traits_.translate(__e[__i]);
2284 __ranges_.push_back(make_pair(
2285 __traits_.transform(__b.begin(), __b.end()),
2286 __traits_.transform(__e.begin(), __e.end())));
2290 if (__b.size() != 1 || __e.size() != 1)
2291 __throw_regex_error<regex_constants::error_collate>();
2294 __b[0] = __traits_.translate_nocase(__b[0]);
2295 __e[0] = __traits_.translate_nocase(__e[0]);
2297 __ranges_.push_back(make_pair(_VSTD::move(__b), _VSTD::move(__e)));
2300 _LIBCPP_INLINE_VISIBILITY
2301 void __add_digraph(_CharT __c1, _CharT __c2)
2304 __digraphs_.push_back(make_pair(__traits_.translate_nocase(__c1),
2305 __traits_.translate_nocase(__c2)));
2306 else if (__collate_)
2307 __digraphs_.push_back(make_pair(__traits_.translate(__c1),
2308 __traits_.translate(__c2)));
2310 __digraphs_.push_back(make_pair(__c1, __c2));
2312 _LIBCPP_INLINE_VISIBILITY
2313 void __add_equivalence(const string_type& __s)
2314 {__equivalences_.push_back(__s);}
2315 _LIBCPP_INLINE_VISIBILITY
2316 void __add_class(typename regex_traits<_CharT>::char_class_type __mask)
2317 {__mask_ |= __mask;}
2318 _LIBCPP_INLINE_VISIBILITY
2319 void __add_neg_class(typename regex_traits<_CharT>::char_class_type __mask)
2320 {__neg_mask_ |= __mask;}
2323 template <class _CharT, class _Traits>
2325 __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const
2327 bool __found = false;
2328 unsigned __consumed = 0;
2329 if (__s.__current_ != __s.__last_)
2332 if (__might_have_digraph_)
2334 const _CharT* __next = _VSTD::next(__s.__current_);
2335 if (__next != __s.__last_)
2337 pair<_CharT, _CharT> __ch2(*__s.__current_, *__next);
2340 __ch2.first = __traits_.translate_nocase(__ch2.first);
2341 __ch2.second = __traits_.translate_nocase(__ch2.second);
2343 else if (__collate_)
2345 __ch2.first = __traits_.translate(__ch2.first);
2346 __ch2.second = __traits_.translate(__ch2.second);
2348 if (!__traits_.lookup_collatename(&__ch2.first, &__ch2.first+2).empty())
2350 // __ch2 is a digraph in this locale
2352 for (size_t __i = 0; __i < __digraphs_.size(); ++__i)
2354 if (__ch2 == __digraphs_[__i])
2360 if (__collate_ && !__ranges_.empty())
2362 string_type __s2 = __traits_.transform(&__ch2.first,
2364 for (size_t __i = 0; __i < __ranges_.size(); ++__i)
2366 if (__ranges_[__i].first <= __s2 &&
2367 __s2 <= __ranges_[__i].second)
2374 if (!__equivalences_.empty())
2376 string_type __s2 = __traits_.transform_primary(&__ch2.first,
2378 for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
2380 if (__s2 == __equivalences_[__i])
2387 if (__traits_.isctype(__ch2.first, __mask_) &&
2388 __traits_.isctype(__ch2.second, __mask_))
2393 if (!__traits_.isctype(__ch2.first, __neg_mask_) &&
2394 !__traits_.isctype(__ch2.second, __neg_mask_))
2403 // test *__s.__current_ as not a digraph
2404 _CharT __ch = *__s.__current_;
2406 __ch = __traits_.translate_nocase(__ch);
2407 else if (__collate_)
2408 __ch = __traits_.translate(__ch);
2409 for (size_t __i = 0; __i < __chars_.size(); ++__i)
2411 if (__ch == __chars_[__i])
2417 // When there's at least one of __neg_chars_ and __neg_mask_, the set
2418 // of "__found" chars is
2419 // union(complement(union(__neg_chars_, __neg_mask_)),
2422 // It doesn't make sense to check this when there are no __neg_chars_
2423 // and no __neg_mask_.
2424 if (!(__neg_mask_ == 0 && __neg_chars_.empty()))
2426 const bool __in_neg_mask = __traits_.isctype(__ch, __neg_mask_);
2427 const bool __in_neg_chars =
2428 std::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) !=
2430 if (!(__in_neg_mask || __in_neg_chars))
2436 if (!__ranges_.empty())
2438 string_type __s2 = __collate_ ?
2439 __traits_.transform(&__ch, &__ch + 1) :
2440 string_type(1, __ch);
2441 for (size_t __i = 0; __i < __ranges_.size(); ++__i)
2443 if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second)
2450 if (!__equivalences_.empty())
2452 string_type __s2 = __traits_.transform_primary(&__ch, &__ch + 1);
2453 for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
2455 if (__s2 == __equivalences_[__i])
2462 if (__traits_.isctype(__ch, __mask_))
2469 __found = __negate_; // force reject
2471 if (__found != __negate_)
2473 __s.__do_ = __state::__accept_and_consume;
2474 __s.__current_ += __consumed;
2475 __s.__node_ = this->first();
2479 __s.__do_ = __state::__reject;
2480 __s.__node_ = nullptr;
2484 template <class _CharT, class _Traits> class __lookahead;
2486 template <class _CharT, class _Traits = regex_traits<_CharT> >
2487 class _LIBCPP_TEMPLATE_VIS basic_regex
2491 typedef _CharT value_type;
2492 typedef _Traits traits_type;
2493 typedef typename _Traits::string_type string_type;
2494 typedef regex_constants::syntax_option_type flag_type;
2495 typedef typename _Traits::locale_type locale_type;
2500 unsigned __marked_count_;
2501 unsigned __loop_count_;
2503 shared_ptr<__empty_state<_CharT> > __start_;
2504 __owns_one_state<_CharT>* __end_;
2506 typedef _VSTD::__state<_CharT> __state;
2507 typedef _VSTD::__node<_CharT> __node;
2511 static const regex_constants::syntax_option_type icase = regex_constants::icase;
2512 static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
2513 static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
2514 static const regex_constants::syntax_option_type collate = regex_constants::collate;
2515 static const regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
2516 static const regex_constants::syntax_option_type basic = regex_constants::basic;
2517 static const regex_constants::syntax_option_type extended = regex_constants::extended;
2518 static const regex_constants::syntax_option_type awk = regex_constants::awk;
2519 static const regex_constants::syntax_option_type grep = regex_constants::grep;
2520 static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
2522 // construct/copy/destroy:
2523 _LIBCPP_INLINE_VISIBILITY
2525 : __flags_(), __marked_count_(0), __loop_count_(0), __open_count_(0),
2528 _LIBCPP_INLINE_VISIBILITY
2529 explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
2530 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2532 {__parse(__p, __p + __traits_.length(__p));}
2533 _LIBCPP_INLINE_VISIBILITY
2534 basic_regex(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
2535 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2537 {__parse(__p, __p + __len);}
2538 // basic_regex(const basic_regex&) = default;
2539 // basic_regex(basic_regex&&) = default;
2540 template <class _ST, class _SA>
2541 _LIBCPP_INLINE_VISIBILITY
2542 explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p,
2543 flag_type __f = regex_constants::ECMAScript)
2544 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2546 {__parse(__p.begin(), __p.end());}
2547 template <class _ForwardIterator>
2548 _LIBCPP_INLINE_VISIBILITY
2549 basic_regex(_ForwardIterator __first, _ForwardIterator __last,
2550 flag_type __f = regex_constants::ECMAScript)
2551 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2553 {__parse(__first, __last);}
2554 #ifndef _LIBCPP_CXX03_LANG
2555 _LIBCPP_INLINE_VISIBILITY
2556 basic_regex(initializer_list<value_type> __il,
2557 flag_type __f = regex_constants::ECMAScript)
2558 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2560 {__parse(__il.begin(), __il.end());}
2561 #endif // _LIBCPP_CXX03_LANG
2563 // ~basic_regex() = default;
2565 // basic_regex& operator=(const basic_regex&) = default;
2566 // basic_regex& operator=(basic_regex&&) = default;
2567 _LIBCPP_INLINE_VISIBILITY
2568 basic_regex& operator=(const value_type* __p)
2569 {return assign(__p);}
2570 #ifndef _LIBCPP_CXX03_LANG
2571 _LIBCPP_INLINE_VISIBILITY
2572 basic_regex& operator=(initializer_list<value_type> __il)
2573 {return assign(__il);}
2574 #endif // _LIBCPP_CXX03_LANG
2575 template <class _ST, class _SA>
2576 _LIBCPP_INLINE_VISIBILITY
2577 basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p)
2578 {return assign(__p);}
2581 _LIBCPP_INLINE_VISIBILITY
2582 basic_regex& assign(const basic_regex& __that)
2583 {return *this = __that;}
2584 #ifndef _LIBCPP_CXX03_LANG
2585 _LIBCPP_INLINE_VISIBILITY
2586 basic_regex& assign(basic_regex&& __that) _NOEXCEPT
2587 {return *this = _VSTD::move(__that);}
2589 _LIBCPP_INLINE_VISIBILITY
2590 basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
2591 {return assign(__p, __p + __traits_.length(__p), __f);}
2592 _LIBCPP_INLINE_VISIBILITY
2593 basic_regex& assign(const value_type* __p, size_t __len, flag_type __f)
2594 {return assign(__p, __p + __len, __f);}
2595 template <class _ST, class _SA>
2596 _LIBCPP_INLINE_VISIBILITY
2597 basic_regex& assign(const basic_string<value_type, _ST, _SA>& __s,
2598 flag_type __f = regex_constants::ECMAScript)
2599 {return assign(__s.begin(), __s.end(), __f);}
2601 template <class _InputIterator>
2602 _LIBCPP_INLINE_VISIBILITY
2605 __is_input_iterator <_InputIterator>::value &&
2606 !__is_forward_iterator<_InputIterator>::value,
2609 assign(_InputIterator __first, _InputIterator __last,
2610 flag_type __f = regex_constants::ECMAScript)
2612 basic_string<_CharT> __t(__first, __last);
2613 return assign(__t.begin(), __t.end(), __f);
2617 _LIBCPP_INLINE_VISIBILITY
2618 void __member_init(flag_type __f)
2621 __marked_count_ = 0;
2628 template <class _ForwardIterator>
2629 _LIBCPP_INLINE_VISIBILITY
2632 __is_forward_iterator<_ForwardIterator>::value,
2635 assign(_ForwardIterator __first, _ForwardIterator __last,
2636 flag_type __f = regex_constants::ECMAScript)
2638 return assign(basic_regex(__first, __last, __f));
2641 #ifndef _LIBCPP_CXX03_LANG
2643 _LIBCPP_INLINE_VISIBILITY
2644 basic_regex& assign(initializer_list<value_type> __il,
2645 flag_type __f = regex_constants::ECMAScript)
2646 {return assign(__il.begin(), __il.end(), __f);}
2648 #endif // _LIBCPP_CXX03_LANG
2650 // const operations:
2651 _LIBCPP_INLINE_VISIBILITY
2652 unsigned mark_count() const {return __marked_count_;}
2653 _LIBCPP_INLINE_VISIBILITY
2654 flag_type flags() const {return __flags_;}
2657 _LIBCPP_INLINE_VISIBILITY
2658 locale_type imbue(locale_type __loc)
2660 __member_init(ECMAScript);
2662 return __traits_.imbue(__loc);
2664 _LIBCPP_INLINE_VISIBILITY
2665 locale_type getloc() const {return __traits_.getloc();}
2668 void swap(basic_regex& __r);
2671 _LIBCPP_INLINE_VISIBILITY
2672 unsigned __loop_count() const {return __loop_count_;}
2674 template <class _ForwardIterator>
2676 __parse(_ForwardIterator __first, _ForwardIterator __last);
2677 template <class _ForwardIterator>
2679 __parse_basic_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
2680 template <class _ForwardIterator>
2682 __parse_RE_expression(_ForwardIterator __first, _ForwardIterator __last);
2683 template <class _ForwardIterator>
2685 __parse_simple_RE(_ForwardIterator __first, _ForwardIterator __last);
2686 template <class _ForwardIterator>
2688 __parse_nondupl_RE(_ForwardIterator __first, _ForwardIterator __last);
2689 template <class _ForwardIterator>
2691 __parse_one_char_or_coll_elem_RE(_ForwardIterator __first, _ForwardIterator __last);
2692 template <class _ForwardIterator>
2694 __parse_Back_open_paren(_ForwardIterator __first, _ForwardIterator __last);
2695 template <class _ForwardIterator>
2697 __parse_Back_close_paren(_ForwardIterator __first, _ForwardIterator __last);
2698 template <class _ForwardIterator>
2700 __parse_Back_open_brace(_ForwardIterator __first, _ForwardIterator __last);
2701 template <class _ForwardIterator>
2703 __parse_Back_close_brace(_ForwardIterator __first, _ForwardIterator __last);
2704 template <class _ForwardIterator>
2706 __parse_BACKREF(_ForwardIterator __first, _ForwardIterator __last);
2707 template <class _ForwardIterator>
2709 __parse_ORD_CHAR(_ForwardIterator __first, _ForwardIterator __last);
2710 template <class _ForwardIterator>
2712 __parse_QUOTED_CHAR(_ForwardIterator __first, _ForwardIterator __last);
2713 template <class _ForwardIterator>
2715 __parse_RE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
2716 __owns_one_state<_CharT>* __s,
2717 unsigned __mexp_begin, unsigned __mexp_end);
2718 template <class _ForwardIterator>
2720 __parse_ERE_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_bracket_expression(_ForwardIterator __first, _ForwardIterator __last);
2726 template <class _ForwardIterator>
2728 __parse_follow_list(_ForwardIterator __first, _ForwardIterator __last,
2729 __bracket_expression<_CharT, _Traits>* __ml);
2730 template <class _ForwardIterator>
2732 __parse_expression_term(_ForwardIterator __first, _ForwardIterator __last,
2733 __bracket_expression<_CharT, _Traits>* __ml);
2734 template <class _ForwardIterator>
2736 __parse_equivalence_class(_ForwardIterator __first, _ForwardIterator __last,
2737 __bracket_expression<_CharT, _Traits>* __ml);
2738 template <class _ForwardIterator>
2740 __parse_character_class(_ForwardIterator __first, _ForwardIterator __last,
2741 __bracket_expression<_CharT, _Traits>* __ml);
2742 template <class _ForwardIterator>
2744 __parse_collating_symbol(_ForwardIterator __first, _ForwardIterator __last,
2745 basic_string<_CharT>& __col_sym);
2746 template <class _ForwardIterator>
2748 __parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c);
2749 template <class _ForwardIterator>
2751 __parse_extended_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
2752 template <class _ForwardIterator>
2754 __parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last);
2755 template <class _ForwardIterator>
2757 __parse_ERE_expression(_ForwardIterator __first, _ForwardIterator __last);
2758 template <class _ForwardIterator>
2760 __parse_one_char_or_coll_elem_ERE(_ForwardIterator __first, _ForwardIterator __last);
2761 template <class _ForwardIterator>
2763 __parse_ORD_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
2764 template <class _ForwardIterator>
2766 __parse_QUOTED_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
2767 template <class _ForwardIterator>
2769 __parse_ecma_exp(_ForwardIterator __first, _ForwardIterator __last);
2770 template <class _ForwardIterator>
2772 __parse_alternative(_ForwardIterator __first, _ForwardIterator __last);
2773 template <class _ForwardIterator>
2775 __parse_term(_ForwardIterator __first, _ForwardIterator __last);
2776 template <class _ForwardIterator>
2778 __parse_assertion(_ForwardIterator __first, _ForwardIterator __last);
2779 template <class _ForwardIterator>
2781 __parse_atom(_ForwardIterator __first, _ForwardIterator __last);
2782 template <class _ForwardIterator>
2784 __parse_atom_escape(_ForwardIterator __first, _ForwardIterator __last);
2785 template <class _ForwardIterator>
2787 __parse_decimal_escape(_ForwardIterator __first, _ForwardIterator __last);
2788 template <class _ForwardIterator>
2790 __parse_character_class_escape(_ForwardIterator __first, _ForwardIterator __last);
2791 template <class _ForwardIterator>
2793 __parse_character_escape(_ForwardIterator __first, _ForwardIterator __last,
2794 basic_string<_CharT>* __str = nullptr);
2795 template <class _ForwardIterator>
2797 __parse_pattern_character(_ForwardIterator __first, _ForwardIterator __last);
2798 template <class _ForwardIterator>
2800 __parse_grep(_ForwardIterator __first, _ForwardIterator __last);
2801 template <class _ForwardIterator>
2803 __parse_egrep(_ForwardIterator __first, _ForwardIterator __last);
2804 template <class _ForwardIterator>
2806 __parse_class_escape(_ForwardIterator __first, _ForwardIterator __last,
2807 basic_string<_CharT>& __str,
2808 __bracket_expression<_CharT, _Traits>* __ml);
2809 template <class _ForwardIterator>
2811 __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last,
2812 basic_string<_CharT>* __str = nullptr);
2814 _LIBCPP_INLINE_VISIBILITY
2815 void __push_l_anchor();
2816 void __push_r_anchor();
2817 void __push_match_any();
2818 void __push_match_any_but_newline();
2819 _LIBCPP_INLINE_VISIBILITY
2820 void __push_greedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
2821 unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
2822 {__push_loop(__min, numeric_limits<size_t>::max(), __s,
2823 __mexp_begin, __mexp_end);}
2824 _LIBCPP_INLINE_VISIBILITY
2825 void __push_nongreedy_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, false);}
2829 void __push_loop(size_t __min, size_t __max, __owns_one_state<_CharT>* __s,
2830 size_t __mexp_begin = 0, size_t __mexp_end = 0,
2831 bool __greedy = true);
2832 __bracket_expression<_CharT, _Traits>* __start_matching_list(bool __negate);
2833 void __push_char(value_type __c);
2834 void __push_back_ref(int __i);
2835 void __push_alternation(__owns_one_state<_CharT>* __sa,
2836 __owns_one_state<_CharT>* __sb);
2837 void __push_begin_marked_subexpression();
2838 void __push_end_marked_subexpression(unsigned);
2839 void __push_empty();
2840 void __push_word_boundary(bool);
2841 void __push_lookahead(const basic_regex&, bool, unsigned);
2843 template <class _Allocator>
2845 __search(const _CharT* __first, const _CharT* __last,
2846 match_results<const _CharT*, _Allocator>& __m,
2847 regex_constants::match_flag_type __flags) const;
2849 template <class _Allocator>
2851 __match_at_start(const _CharT* __first, const _CharT* __last,
2852 match_results<const _CharT*, _Allocator>& __m,
2853 regex_constants::match_flag_type __flags, bool) const;
2854 template <class _Allocator>
2856 __match_at_start_ecma(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_posix_nosubs(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_subs(const _CharT* __first, const _CharT* __last,
2867 match_results<const _CharT*, _Allocator>& __m,
2868 regex_constants::match_flag_type __flags, bool) const;
2870 template <class _Bp, class _Ap, class _Cp, class _Tp>
2873 regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
2874 regex_constants::match_flag_type);
2876 template <class _Ap, class _Cp, class _Tp>
2879 regex_search(const _Cp*, const _Cp*, match_results<const _Cp*, _Ap>&,
2880 const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
2882 template <class _Bp, class _Cp, class _Tp>
2885 regex_search(_Bp, _Bp, const basic_regex<_Cp, _Tp>&,
2886 regex_constants::match_flag_type);
2888 template <class _Cp, class _Tp>
2891 regex_search(const _Cp*, const _Cp*,
2892 const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
2894 template <class _Cp, class _Ap, class _Tp>
2897 regex_search(const _Cp*, match_results<const _Cp*, _Ap>&, const basic_regex<_Cp, _Tp>&,
2898 regex_constants::match_flag_type);
2900 template <class _ST, class _SA, class _Cp, class _Tp>
2903 regex_search(const basic_string<_Cp, _ST, _SA>& __s,
2904 const basic_regex<_Cp, _Tp>& __e,
2905 regex_constants::match_flag_type __flags);
2907 template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
2910 regex_search(const basic_string<_Cp, _ST, _SA>& __s,
2911 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
2912 const basic_regex<_Cp, _Tp>& __e,
2913 regex_constants::match_flag_type __flags);
2915 template <class _Iter, class _Ap, class _Cp, class _Tp>
2918 regex_search(__wrap_iter<_Iter> __first,
2919 __wrap_iter<_Iter> __last,
2920 match_results<__wrap_iter<_Iter>, _Ap>& __m,
2921 const basic_regex<_Cp, _Tp>& __e,
2922 regex_constants::match_flag_type __flags);
2924 template <class, class> friend class __lookahead;
2927 #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
2928 template <class _ForwardIterator,
2929 class = typename enable_if<__is_forward_iterator<_ForwardIterator>::value, nullptr_t>::type
2931 basic_regex(_ForwardIterator, _ForwardIterator,
2932 regex_constants::syntax_option_type = regex_constants::ECMAScript)
2933 -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>;
2936 template <class _CharT, class _Traits>
2937 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;
2938 template <class _CharT, class _Traits>
2939 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::nosubs;
2940 template <class _CharT, class _Traits>
2941 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::optimize;
2942 template <class _CharT, class _Traits>
2943 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::collate;
2944 template <class _CharT, class _Traits>
2945 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::ECMAScript;
2946 template <class _CharT, class _Traits>
2947 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::basic;
2948 template <class _CharT, class _Traits>
2949 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::extended;
2950 template <class _CharT, class _Traits>
2951 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::awk;
2952 template <class _CharT, class _Traits>
2953 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::grep;
2954 template <class _CharT, class _Traits>
2955 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::egrep;
2957 template <class _CharT, class _Traits>
2959 basic_regex<_CharT, _Traits>::swap(basic_regex& __r)
2962 swap(__traits_, __r.__traits_);
2963 swap(__flags_, __r.__flags_);
2964 swap(__marked_count_, __r.__marked_count_);
2965 swap(__loop_count_, __r.__loop_count_);
2966 swap(__open_count_, __r.__open_count_);
2967 swap(__start_, __r.__start_);
2968 swap(__end_, __r.__end_);
2971 template <class _CharT, class _Traits>
2972 inline _LIBCPP_INLINE_VISIBILITY
2974 swap(basic_regex<_CharT, _Traits>& __x, basic_regex<_CharT, _Traits>& __y)
2976 return __x.swap(__y);
2981 template <class _CharT, class _Traits>
2983 : public __owns_one_state<_CharT>
2985 typedef __owns_one_state<_CharT> base;
2987 basic_regex<_CharT, _Traits> __exp_;
2991 __lookahead(const __lookahead&);
2992 __lookahead& operator=(const __lookahead&);
2994 typedef _VSTD::__state<_CharT> __state;
2996 _LIBCPP_INLINE_VISIBILITY
2997 __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp)
2998 : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {}
3000 virtual void __exec(__state&) const;
3003 template <class _CharT, class _Traits>
3005 __lookahead<_CharT, _Traits>::__exec(__state& __s) const
3007 match_results<const _CharT*> __m;
3008 __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
3009 bool __matched = __exp_.__match_at_start_ecma(
3010 __s.__current_, __s.__last_,
3012 (__s.__flags_ | regex_constants::match_continuous) &
3013 ~regex_constants::__full_match,
3014 __s.__at_first_ && __s.__current_ == __s.__first_);
3015 if (__matched != __invert_)
3017 __s.__do_ = __state::__accept_but_not_consume;
3018 __s.__node_ = this->first();
3019 for (unsigned __i = 1; __i < __m.size(); ++__i) {
3020 __s.__sub_matches_[__mexp_ + __i - 1] = __m.__matches_[__i];
3025 __s.__do_ = __state::__reject;
3026 __s.__node_ = nullptr;
3030 template <class _CharT, class _Traits>
3031 template <class _ForwardIterator>
3033 basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
3034 _ForwardIterator __last)
3037 unique_ptr<__node> __h(new __end_state<_CharT>);
3038 __start_.reset(new __empty_state<_CharT>(__h.get()));
3040 __end_ = __start_.get();
3042 switch (__flags_ & 0x1F0)
3045 __first = __parse_ecma_exp(__first, __last);
3048 __first = __parse_basic_reg_exp(__first, __last);
3052 __first = __parse_extended_reg_exp(__first, __last);
3055 __first = __parse_grep(__first, __last);
3058 __first = __parse_egrep(__first, __last);
3061 __throw_regex_error<regex_constants::__re_err_grammar>();
3066 template <class _CharT, class _Traits>
3067 template <class _ForwardIterator>
3069 basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first,
3070 _ForwardIterator __last)
3072 if (__first != __last)
3074 if (*__first == '^')
3079 if (__first != __last)
3081 __first = __parse_RE_expression(__first, __last);
3082 if (__first != __last)
3084 _ForwardIterator __temp = _VSTD::next(__first);
3085 if (__temp == __last && *__first == '$')
3092 if (__first != __last)
3093 __throw_regex_error<regex_constants::__re_err_empty>();
3098 template <class _CharT, class _Traits>
3099 template <class _ForwardIterator>
3101 basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
3102 _ForwardIterator __last)
3104 __owns_one_state<_CharT>* __sa = __end_;
3105 _ForwardIterator __temp = __parse_ERE_branch(__first, __last);
3106 if (__temp == __first)
3107 __throw_regex_error<regex_constants::__re_err_empty>();
3109 while (__first != __last && *__first == '|')
3111 __owns_one_state<_CharT>* __sb = __end_;
3112 __temp = __parse_ERE_branch(++__first, __last);
3113 if (__temp == __first)
3114 __throw_regex_error<regex_constants::__re_err_empty>();
3115 __push_alternation(__sa, __sb);
3121 template <class _CharT, class _Traits>
3122 template <class _ForwardIterator>
3124 basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first,
3125 _ForwardIterator __last)
3127 _ForwardIterator __temp = __parse_ERE_expression(__first, __last);
3128 if (__temp == __first)
3129 __throw_regex_error<regex_constants::__re_err_empty>();
3133 __temp = __parse_ERE_expression(__first, __last);
3134 } while (__temp != __first);
3138 template <class _CharT, class _Traits>
3139 template <class _ForwardIterator>
3141 basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first,
3142 _ForwardIterator __last)
3144 __owns_one_state<_CharT>* __e = __end_;
3145 unsigned __mexp_begin = __marked_count_;
3146 _ForwardIterator __temp = __parse_one_char_or_coll_elem_ERE(__first, __last);
3147 if (__temp == __first && __temp != __last)
3160 __push_begin_marked_subexpression();
3161 unsigned __temp_count = __marked_count_;
3163 __temp = __parse_extended_reg_exp(++__temp, __last);
3164 if (__temp == __last || *__temp != ')')
3165 __throw_regex_error<regex_constants::error_paren>();
3166 __push_end_marked_subexpression(__temp_count);
3172 if (__temp != __first)
3173 __temp = __parse_ERE_dupl_symbol(__temp, __last, __e, __mexp_begin+1,
3179 template <class _CharT, class _Traits>
3180 template <class _ForwardIterator>
3182 basic_regex<_CharT, _Traits>::__parse_RE_expression(_ForwardIterator __first,
3183 _ForwardIterator __last)
3187 _ForwardIterator __temp = __parse_simple_RE(__first, __last);
3188 if (__temp == __first)
3195 template <class _CharT, class _Traits>
3196 template <class _ForwardIterator>
3198 basic_regex<_CharT, _Traits>::__parse_simple_RE(_ForwardIterator __first,
3199 _ForwardIterator __last)
3201 if (__first != __last)
3203 __owns_one_state<_CharT>* __e = __end_;
3204 unsigned __mexp_begin = __marked_count_;
3205 _ForwardIterator __temp = __parse_nondupl_RE(__first, __last);
3206 if (__temp != __first)
3207 __first = __parse_RE_dupl_symbol(__temp, __last, __e,
3208 __mexp_begin+1, __marked_count_+1);
3213 template <class _CharT, class _Traits>
3214 template <class _ForwardIterator>
3216 basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first,
3217 _ForwardIterator __last)
3219 _ForwardIterator __temp = __first;
3220 __first = __parse_one_char_or_coll_elem_RE(__first, __last);
3221 if (__temp == __first)
3223 __temp = __parse_Back_open_paren(__first, __last);
3224 if (__temp != __first)
3226 __push_begin_marked_subexpression();
3227 unsigned __temp_count = __marked_count_;
3228 __first = __parse_RE_expression(__temp, __last);
3229 __temp = __parse_Back_close_paren(__first, __last);
3230 if (__temp == __first)
3231 __throw_regex_error<regex_constants::error_paren>();
3232 __push_end_marked_subexpression(__temp_count);
3236 __first = __parse_BACKREF(__first, __last);
3241 template <class _CharT, class _Traits>
3242 template <class _ForwardIterator>
3244 basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_RE(
3245 _ForwardIterator __first,
3246 _ForwardIterator __last)
3248 _ForwardIterator __temp = __parse_ORD_CHAR(__first, __last);
3249 if (__temp == __first)
3251 __temp = __parse_QUOTED_CHAR(__first, __last);
3252 if (__temp == __first)
3254 if (__temp != __last && *__temp == '.')
3260 __temp = __parse_bracket_expression(__first, __last);
3267 template <class _CharT, class _Traits>
3268 template <class _ForwardIterator>
3270 basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_ERE(
3271 _ForwardIterator __first,
3272 _ForwardIterator __last)
3274 _ForwardIterator __temp = __parse_ORD_CHAR_ERE(__first, __last);
3275 if (__temp == __first)
3277 __temp = __parse_QUOTED_CHAR_ERE(__first, __last);
3278 if (__temp == __first)
3280 if (__temp != __last && *__temp == '.')
3286 __temp = __parse_bracket_expression(__first, __last);
3293 template <class _CharT, class _Traits>
3294 template <class _ForwardIterator>
3296 basic_regex<_CharT, _Traits>::__parse_Back_open_paren(_ForwardIterator __first,
3297 _ForwardIterator __last)
3299 if (__first != __last)
3301 _ForwardIterator __temp = _VSTD::next(__first);
3302 if (__temp != __last)
3304 if (*__first == '\\' && *__temp == '(')
3311 template <class _CharT, class _Traits>
3312 template <class _ForwardIterator>
3314 basic_regex<_CharT, _Traits>::__parse_Back_close_paren(_ForwardIterator __first,
3315 _ForwardIterator __last)
3317 if (__first != __last)
3319 _ForwardIterator __temp = _VSTD::next(__first);
3320 if (__temp != __last)
3322 if (*__first == '\\' && *__temp == ')')
3329 template <class _CharT, class _Traits>
3330 template <class _ForwardIterator>
3332 basic_regex<_CharT, _Traits>::__parse_Back_open_brace(_ForwardIterator __first,
3333 _ForwardIterator __last)
3335 if (__first != __last)
3337 _ForwardIterator __temp = _VSTD::next(__first);
3338 if (__temp != __last)
3340 if (*__first == '\\' && *__temp == '{')
3347 template <class _CharT, class _Traits>
3348 template <class _ForwardIterator>
3350 basic_regex<_CharT, _Traits>::__parse_Back_close_brace(_ForwardIterator __first,
3351 _ForwardIterator __last)
3353 if (__first != __last)
3355 _ForwardIterator __temp = _VSTD::next(__first);
3356 if (__temp != __last)
3358 if (*__first == '\\' && *__temp == '}')
3365 template <class _CharT, class _Traits>
3366 template <class _ForwardIterator>
3368 basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first,
3369 _ForwardIterator __last)
3371 if (__first != __last)
3373 _ForwardIterator __temp = _VSTD::next(__first);
3374 if (__temp != __last)
3376 if (*__first == '\\')
3378 int __val = __traits_.value(*__temp, 10);
3379 if (__val >= 1 && __val <= 9)
3381 __push_back_ref(__val);
3390 template <class _CharT, class _Traits>
3391 template <class _ForwardIterator>
3393 basic_regex<_CharT, _Traits>::__parse_ORD_CHAR(_ForwardIterator __first,
3394 _ForwardIterator __last)
3396 if (__first != __last)
3398 _ForwardIterator __temp = _VSTD::next(__first);
3399 if (__temp == __last && *__first == '$')
3401 // Not called inside a bracket
3402 if (*__first == '.' || *__first == '\\' || *__first == '[')
3404 __push_char(*__first);
3410 template <class _CharT, class _Traits>
3411 template <class _ForwardIterator>
3413 basic_regex<_CharT, _Traits>::__parse_ORD_CHAR_ERE(_ForwardIterator __first,
3414 _ForwardIterator __last)
3416 if (__first != __last)
3433 if (__open_count_ == 0)
3435 __push_char(*__first);
3440 __push_char(*__first);
3448 template <class _CharT, class _Traits>
3449 template <class _ForwardIterator>
3451 basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR(_ForwardIterator __first,
3452 _ForwardIterator __last)
3454 if (__first != __last)
3456 _ForwardIterator __temp = _VSTD::next(__first);
3457 if (__temp != __last)
3459 if (*__first == '\\')
3469 __push_char(*__temp);
3479 template <class _CharT, class _Traits>
3480 template <class _ForwardIterator>
3482 basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first,
3483 _ForwardIterator __last)
3485 if (__first != __last)
3487 _ForwardIterator __temp = _VSTD::next(__first);
3488 if (__temp != __last)
3490 if (*__first == '\\')
3507 __push_char(*__temp);
3511 if ((__flags_ & 0x1F0) == awk)
3512 __first = __parse_awk_escape(++__first, __last);
3521 template <class _CharT, class _Traits>
3522 template <class _ForwardIterator>
3524 basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
3525 _ForwardIterator __last,
3526 __owns_one_state<_CharT>* __s,
3527 unsigned __mexp_begin,
3528 unsigned __mexp_end)
3530 if (__first != __last)
3532 if (*__first == '*')
3534 __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3539 _ForwardIterator __temp = __parse_Back_open_brace(__first, __last);
3540 if (__temp != __first)
3544 __temp = __parse_DUP_COUNT(__first, __last, __min);
3545 if (__temp == __first)
3546 __throw_regex_error<regex_constants::error_badbrace>();
3548 if (__first == __last)
3549 __throw_regex_error<regex_constants::error_brace>();
3550 if (*__first != ',')
3552 __temp = __parse_Back_close_brace(__first, __last);
3553 if (__temp == __first)
3554 __throw_regex_error<regex_constants::error_brace>();
3555 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end,
3561 ++__first; // consume ','
3563 __first = __parse_DUP_COUNT(__first, __last, __max);
3564 __temp = __parse_Back_close_brace(__first, __last);
3565 if (__temp == __first)
3566 __throw_regex_error<regex_constants::error_brace>();
3568 __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3572 __throw_regex_error<regex_constants::error_badbrace>();
3573 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end,
3584 template <class _CharT, class _Traits>
3585 template <class _ForwardIterator>
3587 basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
3588 _ForwardIterator __last,
3589 __owns_one_state<_CharT>* __s,
3590 unsigned __mexp_begin,
3591 unsigned __mexp_end)
3593 if (__first != __last)
3595 unsigned __grammar = __flags_ & 0x1F0;
3600 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3603 __push_nongreedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3606 __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3610 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3613 __push_nongreedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
3616 __push_greedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
3620 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3623 __push_loop(0, 1, __s, __mexp_begin, __mexp_end, false);
3626 __push_loop(0, 1, __s, __mexp_begin, __mexp_end);
3631 _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);
3632 if (__temp == __first)
3633 __throw_regex_error<regex_constants::error_badbrace>();
3635 if (__first == __last)
3636 __throw_regex_error<regex_constants::error_brace>();
3641 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3644 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, false);
3647 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end);
3651 if (__first == __last)
3652 __throw_regex_error<regex_constants::error_badbrace>();
3653 if (*__first == '}')
3656 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3659 __push_nongreedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3662 __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3667 __temp = __parse_DUP_COUNT(__first, __last, __max);
3668 if (__temp == __first)
3669 __throw_regex_error<regex_constants::error_brace>();
3671 if (__first == __last || *__first != '}')
3672 __throw_regex_error<regex_constants::error_brace>();
3675 __throw_regex_error<regex_constants::error_badbrace>();
3676 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3679 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false);
3682 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end);
3686 __throw_regex_error<regex_constants::error_badbrace>();
3695 template <class _CharT, class _Traits>
3696 template <class _ForwardIterator>
3698 basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __first,
3699 _ForwardIterator __last)
3701 if (__first != __last && *__first == '[')
3704 if (__first == __last)
3705 __throw_regex_error<regex_constants::error_brack>();
3706 bool __negate = false;
3707 if (*__first == '^')
3712 __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);
3713 // __ml owned by *this
3714 if (__first == __last)
3715 __throw_regex_error<regex_constants::error_brack>();
3716 if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']')
3718 __ml->__add_char(']');
3721 __first = __parse_follow_list(__first, __last, __ml);
3722 if (__first == __last)
3723 __throw_regex_error<regex_constants::error_brack>();
3724 if (*__first == '-')
3726 __ml->__add_char('-');
3729 if (__first == __last || *__first != ']')
3730 __throw_regex_error<regex_constants::error_brack>();
3736 template <class _CharT, class _Traits>
3737 template <class _ForwardIterator>
3739 basic_regex<_CharT, _Traits>::__parse_follow_list(_ForwardIterator __first,
3740 _ForwardIterator __last,
3741 __bracket_expression<_CharT, _Traits>* __ml)
3743 if (__first != __last)
3747 _ForwardIterator __temp = __parse_expression_term(__first, __last,
3749 if (__temp == __first)
3757 template <class _CharT, class _Traits>
3758 template <class _ForwardIterator>
3760 basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first,
3761 _ForwardIterator __last,
3762 __bracket_expression<_CharT, _Traits>* __ml)
3764 if (__first != __last && *__first != ']')
3766 _ForwardIterator __temp = _VSTD::next(__first);
3767 basic_string<_CharT> __start_range;
3768 if (__temp != __last && *__first == '[')
3771 return __parse_equivalence_class(++__temp, __last, __ml);
3772 else if (*__temp == ':')
3773 return __parse_character_class(++__temp, __last, __ml);
3774 else if (*__temp == '.')
3775 __first = __parse_collating_symbol(++__temp, __last, __start_range);
3777 unsigned __grammar = __flags_ & 0x1F0;
3778 if (__start_range.empty())
3780 if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
3782 if (__grammar == ECMAScript)
3783 __first = __parse_class_escape(++__first, __last, __start_range, __ml);
3785 __first = __parse_awk_escape(++__first, __last, &__start_range);
3789 __start_range = *__first;
3793 if (__first != __last && *__first != ']')
3795 __temp = _VSTD::next(__first);
3796 if (__temp != __last && *__first == '-' && *__temp != ']')
3799 basic_string<_CharT> __end_range;
3802 if (__temp != __last && *__first == '[' && *__temp == '.')
3803 __first = __parse_collating_symbol(++__temp, __last, __end_range);
3806 if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
3808 if (__grammar == ECMAScript)
3809 __first = __parse_class_escape(++__first, __last,
3812 __first = __parse_awk_escape(++__first, __last,
3817 __end_range = *__first;
3821 __ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range));
3823 else if (!__start_range.empty())
3825 if (__start_range.size() == 1)
3826 __ml->__add_char(__start_range[0]);
3828 __ml->__add_digraph(__start_range[0], __start_range[1]);
3831 else if (!__start_range.empty())
3833 if (__start_range.size() == 1)
3834 __ml->__add_char(__start_range[0]);
3836 __ml->__add_digraph(__start_range[0], __start_range[1]);
3842 template <class _CharT, class _Traits>
3843 template <class _ForwardIterator>
3845 basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first,
3846 _ForwardIterator __last,
3847 basic_string<_CharT>& __str,
3848 __bracket_expression<_CharT, _Traits>* __ml)
3850 if (__first == __last)
3851 __throw_regex_error<regex_constants::error_escape>();
3861 __ml->__add_class(ctype_base::digit);
3864 __ml->__add_neg_class(ctype_base::digit);
3867 __ml->__add_class(ctype_base::space);
3870 __ml->__add_neg_class(ctype_base::space);
3873 __ml->__add_class(ctype_base::alnum);
3874 __ml->__add_char('_');
3877 __ml->__add_neg_class(ctype_base::alnum);
3878 __ml->__add_neg_char('_');
3881 __first = __parse_character_escape(__first, __last, &__str);
3885 template <class _CharT, class _Traits>
3886 template <class _ForwardIterator>
3888 basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
3889 _ForwardIterator __last,
3890 basic_string<_CharT>* __str)
3892 if (__first == __last)
3893 __throw_regex_error<regex_constants::error_escape>();
3902 __push_char(*__first);
3908 __push_char(_CharT(7));
3914 __push_char(_CharT(8));
3918 *__str = _CharT(0xC);
3920 __push_char(_CharT(0xC));
3924 *__str = _CharT(0xA);
3926 __push_char(_CharT(0xA));
3930 *__str = _CharT(0xD);
3932 __push_char(_CharT(0xD));
3936 *__str = _CharT(0x9);
3938 __push_char(_CharT(0x9));
3942 *__str = _CharT(0xB);
3944 __push_char(_CharT(0xB));
3947 if ('0' <= *__first && *__first <= '7')
3949 unsigned __val = *__first - '0';
3950 if (++__first != __last && ('0' <= *__first && *__first <= '7'))
3952 __val = 8 * __val + *__first - '0';
3953 if (++__first != __last && ('0' <= *__first && *__first <= '7'))
3954 __val = 8 * __val + *__first++ - '0';
3957 *__str = _CharT(__val);
3959 __push_char(_CharT(__val));
3962 __throw_regex_error<regex_constants::error_escape>();
3966 template <class _CharT, class _Traits>
3967 template <class _ForwardIterator>
3969 basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first,
3970 _ForwardIterator __last,
3971 __bracket_expression<_CharT, _Traits>* __ml)
3974 // This means =] must exist
3975 value_type _Equal_close[2] = {'=', ']'};
3976 _ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close,
3978 if (__temp == __last)
3979 __throw_regex_error<regex_constants::error_brack>();
3980 // [__first, __temp) contains all text in [= ... =]
3981 string_type __collate_name =
3982 __traits_.lookup_collatename(__first, __temp);
3983 if (__collate_name.empty())
3984 __throw_regex_error<regex_constants::error_collate>();
3985 string_type __equiv_name =
3986 __traits_.transform_primary(__collate_name.begin(),
3987 __collate_name.end());
3988 if (!__equiv_name.empty())
3989 __ml->__add_equivalence(__equiv_name);
3992 switch (__collate_name.size())
3995 __ml->__add_char(__collate_name[0]);
3998 __ml->__add_digraph(__collate_name[0], __collate_name[1]);
4001 __throw_regex_error<regex_constants::error_collate>();
4004 __first = _VSTD::next(__temp, 2);
4008 template <class _CharT, class _Traits>
4009 template <class _ForwardIterator>
4011 basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
4012 _ForwardIterator __last,
4013 __bracket_expression<_CharT, _Traits>* __ml)
4016 // This means :] must exist
4017 value_type _Colon_close[2] = {':', ']'};
4018 _ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close,
4020 if (__temp == __last)
4021 __throw_regex_error<regex_constants::error_brack>();
4022 // [__first, __temp) contains all text in [: ... :]
4023 typedef typename _Traits::char_class_type char_class_type;
4024 char_class_type __class_type =
4025 __traits_.lookup_classname(__first, __temp, __flags_ & icase);
4026 if (__class_type == 0)
4027 __throw_regex_error<regex_constants::error_ctype>();
4028 __ml->__add_class(__class_type);
4029 __first = _VSTD::next(__temp, 2);
4033 template <class _CharT, class _Traits>
4034 template <class _ForwardIterator>
4036 basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
4037 _ForwardIterator __last,
4038 basic_string<_CharT>& __col_sym)
4041 // This means .] must exist
4042 value_type _Dot_close[2] = {'.', ']'};
4043 _ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close,
4045 if (__temp == __last)
4046 __throw_regex_error<regex_constants::error_brack>();
4047 // [__first, __temp) contains all text in [. ... .]
4048 __col_sym = __traits_.lookup_collatename(__first, __temp);
4049 switch (__col_sym.size())
4055 __throw_regex_error<regex_constants::error_collate>();
4057 __first = _VSTD::next(__temp, 2);
4061 template <class _CharT, class _Traits>
4062 template <class _ForwardIterator>
4064 basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
4065 _ForwardIterator __last,
4068 if (__first != __last )
4070 int __val = __traits_.value(*__first, 10);
4075 __first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
4078 if (__c >= std::numeric_limits<int>::max() / 10)
4079 __throw_regex_error<regex_constants::error_badbrace>();
4088 template <class _CharT, class _Traits>
4089 template <class _ForwardIterator>
4091 basic_regex<_CharT, _Traits>::__parse_ecma_exp(_ForwardIterator __first,
4092 _ForwardIterator __last)
4094 __owns_one_state<_CharT>* __sa = __end_;
4095 _ForwardIterator __temp = __parse_alternative(__first, __last);
4096 if (__temp == __first)
4099 while (__first != __last && *__first == '|')
4101 __owns_one_state<_CharT>* __sb = __end_;
4102 __temp = __parse_alternative(++__first, __last);
4103 if (__temp == __first)
4105 __push_alternation(__sa, __sb);
4111 template <class _CharT, class _Traits>
4112 template <class _ForwardIterator>
4114 basic_regex<_CharT, _Traits>::__parse_alternative(_ForwardIterator __first,
4115 _ForwardIterator __last)
4119 _ForwardIterator __temp = __parse_term(__first, __last);
4120 if (__temp == __first)
4127 template <class _CharT, class _Traits>
4128 template <class _ForwardIterator>
4130 basic_regex<_CharT, _Traits>::__parse_term(_ForwardIterator __first,
4131 _ForwardIterator __last)
4133 _ForwardIterator __temp = __parse_assertion(__first, __last);
4134 if (__temp == __first)
4136 __owns_one_state<_CharT>* __e = __end_;
4137 unsigned __mexp_begin = __marked_count_;
4138 __temp = __parse_atom(__first, __last);
4139 if (__temp != __first)
4140 __first = __parse_ERE_dupl_symbol(__temp, __last, __e,
4141 __mexp_begin+1, __marked_count_+1);
4148 template <class _CharT, class _Traits>
4149 template <class _ForwardIterator>
4151 basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
4152 _ForwardIterator __last)
4154 if (__first != __last)
4168 _ForwardIterator __temp = _VSTD::next(__first);
4169 if (__temp != __last)
4173 __push_word_boundary(false);
4176 else if (*__temp == 'B')
4178 __push_word_boundary(true);
4186 _ForwardIterator __temp = _VSTD::next(__first);
4187 if (__temp != __last && *__temp == '?')
4189 if (++__temp != __last)
4196 __exp.__flags_ = __flags_;
4197 __temp = __exp.__parse(++__temp, __last);
4198 unsigned __mexp = __exp.__marked_count_;
4199 __push_lookahead(_VSTD::move(__exp), false, __marked_count_);
4200 __marked_count_ += __mexp;
4201 if (__temp == __last || *__temp != ')')
4202 __throw_regex_error<regex_constants::error_paren>();
4209 __exp.__flags_ = __flags_;
4210 __temp = __exp.__parse(++__temp, __last);
4211 unsigned __mexp = __exp.__marked_count_;
4212 __push_lookahead(_VSTD::move(__exp), true, __marked_count_);
4213 __marked_count_ += __mexp;
4214 if (__temp == __last || *__temp != ')')
4215 __throw_regex_error<regex_constants::error_paren>();
4229 template <class _CharT, class _Traits>
4230 template <class _ForwardIterator>
4232 basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
4233 _ForwardIterator __last)
4235 if (__first != __last)
4240 __push_match_any_but_newline();
4244 __first = __parse_atom_escape(__first, __last);
4247 __first = __parse_bracket_expression(__first, __last);
4252 if (__first == __last)
4253 __throw_regex_error<regex_constants::error_paren>();
4254 _ForwardIterator __temp = _VSTD::next(__first);
4255 if (__temp != __last && *__first == '?' && *__temp == ':')
4258 __first = __parse_ecma_exp(++__temp, __last);
4259 if (__first == __last || *__first != ')')
4260 __throw_regex_error<regex_constants::error_paren>();
4266 __push_begin_marked_subexpression();
4267 unsigned __temp_count = __marked_count_;
4269 __first = __parse_ecma_exp(__first, __last);
4270 if (__first == __last || *__first != ')')
4271 __throw_regex_error<regex_constants::error_paren>();
4272 __push_end_marked_subexpression(__temp_count);
4282 __throw_regex_error<regex_constants::error_badrepeat>();
4285 __first = __parse_pattern_character(__first, __last);
4292 template <class _CharT, class _Traits>
4293 template <class _ForwardIterator>
4295 basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first,
4296 _ForwardIterator __last)
4298 if (__first != __last && *__first == '\\')
4300 _ForwardIterator __t1 = _VSTD::next(__first);
4302 __throw_regex_error<regex_constants::error_escape>();
4304 _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
4309 __t2 = __parse_character_class_escape(__t1, __last);
4314 __t2 = __parse_character_escape(__t1, __last);
4323 template <class _CharT, class _Traits>
4324 template <class _ForwardIterator>
4326 basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
4327 _ForwardIterator __last)
4329 if (__first != __last)
4331 if (*__first == '0')
4333 __push_char(_CharT());
4336 else if ('1' <= *__first && *__first <= '9')
4338 unsigned __v = *__first - '0';
4340 __first != __last && '0' <= *__first && *__first <= '9'; ++__first)
4342 if (__v >= std::numeric_limits<unsigned>::max() / 10)
4343 __throw_regex_error<regex_constants::error_backref>();
4344 __v = 10 * __v + *__first - '0';
4346 if (__v == 0 || __v > mark_count())
4347 __throw_regex_error<regex_constants::error_backref>();
4348 __push_back_ref(__v);
4354 template <class _CharT, class _Traits>
4355 template <class _ForwardIterator>
4357 basic_regex<_CharT, _Traits>::__parse_character_class_escape(_ForwardIterator __first,
4358 _ForwardIterator __last)
4360 if (__first != __last)
4362 __bracket_expression<_CharT, _Traits>* __ml;
4366 __ml = __start_matching_list(false);
4367 __ml->__add_class(ctype_base::digit);
4371 __ml = __start_matching_list(true);
4372 __ml->__add_class(ctype_base::digit);
4376 __ml = __start_matching_list(false);
4377 __ml->__add_class(ctype_base::space);
4381 __ml = __start_matching_list(true);
4382 __ml->__add_class(ctype_base::space);
4386 __ml = __start_matching_list(false);
4387 __ml->__add_class(ctype_base::alnum);
4388 __ml->__add_char('_');
4392 __ml = __start_matching_list(true);
4393 __ml->__add_class(ctype_base::alnum);
4394 __ml->__add_char('_');
4402 template <class _CharT, class _Traits>
4403 template <class _ForwardIterator>
4405 basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
4406 _ForwardIterator __last,
4407 basic_string<_CharT>* __str)
4409 if (__first != __last)
4411 _ForwardIterator __t;
4418 *__str = _CharT(0xC);
4420 __push_char(_CharT(0xC));
4425 *__str = _CharT(0xA);
4427 __push_char(_CharT(0xA));
4432 *__str = _CharT(0xD);
4434 __push_char(_CharT(0xD));
4439 *__str = _CharT(0x9);
4441 __push_char(_CharT(0x9));
4446 *__str = _CharT(0xB);
4448 __push_char(_CharT(0xB));
4452 if ((__t = _VSTD::next(__first)) != __last)
4454 if (('A' <= *__t && *__t <= 'Z') ||
4455 ('a' <= *__t && *__t <= 'z'))
4458 *__str = _CharT(*__t % 32);
4460 __push_char(_CharT(*__t % 32));
4464 __throw_regex_error<regex_constants::error_escape>();
4467 __throw_regex_error<regex_constants::error_escape>();
4471 if (__first == __last)
4472 __throw_regex_error<regex_constants::error_escape>();
4473 __hd = __traits_.value(*__first, 16);
4475 __throw_regex_error<regex_constants::error_escape>();
4476 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4478 if (__first == __last)
4479 __throw_regex_error<regex_constants::error_escape>();
4480 __hd = __traits_.value(*__first, 16);
4482 __throw_regex_error<regex_constants::error_escape>();
4483 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4487 if (__first == __last)
4488 __throw_regex_error<regex_constants::error_escape>();
4489 __hd = __traits_.value(*__first, 16);
4491 __throw_regex_error<regex_constants::error_escape>();
4492 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4494 if (__first == __last)
4495 __throw_regex_error<regex_constants::error_escape>();
4496 __hd = __traits_.value(*__first, 16);
4498 __throw_regex_error<regex_constants::error_escape>();
4499 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4501 *__str = _CharT(__sum);
4503 __push_char(_CharT(__sum));
4510 __push_char(_CharT(0));
4514 if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum))
4519 __push_char(*__first);
4523 __throw_regex_error<regex_constants::error_escape>();
4530 template <class _CharT, class _Traits>
4531 template <class _ForwardIterator>
4533 basic_regex<_CharT, _Traits>::__parse_pattern_character(_ForwardIterator __first,
4534 _ForwardIterator __last)
4536 if (__first != __last)
4556 __push_char(*__first);
4564 template <class _CharT, class _Traits>
4565 template <class _ForwardIterator>
4567 basic_regex<_CharT, _Traits>::__parse_grep(_ForwardIterator __first,
4568 _ForwardIterator __last)
4570 __owns_one_state<_CharT>* __sa = __end_;
4571 _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4572 if (__t1 != __first)
4573 __parse_basic_reg_exp(__first, __t1);
4577 if (__first != __last)
4579 while (__first != __last)
4581 __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4582 __owns_one_state<_CharT>* __sb = __end_;
4583 if (__t1 != __first)
4584 __parse_basic_reg_exp(__first, __t1);
4587 __push_alternation(__sa, __sb);
4589 if (__first != __last)
4595 template <class _CharT, class _Traits>
4596 template <class _ForwardIterator>
4598 basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first,
4599 _ForwardIterator __last)
4601 __owns_one_state<_CharT>* __sa = __end_;
4602 _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4603 if (__t1 != __first)
4604 __parse_extended_reg_exp(__first, __t1);
4608 if (__first != __last)
4610 while (__first != __last)
4612 __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4613 __owns_one_state<_CharT>* __sb = __end_;
4614 if (__t1 != __first)
4615 __parse_extended_reg_exp(__first, __t1);
4618 __push_alternation(__sa, __sb);
4620 if (__first != __last)
4626 template <class _CharT, class _Traits>
4628 basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max,
4629 __owns_one_state<_CharT>* __s, size_t __mexp_begin, size_t __mexp_end,
4632 unique_ptr<__empty_state<_CharT> > __e1(new __empty_state<_CharT>(__end_->first()));
4633 __end_->first() = nullptr;
4634 unique_ptr<__loop<_CharT> > __e2(new __loop<_CharT>(__loop_count_,
4635 __s->first(), __e1.get(), __mexp_begin, __mexp_end, __greedy,
4637 __s->first() = nullptr;
4639 __end_->first() = new __repeat_one_loop<_CharT>(__e2.get());
4640 __end_ = __e2->second();
4641 __s->first() = __e2.release();
4645 template <class _CharT, class _Traits>
4647 basic_regex<_CharT, _Traits>::__push_char(value_type __c)
4649 if (flags() & icase)
4650 __end_->first() = new __match_char_icase<_CharT, _Traits>
4651 (__traits_, __c, __end_->first());
4652 else if (flags() & collate)
4653 __end_->first() = new __match_char_collate<_CharT, _Traits>
4654 (__traits_, __c, __end_->first());
4656 __end_->first() = new __match_char<_CharT>(__c, __end_->first());
4657 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4660 template <class _CharT, class _Traits>
4662 basic_regex<_CharT, _Traits>::__push_begin_marked_subexpression()
4664 if (!(__flags_ & nosubs))
4667 new __begin_marked_subexpression<_CharT>(++__marked_count_,
4669 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4673 template <class _CharT, class _Traits>
4675 basic_regex<_CharT, _Traits>::__push_end_marked_subexpression(unsigned __sub)
4677 if (!(__flags_ & nosubs))
4680 new __end_marked_subexpression<_CharT>(__sub, __end_->first());
4681 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4685 template <class _CharT, class _Traits>
4687 basic_regex<_CharT, _Traits>::__push_l_anchor()
4689 __end_->first() = new __l_anchor<_CharT>(__end_->first());
4690 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4693 template <class _CharT, class _Traits>
4695 basic_regex<_CharT, _Traits>::__push_r_anchor()
4697 __end_->first() = new __r_anchor<_CharT>(__end_->first());
4698 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4701 template <class _CharT, class _Traits>
4703 basic_regex<_CharT, _Traits>::__push_match_any()
4705 __end_->first() = new __match_any<_CharT>(__end_->first());
4706 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4709 template <class _CharT, class _Traits>
4711 basic_regex<_CharT, _Traits>::__push_match_any_but_newline()
4713 __end_->first() = new __match_any_but_newline<_CharT>(__end_->first());
4714 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4717 template <class _CharT, class _Traits>
4719 basic_regex<_CharT, _Traits>::__push_empty()
4721 __end_->first() = new __empty_state<_CharT>(__end_->first());
4722 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4725 template <class _CharT, class _Traits>
4727 basic_regex<_CharT, _Traits>::__push_word_boundary(bool __invert)
4729 __end_->first() = new __word_boundary<_CharT, _Traits>(__traits_, __invert,
4731 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4734 template <class _CharT, class _Traits>
4736 basic_regex<_CharT, _Traits>::__push_back_ref(int __i)
4738 if (flags() & icase)
4739 __end_->first() = new __back_ref_icase<_CharT, _Traits>
4740 (__traits_, __i, __end_->first());
4741 else if (flags() & collate)
4742 __end_->first() = new __back_ref_collate<_CharT, _Traits>
4743 (__traits_, __i, __end_->first());
4745 __end_->first() = new __back_ref<_CharT>(__i, __end_->first());
4746 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4749 template <class _CharT, class _Traits>
4751 basic_regex<_CharT, _Traits>::__push_alternation(__owns_one_state<_CharT>* __sa,
4752 __owns_one_state<_CharT>* __ea)
4754 __sa->first() = new __alternate<_CharT>(
4755 static_cast<__owns_one_state<_CharT>*>(__sa->first()),
4756 static_cast<__owns_one_state<_CharT>*>(__ea->first()));
4757 __ea->first() = nullptr;
4758 __ea->first() = new __empty_state<_CharT>(__end_->first());
4759 __end_->first() = nullptr;
4760 __end_->first() = new __empty_non_own_state<_CharT>(__ea->first());
4761 __end_ = static_cast<__owns_one_state<_CharT>*>(__ea->first());
4764 template <class _CharT, class _Traits>
4765 __bracket_expression<_CharT, _Traits>*
4766 basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate)
4768 __bracket_expression<_CharT, _Traits>* __r =
4769 new __bracket_expression<_CharT, _Traits>(__traits_, __end_->first(),
4770 __negate, __flags_ & icase,
4771 __flags_ & collate);
4772 __end_->first() = __r;
4777 template <class _CharT, class _Traits>
4779 basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp,
4783 __end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert,
4784 __end_->first(), __mexp);
4785 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4788 typedef basic_regex<char> regex;
4789 typedef basic_regex<wchar_t> wregex;
4793 template <class _BidirectionalIterator>
4794 class _LIBCPP_TEMPLATE_VIS sub_match
4795 : public pair<_BidirectionalIterator, _BidirectionalIterator>
4798 typedef _BidirectionalIterator iterator;
4799 typedef typename iterator_traits<iterator>::value_type value_type;
4800 typedef typename iterator_traits<iterator>::difference_type difference_type;
4801 typedef basic_string<value_type> string_type;
4805 _LIBCPP_INLINE_VISIBILITY
4806 _LIBCPP_CONSTEXPR sub_match() : matched() {}
4808 _LIBCPP_INLINE_VISIBILITY
4809 difference_type length() const
4810 {return matched ? _VSTD::distance(this->first, this->second) : 0;}
4811 _LIBCPP_INLINE_VISIBILITY
4812 string_type str() const
4813 {return matched ? string_type(this->first, this->second) : string_type();}
4814 _LIBCPP_INLINE_VISIBILITY
4815 operator string_type() const
4818 _LIBCPP_INLINE_VISIBILITY
4819 int compare(const sub_match& __s) const
4820 {return str().compare(__s.str());}
4821 _LIBCPP_INLINE_VISIBILITY
4822 int compare(const string_type& __s) const
4823 {return str().compare(__s);}
4824 _LIBCPP_INLINE_VISIBILITY
4825 int compare(const value_type* __s) const
4826 {return str().compare(__s);}
4829 typedef sub_match<const char*> csub_match;
4830 typedef sub_match<const wchar_t*> wcsub_match;
4831 typedef sub_match<string::const_iterator> ssub_match;
4832 typedef sub_match<wstring::const_iterator> wssub_match;
4834 template <class _BiIter>
4835 inline _LIBCPP_INLINE_VISIBILITY
4837 operator==(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4839 return __x.compare(__y) == 0;
4842 template <class _BiIter>
4843 inline _LIBCPP_INLINE_VISIBILITY
4845 operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4847 return !(__x == __y);
4850 template <class _BiIter>
4851 inline _LIBCPP_INLINE_VISIBILITY
4853 operator<(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4855 return __x.compare(__y) < 0;
4858 template <class _BiIter>
4859 inline _LIBCPP_INLINE_VISIBILITY
4861 operator<=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4863 return !(__y < __x);
4866 template <class _BiIter>
4867 inline _LIBCPP_INLINE_VISIBILITY
4869 operator>=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4871 return !(__x < __y);
4874 template <class _BiIter>
4875 inline _LIBCPP_INLINE_VISIBILITY
4877 operator>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4882 template <class _BiIter, class _ST, class _SA>
4883 inline _LIBCPP_INLINE_VISIBILITY
4885 operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4886 const sub_match<_BiIter>& __y)
4888 return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0;
4891 template <class _BiIter, class _ST, class _SA>
4892 inline _LIBCPP_INLINE_VISIBILITY
4894 operator!=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4895 const sub_match<_BiIter>& __y)
4897 return !(__x == __y);
4900 template <class _BiIter, class _ST, class _SA>
4901 inline _LIBCPP_INLINE_VISIBILITY
4903 operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4904 const sub_match<_BiIter>& __y)
4906 return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0;
4909 template <class _BiIter, class _ST, class _SA>
4910 inline _LIBCPP_INLINE_VISIBILITY
4912 operator>(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4913 const sub_match<_BiIter>& __y)
4918 template <class _BiIter, class _ST, class _SA>
4919 inline _LIBCPP_INLINE_VISIBILITY
4920 bool operator>=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4921 const sub_match<_BiIter>& __y)
4923 return !(__x < __y);
4926 template <class _BiIter, class _ST, class _SA>
4927 inline _LIBCPP_INLINE_VISIBILITY
4929 operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4930 const sub_match<_BiIter>& __y)
4932 return !(__y < __x);
4935 template <class _BiIter, class _ST, class _SA>
4936 inline _LIBCPP_INLINE_VISIBILITY
4938 operator==(const sub_match<_BiIter>& __x,
4939 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4941 return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;
4944 template <class _BiIter, class _ST, class _SA>
4945 inline _LIBCPP_INLINE_VISIBILITY
4947 operator!=(const sub_match<_BiIter>& __x,
4948 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4950 return !(__x == __y);
4953 template <class _BiIter, class _ST, class _SA>
4954 inline _LIBCPP_INLINE_VISIBILITY
4956 operator<(const sub_match<_BiIter>& __x,
4957 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4959 return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0;
4962 template <class _BiIter, class _ST, class _SA>
4963 inline _LIBCPP_INLINE_VISIBILITY
4964 bool operator>(const sub_match<_BiIter>& __x,
4965 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4970 template <class _BiIter, class _ST, class _SA>
4971 inline _LIBCPP_INLINE_VISIBILITY
4973 operator>=(const sub_match<_BiIter>& __x,
4974 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4976 return !(__x < __y);
4979 template <class _BiIter, class _ST, class _SA>
4980 inline _LIBCPP_INLINE_VISIBILITY
4982 operator<=(const sub_match<_BiIter>& __x,
4983 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4985 return !(__y < __x);
4988 template <class _BiIter>
4989 inline _LIBCPP_INLINE_VISIBILITY
4991 operator==(typename iterator_traits<_BiIter>::value_type const* __x,
4992 const sub_match<_BiIter>& __y)
4994 return __y.compare(__x) == 0;
4997 template <class _BiIter>
4998 inline _LIBCPP_INLINE_VISIBILITY
5000 operator!=(typename iterator_traits<_BiIter>::value_type const* __x,
5001 const sub_match<_BiIter>& __y)
5003 return !(__x == __y);
5006 template <class _BiIter>
5007 inline _LIBCPP_INLINE_VISIBILITY
5009 operator<(typename iterator_traits<_BiIter>::value_type const* __x,
5010 const sub_match<_BiIter>& __y)
5012 return __y.compare(__x) > 0;
5015 template <class _BiIter>
5016 inline _LIBCPP_INLINE_VISIBILITY
5018 operator>(typename iterator_traits<_BiIter>::value_type const* __x,
5019 const sub_match<_BiIter>& __y)
5024 template <class _BiIter>
5025 inline _LIBCPP_INLINE_VISIBILITY
5027 operator>=(typename iterator_traits<_BiIter>::value_type const* __x,
5028 const sub_match<_BiIter>& __y)
5030 return !(__x < __y);
5033 template <class _BiIter>
5034 inline _LIBCPP_INLINE_VISIBILITY
5036 operator<=(typename iterator_traits<_BiIter>::value_type const* __x,
5037 const sub_match<_BiIter>& __y)
5039 return !(__y < __x);
5042 template <class _BiIter>
5043 inline _LIBCPP_INLINE_VISIBILITY
5045 operator==(const sub_match<_BiIter>& __x,
5046 typename iterator_traits<_BiIter>::value_type const* __y)
5048 return __x.compare(__y) == 0;
5051 template <class _BiIter>
5052 inline _LIBCPP_INLINE_VISIBILITY
5054 operator!=(const sub_match<_BiIter>& __x,
5055 typename iterator_traits<_BiIter>::value_type const* __y)
5057 return !(__x == __y);
5060 template <class _BiIter>
5061 inline _LIBCPP_INLINE_VISIBILITY
5063 operator<(const sub_match<_BiIter>& __x,
5064 typename iterator_traits<_BiIter>::value_type const* __y)
5066 return __x.compare(__y) < 0;
5069 template <class _BiIter>
5070 inline _LIBCPP_INLINE_VISIBILITY
5072 operator>(const sub_match<_BiIter>& __x,
5073 typename iterator_traits<_BiIter>::value_type const* __y)
5078 template <class _BiIter>
5079 inline _LIBCPP_INLINE_VISIBILITY
5081 operator>=(const sub_match<_BiIter>& __x,
5082 typename iterator_traits<_BiIter>::value_type const* __y)
5084 return !(__x < __y);
5087 template <class _BiIter>
5088 inline _LIBCPP_INLINE_VISIBILITY
5090 operator<=(const sub_match<_BiIter>& __x,
5091 typename iterator_traits<_BiIter>::value_type const* __y)
5093 return !(__y < __x);
5096 template <class _BiIter>
5097 inline _LIBCPP_INLINE_VISIBILITY
5099 operator==(typename iterator_traits<_BiIter>::value_type const& __x,
5100 const sub_match<_BiIter>& __y)
5102 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5103 return __y.compare(string_type(1, __x)) == 0;
5106 template <class _BiIter>
5107 inline _LIBCPP_INLINE_VISIBILITY
5109 operator!=(typename iterator_traits<_BiIter>::value_type const& __x,
5110 const sub_match<_BiIter>& __y)
5112 return !(__x == __y);
5115 template <class _BiIter>
5116 inline _LIBCPP_INLINE_VISIBILITY
5118 operator<(typename iterator_traits<_BiIter>::value_type const& __x,
5119 const sub_match<_BiIter>& __y)
5121 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5122 return __y.compare(string_type(1, __x)) > 0;
5125 template <class _BiIter>
5126 inline _LIBCPP_INLINE_VISIBILITY
5128 operator>(typename iterator_traits<_BiIter>::value_type const& __x,
5129 const sub_match<_BiIter>& __y)
5134 template <class _BiIter>
5135 inline _LIBCPP_INLINE_VISIBILITY
5137 operator>=(typename iterator_traits<_BiIter>::value_type const& __x,
5138 const sub_match<_BiIter>& __y)
5140 return !(__x < __y);
5143 template <class _BiIter>
5144 inline _LIBCPP_INLINE_VISIBILITY
5146 operator<=(typename iterator_traits<_BiIter>::value_type const& __x,
5147 const sub_match<_BiIter>& __y)
5149 return !(__y < __x);
5152 template <class _BiIter>
5153 inline _LIBCPP_INLINE_VISIBILITY
5155 operator==(const sub_match<_BiIter>& __x,
5156 typename iterator_traits<_BiIter>::value_type const& __y)
5158 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5159 return __x.compare(string_type(1, __y)) == 0;
5162 template <class _BiIter>
5163 inline _LIBCPP_INLINE_VISIBILITY
5165 operator!=(const sub_match<_BiIter>& __x,
5166 typename iterator_traits<_BiIter>::value_type const& __y)
5168 return !(__x == __y);
5171 template <class _BiIter>
5172 inline _LIBCPP_INLINE_VISIBILITY
5174 operator<(const sub_match<_BiIter>& __x,
5175 typename iterator_traits<_BiIter>::value_type const& __y)
5177 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5178 return __x.compare(string_type(1, __y)) < 0;
5181 template <class _BiIter>
5182 inline _LIBCPP_INLINE_VISIBILITY
5184 operator>(const sub_match<_BiIter>& __x,
5185 typename iterator_traits<_BiIter>::value_type const& __y)
5190 template <class _BiIter>
5191 inline _LIBCPP_INLINE_VISIBILITY
5193 operator>=(const sub_match<_BiIter>& __x,
5194 typename iterator_traits<_BiIter>::value_type const& __y)
5196 return !(__x < __y);
5199 template <class _BiIter>
5200 inline _LIBCPP_INLINE_VISIBILITY
5202 operator<=(const sub_match<_BiIter>& __x,
5203 typename iterator_traits<_BiIter>::value_type const& __y)
5205 return !(__y < __x);
5208 template <class _CharT, class _ST, class _BiIter>
5209 inline _LIBCPP_INLINE_VISIBILITY
5210 basic_ostream<_CharT, _ST>&
5211 operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m)
5213 return __os << __m.str();
5216 template <class _BidirectionalIterator, class _Allocator>
5217 class _LIBCPP_TEMPLATE_VIS match_results
5220 typedef _Allocator allocator_type;
5221 typedef sub_match<_BidirectionalIterator> value_type;
5223 typedef vector<value_type, allocator_type> __container_type;
5225 __container_type __matches_;
5226 value_type __unmatched_;
5227 value_type __prefix_;
5228 value_type __suffix_;
5231 _BidirectionalIterator __position_start_;
5232 typedef const value_type& const_reference;
5233 typedef value_type& reference;
5234 typedef typename __container_type::const_iterator const_iterator;
5235 typedef const_iterator iterator;
5236 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
5237 typedef typename allocator_traits<allocator_type>::size_type size_type;
5238 typedef typename iterator_traits<_BidirectionalIterator>::value_type char_type;
5239 typedef basic_string<char_type> string_type;
5241 // construct/copy/destroy:
5242 explicit match_results(const allocator_type& __a = allocator_type());
5243 // match_results(const match_results&) = default;
5244 // match_results& operator=(const match_results&) = default;
5245 // match_results(match_results&& __m) = default;
5246 // match_results& operator=(match_results&& __m) = default;
5247 // ~match_results() = default;
5249 _LIBCPP_INLINE_VISIBILITY
5250 bool ready() const {return __ready_;}
5253 _LIBCPP_INLINE_VISIBILITY
5254 size_type size() const _NOEXCEPT {return __matches_.size();}
5255 _LIBCPP_INLINE_VISIBILITY
5256 size_type max_size() const _NOEXCEPT {return __matches_.max_size();}
5257 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
5258 bool empty() const _NOEXCEPT {return size() == 0;}
5261 _LIBCPP_INLINE_VISIBILITY
5262 difference_type length(size_type __sub = 0) const
5263 {return (*this)[__sub].length();}
5264 _LIBCPP_INLINE_VISIBILITY
5265 difference_type position(size_type __sub = 0) const
5266 {return _VSTD::distance(__position_start_, (*this)[__sub].first);}
5267 _LIBCPP_INLINE_VISIBILITY
5268 string_type str(size_type __sub = 0) const
5269 {return (*this)[__sub].str();}
5270 _LIBCPP_INLINE_VISIBILITY
5271 const_reference operator[](size_type __n) const
5272 {return __n < __matches_.size() ? __matches_[__n] : __unmatched_;}
5274 _LIBCPP_INLINE_VISIBILITY
5275 const_reference prefix() const {return __prefix_;}
5276 _LIBCPP_INLINE_VISIBILITY
5277 const_reference suffix() const {return __suffix_;}
5279 _LIBCPP_INLINE_VISIBILITY
5280 const_iterator begin() const {return empty() ? __matches_.end() : __matches_.begin();}
5281 _LIBCPP_INLINE_VISIBILITY
5282 const_iterator end() const {return __matches_.end();}
5283 _LIBCPP_INLINE_VISIBILITY
5284 const_iterator cbegin() const {return empty() ? __matches_.end() : __matches_.begin();}
5285 _LIBCPP_INLINE_VISIBILITY
5286 const_iterator cend() const {return __matches_.end();}
5289 template <class _OutputIter>
5291 format(_OutputIter __output_iter, const char_type* __fmt_first,
5292 const char_type* __fmt_last,
5293 regex_constants::match_flag_type __flags = regex_constants::format_default) const;
5294 template <class _OutputIter, class _ST, class _SA>
5295 _LIBCPP_INLINE_VISIBILITY
5297 format(_OutputIter __output_iter, const basic_string<char_type, _ST, _SA>& __fmt,
5298 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5299 {return format(__output_iter, __fmt.data(), __fmt.data() + __fmt.size(), __flags);}
5300 template <class _ST, class _SA>
5301 _LIBCPP_INLINE_VISIBILITY
5302 basic_string<char_type, _ST, _SA>
5303 format(const basic_string<char_type, _ST, _SA>& __fmt,
5304 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5306 basic_string<char_type, _ST, _SA> __r;
5307 format(back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(),
5311 _LIBCPP_INLINE_VISIBILITY
5313 format(const char_type* __fmt,
5314 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5317 format(back_inserter(__r), __fmt,
5318 __fmt + char_traits<char_type>::length(__fmt), __flags);
5323 _LIBCPP_INLINE_VISIBILITY
5324 allocator_type get_allocator() const {return __matches_.get_allocator();}
5327 void swap(match_results& __m);
5329 template <class _Bp, class _Ap>
5330 _LIBCPP_INLINE_VISIBILITY
5331 void __assign(_BidirectionalIterator __f, _BidirectionalIterator __l,
5332 const match_results<_Bp, _Ap>& __m, bool __no_update_pos)
5334 _Bp __mf = __m.prefix().first;
5335 __matches_.resize(__m.size());
5336 for (size_type __i = 0; __i < __matches_.size(); ++__i)
5338 __matches_[__i].first = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].first));
5339 __matches_[__i].second = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].second));
5340 __matches_[__i].matched = __m[__i].matched;
5342 __unmatched_.first = __l;
5343 __unmatched_.second = __l;
5344 __unmatched_.matched = false;
5345 __prefix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().first));
5346 __prefix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().second));
5347 __prefix_.matched = __m.prefix().matched;
5348 __suffix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().first));
5349 __suffix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().second));
5350 __suffix_.matched = __m.suffix().matched;
5351 if (!__no_update_pos)
5352 __position_start_ = __prefix_.first;
5353 __ready_ = __m.ready();
5357 void __init(unsigned __s,
5358 _BidirectionalIterator __f, _BidirectionalIterator __l,
5359 bool __no_update_pos = false);
5361 template <class, class> friend class basic_regex;
5363 template <class _Bp, class _Ap, class _Cp, class _Tp>
5366 regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
5367 regex_constants::match_flag_type);
5369 template <class _Bp, class _Ap>
5372 operator==(const match_results<_Bp, _Ap>&, const match_results<_Bp, _Ap>&);
5374 template <class, class> friend class __lookahead;
5377 template <class _BidirectionalIterator, class _Allocator>
5378 match_results<_BidirectionalIterator, _Allocator>::match_results(
5379 const allocator_type& __a)
5389 template <class _BidirectionalIterator, class _Allocator>
5391 match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s,
5392 _BidirectionalIterator __f, _BidirectionalIterator __l,
5393 bool __no_update_pos)
5395 __unmatched_.first = __l;
5396 __unmatched_.second = __l;
5397 __unmatched_.matched = false;
5398 __matches_.assign(__s, __unmatched_);
5399 __prefix_.first = __f;
5400 __prefix_.second = __f;
5401 __prefix_.matched = false;
5402 __suffix_ = __unmatched_;
5403 if (!__no_update_pos)
5404 __position_start_ = __prefix_.first;
5408 template <class _BidirectionalIterator, class _Allocator>
5409 template <class _OutputIter>
5411 match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output_iter,
5412 const char_type* __fmt_first, const char_type* __fmt_last,
5413 regex_constants::match_flag_type __flags) const
5415 if (__flags & regex_constants::format_sed)
5417 for (; __fmt_first != __fmt_last; ++__fmt_first)
5419 if (*__fmt_first == '&')
5420 __output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second,
5422 else if (*__fmt_first == '\\' && __fmt_first + 1 != __fmt_last)
5425 if ('0' <= *__fmt_first && *__fmt_first <= '9')
5427 size_t __i = *__fmt_first - '0';
5428 __output_iter = _VSTD::copy((*this)[__i].first,
5429 (*this)[__i].second, __output_iter);
5433 *__output_iter = *__fmt_first;
5439 *__output_iter = *__fmt_first;
5446 for (; __fmt_first != __fmt_last; ++__fmt_first)
5448 if (*__fmt_first == '$' && __fmt_first + 1 != __fmt_last)
5450 switch (__fmt_first[1])
5453 *__output_iter = *++__fmt_first;
5458 __output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second,
5463 __output_iter = _VSTD::copy(__prefix_.first, __prefix_.second, __output_iter);
5467 __output_iter = _VSTD::copy(__suffix_.first, __suffix_.second, __output_iter);
5470 if ('0' <= __fmt_first[1] && __fmt_first[1] <= '9')
5473 size_t __idx = *__fmt_first - '0';
5474 if (__fmt_first + 1 != __fmt_last &&
5475 '0' <= __fmt_first[1] && __fmt_first[1] <= '9')
5478 if (__idx >= std::numeric_limits<size_t>::max() / 10)
5479 __throw_regex_error<regex_constants::error_escape>();
5480 __idx = 10 * __idx + *__fmt_first - '0';
5482 __output_iter = _VSTD::copy((*this)[__idx].first,
5483 (*this)[__idx].second, __output_iter);
5487 *__output_iter = *__fmt_first;
5495 *__output_iter = *__fmt_first;
5500 return __output_iter;
5503 template <class _BidirectionalIterator, class _Allocator>
5505 match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
5508 swap(__matches_, __m.__matches_);
5509 swap(__unmatched_, __m.__unmatched_);
5510 swap(__prefix_, __m.__prefix_);
5511 swap(__suffix_, __m.__suffix_);
5512 swap(__position_start_, __m.__position_start_);
5513 swap(__ready_, __m.__ready_);
5516 typedef match_results<const char*> cmatch;
5517 typedef match_results<const wchar_t*> wcmatch;
5518 typedef match_results<string::const_iterator> smatch;
5519 typedef match_results<wstring::const_iterator> wsmatch;
5521 template <class _BidirectionalIterator, class _Allocator>
5523 operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
5524 const match_results<_BidirectionalIterator, _Allocator>& __y)
5526 if (__x.__ready_ != __y.__ready_)
5530 return __x.__matches_ == __y.__matches_ &&
5531 __x.__prefix_ == __y.__prefix_ &&
5532 __x.__suffix_ == __y.__suffix_;
5535 template <class _BidirectionalIterator, class _Allocator>
5536 inline _LIBCPP_INLINE_VISIBILITY
5538 operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,
5539 const match_results<_BidirectionalIterator, _Allocator>& __y)
5541 return !(__x == __y);
5544 template <class _BidirectionalIterator, class _Allocator>
5545 inline _LIBCPP_INLINE_VISIBILITY
5547 swap(match_results<_BidirectionalIterator, _Allocator>& __x,
5548 match_results<_BidirectionalIterator, _Allocator>& __y)
5555 template <class _CharT, class _Traits>
5556 template <class _Allocator>
5558 basic_regex<_CharT, _Traits>::__match_at_start_ecma(
5559 const _CharT* __first, const _CharT* __last,
5560 match_results<const _CharT*, _Allocator>& __m,
5561 regex_constants::match_flag_type __flags, bool __at_first) const
5563 vector<__state> __states;
5564 __node* __st = __start_.get();
5567 sub_match<const _CharT*> __unmatched;
5568 __unmatched.first = __last;
5569 __unmatched.second = __last;
5570 __unmatched.matched = false;
5572 __states.push_back(__state());
5573 __states.back().__do_ = 0;
5574 __states.back().__first_ = __first;
5575 __states.back().__current_ = __first;
5576 __states.back().__last_ = __last;
5577 __states.back().__sub_matches_.resize(mark_count(), __unmatched);
5578 __states.back().__loop_data_.resize(__loop_count());
5579 __states.back().__node_ = __st;
5580 __states.back().__flags_ = __flags;
5581 __states.back().__at_first_ = __at_first;
5583 int __length = __last - __first;
5587 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
5588 __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
5589 __throw_regex_error<regex_constants::error_complexity>();
5590 __state& __s = __states.back();
5592 __s.__node_->__exec(__s);
5595 case __state::__end_state:
5596 if ((__flags & regex_constants::match_not_null) &&
5597 __s.__current_ == __first)
5599 __states.pop_back();
5602 if ((__flags & regex_constants::__full_match) &&
5603 __s.__current_ != __last)
5605 __states.pop_back();
5608 __m.__matches_[0].first = __first;
5609 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first);
5610 __m.__matches_[0].matched = true;
5611 for (unsigned __i = 0; __i < __s.__sub_matches_.size(); ++__i)
5612 __m.__matches_[__i+1] = __s.__sub_matches_[__i];
5614 case __state::__accept_and_consume:
5615 case __state::__repeat:
5616 case __state::__accept_but_not_consume:
5618 case __state::__split:
5620 __state __snext = __s;
5621 __s.__node_->__exec_split(true, __s);
5622 __snext.__node_->__exec_split(false, __snext);
5623 __states.push_back(_VSTD::move(__snext));
5626 case __state::__reject:
5627 __states.pop_back();
5630 __throw_regex_error<regex_constants::__re_err_unknown>();
5634 } while (!__states.empty());
5639 template <class _CharT, class _Traits>
5640 template <class _Allocator>
5642 basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
5643 const _CharT* __first, const _CharT* __last,
5644 match_results<const _CharT*, _Allocator>& __m,
5645 regex_constants::match_flag_type __flags, bool __at_first) const
5647 deque<__state> __states;
5648 ptrdiff_t __highest_j = 0;
5649 ptrdiff_t _Np = _VSTD::distance(__first, __last);
5650 __node* __st = __start_.get();
5653 __states.push_back(__state());
5654 __states.back().__do_ = 0;
5655 __states.back().__first_ = __first;
5656 __states.back().__current_ = __first;
5657 __states.back().__last_ = __last;
5658 __states.back().__loop_data_.resize(__loop_count());
5659 __states.back().__node_ = __st;
5660 __states.back().__flags_ = __flags;
5661 __states.back().__at_first_ = __at_first;
5662 bool __matched = false;
5664 int __length = __last - __first;
5668 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
5669 __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
5670 __throw_regex_error<regex_constants::error_complexity>();
5671 __state& __s = __states.back();
5673 __s.__node_->__exec(__s);
5676 case __state::__end_state:
5677 if ((__flags & regex_constants::match_not_null) &&
5678 __s.__current_ == __first)
5680 __states.pop_back();
5683 if ((__flags & regex_constants::__full_match) &&
5684 __s.__current_ != __last)
5686 __states.pop_back();
5689 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
5690 __highest_j = __s.__current_ - __s.__first_;
5692 if (__highest_j == _Np)
5695 __states.pop_back();
5697 case __state::__consume_input:
5699 case __state::__accept_and_consume:
5700 __states.push_front(_VSTD::move(__s));
5701 __states.pop_back();
5703 case __state::__repeat:
5704 case __state::__accept_but_not_consume:
5706 case __state::__split:
5708 __state __snext = __s;
5709 __s.__node_->__exec_split(true, __s);
5710 __snext.__node_->__exec_split(false, __snext);
5711 __states.push_back(_VSTD::move(__snext));
5714 case __state::__reject:
5715 __states.pop_back();
5718 __throw_regex_error<regex_constants::__re_err_unknown>();
5721 } while (!__states.empty());
5724 __m.__matches_[0].first = __first;
5725 __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
5726 __m.__matches_[0].matched = true;
5733 template <class _CharT, class _Traits>
5734 template <class _Allocator>
5736 basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
5737 const _CharT* __first, const _CharT* __last,
5738 match_results<const _CharT*, _Allocator>& __m,
5739 regex_constants::match_flag_type __flags, bool __at_first) const
5741 vector<__state> __states;
5742 __state __best_state;
5744 ptrdiff_t __highest_j = 0;
5745 ptrdiff_t _Np = _VSTD::distance(__first, __last);
5746 __node* __st = __start_.get();
5749 sub_match<const _CharT*> __unmatched;
5750 __unmatched.first = __last;
5751 __unmatched.second = __last;
5752 __unmatched.matched = false;
5754 __states.push_back(__state());
5755 __states.back().__do_ = 0;
5756 __states.back().__first_ = __first;
5757 __states.back().__current_ = __first;
5758 __states.back().__last_ = __last;
5759 __states.back().__sub_matches_.resize(mark_count(), __unmatched);
5760 __states.back().__loop_data_.resize(__loop_count());
5761 __states.back().__node_ = __st;
5762 __states.back().__flags_ = __flags;
5763 __states.back().__at_first_ = __at_first;
5764 const _CharT* __current = __first;
5765 bool __matched = false;
5767 int __length = __last - __first;
5771 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
5772 __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
5773 __throw_regex_error<regex_constants::error_complexity>();
5774 __state& __s = __states.back();
5776 __s.__node_->__exec(__s);
5779 case __state::__end_state:
5780 if ((__flags & regex_constants::match_not_null) &&
5781 __s.__current_ == __first)
5783 __states.pop_back();
5786 if ((__flags & regex_constants::__full_match) &&
5787 __s.__current_ != __last)
5789 __states.pop_back();
5792 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
5794 __highest_j = __s.__current_ - __s.__first_;
5798 if (__highest_j == _Np)
5801 __states.pop_back();
5803 case __state::__accept_and_consume:
5804 __j += __s.__current_ - __current;
5805 __current = __s.__current_;
5807 case __state::__repeat:
5808 case __state::__accept_but_not_consume:
5810 case __state::__split:
5812 __state __snext = __s;
5813 __s.__node_->__exec_split(true, __s);
5814 __snext.__node_->__exec_split(false, __snext);
5815 __states.push_back(_VSTD::move(__snext));
5818 case __state::__reject:
5819 __states.pop_back();
5822 __throw_regex_error<regex_constants::__re_err_unknown>();
5825 } while (!__states.empty());
5828 __m.__matches_[0].first = __first;
5829 __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
5830 __m.__matches_[0].matched = true;
5831 for (unsigned __i = 0; __i < __best_state.__sub_matches_.size(); ++__i)
5832 __m.__matches_[__i+1] = __best_state.__sub_matches_[__i];
5839 template <class _CharT, class _Traits>
5840 template <class _Allocator>
5842 basic_regex<_CharT, _Traits>::__match_at_start(
5843 const _CharT* __first, const _CharT* __last,
5844 match_results<const _CharT*, _Allocator>& __m,
5845 regex_constants::match_flag_type __flags, bool __at_first) const
5847 if ((__flags_ & 0x1F0) == ECMAScript)
5848 return __match_at_start_ecma(__first, __last, __m, __flags, __at_first);
5849 if (mark_count() == 0)
5850 return __match_at_start_posix_nosubs(__first, __last, __m, __flags, __at_first);
5851 return __match_at_start_posix_subs(__first, __last, __m, __flags, __at_first);
5854 template <class _CharT, class _Traits>
5855 template <class _Allocator>
5857 basic_regex<_CharT, _Traits>::__search(
5858 const _CharT* __first, const _CharT* __last,
5859 match_results<const _CharT*, _Allocator>& __m,
5860 regex_constants::match_flag_type __flags) const
5862 __m.__init(1 + mark_count(), __first, __last,
5863 __flags & regex_constants::__no_update_pos);
5864 if (__match_at_start(__first, __last, __m, __flags,
5865 !(__flags & regex_constants::__no_update_pos)))
5867 __m.__prefix_.second = __m[0].first;
5868 __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
5869 __m.__suffix_.first = __m[0].second;
5870 __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
5873 if (__first != __last && !(__flags & regex_constants::match_continuous))
5875 __flags |= regex_constants::match_prev_avail;
5876 for (++__first; __first != __last; ++__first)
5878 __m.__matches_.assign(__m.size(), __m.__unmatched_);
5879 if (__match_at_start(__first, __last, __m, __flags, false))
5881 __m.__prefix_.second = __m[0].first;
5882 __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
5883 __m.__suffix_.first = __m[0].second;
5884 __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
5887 __m.__matches_.assign(__m.size(), __m.__unmatched_);
5890 __m.__matches_.clear();
5894 template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
5895 inline _LIBCPP_INLINE_VISIBILITY
5897 regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
5898 match_results<_BidirectionalIterator, _Allocator>& __m,
5899 const basic_regex<_CharT, _Traits>& __e,
5900 regex_constants::match_flag_type __flags = regex_constants::match_default)
5902 int __offset = (__flags & regex_constants::match_prev_avail) ? 1 : 0;
5903 basic_string<_CharT> __s(_VSTD::prev(__first, __offset), __last);
5904 match_results<const _CharT*> __mc;
5905 bool __r = __e.__search(__s.data() + __offset, __s.data() + __s.size(), __mc, __flags);
5906 __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
5910 template <class _Iter, class _Allocator, class _CharT, class _Traits>
5911 inline _LIBCPP_INLINE_VISIBILITY
5913 regex_search(__wrap_iter<_Iter> __first,
5914 __wrap_iter<_Iter> __last,
5915 match_results<__wrap_iter<_Iter>, _Allocator>& __m,
5916 const basic_regex<_CharT, _Traits>& __e,
5917 regex_constants::match_flag_type __flags = regex_constants::match_default)
5919 match_results<const _CharT*> __mc;
5920 bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags);
5921 __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
5925 template <class _Allocator, class _CharT, class _Traits>
5926 inline _LIBCPP_INLINE_VISIBILITY
5928 regex_search(const _CharT* __first, const _CharT* __last,
5929 match_results<const _CharT*, _Allocator>& __m,
5930 const basic_regex<_CharT, _Traits>& __e,
5931 regex_constants::match_flag_type __flags = regex_constants::match_default)
5933 return __e.__search(__first, __last, __m, __flags);
5936 template <class _BidirectionalIterator, class _CharT, class _Traits>
5937 inline _LIBCPP_INLINE_VISIBILITY
5939 regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
5940 const basic_regex<_CharT, _Traits>& __e,
5941 regex_constants::match_flag_type __flags = regex_constants::match_default)
5943 basic_string<_CharT> __s(__first, __last);
5944 match_results<const _CharT*> __mc;
5945 return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
5948 template <class _CharT, class _Traits>
5949 inline _LIBCPP_INLINE_VISIBILITY
5951 regex_search(const _CharT* __first, const _CharT* __last,
5952 const basic_regex<_CharT, _Traits>& __e,
5953 regex_constants::match_flag_type __flags = regex_constants::match_default)
5955 match_results<const _CharT*> __mc;
5956 return __e.__search(__first, __last, __mc, __flags);
5959 template <class _CharT, class _Allocator, class _Traits>
5960 inline _LIBCPP_INLINE_VISIBILITY
5962 regex_search(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
5963 const basic_regex<_CharT, _Traits>& __e,
5964 regex_constants::match_flag_type __flags = regex_constants::match_default)
5966 return __e.__search(__str, __str + _Traits::length(__str), __m, __flags);
5969 template <class _CharT, class _Traits>
5970 inline _LIBCPP_INLINE_VISIBILITY
5972 regex_search(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
5973 regex_constants::match_flag_type __flags = regex_constants::match_default)
5975 match_results<const _CharT*> __m;
5976 return _VSTD::regex_search(__str, __m, __e, __flags);
5979 template <class _ST, class _SA, class _CharT, class _Traits>
5980 inline _LIBCPP_INLINE_VISIBILITY
5982 regex_search(const basic_string<_CharT, _ST, _SA>& __s,
5983 const basic_regex<_CharT, _Traits>& __e,
5984 regex_constants::match_flag_type __flags = regex_constants::match_default)
5986 match_results<const _CharT*> __mc;
5987 return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
5990 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
5991 inline _LIBCPP_INLINE_VISIBILITY
5993 regex_search(const basic_string<_CharT, _ST, _SA>& __s,
5994 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
5995 const basic_regex<_CharT, _Traits>& __e,
5996 regex_constants::match_flag_type __flags = regex_constants::match_default)
5998 match_results<const _CharT*> __mc;
5999 bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
6000 __m.__assign(__s.begin(), __s.end(), __mc, __flags & regex_constants::__no_update_pos);
6004 #if _LIBCPP_STD_VER > 11
6005 template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
6007 regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
6008 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
6009 const basic_regex<_Cp, _Tp>& __e,
6010 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
6015 template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
6017 regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
6018 match_results<_BidirectionalIterator, _Allocator>& __m,
6019 const basic_regex<_CharT, _Traits>& __e,
6020 regex_constants::match_flag_type __flags = regex_constants::match_default)
6022 bool __r = _VSTD::regex_search(
6023 __first, __last, __m, __e,
6024 __flags | regex_constants::match_continuous |
6025 regex_constants::__full_match);
6028 __r = !__m.suffix().matched;
6030 __m.__matches_.clear();
6035 template <class _BidirectionalIterator, class _CharT, class _Traits>
6036 inline _LIBCPP_INLINE_VISIBILITY
6038 regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
6039 const basic_regex<_CharT, _Traits>& __e,
6040 regex_constants::match_flag_type __flags = regex_constants::match_default)
6042 match_results<_BidirectionalIterator> __m;
6043 return _VSTD::regex_match(__first, __last, __m, __e, __flags);
6046 template <class _CharT, class _Allocator, class _Traits>
6047 inline _LIBCPP_INLINE_VISIBILITY
6049 regex_match(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
6050 const basic_regex<_CharT, _Traits>& __e,
6051 regex_constants::match_flag_type __flags = regex_constants::match_default)
6053 return _VSTD::regex_match(__str, __str + _Traits::length(__str), __m, __e, __flags);
6056 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
6057 inline _LIBCPP_INLINE_VISIBILITY
6059 regex_match(const basic_string<_CharT, _ST, _SA>& __s,
6060 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
6061 const basic_regex<_CharT, _Traits>& __e,
6062 regex_constants::match_flag_type __flags = regex_constants::match_default)
6064 return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags);
6067 #if _LIBCPP_STD_VER > 11
6068 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
6069 inline _LIBCPP_INLINE_VISIBILITY
6071 regex_match(const basic_string<_CharT, _ST, _SA>&& __s,
6072 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
6073 const basic_regex<_CharT, _Traits>& __e,
6074 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
6077 template <class _CharT, class _Traits>
6078 inline _LIBCPP_INLINE_VISIBILITY
6080 regex_match(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
6081 regex_constants::match_flag_type __flags = regex_constants::match_default)
6083 return _VSTD::regex_match(__str, __str + _Traits::length(__str), __e, __flags);
6086 template <class _ST, class _SA, class _CharT, class _Traits>
6087 inline _LIBCPP_INLINE_VISIBILITY
6089 regex_match(const basic_string<_CharT, _ST, _SA>& __s,
6090 const basic_regex<_CharT, _Traits>& __e,
6091 regex_constants::match_flag_type __flags = regex_constants::match_default)
6093 return _VSTD::regex_match(__s.begin(), __s.end(), __e, __flags);
6098 template <class _BidirectionalIterator,
6099 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
6100 class _Traits = regex_traits<_CharT> >
6101 class _LIBCPP_TEMPLATE_VIS regex_iterator
6104 typedef basic_regex<_CharT, _Traits> regex_type;
6105 typedef match_results<_BidirectionalIterator> value_type;
6106 typedef ptrdiff_t difference_type;
6107 typedef const value_type* pointer;
6108 typedef const value_type& reference;
6109 typedef forward_iterator_tag iterator_category;
6112 _BidirectionalIterator __begin_;
6113 _BidirectionalIterator __end_;
6114 const regex_type* __pregex_;
6115 regex_constants::match_flag_type __flags_;
6116 value_type __match_;
6120 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6121 const regex_type& __re,
6122 regex_constants::match_flag_type __m
6123 = regex_constants::match_default);
6124 #if _LIBCPP_STD_VER > 11
6125 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6126 const regex_type&& __re,
6127 regex_constants::match_flag_type __m
6128 = regex_constants::match_default) = delete;
6131 bool operator==(const regex_iterator& __x) const;
6132 _LIBCPP_INLINE_VISIBILITY
6133 bool operator!=(const regex_iterator& __x) const {return !(*this == __x);}
6135 _LIBCPP_INLINE_VISIBILITY
6136 reference operator*() const {return __match_;}
6137 _LIBCPP_INLINE_VISIBILITY
6138 pointer operator->() const {return &__match_;}
6140 regex_iterator& operator++();
6141 _LIBCPP_INLINE_VISIBILITY
6142 regex_iterator operator++(int)
6144 regex_iterator __t(*this);
6150 template <class _BidirectionalIterator, class _CharT, class _Traits>
6151 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_iterator()
6152 : __begin_(), __end_(), __pregex_(nullptr), __flags_(), __match_()
6156 template <class _BidirectionalIterator, class _CharT, class _Traits>
6157 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
6158 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6159 const regex_type& __re, regex_constants::match_flag_type __m)
6165 _VSTD::regex_search(__begin_, __end_, __match_, *__pregex_, __flags_);
6168 template <class _BidirectionalIterator, class _CharT, class _Traits>
6170 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
6171 operator==(const regex_iterator& __x) const
6173 if (__match_.empty() && __x.__match_.empty())
6175 if (__match_.empty() || __x.__match_.empty())
6177 return __begin_ == __x.__begin_ &&
6178 __end_ == __x.__end_ &&
6179 __pregex_ == __x.__pregex_ &&
6180 __flags_ == __x.__flags_ &&
6181 __match_[0] == __x.__match_[0];
6184 template <class _BidirectionalIterator, class _CharT, class _Traits>
6185 regex_iterator<_BidirectionalIterator, _CharT, _Traits>&
6186 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6188 __flags_ |= regex_constants::__no_update_pos;
6189 _BidirectionalIterator __start = __match_[0].second;
6190 if (__match_[0].first == __match_[0].second)
6192 if (__start == __end_)
6194 __match_ = value_type();
6197 else if (_VSTD::regex_search(__start, __end_, __match_, *__pregex_,
6198 __flags_ | regex_constants::match_not_null |
6199 regex_constants::match_continuous))
6204 __flags_ |= regex_constants::match_prev_avail;
6205 if (!_VSTD::regex_search(__start, __end_, __match_, *__pregex_, __flags_))
6206 __match_ = value_type();
6210 typedef regex_iterator<const char*> cregex_iterator;
6211 typedef regex_iterator<const wchar_t*> wcregex_iterator;
6212 typedef regex_iterator<string::const_iterator> sregex_iterator;
6213 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
6215 // regex_token_iterator
6217 template <class _BidirectionalIterator,
6218 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
6219 class _Traits = regex_traits<_CharT> >
6220 class _LIBCPP_TEMPLATE_VIS regex_token_iterator
6223 typedef basic_regex<_CharT, _Traits> regex_type;
6224 typedef sub_match<_BidirectionalIterator> value_type;
6225 typedef ptrdiff_t difference_type;
6226 typedef const value_type* pointer;
6227 typedef const value_type& reference;
6228 typedef forward_iterator_tag iterator_category;
6231 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position;
6233 _Position __position_;
6234 const value_type* __result_;
6235 value_type __suffix_;
6237 vector<int> __subs_;
6240 regex_token_iterator();
6241 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6242 const regex_type& __re, int __submatch = 0,
6243 regex_constants::match_flag_type __m =
6244 regex_constants::match_default);
6245 #if _LIBCPP_STD_VER > 11
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) = delete;
6252 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6253 const regex_type& __re, const vector<int>& __submatches,
6254 regex_constants::match_flag_type __m =
6255 regex_constants::match_default);
6256 #if _LIBCPP_STD_VER > 11
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) = delete;
6263 #ifndef _LIBCPP_CXX03_LANG
6264 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6265 const regex_type& __re,
6266 initializer_list<int> __submatches,
6267 regex_constants::match_flag_type __m =
6268 regex_constants::match_default);
6270 #if _LIBCPP_STD_VER > 11
6271 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6272 const regex_type&& __re,
6273 initializer_list<int> __submatches,
6274 regex_constants::match_flag_type __m =
6275 regex_constants::match_default) = delete;
6277 #endif // _LIBCPP_CXX03_LANG
6278 template <size_t _Np>
6279 regex_token_iterator(_BidirectionalIterator __a,
6280 _BidirectionalIterator __b,
6281 const regex_type& __re,
6282 const int (&__submatches)[_Np],
6283 regex_constants::match_flag_type __m =
6284 regex_constants::match_default);
6285 #if _LIBCPP_STD_VER > 11
6286 template <std::size_t _Np>
6287 regex_token_iterator(_BidirectionalIterator __a,
6288 _BidirectionalIterator __b,
6289 const regex_type&& __re,
6290 const int (&__submatches)[_Np],
6291 regex_constants::match_flag_type __m =
6292 regex_constants::match_default) = delete;
6295 regex_token_iterator(const regex_token_iterator&);
6296 regex_token_iterator& operator=(const regex_token_iterator&);
6298 bool operator==(const regex_token_iterator& __x) const;
6299 _LIBCPP_INLINE_VISIBILITY
6300 bool operator!=(const regex_token_iterator& __x) const {return !(*this == __x);}
6302 _LIBCPP_INLINE_VISIBILITY
6303 const value_type& operator*() const {return *__result_;}
6304 _LIBCPP_INLINE_VISIBILITY
6305 const value_type* operator->() const {return __result_;}
6307 regex_token_iterator& operator++();
6308 _LIBCPP_INLINE_VISIBILITY
6309 regex_token_iterator operator++(int)
6311 regex_token_iterator __t(*this);
6317 void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
6318 void __establish_result () {
6319 if (__subs_[__n_] == -1)
6320 __result_ = &__position_->prefix();
6322 __result_ = &(*__position_)[__subs_[__n_]];
6326 template <class _BidirectionalIterator, class _CharT, class _Traits>
6327 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6328 regex_token_iterator()
6329 : __result_(nullptr),
6335 template <class _BidirectionalIterator, class _CharT, class _Traits>
6337 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6338 __init(_BidirectionalIterator __a, _BidirectionalIterator __b)
6340 if (__position_ != _Position())
6341 __establish_result ();
6342 else if (__subs_[__n_] == -1)
6344 __suffix_.matched = true;
6345 __suffix_.first = __a;
6346 __suffix_.second = __b;
6347 __result_ = &__suffix_;
6350 __result_ = nullptr;
6353 template <class _BidirectionalIterator, class _CharT, class _Traits>
6354 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6355 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6356 const regex_type& __re, int __submatch,
6357 regex_constants::match_flag_type __m)
6358 : __position_(__a, __b, __re, __m),
6360 __subs_(1, __submatch)
6365 template <class _BidirectionalIterator, class _CharT, class _Traits>
6366 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6367 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6368 const regex_type& __re, const vector<int>& __submatches,
6369 regex_constants::match_flag_type __m)
6370 : __position_(__a, __b, __re, __m),
6372 __subs_(__submatches)
6377 #ifndef _LIBCPP_CXX03_LANG
6379 template <class _BidirectionalIterator, class _CharT, class _Traits>
6380 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6381 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6382 const regex_type& __re,
6383 initializer_list<int> __submatches,
6384 regex_constants::match_flag_type __m)
6385 : __position_(__a, __b, __re, __m),
6387 __subs_(__submatches)
6392 #endif // _LIBCPP_CXX03_LANG
6394 template <class _BidirectionalIterator, class _CharT, class _Traits>
6395 template <size_t _Np>
6396 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6397 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6398 const regex_type& __re,
6399 const int (&__submatches)[_Np],
6400 regex_constants::match_flag_type __m)
6401 : __position_(__a, __b, __re, __m),
6403 __subs_(__submatches, __submatches + _Np)
6408 template <class _BidirectionalIterator, class _CharT, class _Traits>
6409 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6410 regex_token_iterator(const regex_token_iterator& __x)
6411 : __position_(__x.__position_),
6412 __result_(__x.__result_),
6413 __suffix_(__x.__suffix_),
6415 __subs_(__x.__subs_)
6417 if (__x.__result_ == &__x.__suffix_)
6418 __result_ = &__suffix_;
6419 else if ( __result_ != nullptr )
6420 __establish_result ();
6423 template <class _BidirectionalIterator, class _CharT, class _Traits>
6424 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
6425 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6426 operator=(const regex_token_iterator& __x)
6430 __position_ = __x.__position_;
6431 if (__x.__result_ == &__x.__suffix_)
6432 __result_ = &__suffix_;
6434 __result_ = __x.__result_;
6435 __suffix_ = __x.__suffix_;
6437 __subs_ = __x.__subs_;
6439 if ( __result_ != nullptr && __result_ != &__suffix_ )
6440 __establish_result();
6445 template <class _BidirectionalIterator, class _CharT, class _Traits>
6447 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6448 operator==(const regex_token_iterator& __x) const
6450 if (__result_ == nullptr && __x.__result_ == nullptr)
6452 if (__result_ == &__suffix_ && __x.__result_ == &__x.__suffix_ &&
6453 __suffix_ == __x.__suffix_)
6455 if (__result_ == nullptr || __x.__result_ == nullptr)
6457 if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_)
6459 return __position_ == __x.__position_ && __n_ == __x.__n_ &&
6460 __subs_ == __x.__subs_;
6463 template <class _BidirectionalIterator, class _CharT, class _Traits>
6464 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
6465 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6467 _Position __prev = __position_;
6468 if (__result_ == &__suffix_)
6469 __result_ = nullptr;
6470 else if (static_cast<size_t>(__n_ + 1) < __subs_.size())
6473 __establish_result();
6479 if (__position_ != _Position())
6480 __establish_result();
6483 if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end()
6484 && __prev->suffix().length() != 0)
6486 __suffix_.matched = true;
6487 __suffix_.first = __prev->suffix().first;
6488 __suffix_.second = __prev->suffix().second;
6489 __result_ = &__suffix_;
6492 __result_ = nullptr;
6498 typedef regex_token_iterator<const char*> cregex_token_iterator;
6499 typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
6500 typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
6501 typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
6505 template <class _OutputIterator, class _BidirectionalIterator,
6506 class _Traits, class _CharT>
6508 regex_replace(_OutputIterator __output_iter,
6509 _BidirectionalIterator __first, _BidirectionalIterator __last,
6510 const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
6511 regex_constants::match_flag_type __flags = regex_constants::match_default)
6513 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Iter;
6514 _Iter __i(__first, __last, __e, __flags);
6518 if (!(__flags & regex_constants::format_no_copy))
6519 __output_iter = _VSTD::copy(__first, __last, __output_iter);
6523 sub_match<_BidirectionalIterator> __lm;
6524 for (size_t __len = char_traits<_CharT>::length(__fmt); __i != __eof; ++__i)
6526 if (!(__flags & regex_constants::format_no_copy))
6527 __output_iter = _VSTD::copy(__i->prefix().first, __i->prefix().second, __output_iter);
6528 __output_iter = __i->format(__output_iter, __fmt, __fmt + __len, __flags);
6529 __lm = __i->suffix();
6530 if (__flags & regex_constants::format_first_only)
6533 if (!(__flags & regex_constants::format_no_copy))
6534 __output_iter = _VSTD::copy(__lm.first, __lm.second, __output_iter);
6536 return __output_iter;
6539 template <class _OutputIterator, class _BidirectionalIterator,
6540 class _Traits, class _CharT, class _ST, class _SA>
6541 inline _LIBCPP_INLINE_VISIBILITY
6543 regex_replace(_OutputIterator __output_iter,
6544 _BidirectionalIterator __first, _BidirectionalIterator __last,
6545 const basic_regex<_CharT, _Traits>& __e,
6546 const basic_string<_CharT, _ST, _SA>& __fmt,
6547 regex_constants::match_flag_type __flags = regex_constants::match_default)
6549 return _VSTD::regex_replace(__output_iter, __first, __last, __e, __fmt.c_str(), __flags);
6552 template <class _Traits, class _CharT, class _ST, class _SA, class _FST,
6554 inline _LIBCPP_INLINE_VISIBILITY
6555 basic_string<_CharT, _ST, _SA>
6556 regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6557 const basic_regex<_CharT, _Traits>& __e,
6558 const basic_string<_CharT, _FST, _FSA>& __fmt,
6559 regex_constants::match_flag_type __flags = regex_constants::match_default)
6561 basic_string<_CharT, _ST, _SA> __r;
6562 _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6563 __fmt.c_str(), __flags);
6567 template <class _Traits, class _CharT, class _ST, class _SA>
6568 inline _LIBCPP_INLINE_VISIBILITY
6569 basic_string<_CharT, _ST, _SA>
6570 regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6571 const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
6572 regex_constants::match_flag_type __flags = regex_constants::match_default)
6574 basic_string<_CharT, _ST, _SA> __r;
6575 _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6580 template <class _Traits, class _CharT, class _ST, class _SA>
6581 inline _LIBCPP_INLINE_VISIBILITY
6582 basic_string<_CharT>
6583 regex_replace(const _CharT* __s,
6584 const basic_regex<_CharT, _Traits>& __e,
6585 const basic_string<_CharT, _ST, _SA>& __fmt,
6586 regex_constants::match_flag_type __flags = regex_constants::match_default)
6588 basic_string<_CharT> __r;
6589 _VSTD::regex_replace(back_inserter(__r), __s,
6590 __s + char_traits<_CharT>::length(__s), __e,
6591 __fmt.c_str(), __flags);
6595 template <class _Traits, class _CharT>
6596 inline _LIBCPP_INLINE_VISIBILITY
6597 basic_string<_CharT>
6598 regex_replace(const _CharT* __s,
6599 const basic_regex<_CharT, _Traits>& __e,
6600 const _CharT* __fmt,
6601 regex_constants::match_flag_type __flags = regex_constants::match_default)
6603 basic_string<_CharT> __r;
6604 _VSTD::regex_replace(back_inserter(__r), __s,
6605 __s + char_traits<_CharT>::length(__s), __e,
6610 _LIBCPP_END_NAMESPACE_STD
6614 #endif // _LIBCPP_REGEX