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 regex_constants::syntax_option_type flag_type;
131 typedef typename traits::locale_type locale_type;
134 static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
135 static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
136 static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
137 static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
138 static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
139 static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
140 static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
141 static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
142 static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
143 static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
145 // construct/copy/destroy:
147 explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
148 basic_regex(const charT* p, size_t len, flag_type f);
149 basic_regex(const basic_regex&);
150 basic_regex(basic_regex&&) noexcept;
151 template <class ST, class SA>
152 explicit basic_regex(const basic_string<charT, ST, SA>& p,
153 flag_type f = regex_constants::ECMAScript);
154 template <class ForwardIterator>
155 basic_regex(ForwardIterator first, ForwardIterator last,
156 flag_type f = regex_constants::ECMAScript);
157 basic_regex(initializer_list<charT>, flag_type = regex_constants::ECMAScript);
161 basic_regex& operator=(const basic_regex&);
162 basic_regex& operator=(basic_regex&&) noexcept;
163 basic_regex& operator=(const charT* ptr);
164 basic_regex& operator=(initializer_list<charT> il);
165 template <class ST, class SA>
166 basic_regex& operator=(const basic_string<charT, ST, SA>& p);
169 basic_regex& assign(const basic_regex& that);
170 basic_regex& assign(basic_regex&& that) noexcept;
171 basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
172 basic_regex& assign(const charT* p, size_t len, flag_type f);
173 template <class string_traits, class A>
174 basic_regex& assign(const basic_string<charT, string_traits, A>& s,
175 flag_type f = regex_constants::ECMAScript);
176 template <class InputIterator>
177 basic_regex& assign(InputIterator first, InputIterator last,
178 flag_type f = regex_constants::ECMAScript);
179 basic_regex& assign(initializer_list<charT>, flag_type = regex_constants::ECMAScript);
182 unsigned mark_count() const;
183 flag_type flags() const;
186 locale_type imbue(locale_type loc);
187 locale_type getloc() const;
190 void swap(basic_regex&);
193 typedef basic_regex<char> regex;
194 typedef basic_regex<wchar_t> wregex;
196 template <class charT, class traits>
197 void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2);
199 template <class BidirectionalIterator>
201 : public pair<BidirectionalIterator, BidirectionalIterator>
204 typedef typename iterator_traits<BidirectionalIterator>::value_type value_type;
205 typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
206 typedef BidirectionalIterator iterator;
207 typedef basic_string<value_type> string_type;
211 constexpr sub_match();
213 difference_type length() const;
214 operator string_type() const;
215 string_type str() const;
217 int compare(const sub_match& s) const;
218 int compare(const string_type& s) const;
219 int compare(const value_type* s) const;
222 typedef sub_match<const char*> csub_match;
223 typedef sub_match<const wchar_t*> wcsub_match;
224 typedef sub_match<string::const_iterator> ssub_match;
225 typedef sub_match<wstring::const_iterator> wssub_match;
227 template <class BiIter>
229 operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
231 template <class BiIter>
233 operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
235 template <class BiIter>
237 operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
239 template <class BiIter>
241 operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
243 template <class BiIter>
245 operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
247 template <class BiIter>
249 operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
251 template <class BiIter, class ST, class SA>
253 operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
254 const sub_match<BiIter>& rhs);
256 template <class BiIter, class ST, class SA>
258 operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
259 const sub_match<BiIter>& rhs);
261 template <class BiIter, class ST, class SA>
263 operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
264 const sub_match<BiIter>& rhs);
266 template <class BiIter, class ST, class SA>
268 operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
269 const sub_match<BiIter>& rhs);
271 template <class BiIter, class ST, class SA>
272 bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
273 const sub_match<BiIter>& rhs);
275 template <class BiIter, class ST, class SA>
277 operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
278 const sub_match<BiIter>& rhs);
280 template <class BiIter, class ST, class SA>
282 operator==(const sub_match<BiIter>& lhs,
283 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
285 template <class BiIter, class ST, class SA>
287 operator!=(const sub_match<BiIter>& lhs,
288 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
290 template <class BiIter, class ST, class SA>
292 operator<(const sub_match<BiIter>& lhs,
293 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
295 template <class BiIter, class ST, class SA>
296 bool operator>(const sub_match<BiIter>& lhs,
297 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
299 template <class BiIter, class ST, class SA>
301 operator>=(const sub_match<BiIter>& lhs,
302 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
304 template <class BiIter, class ST, class SA>
306 operator<=(const sub_match<BiIter>& lhs,
307 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
309 template <class BiIter>
311 operator==(typename iterator_traits<BiIter>::value_type const* lhs,
312 const sub_match<BiIter>& rhs);
314 template <class BiIter>
316 operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
317 const sub_match<BiIter>& rhs);
319 template <class BiIter>
321 operator<(typename iterator_traits<BiIter>::value_type const* lhs,
322 const sub_match<BiIter>& rhs);
324 template <class BiIter>
326 operator>(typename iterator_traits<BiIter>::value_type const* lhs,
327 const sub_match<BiIter>& rhs);
329 template <class BiIter>
331 operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
332 const sub_match<BiIter>& rhs);
334 template <class BiIter>
336 operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
337 const sub_match<BiIter>& rhs);
339 template <class BiIter>
341 operator==(const sub_match<BiIter>& lhs,
342 typename iterator_traits<BiIter>::value_type const* rhs);
344 template <class BiIter>
346 operator!=(const sub_match<BiIter>& lhs,
347 typename iterator_traits<BiIter>::value_type const* rhs);
349 template <class BiIter>
351 operator<(const sub_match<BiIter>& lhs,
352 typename iterator_traits<BiIter>::value_type const* rhs);
354 template <class BiIter>
356 operator>(const sub_match<BiIter>& lhs,
357 typename iterator_traits<BiIter>::value_type const* rhs);
359 template <class BiIter>
361 operator>=(const sub_match<BiIter>& lhs,
362 typename iterator_traits<BiIter>::value_type const* rhs);
364 template <class BiIter>
366 operator<=(const sub_match<BiIter>& lhs,
367 typename iterator_traits<BiIter>::value_type const* rhs);
369 template <class BiIter>
371 operator==(typename iterator_traits<BiIter>::value_type const& lhs,
372 const sub_match<BiIter>& rhs);
374 template <class BiIter>
376 operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
377 const sub_match<BiIter>& rhs);
379 template <class BiIter>
381 operator<(typename iterator_traits<BiIter>::value_type const& lhs,
382 const sub_match<BiIter>& rhs);
384 template <class BiIter>
386 operator>(typename iterator_traits<BiIter>::value_type const& lhs,
387 const sub_match<BiIter>& rhs);
389 template <class BiIter>
391 operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
392 const sub_match<BiIter>& rhs);
394 template <class BiIter>
396 operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
397 const sub_match<BiIter>& rhs);
399 template <class BiIter>
401 operator==(const sub_match<BiIter>& lhs,
402 typename iterator_traits<BiIter>::value_type const& rhs);
404 template <class BiIter>
406 operator!=(const sub_match<BiIter>& lhs,
407 typename iterator_traits<BiIter>::value_type const& rhs);
409 template <class BiIter>
411 operator<(const sub_match<BiIter>& lhs,
412 typename iterator_traits<BiIter>::value_type const& rhs);
414 template <class BiIter>
416 operator>(const sub_match<BiIter>& lhs,
417 typename iterator_traits<BiIter>::value_type const& rhs);
419 template <class BiIter>
421 operator>=(const sub_match<BiIter>& lhs,
422 typename iterator_traits<BiIter>::value_type const& rhs);
424 template <class BiIter>
426 operator<=(const sub_match<BiIter>& lhs,
427 typename iterator_traits<BiIter>::value_type const& rhs);
429 template <class charT, class ST, class BiIter>
430 basic_ostream<charT, ST>&
431 operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
433 template <class BidirectionalIterator,
434 class Allocator = allocator<sub_match<BidirectionalIterator>>>
438 typedef sub_match<BidirectionalIterator> value_type;
439 typedef const value_type& const_reference;
440 typedef value_type& reference;
441 typedef /implementation-defined/ const_iterator;
442 typedef const_iterator iterator;
443 typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
444 typedef typename allocator_traits<Allocator>::size_type size_type;
445 typedef Allocator allocator_type;
446 typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;
447 typedef basic_string<char_type> string_type;
449 // construct/copy/destroy:
450 explicit match_results(const Allocator& a = Allocator());
451 match_results(const match_results& m);
452 match_results(match_results&& m) noexcept;
453 match_results& operator=(const match_results& m);
454 match_results& operator=(match_results&& m);
460 size_type size() const;
461 size_type max_size() const;
465 difference_type length(size_type sub = 0) const;
466 difference_type position(size_type sub = 0) const;
467 string_type str(size_type sub = 0) const;
468 const_reference operator[](size_type n) const;
470 const_reference prefix() const;
471 const_reference suffix() const;
473 const_iterator begin() const;
474 const_iterator end() const;
475 const_iterator cbegin() const;
476 const_iterator cend() const;
479 template <class OutputIter>
481 format(OutputIter out, const char_type* fmt_first,
482 const char_type* fmt_last,
483 regex_constants::match_flag_type flags = regex_constants::format_default) const;
484 template <class OutputIter, class ST, class SA>
486 format(OutputIter out, const basic_string<char_type, ST, SA>& fmt,
487 regex_constants::match_flag_type flags = regex_constants::format_default) const;
488 template <class ST, class SA>
489 basic_string<char_type, ST, SA>
490 format(const basic_string<char_type, ST, SA>& fmt,
491 regex_constants::match_flag_type flags = regex_constants::format_default) const;
493 format(const char_type* fmt,
494 regex_constants::match_flag_type flags = regex_constants::format_default) const;
497 allocator_type get_allocator() const;
500 void swap(match_results& that);
503 typedef match_results<const char*> cmatch;
504 typedef match_results<const wchar_t*> wcmatch;
505 typedef match_results<string::const_iterator> smatch;
506 typedef match_results<wstring::const_iterator> wsmatch;
508 template <class BidirectionalIterator, class Allocator>
510 operator==(const match_results<BidirectionalIterator, Allocator>& m1,
511 const match_results<BidirectionalIterator, Allocator>& m2);
513 template <class BidirectionalIterator, class Allocator>
515 operator!=(const match_results<BidirectionalIterator, Allocator>& m1,
516 const match_results<BidirectionalIterator, Allocator>& m2);
518 template <class BidirectionalIterator, class Allocator>
520 swap(match_results<BidirectionalIterator, Allocator>& m1,
521 match_results<BidirectionalIterator, Allocator>& m2);
523 template <class BidirectionalIterator, class Allocator, class charT, class traits>
525 regex_match(BidirectionalIterator first, BidirectionalIterator last,
526 match_results<BidirectionalIterator, Allocator>& m,
527 const basic_regex<charT, traits>& e,
528 regex_constants::match_flag_type flags = regex_constants::match_default);
530 template <class BidirectionalIterator, class charT, class traits>
532 regex_match(BidirectionalIterator first, BidirectionalIterator last,
533 const basic_regex<charT, traits>& e,
534 regex_constants::match_flag_type flags = regex_constants::match_default);
536 template <class charT, class Allocator, class traits>
538 regex_match(const charT* str, match_results<const charT*, Allocator>& m,
539 const basic_regex<charT, traits>& e,
540 regex_constants::match_flag_type flags = regex_constants::match_default);
542 template <class ST, class SA, class Allocator, class charT, class traits>
544 regex_match(const basic_string<charT, ST, SA>& s,
545 match_results<typename basic_string<charT, ST, SA>::const_iterator, 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) = delete; // C++14
556 template <class charT, class traits>
558 regex_match(const charT* str, const basic_regex<charT, traits>& e,
559 regex_constants::match_flag_type flags = regex_constants::match_default);
561 template <class ST, class SA, class charT, class traits>
563 regex_match(const basic_string<charT, ST, SA>& s,
564 const basic_regex<charT, traits>& e,
565 regex_constants::match_flag_type flags = regex_constants::match_default);
567 template <class BidirectionalIterator, class Allocator, class charT, class traits>
569 regex_search(BidirectionalIterator first, BidirectionalIterator last,
570 match_results<BidirectionalIterator, Allocator>& m,
571 const basic_regex<charT, traits>& e,
572 regex_constants::match_flag_type flags = regex_constants::match_default);
574 template <class BidirectionalIterator, class charT, class traits>
576 regex_search(BidirectionalIterator first, BidirectionalIterator last,
577 const basic_regex<charT, traits>& e,
578 regex_constants::match_flag_type flags = regex_constants::match_default);
580 template <class charT, class Allocator, class traits>
582 regex_search(const charT* str, match_results<const charT*, Allocator>& m,
583 const basic_regex<charT, traits>& e,
584 regex_constants::match_flag_type flags = regex_constants::match_default);
586 template <class charT, class traits>
588 regex_search(const charT* str, const basic_regex<charT, traits>& e,
589 regex_constants::match_flag_type flags = regex_constants::match_default);
591 template <class ST, class SA, class charT, class traits>
593 regex_search(const basic_string<charT, ST, SA>& s,
594 const basic_regex<charT, traits>& e,
595 regex_constants::match_flag_type flags = regex_constants::match_default);
597 template <class ST, class SA, class Allocator, class charT, class traits>
599 regex_search(const basic_string<charT, ST, SA>& s,
600 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
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) = delete; // C++14
611 template <class OutputIterator, class BidirectionalIterator,
612 class traits, class charT, class ST, class SA>
614 regex_replace(OutputIterator out,
615 BidirectionalIterator first, BidirectionalIterator last,
616 const basic_regex<charT, traits>& e,
617 const basic_string<charT, ST, SA>& fmt,
618 regex_constants::match_flag_type flags = regex_constants::match_default);
620 template <class OutputIterator, class BidirectionalIterator,
621 class traits, class charT>
623 regex_replace(OutputIterator out,
624 BidirectionalIterator first, BidirectionalIterator last,
625 const basic_regex<charT, traits>& e, const charT* fmt,
626 regex_constants::match_flag_type flags = regex_constants::match_default);
628 template <class traits, class charT, class ST, class SA, class FST, class FSA>>
629 basic_string<charT, ST, SA>
630 regex_replace(const basic_string<charT, ST, SA>& s,
631 const basic_regex<charT, traits>& e,
632 const basic_string<charT, FST, FSA>& fmt,
633 regex_constants::match_flag_type flags = regex_constants::match_default);
635 template <class traits, class charT, class ST, class SA>
636 basic_string<charT, ST, SA>
637 regex_replace(const basic_string<charT, ST, SA>& s,
638 const basic_regex<charT, traits>& e, const charT* fmt,
639 regex_constants::match_flag_type flags = regex_constants::match_default);
641 template <class traits, class charT, class ST, class SA>
643 regex_replace(const charT* s,
644 const basic_regex<charT, traits>& e,
645 const basic_string<charT, ST, SA>& fmt,
646 regex_constants::match_flag_type flags = regex_constants::match_default);
648 template <class traits, class charT>
650 regex_replace(const charT* s,
651 const basic_regex<charT, traits>& e,
653 regex_constants::match_flag_type flags = regex_constants::match_default);
655 template <class BidirectionalIterator,
656 class charT = typename iterator_traits< BidirectionalIterator>::value_type,
657 class traits = regex_traits<charT>>
661 typedef basic_regex<charT, traits> regex_type;
662 typedef match_results<BidirectionalIterator> value_type;
663 typedef ptrdiff_t difference_type;
664 typedef const value_type* pointer;
665 typedef const value_type& reference;
666 typedef forward_iterator_tag iterator_category;
669 regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
670 const regex_type& re,
671 regex_constants::match_flag_type m = regex_constants::match_default);
672 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
673 const regex_type&& __re,
674 regex_constants::match_flag_type __m
675 = regex_constants::match_default) = delete; // C++14
676 regex_iterator(const regex_iterator&);
677 regex_iterator& operator=(const regex_iterator&);
679 bool operator==(const regex_iterator&) const;
680 bool operator!=(const regex_iterator&) const;
682 const value_type& operator*() const;
683 const value_type* operator->() const;
685 regex_iterator& operator++();
686 regex_iterator operator++(int);
689 typedef regex_iterator<const char*> cregex_iterator;
690 typedef regex_iterator<const wchar_t*> wcregex_iterator;
691 typedef regex_iterator<string::const_iterator> sregex_iterator;
692 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
694 template <class BidirectionalIterator,
695 class charT = typename iterator_traits< BidirectionalIterator>::value_type,
696 class traits = regex_traits<charT>>
697 class regex_token_iterator
700 typedef basic_regex<charT, traits> regex_type;
701 typedef sub_match<BidirectionalIterator> value_type;
702 typedef ptrdiff_t difference_type;
703 typedef const value_type* pointer;
704 typedef const value_type& reference;
705 typedef forward_iterator_tag iterator_category;
707 regex_token_iterator();
708 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
709 const regex_type& re, int submatch = 0,
710 regex_constants::match_flag_type m = regex_constants::match_default);
711 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
712 const regex_type&& re, int submatch = 0,
713 regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
714 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
715 const regex_type& re, const vector<int>& submatches,
716 regex_constants::match_flag_type m = regex_constants::match_default);
717 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
718 const regex_type&& re, const vector<int>& submatches,
719 regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
720 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
721 const regex_type& re, initializer_list<int> submatches,
722 regex_constants::match_flag_type m = regex_constants::match_default);
723 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
724 const regex_type&& re, initializer_list<int> submatches,
725 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, const int (&submatches)[N],
729 regex_constants::match_flag_type m = regex_constants::match_default);
731 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
732 const regex_type& re, const int (&submatches)[N],
733 regex_constants::match_flag_type m = regex_constants::match_default) = delete // C++14;
734 regex_token_iterator(const regex_token_iterator&);
735 regex_token_iterator& operator=(const regex_token_iterator&);
737 bool operator==(const regex_token_iterator&) const;
738 bool operator!=(const regex_token_iterator&) const;
740 const value_type& operator*() const;
741 const value_type* operator->() const;
743 regex_token_iterator& operator++();
744 regex_token_iterator operator++(int);
747 typedef regex_token_iterator<const char*> cregex_token_iterator;
748 typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
749 typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
750 typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
758 #include <initializer_list>
766 #include <__undef_min_max>
768 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
769 #pragma GCC system_header
772 _LIBCPP_BEGIN_NAMESPACE_STD
774 namespace regex_constants
777 // syntax_option_type
779 enum syntax_option_type
793 inline _LIBCPP_INLINE_VISIBILITY
796 operator~(syntax_option_type __x)
798 return syntax_option_type(~int(__x) & 0x1FF);
801 inline _LIBCPP_INLINE_VISIBILITY
804 operator&(syntax_option_type __x, syntax_option_type __y)
806 return syntax_option_type(int(__x) & int(__y));
809 inline _LIBCPP_INLINE_VISIBILITY
812 operator|(syntax_option_type __x, syntax_option_type __y)
814 return syntax_option_type(int(__x) | int(__y));
817 inline _LIBCPP_INLINE_VISIBILITY
820 operator^(syntax_option_type __x, syntax_option_type __y)
822 return syntax_option_type(int(__x) ^ int(__y));
825 inline _LIBCPP_INLINE_VISIBILITY
827 operator&=(syntax_option_type& __x, syntax_option_type __y)
833 inline _LIBCPP_INLINE_VISIBILITY
835 operator|=(syntax_option_type& __x, syntax_option_type __y)
841 inline _LIBCPP_INLINE_VISIBILITY
843 operator^=(syntax_option_type& __x, syntax_option_type __y)
854 match_not_bol = 1 << 0,
855 match_not_eol = 1 << 1,
856 match_not_bow = 1 << 2,
857 match_not_eow = 1 << 3,
859 match_not_null = 1 << 5,
860 match_continuous = 1 << 6,
861 match_prev_avail = 1 << 7,
864 format_no_copy = 1 << 9,
865 format_first_only = 1 << 10,
866 __no_update_pos = 1 << 11
869 inline _LIBCPP_INLINE_VISIBILITY
872 operator~(match_flag_type __x)
874 return match_flag_type(~int(__x) & 0x0FFF);
877 inline _LIBCPP_INLINE_VISIBILITY
880 operator&(match_flag_type __x, match_flag_type __y)
882 return match_flag_type(int(__x) & int(__y));
885 inline _LIBCPP_INLINE_VISIBILITY
888 operator|(match_flag_type __x, match_flag_type __y)
890 return match_flag_type(int(__x) | int(__y));
893 inline _LIBCPP_INLINE_VISIBILITY
896 operator^(match_flag_type __x, match_flag_type __y)
898 return match_flag_type(int(__x) ^ int(__y));
901 inline _LIBCPP_INLINE_VISIBILITY
903 operator&=(match_flag_type& __x, match_flag_type __y)
909 inline _LIBCPP_INLINE_VISIBILITY
911 operator|=(match_flag_type& __x, match_flag_type __y)
917 inline _LIBCPP_INLINE_VISIBILITY
919 operator^=(match_flag_type& __x, match_flag_type __y)
947 class _LIBCPP_EXCEPTION_ABI regex_error
948 : public runtime_error
950 regex_constants::error_type __code_;
952 explicit regex_error(regex_constants::error_type __ecode);
953 virtual ~regex_error() throw();
954 _LIBCPP_INLINE_VISIBILITY
955 regex_constants::error_type code() const {return __code_;}
958 template <class _CharT>
959 struct _LIBCPP_TYPE_VIS_ONLY regex_traits
962 typedef _CharT char_type;
963 typedef basic_string<char_type> string_type;
964 typedef locale locale_type;
965 typedef ctype_base::mask char_class_type;
967 static const char_class_type __regex_word = 0x80;
970 const ctype<char_type>* __ct_;
971 const collate<char_type>* __col_;
976 _LIBCPP_INLINE_VISIBILITY
977 static size_t length(const char_type* __p)
978 {return char_traits<char_type>::length(__p);}
979 _LIBCPP_INLINE_VISIBILITY
980 char_type translate(char_type __c) const {return __c;}
981 char_type translate_nocase(char_type __c) const;
982 template <class _ForwardIterator>
984 transform(_ForwardIterator __f, _ForwardIterator __l) const;
985 template <class _ForwardIterator>
986 _LIBCPP_INLINE_VISIBILITY
988 transform_primary( _ForwardIterator __f, _ForwardIterator __l) const
989 {return __transform_primary(__f, __l, char_type());}
990 template <class _ForwardIterator>
991 _LIBCPP_INLINE_VISIBILITY
993 lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const
994 {return __lookup_collatename(__f, __l, char_type());}
995 template <class _ForwardIterator>
996 _LIBCPP_INLINE_VISIBILITY
998 lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
999 bool __icase = false) const
1000 {return __lookup_classname(__f, __l, __icase, char_type());}
1001 bool isctype(char_type __c, char_class_type __m) const;
1002 _LIBCPP_INLINE_VISIBILITY
1003 int value(char_type __ch, int __radix) const
1004 {return __regex_traits_value(__ch, __radix);}
1005 locale_type imbue(locale_type __l);
1006 _LIBCPP_INLINE_VISIBILITY
1007 locale_type getloc()const {return __loc_;}
1012 template <class _ForwardIterator>
1014 __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;
1015 template <class _ForwardIterator>
1017 __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1019 template <class _ForwardIterator>
1021 __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;
1022 template <class _ForwardIterator>
1024 __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1026 template <class _ForwardIterator>
1028 __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1029 bool __icase, char) const;
1030 template <class _ForwardIterator>
1032 __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1033 bool __icase, wchar_t) const;
1035 static int __regex_traits_value(unsigned char __ch, int __radix);
1036 _LIBCPP_INLINE_VISIBILITY
1037 int __regex_traits_value(char __ch, int __radix) const
1038 {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);}
1039 int __regex_traits_value(wchar_t __ch, int __radix) const;
1042 template <class _CharT>
1043 const typename regex_traits<_CharT>::char_class_type
1044 regex_traits<_CharT>::__regex_word;
1046 template <class _CharT>
1047 regex_traits<_CharT>::regex_traits()
1052 template <class _CharT>
1053 typename regex_traits<_CharT>::char_type
1054 regex_traits<_CharT>::translate_nocase(char_type __c) const
1056 return __ct_->tolower(__c);
1059 template <class _CharT>
1060 template <class _ForwardIterator>
1061 typename regex_traits<_CharT>::string_type
1062 regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const
1064 string_type __s(__f, __l);
1065 return __col_->transform(__s.data(), __s.data() + __s.size());
1068 template <class _CharT>
1070 regex_traits<_CharT>::__init()
1072 __ct_ = &use_facet<ctype<char_type> >(__loc_);
1073 __col_ = &use_facet<collate<char_type> >(__loc_);
1076 template <class _CharT>
1077 typename regex_traits<_CharT>::locale_type
1078 regex_traits<_CharT>::imbue(locale_type __l)
1080 locale __r = __loc_;
1086 // transform_primary is very FreeBSD-specific
1088 template <class _CharT>
1089 template <class _ForwardIterator>
1090 typename regex_traits<_CharT>::string_type
1091 regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
1092 _ForwardIterator __l, char) const
1094 const string_type __s(__f, __l);
1095 string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
1110 template <class _CharT>
1111 template <class _ForwardIterator>
1112 typename regex_traits<_CharT>::string_type
1113 regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
1114 _ForwardIterator __l, wchar_t) const
1116 const string_type __s(__f, __l);
1117 string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
1132 // lookup_collatename is very FreeBSD-specific
1134 _LIBCPP_FUNC_VIS string __get_collation_name(const char* __s);
1136 template <class _CharT>
1137 template <class _ForwardIterator>
1138 typename regex_traits<_CharT>::string_type
1139 regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
1140 _ForwardIterator __l, char) const
1142 string_type __s(__f, __l);
1146 __r = __get_collation_name(__s.c_str());
1147 if (__r.empty() && __s.size() <= 2)
1149 __r = __col_->transform(__s.data(), __s.data() + __s.size());
1150 if (__r.size() == 1 || __r.size() == 12)
1159 template <class _CharT>
1160 template <class _ForwardIterator>
1161 typename regex_traits<_CharT>::string_type
1162 regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
1163 _ForwardIterator __l, wchar_t) const
1165 string_type __s(__f, __l);
1167 __n.reserve(__s.size());
1168 for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
1171 if (static_cast<unsigned>(*__i) >= 127)
1172 return string_type();
1173 __n.push_back(char(*__i));
1178 __n = __get_collation_name(__n.c_str());
1180 __r.assign(__n.begin(), __n.end());
1181 else if (__s.size() <= 2)
1183 __r = __col_->transform(__s.data(), __s.data() + __s.size());
1184 if (__r.size() == 1 || __r.size() == 3)
1195 ctype_base::mask _LIBCPP_FUNC_VIS __get_classname(const char* __s, bool __icase);
1197 template <class _CharT>
1198 template <class _ForwardIterator>
1199 typename regex_traits<_CharT>::char_class_type
1200 regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
1201 _ForwardIterator __l,
1202 bool __icase, char) const
1204 string_type __s(__f, __l);
1205 __ct_->tolower(&__s[0], &__s[0] + __s.size());
1206 return __get_classname(__s.c_str(), __icase);
1209 template <class _CharT>
1210 template <class _ForwardIterator>
1211 typename regex_traits<_CharT>::char_class_type
1212 regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
1213 _ForwardIterator __l,
1214 bool __icase, wchar_t) const
1216 string_type __s(__f, __l);
1217 __ct_->tolower(&__s[0], &__s[0] + __s.size());
1219 __n.reserve(__s.size());
1220 for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
1223 if (static_cast<unsigned>(*__i) >= 127)
1224 return char_class_type();
1225 __n.push_back(char(*__i));
1227 return __get_classname(__n.c_str(), __icase);
1230 template <class _CharT>
1232 regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const
1234 if (__ct_->is(__m, __c))
1236 return (__c == '_' && (__m & __regex_word));
1239 template <class _CharT>
1241 regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix)
1243 if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7'
1247 if ((__ch & 0xFEu) == 0x38) // '8' <= __ch && __ch <= '9'
1251 __ch |= 0x20; // tolower
1252 if ('a' <= __ch && __ch <= 'f')
1253 return __ch - ('a' - 10);
1259 template <class _CharT>
1260 inline _LIBCPP_INLINE_VISIBILITY
1262 regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const
1264 return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix);
1267 template <class _CharT> class __node;
1269 template <class _BidirectionalIterator> class _LIBCPP_TYPE_VIS_ONLY sub_match;
1271 template <class _BidirectionalIterator,
1272 class _Allocator = allocator<sub_match<_BidirectionalIterator> > >
1273 class _LIBCPP_TYPE_VIS_ONLY match_results;
1275 template <class _CharT>
1280 __end_state = -1000,
1281 __consume_input, // -999
1282 __begin_marked_expr, // -998
1283 __end_marked_expr, // -997
1284 __pop_state, // -996
1285 __accept_and_consume, // -995
1286 __accept_but_not_consume, // -994
1293 const _CharT* __first_;
1294 const _CharT* __current_;
1295 const _CharT* __last_;
1296 vector<sub_match<const _CharT*> > __sub_matches_;
1297 vector<pair<size_t, const _CharT*> > __loop_data_;
1298 const __node<_CharT>* __node_;
1299 regex_constants::match_flag_type __flags_;
1302 _LIBCPP_INLINE_VISIBILITY
1304 : __do_(0), __first_(nullptr), __current_(nullptr), __last_(nullptr),
1305 __node_(nullptr), __flags_() {}
1310 template <class _CharT>
1313 __node(const __node&);
1314 __node& operator=(const __node&);
1316 typedef _VSTD::__state<_CharT> __state;
1318 _LIBCPP_INLINE_VISIBILITY
1320 _LIBCPP_INLINE_VISIBILITY
1321 virtual ~__node() {}
1323 _LIBCPP_INLINE_VISIBILITY
1324 virtual void __exec(__state&) const {};
1325 _LIBCPP_INLINE_VISIBILITY
1326 virtual void __exec_split(bool, __state&) const {};
1331 template <class _CharT>
1333 : public __node<_CharT>
1336 typedef _VSTD::__state<_CharT> __state;
1338 _LIBCPP_INLINE_VISIBILITY
1341 virtual void __exec(__state&) const;
1344 template <class _CharT>
1346 __end_state<_CharT>::__exec(__state& __s) const
1348 __s.__do_ = __state::__end_state;
1353 template <class _CharT>
1354 class __has_one_state
1355 : public __node<_CharT>
1357 __node<_CharT>* __first_;
1360 _LIBCPP_INLINE_VISIBILITY
1361 explicit __has_one_state(__node<_CharT>* __s)
1364 _LIBCPP_INLINE_VISIBILITY
1365 __node<_CharT>* first() const {return __first_;}
1366 _LIBCPP_INLINE_VISIBILITY
1367 __node<_CharT>*& first() {return __first_;}
1372 template <class _CharT>
1373 class __owns_one_state
1374 : public __has_one_state<_CharT>
1376 typedef __has_one_state<_CharT> base;
1379 _LIBCPP_INLINE_VISIBILITY
1380 explicit __owns_one_state(__node<_CharT>* __s)
1383 virtual ~__owns_one_state();
1386 template <class _CharT>
1387 __owns_one_state<_CharT>::~__owns_one_state()
1389 delete this->first();
1394 template <class _CharT>
1396 : public __owns_one_state<_CharT>
1398 typedef __owns_one_state<_CharT> base;
1401 typedef _VSTD::__state<_CharT> __state;
1403 _LIBCPP_INLINE_VISIBILITY
1404 explicit __empty_state(__node<_CharT>* __s)
1407 virtual void __exec(__state&) const;
1410 template <class _CharT>
1412 __empty_state<_CharT>::__exec(__state& __s) const
1414 __s.__do_ = __state::__accept_but_not_consume;
1415 __s.__node_ = this->first();
1418 // __empty_non_own_state
1420 template <class _CharT>
1421 class __empty_non_own_state
1422 : public __has_one_state<_CharT>
1424 typedef __has_one_state<_CharT> base;
1427 typedef _VSTD::__state<_CharT> __state;
1429 _LIBCPP_INLINE_VISIBILITY
1430 explicit __empty_non_own_state(__node<_CharT>* __s)
1433 virtual void __exec(__state&) const;
1436 template <class _CharT>
1438 __empty_non_own_state<_CharT>::__exec(__state& __s) const
1440 __s.__do_ = __state::__accept_but_not_consume;
1441 __s.__node_ = this->first();
1444 // __repeat_one_loop
1446 template <class _CharT>
1447 class __repeat_one_loop
1448 : public __has_one_state<_CharT>
1450 typedef __has_one_state<_CharT> base;
1453 typedef _VSTD::__state<_CharT> __state;
1455 _LIBCPP_INLINE_VISIBILITY
1456 explicit __repeat_one_loop(__node<_CharT>* __s)
1459 virtual void __exec(__state&) const;
1462 template <class _CharT>
1464 __repeat_one_loop<_CharT>::__exec(__state& __s) const
1466 __s.__do_ = __state::__repeat;
1467 __s.__node_ = this->first();
1470 // __owns_two_states
1472 template <class _CharT>
1473 class __owns_two_states
1474 : public __owns_one_state<_CharT>
1476 typedef __owns_one_state<_CharT> base;
1481 _LIBCPP_INLINE_VISIBILITY
1482 explicit __owns_two_states(__node<_CharT>* __s1, base* __s2)
1483 : base(__s1), __second_(__s2) {}
1485 virtual ~__owns_two_states();
1487 _LIBCPP_INLINE_VISIBILITY
1488 base* second() const {return __second_;}
1489 _LIBCPP_INLINE_VISIBILITY
1490 base*& second() {return __second_;}
1493 template <class _CharT>
1494 __owns_two_states<_CharT>::~__owns_two_states()
1501 template <class _CharT>
1503 : public __owns_two_states<_CharT>
1505 typedef __owns_two_states<_CharT> base;
1509 unsigned __loop_id_;
1510 unsigned __mexp_begin_;
1511 unsigned __mexp_end_;
1515 typedef _VSTD::__state<_CharT> __state;
1517 _LIBCPP_INLINE_VISIBILITY
1518 explicit __loop(unsigned __loop_id,
1519 __node<_CharT>* __s1, __owns_one_state<_CharT>* __s2,
1520 unsigned __mexp_begin, unsigned __mexp_end,
1521 bool __greedy = true,
1523 size_t __max = numeric_limits<size_t>::max())
1524 : base(__s1, __s2), __min_(__min), __max_(__max), __loop_id_(__loop_id),
1525 __mexp_begin_(__mexp_begin), __mexp_end_(__mexp_end),
1526 __greedy_(__greedy) {}
1528 virtual void __exec(__state& __s) const;
1529 virtual void __exec_split(bool __second, __state& __s) const;
1532 _LIBCPP_INLINE_VISIBILITY
1533 void __init_repeat(__state& __s) const
1535 __s.__loop_data_[__loop_id_].second = __s.__current_;
1536 for (size_t __i = __mexp_begin_-1; __i != __mexp_end_-1; ++__i)
1538 __s.__sub_matches_[__i].first = __s.__last_;
1539 __s.__sub_matches_[__i].second = __s.__last_;
1540 __s.__sub_matches_[__i].matched = false;
1545 template <class _CharT>
1547 __loop<_CharT>::__exec(__state& __s) const
1549 if (__s.__do_ == __state::__repeat)
1551 bool __do_repeat = ++__s.__loop_data_[__loop_id_].first < __max_;
1552 bool __do_alt = __s.__loop_data_[__loop_id_].first >= __min_;
1553 if (__do_repeat && __do_alt &&
1554 __s.__loop_data_[__loop_id_].second == __s.__current_)
1555 __do_repeat = false;
1556 if (__do_repeat && __do_alt)
1557 __s.__do_ = __state::__split;
1558 else if (__do_repeat)
1560 __s.__do_ = __state::__accept_but_not_consume;
1561 __s.__node_ = this->first();
1566 __s.__do_ = __state::__accept_but_not_consume;
1567 __s.__node_ = this->second();
1572 __s.__loop_data_[__loop_id_].first = 0;
1573 bool __do_repeat = 0 < __max_;
1574 bool __do_alt = 0 >= __min_;
1575 if (__do_repeat && __do_alt)
1576 __s.__do_ = __state::__split;
1577 else if (__do_repeat)
1579 __s.__do_ = __state::__accept_but_not_consume;
1580 __s.__node_ = this->first();
1585 __s.__do_ = __state::__accept_but_not_consume;
1586 __s.__node_ = this->second();
1591 template <class _CharT>
1593 __loop<_CharT>::__exec_split(bool __second, __state& __s) const
1595 __s.__do_ = __state::__accept_but_not_consume;
1596 if (__greedy_ != __second)
1598 __s.__node_ = this->first();
1602 __s.__node_ = this->second();
1607 template <class _CharT>
1609 : public __owns_two_states<_CharT>
1611 typedef __owns_two_states<_CharT> base;
1614 typedef _VSTD::__state<_CharT> __state;
1616 _LIBCPP_INLINE_VISIBILITY
1617 explicit __alternate(__owns_one_state<_CharT>* __s1,
1618 __owns_one_state<_CharT>* __s2)
1619 : base(__s1, __s2) {}
1621 virtual void __exec(__state& __s) const;
1622 virtual void __exec_split(bool __second, __state& __s) const;
1625 template <class _CharT>
1627 __alternate<_CharT>::__exec(__state& __s) const
1629 __s.__do_ = __state::__split;
1632 template <class _CharT>
1634 __alternate<_CharT>::__exec_split(bool __second, __state& __s) const
1636 __s.__do_ = __state::__accept_but_not_consume;
1638 __s.__node_ = this->second();
1640 __s.__node_ = this->first();
1643 // __begin_marked_subexpression
1645 template <class _CharT>
1646 class __begin_marked_subexpression
1647 : public __owns_one_state<_CharT>
1649 typedef __owns_one_state<_CharT> base;
1653 typedef _VSTD::__state<_CharT> __state;
1655 _LIBCPP_INLINE_VISIBILITY
1656 explicit __begin_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
1657 : base(__s), __mexp_(__mexp) {}
1659 virtual void __exec(__state&) const;
1662 template <class _CharT>
1664 __begin_marked_subexpression<_CharT>::__exec(__state& __s) const
1666 __s.__do_ = __state::__accept_but_not_consume;
1667 __s.__sub_matches_[__mexp_-1].first = __s.__current_;
1668 __s.__node_ = this->first();
1671 // __end_marked_subexpression
1673 template <class _CharT>
1674 class __end_marked_subexpression
1675 : public __owns_one_state<_CharT>
1677 typedef __owns_one_state<_CharT> base;
1681 typedef _VSTD::__state<_CharT> __state;
1683 _LIBCPP_INLINE_VISIBILITY
1684 explicit __end_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
1685 : base(__s), __mexp_(__mexp) {}
1687 virtual void __exec(__state&) const;
1690 template <class _CharT>
1692 __end_marked_subexpression<_CharT>::__exec(__state& __s) const
1694 __s.__do_ = __state::__accept_but_not_consume;
1695 __s.__sub_matches_[__mexp_-1].second = __s.__current_;
1696 __s.__sub_matches_[__mexp_-1].matched = true;
1697 __s.__node_ = this->first();
1702 template <class _CharT>
1704 : public __owns_one_state<_CharT>
1706 typedef __owns_one_state<_CharT> base;
1710 typedef _VSTD::__state<_CharT> __state;
1712 _LIBCPP_INLINE_VISIBILITY
1713 explicit __back_ref(unsigned __mexp, __node<_CharT>* __s)
1714 : base(__s), __mexp_(__mexp) {}
1716 virtual void __exec(__state&) const;
1719 template <class _CharT>
1721 __back_ref<_CharT>::__exec(__state& __s) const
1723 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1726 ptrdiff_t __len = __sm.second - __sm.first;
1727 if (__s.__last_ - __s.__current_ >= __len &&
1728 _VSTD::equal(__sm.first, __sm.second, __s.__current_))
1730 __s.__do_ = __state::__accept_but_not_consume;
1731 __s.__current_ += __len;
1732 __s.__node_ = this->first();
1736 __s.__do_ = __state::__reject;
1737 __s.__node_ = nullptr;
1742 __s.__do_ = __state::__reject;
1743 __s.__node_ = nullptr;
1749 template <class _CharT, class _Traits>
1750 class __back_ref_icase
1751 : public __owns_one_state<_CharT>
1753 typedef __owns_one_state<_CharT> base;
1758 typedef _VSTD::__state<_CharT> __state;
1760 _LIBCPP_INLINE_VISIBILITY
1761 explicit __back_ref_icase(const _Traits& __traits, unsigned __mexp,
1762 __node<_CharT>* __s)
1763 : base(__s), __traits_(__traits), __mexp_(__mexp) {}
1765 virtual void __exec(__state&) const;
1768 template <class _CharT, class _Traits>
1770 __back_ref_icase<_CharT, _Traits>::__exec(__state& __s) const
1772 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1775 ptrdiff_t __len = __sm.second - __sm.first;
1776 if (__s.__last_ - __s.__current_ >= __len)
1778 for (ptrdiff_t __i = 0; __i < __len; ++__i)
1780 if (__traits_.translate_nocase(__sm.first[__i]) !=
1781 __traits_.translate_nocase(__s.__current_[__i]))
1784 __s.__do_ = __state::__accept_but_not_consume;
1785 __s.__current_ += __len;
1786 __s.__node_ = this->first();
1790 __s.__do_ = __state::__reject;
1791 __s.__node_ = nullptr;
1797 __s.__do_ = __state::__reject;
1798 __s.__node_ = nullptr;
1802 // __back_ref_collate
1804 template <class _CharT, class _Traits>
1805 class __back_ref_collate
1806 : public __owns_one_state<_CharT>
1808 typedef __owns_one_state<_CharT> base;
1813 typedef _VSTD::__state<_CharT> __state;
1815 _LIBCPP_INLINE_VISIBILITY
1816 explicit __back_ref_collate(const _Traits& __traits, unsigned __mexp,
1817 __node<_CharT>* __s)
1818 : base(__s), __traits_(__traits), __mexp_(__mexp) {}
1820 virtual void __exec(__state&) const;
1823 template <class _CharT, class _Traits>
1825 __back_ref_collate<_CharT, _Traits>::__exec(__state& __s) const
1827 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1830 ptrdiff_t __len = __sm.second - __sm.first;
1831 if (__s.__last_ - __s.__current_ >= __len)
1833 for (ptrdiff_t __i = 0; __i < __len; ++__i)
1835 if (__traits_.translate(__sm.first[__i]) !=
1836 __traits_.translate(__s.__current_[__i]))
1839 __s.__do_ = __state::__accept_but_not_consume;
1840 __s.__current_ += __len;
1841 __s.__node_ = this->first();
1845 __s.__do_ = __state::__reject;
1846 __s.__node_ = nullptr;
1852 __s.__do_ = __state::__reject;
1853 __s.__node_ = nullptr;
1859 template <class _CharT, class _Traits>
1860 class __word_boundary
1861 : public __owns_one_state<_CharT>
1863 typedef __owns_one_state<_CharT> base;
1868 typedef _VSTD::__state<_CharT> __state;
1870 _LIBCPP_INLINE_VISIBILITY
1871 explicit __word_boundary(const _Traits& __traits, bool __invert,
1872 __node<_CharT>* __s)
1873 : base(__s), __traits_(__traits), __invert_(__invert) {}
1875 virtual void __exec(__state&) const;
1878 template <class _CharT, class _Traits>
1880 __word_boundary<_CharT, _Traits>::__exec(__state& __s) const
1882 bool __is_word_b = false;
1883 if (__s.__first_ != __s.__last_)
1885 if (__s.__current_ == __s.__last_)
1887 if (!(__s.__flags_ & regex_constants::match_not_eow))
1889 _CharT __c = __s.__current_[-1];
1890 __is_word_b = __c == '_' ||
1891 __traits_.isctype(__c, ctype_base::alnum);
1894 else if (__s.__current_ == __s.__first_ &&
1895 !(__s.__flags_ & regex_constants::match_prev_avail))
1897 if (!(__s.__flags_ & regex_constants::match_not_bow))
1899 _CharT __c = *__s.__current_;
1900 __is_word_b = __c == '_' ||
1901 __traits_.isctype(__c, ctype_base::alnum);
1906 _CharT __c1 = __s.__current_[-1];
1907 _CharT __c2 = *__s.__current_;
1908 bool __is_c1_b = __c1 == '_' ||
1909 __traits_.isctype(__c1, ctype_base::alnum);
1910 bool __is_c2_b = __c2 == '_' ||
1911 __traits_.isctype(__c2, ctype_base::alnum);
1912 __is_word_b = __is_c1_b != __is_c2_b;
1915 if (__is_word_b != __invert_)
1917 __s.__do_ = __state::__accept_but_not_consume;
1918 __s.__node_ = this->first();
1922 __s.__do_ = __state::__reject;
1923 __s.__node_ = nullptr;
1929 template <class _CharT>
1931 : public __owns_one_state<_CharT>
1933 typedef __owns_one_state<_CharT> base;
1936 typedef _VSTD::__state<_CharT> __state;
1938 _LIBCPP_INLINE_VISIBILITY
1939 __l_anchor(__node<_CharT>* __s)
1942 virtual void __exec(__state&) const;
1945 template <class _CharT>
1947 __l_anchor<_CharT>::__exec(__state& __s) const
1949 if (__s.__at_first_ && __s.__current_ == __s.__first_)
1951 __s.__do_ = __state::__accept_but_not_consume;
1952 __s.__node_ = this->first();
1956 __s.__do_ = __state::__reject;
1957 __s.__node_ = nullptr;
1963 template <class _CharT>
1965 : public __owns_one_state<_CharT>
1967 typedef __owns_one_state<_CharT> base;
1970 typedef _VSTD::__state<_CharT> __state;
1972 _LIBCPP_INLINE_VISIBILITY
1973 __r_anchor(__node<_CharT>* __s)
1976 virtual void __exec(__state&) const;
1979 template <class _CharT>
1981 __r_anchor<_CharT>::__exec(__state& __s) const
1983 if (__s.__current_ == __s.__last_)
1985 __s.__do_ = __state::__accept_but_not_consume;
1986 __s.__node_ = this->first();
1990 __s.__do_ = __state::__reject;
1991 __s.__node_ = nullptr;
1997 template <class _CharT>
1999 : public __owns_one_state<_CharT>
2001 typedef __owns_one_state<_CharT> base;
2004 typedef _VSTD::__state<_CharT> __state;
2006 _LIBCPP_INLINE_VISIBILITY
2007 __match_any(__node<_CharT>* __s)
2010 virtual void __exec(__state&) const;
2013 template <class _CharT>
2015 __match_any<_CharT>::__exec(__state& __s) const
2017 if (__s.__current_ != __s.__last_ && *__s.__current_ != 0)
2019 __s.__do_ = __state::__accept_and_consume;
2021 __s.__node_ = this->first();
2025 __s.__do_ = __state::__reject;
2026 __s.__node_ = nullptr;
2030 // __match_any_but_newline
2032 template <class _CharT>
2033 class __match_any_but_newline
2034 : public __owns_one_state<_CharT>
2036 typedef __owns_one_state<_CharT> base;
2039 typedef _VSTD::__state<_CharT> __state;
2041 _LIBCPP_INLINE_VISIBILITY
2042 __match_any_but_newline(__node<_CharT>* __s)
2045 virtual void __exec(__state&) const;
2048 template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const;
2049 template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<wchar_t>::__exec(__state&) const;
2053 template <class _CharT>
2055 : public __owns_one_state<_CharT>
2057 typedef __owns_one_state<_CharT> base;
2061 __match_char(const __match_char&);
2062 __match_char& operator=(const __match_char&);
2064 typedef _VSTD::__state<_CharT> __state;
2066 _LIBCPP_INLINE_VISIBILITY
2067 __match_char(_CharT __c, __node<_CharT>* __s)
2068 : base(__s), __c_(__c) {}
2070 virtual void __exec(__state&) const;
2073 template <class _CharT>
2075 __match_char<_CharT>::__exec(__state& __s) const
2077 if (__s.__current_ != __s.__last_ && *__s.__current_ == __c_)
2079 __s.__do_ = __state::__accept_and_consume;
2081 __s.__node_ = this->first();
2085 __s.__do_ = __state::__reject;
2086 __s.__node_ = nullptr;
2090 // __match_char_icase
2092 template <class _CharT, class _Traits>
2093 class __match_char_icase
2094 : public __owns_one_state<_CharT>
2096 typedef __owns_one_state<_CharT> base;
2101 __match_char_icase(const __match_char_icase&);
2102 __match_char_icase& operator=(const __match_char_icase&);
2104 typedef _VSTD::__state<_CharT> __state;
2106 _LIBCPP_INLINE_VISIBILITY
2107 __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
2108 : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {}
2110 virtual void __exec(__state&) const;
2113 template <class _CharT, class _Traits>
2115 __match_char_icase<_CharT, _Traits>::__exec(__state& __s) const
2117 if (__s.__current_ != __s.__last_ &&
2118 __traits_.translate_nocase(*__s.__current_) == __c_)
2120 __s.__do_ = __state::__accept_and_consume;
2122 __s.__node_ = this->first();
2126 __s.__do_ = __state::__reject;
2127 __s.__node_ = nullptr;
2131 // __match_char_collate
2133 template <class _CharT, class _Traits>
2134 class __match_char_collate
2135 : public __owns_one_state<_CharT>
2137 typedef __owns_one_state<_CharT> base;
2142 __match_char_collate(const __match_char_collate&);
2143 __match_char_collate& operator=(const __match_char_collate&);
2145 typedef _VSTD::__state<_CharT> __state;
2147 _LIBCPP_INLINE_VISIBILITY
2148 __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
2149 : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {}
2151 virtual void __exec(__state&) const;
2154 template <class _CharT, class _Traits>
2156 __match_char_collate<_CharT, _Traits>::__exec(__state& __s) const
2158 if (__s.__current_ != __s.__last_ &&
2159 __traits_.translate(*__s.__current_) == __c_)
2161 __s.__do_ = __state::__accept_and_consume;
2163 __s.__node_ = this->first();
2167 __s.__do_ = __state::__reject;
2168 __s.__node_ = nullptr;
2172 // __bracket_expression
2174 template <class _CharT, class _Traits>
2175 class __bracket_expression
2176 : public __owns_one_state<_CharT>
2178 typedef __owns_one_state<_CharT> base;
2179 typedef typename _Traits::string_type string_type;
2182 vector<_CharT> __chars_;
2183 vector<_CharT> __neg_chars_;
2184 vector<pair<string_type, string_type> > __ranges_;
2185 vector<pair<_CharT, _CharT> > __digraphs_;
2186 vector<string_type> __equivalences_;
2187 ctype_base::mask __mask_;
2188 ctype_base::mask __neg_mask_;
2192 bool __might_have_digraph_;
2194 __bracket_expression(const __bracket_expression&);
2195 __bracket_expression& operator=(const __bracket_expression&);
2197 typedef _VSTD::__state<_CharT> __state;
2199 _LIBCPP_INLINE_VISIBILITY
2200 __bracket_expression(const _Traits& __traits, __node<_CharT>* __s,
2201 bool __negate, bool __icase, bool __collate)
2202 : base(__s), __traits_(__traits), __mask_(), __neg_mask_(),
2203 __negate_(__negate), __icase_(__icase), __collate_(__collate),
2204 __might_have_digraph_(__traits_.getloc().name() != "C") {}
2206 virtual void __exec(__state&) const;
2208 _LIBCPP_INLINE_VISIBILITY
2209 bool __negated() const {return __negate_;}
2211 _LIBCPP_INLINE_VISIBILITY
2212 void __add_char(_CharT __c)
2215 __chars_.push_back(__traits_.translate_nocase(__c));
2216 else if (__collate_)
2217 __chars_.push_back(__traits_.translate(__c));
2219 __chars_.push_back(__c);
2221 _LIBCPP_INLINE_VISIBILITY
2222 void __add_neg_char(_CharT __c)
2225 __neg_chars_.push_back(__traits_.translate_nocase(__c));
2226 else if (__collate_)
2227 __neg_chars_.push_back(__traits_.translate(__c));
2229 __neg_chars_.push_back(__c);
2231 _LIBCPP_INLINE_VISIBILITY
2232 void __add_range(string_type __b, string_type __e)
2238 for (size_t __i = 0; __i < __b.size(); ++__i)
2239 __b[__i] = __traits_.translate_nocase(__b[__i]);
2240 for (size_t __i = 0; __i < __e.size(); ++__i)
2241 __e[__i] = __traits_.translate_nocase(__e[__i]);
2245 for (size_t __i = 0; __i < __b.size(); ++__i)
2246 __b[__i] = __traits_.translate(__b[__i]);
2247 for (size_t __i = 0; __i < __e.size(); ++__i)
2248 __e[__i] = __traits_.translate(__e[__i]);
2250 __ranges_.push_back(make_pair(
2251 __traits_.transform(__b.begin(), __b.end()),
2252 __traits_.transform(__e.begin(), __e.end())));
2256 #ifndef _LIBCPP_NO_EXCEPTIONS
2257 if (__b.size() != 1 || __e.size() != 1)
2258 throw regex_error(regex_constants::error_collate);
2259 #endif // _LIBCPP_NO_EXCEPTIONS
2262 __b[0] = __traits_.translate_nocase(__b[0]);
2263 __e[0] = __traits_.translate_nocase(__e[0]);
2265 __ranges_.push_back(make_pair(_VSTD::move(__b), _VSTD::move(__e)));
2268 _LIBCPP_INLINE_VISIBILITY
2269 void __add_digraph(_CharT __c1, _CharT __c2)
2272 __digraphs_.push_back(make_pair(__traits_.translate_nocase(__c1),
2273 __traits_.translate_nocase(__c2)));
2274 else if (__collate_)
2275 __digraphs_.push_back(make_pair(__traits_.translate(__c1),
2276 __traits_.translate(__c2)));
2278 __digraphs_.push_back(make_pair(__c1, __c2));
2280 _LIBCPP_INLINE_VISIBILITY
2281 void __add_equivalence(const string_type& __s)
2282 {__equivalences_.push_back(__s);}
2283 _LIBCPP_INLINE_VISIBILITY
2284 void __add_class(ctype_base::mask __mask)
2285 {__mask_ |= __mask;}
2286 _LIBCPP_INLINE_VISIBILITY
2287 void __add_neg_class(ctype_base::mask __mask)
2288 {__neg_mask_ |= __mask;}
2291 template <class _CharT, class _Traits>
2293 __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const
2295 bool __found = false;
2296 unsigned __consumed = 0;
2297 if (__s.__current_ != __s.__last_)
2300 if (__might_have_digraph_)
2302 const _CharT* __next = _VSTD::next(__s.__current_);
2303 if (__next != __s.__last_)
2305 pair<_CharT, _CharT> __ch2(*__s.__current_, *__next);
2308 __ch2.first = __traits_.translate_nocase(__ch2.first);
2309 __ch2.second = __traits_.translate_nocase(__ch2.second);
2311 else if (__collate_)
2313 __ch2.first = __traits_.translate(__ch2.first);
2314 __ch2.second = __traits_.translate(__ch2.second);
2316 if (!__traits_.lookup_collatename(&__ch2.first, &__ch2.first+2).empty())
2318 // __ch2 is a digraph in this locale
2320 for (size_t __i = 0; __i < __digraphs_.size(); ++__i)
2322 if (__ch2 == __digraphs_[__i])
2328 if (__collate_ && !__ranges_.empty())
2330 string_type __s2 = __traits_.transform(&__ch2.first,
2332 for (size_t __i = 0; __i < __ranges_.size(); ++__i)
2334 if (__ranges_[__i].first <= __s2 &&
2335 __s2 <= __ranges_[__i].second)
2342 if (!__equivalences_.empty())
2344 string_type __s2 = __traits_.transform_primary(&__ch2.first,
2346 for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
2348 if (__s2 == __equivalences_[__i])
2355 if (__traits_.isctype(__ch2.first, __mask_) &&
2356 __traits_.isctype(__ch2.second, __mask_))
2361 if (!__traits_.isctype(__ch2.first, __neg_mask_) &&
2362 !__traits_.isctype(__ch2.second, __neg_mask_))
2371 // test *__s.__current_ as not a digraph
2372 _CharT __ch = *__s.__current_;
2374 __ch = __traits_.translate_nocase(__ch);
2375 else if (__collate_)
2376 __ch = __traits_.translate(__ch);
2377 for (size_t __i = 0; __i < __chars_.size(); ++__i)
2379 if (__ch == __chars_[__i])
2385 if (!__neg_chars_.empty())
2387 for (size_t __i = 0; __i < __neg_chars_.size(); ++__i)
2389 if (__ch == __neg_chars_[__i])
2396 if (!__ranges_.empty())
2398 string_type __s2 = __collate_ ?
2399 __traits_.transform(&__ch, &__ch + 1) :
2400 string_type(1, __ch);
2401 for (size_t __i = 0; __i < __ranges_.size(); ++__i)
2403 if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second)
2410 if (!__equivalences_.empty())
2412 string_type __s2 = __traits_.transform_primary(&__ch, &__ch + 1);
2413 for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
2415 if (__s2 == __equivalences_[__i])
2422 if (__traits_.isctype(__ch, __mask_))
2427 if (__neg_mask_ && !__traits_.isctype(__ch, __neg_mask_))
2434 __found = __negate_; // force reject
2436 if (__found != __negate_)
2438 __s.__do_ = __state::__accept_and_consume;
2439 __s.__current_ += __consumed;
2440 __s.__node_ = this->first();
2444 __s.__do_ = __state::__reject;
2445 __s.__node_ = nullptr;
2449 template <class _CharT, class _Traits> class __lookahead;
2451 template <class _CharT, class _Traits = regex_traits<_CharT> >
2452 class _LIBCPP_TYPE_VIS_ONLY basic_regex
2456 typedef _CharT value_type;
2457 typedef regex_constants::syntax_option_type flag_type;
2458 typedef typename _Traits::locale_type locale_type;
2463 unsigned __marked_count_;
2464 unsigned __loop_count_;
2466 shared_ptr<__empty_state<_CharT> > __start_;
2467 __owns_one_state<_CharT>* __end_;
2469 typedef _VSTD::__state<_CharT> __state;
2470 typedef _VSTD::__node<_CharT> __node;
2474 static const regex_constants::syntax_option_type icase = regex_constants::icase;
2475 static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
2476 static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
2477 static const regex_constants::syntax_option_type collate = regex_constants::collate;
2478 static const regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
2479 static const regex_constants::syntax_option_type basic = regex_constants::basic;
2480 static const regex_constants::syntax_option_type extended = regex_constants::extended;
2481 static const regex_constants::syntax_option_type awk = regex_constants::awk;
2482 static const regex_constants::syntax_option_type grep = regex_constants::grep;
2483 static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
2485 // construct/copy/destroy:
2486 _LIBCPP_INLINE_VISIBILITY
2488 : __flags_(), __marked_count_(0), __loop_count_(0), __open_count_(0),
2491 _LIBCPP_INLINE_VISIBILITY
2492 explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
2493 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2495 {__parse(__p, __p + __traits_.length(__p));}
2496 _LIBCPP_INLINE_VISIBILITY
2497 basic_regex(const value_type* __p, size_t __len, flag_type __f)
2498 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2500 {__parse(__p, __p + __len);}
2501 // basic_regex(const basic_regex&) = default;
2502 // basic_regex(basic_regex&&) = default;
2503 template <class _ST, class _SA>
2504 _LIBCPP_INLINE_VISIBILITY
2505 explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p,
2506 flag_type __f = regex_constants::ECMAScript)
2507 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2509 {__parse(__p.begin(), __p.end());}
2510 template <class _ForwardIterator>
2511 _LIBCPP_INLINE_VISIBILITY
2512 basic_regex(_ForwardIterator __first, _ForwardIterator __last,
2513 flag_type __f = regex_constants::ECMAScript)
2514 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2516 {__parse(__first, __last);}
2517 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2518 _LIBCPP_INLINE_VISIBILITY
2519 basic_regex(initializer_list<value_type> __il,
2520 flag_type __f = regex_constants::ECMAScript)
2521 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2523 {__parse(__il.begin(), __il.end());}
2524 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2526 // ~basic_regex() = default;
2528 // basic_regex& operator=(const basic_regex&) = default;
2529 // basic_regex& operator=(basic_regex&&) = default;
2530 _LIBCPP_INLINE_VISIBILITY
2531 basic_regex& operator=(const value_type* __p)
2532 {return assign(__p);}
2533 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2534 _LIBCPP_INLINE_VISIBILITY
2535 basic_regex& operator=(initializer_list<value_type> __il)
2536 {return assign(__il);}
2537 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2538 template <class _ST, class _SA>
2539 _LIBCPP_INLINE_VISIBILITY
2540 basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p)
2541 {return assign(__p);}
2544 _LIBCPP_INLINE_VISIBILITY
2545 basic_regex& assign(const basic_regex& __that)
2546 {return *this = __that;}
2547 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2548 _LIBCPP_INLINE_VISIBILITY
2549 basic_regex& assign(basic_regex&& __that) _NOEXCEPT
2550 {return *this = _VSTD::move(__that);}
2552 _LIBCPP_INLINE_VISIBILITY
2553 basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
2554 {return assign(__p, __p + __traits_.length(__p), __f);}
2555 _LIBCPP_INLINE_VISIBILITY
2556 basic_regex& assign(const value_type* __p, size_t __len, flag_type __f)
2557 {return assign(__p, __p + __len, __f);}
2558 template <class _ST, class _SA>
2559 _LIBCPP_INLINE_VISIBILITY
2560 basic_regex& assign(const basic_string<value_type, _ST, _SA>& __s,
2561 flag_type __f = regex_constants::ECMAScript)
2562 {return assign(__s.begin(), __s.end(), __f);}
2564 template <class _InputIterator>
2565 _LIBCPP_INLINE_VISIBILITY
2568 __is_input_iterator <_InputIterator>::value &&
2569 !__is_forward_iterator<_InputIterator>::value,
2572 assign(_InputIterator __first, _InputIterator __last,
2573 flag_type __f = regex_constants::ECMAScript)
2575 basic_string<_CharT> __t(__first, __last);
2576 return assign(__t.begin(), __t.end(), __f);
2580 _LIBCPP_INLINE_VISIBILITY
2581 void __member_init(flag_type __f)
2584 __marked_count_ = 0;
2591 template <class _ForwardIterator>
2592 _LIBCPP_INLINE_VISIBILITY
2595 __is_forward_iterator<_ForwardIterator>::value,
2598 assign(_ForwardIterator __first, _ForwardIterator __last,
2599 flag_type __f = regex_constants::ECMAScript)
2602 __parse(__first, __last);
2606 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2608 _LIBCPP_INLINE_VISIBILITY
2609 basic_regex& assign(initializer_list<value_type> __il,
2610 flag_type __f = regex_constants::ECMAScript)
2611 {return assign(__il.begin(), __il.end(), __f);}
2613 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2615 // const operations:
2616 _LIBCPP_INLINE_VISIBILITY
2617 unsigned mark_count() const {return __marked_count_;}
2618 _LIBCPP_INLINE_VISIBILITY
2619 flag_type flags() const {return __flags_;}
2622 _LIBCPP_INLINE_VISIBILITY
2623 locale_type imbue(locale_type __loc)
2625 __member_init(ECMAScript);
2627 return __traits_.imbue(__loc);
2629 _LIBCPP_INLINE_VISIBILITY
2630 locale_type getloc() const {return __traits_.getloc();}
2633 void swap(basic_regex& __r);
2636 _LIBCPP_INLINE_VISIBILITY
2637 unsigned __loop_count() const {return __loop_count_;}
2639 template <class _ForwardIterator>
2641 __parse(_ForwardIterator __first, _ForwardIterator __last);
2642 template <class _ForwardIterator>
2644 __parse_basic_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
2645 template <class _ForwardIterator>
2647 __parse_RE_expression(_ForwardIterator __first, _ForwardIterator __last);
2648 template <class _ForwardIterator>
2650 __parse_simple_RE(_ForwardIterator __first, _ForwardIterator __last);
2651 template <class _ForwardIterator>
2653 __parse_nondupl_RE(_ForwardIterator __first, _ForwardIterator __last);
2654 template <class _ForwardIterator>
2656 __parse_one_char_or_coll_elem_RE(_ForwardIterator __first, _ForwardIterator __last);
2657 template <class _ForwardIterator>
2659 __parse_Back_open_paren(_ForwardIterator __first, _ForwardIterator __last);
2660 template <class _ForwardIterator>
2662 __parse_Back_close_paren(_ForwardIterator __first, _ForwardIterator __last);
2663 template <class _ForwardIterator>
2665 __parse_Back_open_brace(_ForwardIterator __first, _ForwardIterator __last);
2666 template <class _ForwardIterator>
2668 __parse_Back_close_brace(_ForwardIterator __first, _ForwardIterator __last);
2669 template <class _ForwardIterator>
2671 __parse_BACKREF(_ForwardIterator __first, _ForwardIterator __last);
2672 template <class _ForwardIterator>
2674 __parse_ORD_CHAR(_ForwardIterator __first, _ForwardIterator __last);
2675 template <class _ForwardIterator>
2677 __parse_QUOTED_CHAR(_ForwardIterator __first, _ForwardIterator __last);
2678 template <class _ForwardIterator>
2680 __parse_RE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
2681 __owns_one_state<_CharT>* __s,
2682 unsigned __mexp_begin, unsigned __mexp_end);
2683 template <class _ForwardIterator>
2685 __parse_ERE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
2686 __owns_one_state<_CharT>* __s,
2687 unsigned __mexp_begin, unsigned __mexp_end);
2688 template <class _ForwardIterator>
2690 __parse_bracket_expression(_ForwardIterator __first, _ForwardIterator __last);
2691 template <class _ForwardIterator>
2693 __parse_follow_list(_ForwardIterator __first, _ForwardIterator __last,
2694 __bracket_expression<_CharT, _Traits>* __ml);
2695 template <class _ForwardIterator>
2697 __parse_expression_term(_ForwardIterator __first, _ForwardIterator __last,
2698 __bracket_expression<_CharT, _Traits>* __ml);
2699 template <class _ForwardIterator>
2701 __parse_equivalence_class(_ForwardIterator __first, _ForwardIterator __last,
2702 __bracket_expression<_CharT, _Traits>* __ml);
2703 template <class _ForwardIterator>
2705 __parse_character_class(_ForwardIterator __first, _ForwardIterator __last,
2706 __bracket_expression<_CharT, _Traits>* __ml);
2707 template <class _ForwardIterator>
2709 __parse_collating_symbol(_ForwardIterator __first, _ForwardIterator __last,
2710 basic_string<_CharT>& __col_sym);
2711 template <class _ForwardIterator>
2713 __parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c);
2714 template <class _ForwardIterator>
2716 __parse_extended_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
2717 template <class _ForwardIterator>
2719 __parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last);
2720 template <class _ForwardIterator>
2722 __parse_ERE_expression(_ForwardIterator __first, _ForwardIterator __last);
2723 template <class _ForwardIterator>
2725 __parse_one_char_or_coll_elem_ERE(_ForwardIterator __first, _ForwardIterator __last);
2726 template <class _ForwardIterator>
2728 __parse_ORD_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
2729 template <class _ForwardIterator>
2731 __parse_QUOTED_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
2732 template <class _ForwardIterator>
2734 __parse_ecma_exp(_ForwardIterator __first, _ForwardIterator __last);
2735 template <class _ForwardIterator>
2737 __parse_alternative(_ForwardIterator __first, _ForwardIterator __last);
2738 template <class _ForwardIterator>
2740 __parse_term(_ForwardIterator __first, _ForwardIterator __last);
2741 template <class _ForwardIterator>
2743 __parse_assertion(_ForwardIterator __first, _ForwardIterator __last);
2744 template <class _ForwardIterator>
2746 __parse_atom(_ForwardIterator __first, _ForwardIterator __last);
2747 template <class _ForwardIterator>
2749 __parse_atom_escape(_ForwardIterator __first, _ForwardIterator __last);
2750 template <class _ForwardIterator>
2752 __parse_decimal_escape(_ForwardIterator __first, _ForwardIterator __last);
2753 template <class _ForwardIterator>
2755 __parse_character_class_escape(_ForwardIterator __first, _ForwardIterator __last);
2756 template <class _ForwardIterator>
2758 __parse_character_escape(_ForwardIterator __first, _ForwardIterator __last,
2759 basic_string<_CharT>* __str = nullptr);
2760 template <class _ForwardIterator>
2762 __parse_pattern_character(_ForwardIterator __first, _ForwardIterator __last);
2763 template <class _ForwardIterator>
2765 __parse_grep(_ForwardIterator __first, _ForwardIterator __last);
2766 template <class _ForwardIterator>
2768 __parse_egrep(_ForwardIterator __first, _ForwardIterator __last);
2769 template <class _ForwardIterator>
2771 __parse_class_escape(_ForwardIterator __first, _ForwardIterator __last,
2772 basic_string<_CharT>& __str,
2773 __bracket_expression<_CharT, _Traits>* __ml);
2774 template <class _ForwardIterator>
2776 __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last,
2777 basic_string<_CharT>* __str = nullptr);
2779 _LIBCPP_INLINE_VISIBILITY
2780 void __push_l_anchor();
2781 void __push_r_anchor();
2782 void __push_match_any();
2783 void __push_match_any_but_newline();
2784 _LIBCPP_INLINE_VISIBILITY
2785 void __push_greedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
2786 unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
2787 {__push_loop(__min, numeric_limits<size_t>::max(), __s,
2788 __mexp_begin, __mexp_end);}
2789 _LIBCPP_INLINE_VISIBILITY
2790 void __push_nongreedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
2791 unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
2792 {__push_loop(__min, numeric_limits<size_t>::max(), __s,
2793 __mexp_begin, __mexp_end, false);}
2794 void __push_loop(size_t __min, size_t __max, __owns_one_state<_CharT>* __s,
2795 size_t __mexp_begin = 0, size_t __mexp_end = 0,
2796 bool __greedy = true);
2797 __bracket_expression<_CharT, _Traits>* __start_matching_list(bool __negate);
2798 void __push_char(value_type __c);
2799 void __push_back_ref(int __i);
2800 void __push_alternation(__owns_one_state<_CharT>* __sa,
2801 __owns_one_state<_CharT>* __sb);
2802 void __push_begin_marked_subexpression();
2803 void __push_end_marked_subexpression(unsigned);
2804 void __push_empty();
2805 void __push_word_boundary(bool);
2806 void __push_lookahead(const basic_regex&, bool, unsigned);
2808 template <class _Allocator>
2810 __search(const _CharT* __first, const _CharT* __last,
2811 match_results<const _CharT*, _Allocator>& __m,
2812 regex_constants::match_flag_type __flags) const;
2814 template <class _Allocator>
2816 __match_at_start(const _CharT* __first, const _CharT* __last,
2817 match_results<const _CharT*, _Allocator>& __m,
2818 regex_constants::match_flag_type __flags, bool) const;
2819 template <class _Allocator>
2821 __match_at_start_ecma(const _CharT* __first, const _CharT* __last,
2822 match_results<const _CharT*, _Allocator>& __m,
2823 regex_constants::match_flag_type __flags, bool) const;
2824 template <class _Allocator>
2826 __match_at_start_posix_nosubs(const _CharT* __first, const _CharT* __last,
2827 match_results<const _CharT*, _Allocator>& __m,
2828 regex_constants::match_flag_type __flags, bool) const;
2829 template <class _Allocator>
2831 __match_at_start_posix_subs(const _CharT* __first, const _CharT* __last,
2832 match_results<const _CharT*, _Allocator>& __m,
2833 regex_constants::match_flag_type __flags, bool) const;
2835 template <class _Bp, class _Ap, class _Cp, class _Tp>
2838 regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
2839 regex_constants::match_flag_type);
2841 template <class _Ap, class _Cp, class _Tp>
2844 regex_search(const _Cp*, const _Cp*, match_results<const _Cp*, _Ap>&,
2845 const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
2847 template <class _Bp, class _Cp, class _Tp>
2850 regex_search(_Bp, _Bp, const basic_regex<_Cp, _Tp>&,
2851 regex_constants::match_flag_type);
2853 template <class _Cp, class _Tp>
2856 regex_search(const _Cp*, const _Cp*,
2857 const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
2859 template <class _Cp, class _Ap, class _Tp>
2862 regex_search(const _Cp*, match_results<const _Cp*, _Ap>&, const basic_regex<_Cp, _Tp>&,
2863 regex_constants::match_flag_type);
2865 template <class _ST, class _SA, class _Cp, class _Tp>
2868 regex_search(const basic_string<_Cp, _ST, _SA>& __s,
2869 const basic_regex<_Cp, _Tp>& __e,
2870 regex_constants::match_flag_type __flags);
2872 template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
2875 regex_search(const basic_string<_Cp, _ST, _SA>& __s,
2876 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
2877 const basic_regex<_Cp, _Tp>& __e,
2878 regex_constants::match_flag_type __flags);
2880 template <class _Iter, class _Ap, class _Cp, class _Tp>
2883 regex_search(__wrap_iter<_Iter> __first,
2884 __wrap_iter<_Iter> __last,
2885 match_results<__wrap_iter<_Iter>, _Ap>& __m,
2886 const basic_regex<_Cp, _Tp>& __e,
2887 regex_constants::match_flag_type __flags);
2889 template <class, class> friend class __lookahead;
2892 template <class _CharT, class _Traits>
2893 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;
2894 template <class _CharT, class _Traits>
2895 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::nosubs;
2896 template <class _CharT, class _Traits>
2897 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::optimize;
2898 template <class _CharT, class _Traits>
2899 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::collate;
2900 template <class _CharT, class _Traits>
2901 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::ECMAScript;
2902 template <class _CharT, class _Traits>
2903 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::basic;
2904 template <class _CharT, class _Traits>
2905 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::extended;
2906 template <class _CharT, class _Traits>
2907 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::awk;
2908 template <class _CharT, class _Traits>
2909 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::grep;
2910 template <class _CharT, class _Traits>
2911 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::egrep;
2913 template <class _CharT, class _Traits>
2915 basic_regex<_CharT, _Traits>::swap(basic_regex& __r)
2918 swap(__traits_, __r.__traits_);
2919 swap(__flags_, __r.__flags_);
2920 swap(__marked_count_, __r.__marked_count_);
2921 swap(__loop_count_, __r.__loop_count_);
2922 swap(__open_count_, __r.__open_count_);
2923 swap(__start_, __r.__start_);
2924 swap(__end_, __r.__end_);
2927 template <class _CharT, class _Traits>
2928 inline _LIBCPP_INLINE_VISIBILITY
2930 swap(basic_regex<_CharT, _Traits>& __x, basic_regex<_CharT, _Traits>& __y)
2932 return __x.swap(__y);
2937 template <class _CharT, class _Traits>
2939 : public __owns_one_state<_CharT>
2941 typedef __owns_one_state<_CharT> base;
2943 basic_regex<_CharT, _Traits> __exp_;
2947 __lookahead(const __lookahead&);
2948 __lookahead& operator=(const __lookahead&);
2950 typedef _VSTD::__state<_CharT> __state;
2952 _LIBCPP_INLINE_VISIBILITY
2953 __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp)
2954 : base(__s), __exp_(__exp), __invert_(__invert), __mexp_(__mexp) {}
2956 virtual void __exec(__state&) const;
2959 template <class _CharT, class _Traits>
2961 __lookahead<_CharT, _Traits>::__exec(__state& __s) const
2963 match_results<const _CharT*> __m;
2964 __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
2965 bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_,
2967 __s.__flags_ | regex_constants::match_continuous,
2968 __s.__at_first_ && __s.__current_ == __s.__first_);
2969 if (__matched != __invert_)
2971 __s.__do_ = __state::__accept_but_not_consume;
2972 __s.__node_ = this->first();
2973 for (unsigned __i = 1; __i < __m.size(); ++__i) {
2974 __s.__sub_matches_[__mexp_ + __i - 1] = __m.__matches_[__i];
2979 __s.__do_ = __state::__reject;
2980 __s.__node_ = nullptr;
2984 template <class _CharT, class _Traits>
2985 template <class _ForwardIterator>
2987 basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
2988 _ForwardIterator __last)
2991 unique_ptr<__node> __h(new __end_state<_CharT>);
2992 __start_.reset(new __empty_state<_CharT>(__h.get()));
2994 __end_ = __start_.get();
2996 switch (__flags_ & 0x1F0)
2999 __first = __parse_ecma_exp(__first, __last);
3002 __first = __parse_basic_reg_exp(__first, __last);
3006 __first = __parse_extended_reg_exp(__first, __last);
3009 __first = __parse_grep(__first, __last);
3012 __first = __parse_egrep(__first, __last);
3014 #ifndef _LIBCPP_NO_EXCEPTIONS
3016 throw regex_error(regex_constants::__re_err_grammar);
3017 #endif // _LIBCPP_NO_EXCEPTIONS
3022 template <class _CharT, class _Traits>
3023 template <class _ForwardIterator>
3025 basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first,
3026 _ForwardIterator __last)
3028 if (__first != __last)
3030 if (*__first == '^')
3035 if (__first != __last)
3037 __first = __parse_RE_expression(__first, __last);
3038 if (__first != __last)
3040 _ForwardIterator __temp = _VSTD::next(__first);
3041 if (__temp == __last && *__first == '$')
3048 #ifndef _LIBCPP_NO_EXCEPTIONS
3049 if (__first != __last)
3050 throw regex_error(regex_constants::__re_err_empty);
3051 #endif // _LIBCPP_NO_EXCEPTIONS
3056 template <class _CharT, class _Traits>
3057 template <class _ForwardIterator>
3059 basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
3060 _ForwardIterator __last)
3062 __owns_one_state<_CharT>* __sa = __end_;
3063 _ForwardIterator __temp = __parse_ERE_branch(__first, __last);
3064 #ifndef _LIBCPP_NO_EXCEPTIONS
3065 if (__temp == __first)
3066 throw regex_error(regex_constants::__re_err_empty);
3067 #endif // _LIBCPP_NO_EXCEPTIONS
3069 while (__first != __last && *__first == '|')
3071 __owns_one_state<_CharT>* __sb = __end_;
3072 __temp = __parse_ERE_branch(++__first, __last);
3073 #ifndef _LIBCPP_NO_EXCEPTIONS
3074 if (__temp == __first)
3075 throw regex_error(regex_constants::__re_err_empty);
3076 #endif // _LIBCPP_NO_EXCEPTIONS
3077 __push_alternation(__sa, __sb);
3083 template <class _CharT, class _Traits>
3084 template <class _ForwardIterator>
3086 basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first,
3087 _ForwardIterator __last)
3089 _ForwardIterator __temp = __parse_ERE_expression(__first, __last);
3090 #ifndef _LIBCPP_NO_EXCEPTIONS
3091 if (__temp == __first)
3092 throw regex_error(regex_constants::__re_err_empty);
3093 #endif // _LIBCPP_NO_EXCEPTIONS
3097 __temp = __parse_ERE_expression(__first, __last);
3098 } while (__temp != __first);
3102 template <class _CharT, class _Traits>
3103 template <class _ForwardIterator>
3105 basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first,
3106 _ForwardIterator __last)
3108 __owns_one_state<_CharT>* __e = __end_;
3109 unsigned __mexp_begin = __marked_count_;
3110 _ForwardIterator __temp = __parse_one_char_or_coll_elem_ERE(__first, __last);
3111 if (__temp == __first && __temp != __last)
3124 __push_begin_marked_subexpression();
3125 unsigned __temp_count = __marked_count_;
3127 __temp = __parse_extended_reg_exp(++__temp, __last);
3128 #ifndef _LIBCPP_NO_EXCEPTIONS
3129 if (__temp == __last || *__temp != ')')
3130 throw regex_error(regex_constants::error_paren);
3131 #endif // _LIBCPP_NO_EXCEPTIONS
3132 __push_end_marked_subexpression(__temp_count);
3138 if (__temp != __first)
3139 __temp = __parse_ERE_dupl_symbol(__temp, __last, __e, __mexp_begin+1,
3145 template <class _CharT, class _Traits>
3146 template <class _ForwardIterator>
3148 basic_regex<_CharT, _Traits>::__parse_RE_expression(_ForwardIterator __first,
3149 _ForwardIterator __last)
3153 _ForwardIterator __temp = __parse_simple_RE(__first, __last);
3154 if (__temp == __first)
3161 template <class _CharT, class _Traits>
3162 template <class _ForwardIterator>
3164 basic_regex<_CharT, _Traits>::__parse_simple_RE(_ForwardIterator __first,
3165 _ForwardIterator __last)
3167 if (__first != __last)
3169 __owns_one_state<_CharT>* __e = __end_;
3170 unsigned __mexp_begin = __marked_count_;
3171 _ForwardIterator __temp = __parse_nondupl_RE(__first, __last);
3172 if (__temp != __first)
3173 __first = __parse_RE_dupl_symbol(__temp, __last, __e,
3174 __mexp_begin+1, __marked_count_+1);
3179 template <class _CharT, class _Traits>
3180 template <class _ForwardIterator>
3182 basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first,
3183 _ForwardIterator __last)
3185 _ForwardIterator __temp = __first;
3186 __first = __parse_one_char_or_coll_elem_RE(__first, __last);
3187 if (__temp == __first)
3189 __temp = __parse_Back_open_paren(__first, __last);
3190 if (__temp != __first)
3192 __push_begin_marked_subexpression();
3193 unsigned __temp_count = __marked_count_;
3194 __first = __parse_RE_expression(__temp, __last);
3195 __temp = __parse_Back_close_paren(__first, __last);
3196 #ifndef _LIBCPP_NO_EXCEPTIONS
3197 if (__temp == __first)
3198 throw regex_error(regex_constants::error_paren);
3199 #endif // _LIBCPP_NO_EXCEPTIONS
3200 __push_end_marked_subexpression(__temp_count);
3204 __first = __parse_BACKREF(__first, __last);
3209 template <class _CharT, class _Traits>
3210 template <class _ForwardIterator>
3212 basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_RE(
3213 _ForwardIterator __first,
3214 _ForwardIterator __last)
3216 _ForwardIterator __temp = __parse_ORD_CHAR(__first, __last);
3217 if (__temp == __first)
3219 __temp = __parse_QUOTED_CHAR(__first, __last);
3220 if (__temp == __first)
3222 if (__temp != __last && *__temp == '.')
3228 __temp = __parse_bracket_expression(__first, __last);
3235 template <class _CharT, class _Traits>
3236 template <class _ForwardIterator>
3238 basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_ERE(
3239 _ForwardIterator __first,
3240 _ForwardIterator __last)
3242 _ForwardIterator __temp = __parse_ORD_CHAR_ERE(__first, __last);
3243 if (__temp == __first)
3245 __temp = __parse_QUOTED_CHAR_ERE(__first, __last);
3246 if (__temp == __first)
3248 if (__temp != __last && *__temp == '.')
3254 __temp = __parse_bracket_expression(__first, __last);
3261 template <class _CharT, class _Traits>
3262 template <class _ForwardIterator>
3264 basic_regex<_CharT, _Traits>::__parse_Back_open_paren(_ForwardIterator __first,
3265 _ForwardIterator __last)
3267 if (__first != __last)
3269 _ForwardIterator __temp = _VSTD::next(__first);
3270 if (__temp != __last)
3272 if (*__first == '\\' && *__temp == '(')
3279 template <class _CharT, class _Traits>
3280 template <class _ForwardIterator>
3282 basic_regex<_CharT, _Traits>::__parse_Back_close_paren(_ForwardIterator __first,
3283 _ForwardIterator __last)
3285 if (__first != __last)
3287 _ForwardIterator __temp = _VSTD::next(__first);
3288 if (__temp != __last)
3290 if (*__first == '\\' && *__temp == ')')
3297 template <class _CharT, class _Traits>
3298 template <class _ForwardIterator>
3300 basic_regex<_CharT, _Traits>::__parse_Back_open_brace(_ForwardIterator __first,
3301 _ForwardIterator __last)
3303 if (__first != __last)
3305 _ForwardIterator __temp = _VSTD::next(__first);
3306 if (__temp != __last)
3308 if (*__first == '\\' && *__temp == '{')
3315 template <class _CharT, class _Traits>
3316 template <class _ForwardIterator>
3318 basic_regex<_CharT, _Traits>::__parse_Back_close_brace(_ForwardIterator __first,
3319 _ForwardIterator __last)
3321 if (__first != __last)
3323 _ForwardIterator __temp = _VSTD::next(__first);
3324 if (__temp != __last)
3326 if (*__first == '\\' && *__temp == '}')
3333 template <class _CharT, class _Traits>
3334 template <class _ForwardIterator>
3336 basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first,
3337 _ForwardIterator __last)
3339 if (__first != __last)
3341 _ForwardIterator __temp = _VSTD::next(__first);
3342 if (__temp != __last)
3344 if (*__first == '\\')
3346 int __val = __traits_.value(*__temp, 10);
3347 if (__val >= 1 && __val <= 9)
3349 __push_back_ref(__val);
3358 template <class _CharT, class _Traits>
3359 template <class _ForwardIterator>
3361 basic_regex<_CharT, _Traits>::__parse_ORD_CHAR(_ForwardIterator __first,
3362 _ForwardIterator __last)
3364 if (__first != __last)
3366 _ForwardIterator __temp = _VSTD::next(__first);
3367 if (__temp == __last && *__first == '$')
3369 // Not called inside a bracket
3370 if (*__first == '.' || *__first == '\\' || *__first == '[')
3372 __push_char(*__first);
3378 template <class _CharT, class _Traits>
3379 template <class _ForwardIterator>
3381 basic_regex<_CharT, _Traits>::__parse_ORD_CHAR_ERE(_ForwardIterator __first,
3382 _ForwardIterator __last)
3384 if (__first != __last)
3401 if (__open_count_ == 0)
3403 __push_char(*__first);
3408 __push_char(*__first);
3416 template <class _CharT, class _Traits>
3417 template <class _ForwardIterator>
3419 basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR(_ForwardIterator __first,
3420 _ForwardIterator __last)
3422 if (__first != __last)
3424 _ForwardIterator __temp = _VSTD::next(__first);
3425 if (__temp != __last)
3427 if (*__first == '\\')
3437 __push_char(*__temp);
3447 template <class _CharT, class _Traits>
3448 template <class _ForwardIterator>
3450 basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first,
3451 _ForwardIterator __last)
3453 if (__first != __last)
3455 _ForwardIterator __temp = _VSTD::next(__first);
3456 if (__temp != __last)
3458 if (*__first == '\\')
3475 __push_char(*__temp);
3479 if ((__flags_ & 0x1F0) == awk)
3480 __first = __parse_awk_escape(++__first, __last);
3489 template <class _CharT, class _Traits>
3490 template <class _ForwardIterator>
3492 basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
3493 _ForwardIterator __last,
3494 __owns_one_state<_CharT>* __s,
3495 unsigned __mexp_begin,
3496 unsigned __mexp_end)
3498 if (__first != __last)
3500 if (*__first == '*')
3502 __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3507 _ForwardIterator __temp = __parse_Back_open_brace(__first, __last);
3508 if (__temp != __first)
3512 __temp = __parse_DUP_COUNT(__first, __last, __min);
3513 #ifndef _LIBCPP_NO_EXCEPTIONS
3514 if (__temp == __first)
3515 throw regex_error(regex_constants::error_badbrace);
3516 #endif // _LIBCPP_NO_EXCEPTIONS
3518 #ifndef _LIBCPP_NO_EXCEPTIONS
3519 if (__first == __last)
3520 throw regex_error(regex_constants::error_brace);
3521 #endif // _LIBCPP_NO_EXCEPTIONS
3522 if (*__first != ',')
3524 __temp = __parse_Back_close_brace(__first, __last);
3525 #ifndef _LIBCPP_NO_EXCEPTIONS
3526 if (__temp == __first)
3527 throw regex_error(regex_constants::error_brace);
3528 #endif // _LIBCPP_NO_EXCEPTIONS
3529 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end,
3535 ++__first; // consume ','
3537 __first = __parse_DUP_COUNT(__first, __last, __max);
3538 __temp = __parse_Back_close_brace(__first, __last);
3539 #ifndef _LIBCPP_NO_EXCEPTIONS
3540 if (__temp == __first)
3541 throw regex_error(regex_constants::error_brace);
3542 #endif // _LIBCPP_NO_EXCEPTIONS
3544 __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3547 #ifndef _LIBCPP_NO_EXCEPTIONS
3549 throw regex_error(regex_constants::error_badbrace);
3550 #endif // _LIBCPP_NO_EXCEPTIONS
3551 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end,
3562 template <class _CharT, class _Traits>
3563 template <class _ForwardIterator>
3565 basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
3566 _ForwardIterator __last,
3567 __owns_one_state<_CharT>* __s,
3568 unsigned __mexp_begin,
3569 unsigned __mexp_end)
3571 if (__first != __last)
3573 unsigned __grammar = __flags_ & 0x1F0;
3578 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3581 __push_nongreedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3584 __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3588 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3591 __push_nongreedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
3594 __push_greedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
3598 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3601 __push_loop(0, 1, __s, __mexp_begin, __mexp_end, false);
3604 __push_loop(0, 1, __s, __mexp_begin, __mexp_end);
3609 _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);
3610 #ifndef _LIBCPP_NO_EXCEPTIONS
3611 if (__temp == __first)
3612 throw regex_error(regex_constants::error_badbrace);
3613 #endif // _LIBCPP_NO_EXCEPTIONS
3615 #ifndef _LIBCPP_NO_EXCEPTIONS
3616 if (__first == __last)
3617 throw regex_error(regex_constants::error_brace);
3618 #endif // _LIBCPP_NO_EXCEPTIONS
3623 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3626 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, false);
3629 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end);
3633 #ifndef _LIBCPP_NO_EXCEPTIONS
3634 if (__first == __last)
3635 throw regex_error(regex_constants::error_badbrace);
3636 #endif // _LIBCPP_NO_EXCEPTIONS
3637 if (*__first == '}')
3640 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3643 __push_nongreedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3646 __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3651 __temp = __parse_DUP_COUNT(__first, __last, __max);
3652 #ifndef _LIBCPP_NO_EXCEPTIONS
3653 if (__temp == __first)
3654 throw regex_error(regex_constants::error_brace);
3655 #endif // _LIBCPP_NO_EXCEPTIONS
3657 #ifndef _LIBCPP_NO_EXCEPTIONS
3658 if (__first == __last || *__first != '}')
3659 throw regex_error(regex_constants::error_brace);
3660 #endif // _LIBCPP_NO_EXCEPTIONS
3662 #ifndef _LIBCPP_NO_EXCEPTIONS
3664 throw regex_error(regex_constants::error_badbrace);
3665 #endif // _LIBCPP_NO_EXCEPTIONS
3666 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3669 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false);
3672 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end);
3675 #ifndef _LIBCPP_NO_EXCEPTIONS
3677 throw regex_error(regex_constants::error_badbrace);
3678 #endif // _LIBCPP_NO_EXCEPTIONS
3687 template <class _CharT, class _Traits>
3688 template <class _ForwardIterator>
3690 basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __first,
3691 _ForwardIterator __last)
3693 if (__first != __last && *__first == '[')
3696 #ifndef _LIBCPP_NO_EXCEPTIONS
3697 if (__first == __last)
3698 throw regex_error(regex_constants::error_brack);
3699 #endif // _LIBCPP_NO_EXCEPTIONS
3700 bool __negate = false;
3701 if (*__first == '^')
3706 __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);
3707 // __ml owned by *this
3708 #ifndef _LIBCPP_NO_EXCEPTIONS
3709 if (__first == __last)
3710 throw regex_error(regex_constants::error_brack);
3711 #endif // _LIBCPP_NO_EXCEPTIONS
3712 if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']')
3714 __ml->__add_char(']');
3717 __first = __parse_follow_list(__first, __last, __ml);
3718 #ifndef _LIBCPP_NO_EXCEPTIONS
3719 if (__first == __last)
3720 throw regex_error(regex_constants::error_brack);
3721 #endif // _LIBCPP_NO_EXCEPTIONS
3722 if (*__first == '-')
3724 __ml->__add_char('-');
3727 #ifndef _LIBCPP_NO_EXCEPTIONS
3728 if (__first == __last || *__first != ']')
3729 throw regex_error(regex_constants::error_brack);
3730 #endif // _LIBCPP_NO_EXCEPTIONS
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 #ifndef _LIBCPP_NO_EXCEPTIONS
3851 if (__first == __last)
3852 throw regex_error(regex_constants::error_escape);
3853 #endif // _LIBCPP_NO_EXCEPTIONS
3863 __ml->__add_class(ctype_base::digit);
3866 __ml->__add_neg_class(ctype_base::digit);
3869 __ml->__add_class(ctype_base::space);
3872 __ml->__add_neg_class(ctype_base::space);
3875 __ml->__add_class(ctype_base::alnum);
3876 __ml->__add_char('_');
3879 __ml->__add_neg_class(ctype_base::alnum);
3880 __ml->__add_neg_char('_');
3883 __first = __parse_character_escape(__first, __last, &__str);
3887 template <class _CharT, class _Traits>
3888 template <class _ForwardIterator>
3890 basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
3891 _ForwardIterator __last,
3892 basic_string<_CharT>* __str)
3894 #ifndef _LIBCPP_NO_EXCEPTIONS
3895 if (__first == __last)
3896 throw regex_error(regex_constants::error_escape);
3897 #endif // _LIBCPP_NO_EXCEPTIONS
3906 __push_char(*__first);
3912 __push_char(_CharT(7));
3918 __push_char(_CharT(8));
3922 *__str = _CharT(0xC);
3924 __push_char(_CharT(0xC));
3928 *__str = _CharT(0xA);
3930 __push_char(_CharT(0xA));
3934 *__str = _CharT(0xD);
3936 __push_char(_CharT(0xD));
3940 *__str = _CharT(0x9);
3942 __push_char(_CharT(0x9));
3946 *__str = _CharT(0xB);
3948 __push_char(_CharT(0xB));
3951 if ('0' <= *__first && *__first <= '7')
3953 unsigned __val = *__first - '0';
3954 if (++__first != __last && ('0' <= *__first && *__first <= '7'))
3956 __val = 8 * __val + *__first - '0';
3957 if (++__first != __last && ('0' <= *__first && *__first <= '7'))
3958 __val = 8 * __val + *__first++ - '0';
3961 *__str = _CharT(__val);
3963 __push_char(_CharT(__val));
3965 #ifndef _LIBCPP_NO_EXCEPTIONS
3967 throw regex_error(regex_constants::error_escape);
3968 #endif // _LIBCPP_NO_EXCEPTIONS
3972 template <class _CharT, class _Traits>
3973 template <class _ForwardIterator>
3975 basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first,
3976 _ForwardIterator __last,
3977 __bracket_expression<_CharT, _Traits>* __ml)
3980 // This means =] must exist
3981 value_type _Equal_close[2] = {'=', ']'};
3982 _ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close,
3984 #ifndef _LIBCPP_NO_EXCEPTIONS
3985 if (__temp == __last)
3986 throw regex_error(regex_constants::error_brack);
3987 #endif // _LIBCPP_NO_EXCEPTIONS
3988 // [__first, __temp) contains all text in [= ... =]
3989 typedef typename _Traits::string_type string_type;
3990 string_type __collate_name =
3991 __traits_.lookup_collatename(__first, __temp);
3992 #ifndef _LIBCPP_NO_EXCEPTIONS
3993 if (__collate_name.empty())
3994 throw regex_error(regex_constants::error_collate);
3995 #endif // _LIBCPP_NO_EXCEPTIONS
3996 string_type __equiv_name =
3997 __traits_.transform_primary(__collate_name.begin(),
3998 __collate_name.end());
3999 if (!__equiv_name.empty())
4000 __ml->__add_equivalence(__equiv_name);
4003 switch (__collate_name.size())
4006 __ml->__add_char(__collate_name[0]);
4009 __ml->__add_digraph(__collate_name[0], __collate_name[1]);
4011 #ifndef _LIBCPP_NO_EXCEPTIONS
4013 throw regex_error(regex_constants::error_collate);
4014 #endif // _LIBCPP_NO_EXCEPTIONS
4017 __first = _VSTD::next(__temp, 2);
4021 template <class _CharT, class _Traits>
4022 template <class _ForwardIterator>
4024 basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
4025 _ForwardIterator __last,
4026 __bracket_expression<_CharT, _Traits>* __ml)
4029 // This means :] must exist
4030 value_type _Colon_close[2] = {':', ']'};
4031 _ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close,
4033 #ifndef _LIBCPP_NO_EXCEPTIONS
4034 if (__temp == __last)
4035 throw regex_error(regex_constants::error_brack);
4036 #endif // _LIBCPP_NO_EXCEPTIONS
4037 // [__first, __temp) contains all text in [: ... :]
4038 typedef typename _Traits::char_class_type char_class_type;
4039 char_class_type __class_type =
4040 __traits_.lookup_classname(__first, __temp, __flags_ & icase);
4041 #ifndef _LIBCPP_NO_EXCEPTIONS
4042 if (__class_type == 0)
4043 throw regex_error(regex_constants::error_brack);
4044 #endif // _LIBCPP_NO_EXCEPTIONS
4045 __ml->__add_class(__class_type);
4046 __first = _VSTD::next(__temp, 2);
4050 template <class _CharT, class _Traits>
4051 template <class _ForwardIterator>
4053 basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
4054 _ForwardIterator __last,
4055 basic_string<_CharT>& __col_sym)
4058 // This means .] must exist
4059 value_type _Dot_close[2] = {'.', ']'};
4060 _ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close,
4062 #ifndef _LIBCPP_NO_EXCEPTIONS
4063 if (__temp == __last)
4064 throw regex_error(regex_constants::error_brack);
4065 #endif // _LIBCPP_NO_EXCEPTIONS
4066 // [__first, __temp) contains all text in [. ... .]
4067 typedef typename _Traits::string_type string_type;
4068 __col_sym = __traits_.lookup_collatename(__first, __temp);
4069 switch (__col_sym.size())
4074 #ifndef _LIBCPP_NO_EXCEPTIONS
4076 throw regex_error(regex_constants::error_collate);
4077 #endif // _LIBCPP_NO_EXCEPTIONS
4079 __first = _VSTD::next(__temp, 2);
4083 template <class _CharT, class _Traits>
4084 template <class _ForwardIterator>
4086 basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
4087 _ForwardIterator __last,
4090 if (__first != __last )
4092 int __val = __traits_.value(*__first, 10);
4097 __first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
4108 template <class _CharT, class _Traits>
4109 template <class _ForwardIterator>
4111 basic_regex<_CharT, _Traits>::__parse_ecma_exp(_ForwardIterator __first,
4112 _ForwardIterator __last)
4114 __owns_one_state<_CharT>* __sa = __end_;
4115 _ForwardIterator __temp = __parse_alternative(__first, __last);
4116 if (__temp == __first)
4119 while (__first != __last && *__first == '|')
4121 __owns_one_state<_CharT>* __sb = __end_;
4122 __temp = __parse_alternative(++__first, __last);
4123 if (__temp == __first)
4125 __push_alternation(__sa, __sb);
4131 template <class _CharT, class _Traits>
4132 template <class _ForwardIterator>
4134 basic_regex<_CharT, _Traits>::__parse_alternative(_ForwardIterator __first,
4135 _ForwardIterator __last)
4139 _ForwardIterator __temp = __parse_term(__first, __last);
4140 if (__temp == __first)
4147 template <class _CharT, class _Traits>
4148 template <class _ForwardIterator>
4150 basic_regex<_CharT, _Traits>::__parse_term(_ForwardIterator __first,
4151 _ForwardIterator __last)
4153 _ForwardIterator __temp = __parse_assertion(__first, __last);
4154 if (__temp == __first)
4156 __owns_one_state<_CharT>* __e = __end_;
4157 unsigned __mexp_begin = __marked_count_;
4158 __temp = __parse_atom(__first, __last);
4159 if (__temp != __first)
4160 __first = __parse_ERE_dupl_symbol(__temp, __last, __e,
4161 __mexp_begin+1, __marked_count_+1);
4168 template <class _CharT, class _Traits>
4169 template <class _ForwardIterator>
4171 basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
4172 _ForwardIterator __last)
4174 if (__first != __last)
4188 _ForwardIterator __temp = _VSTD::next(__first);
4189 if (__temp != __last)
4193 __push_word_boundary(false);
4196 else if (*__temp == 'B')
4198 __push_word_boundary(true);
4206 _ForwardIterator __temp = _VSTD::next(__first);
4207 if (__temp != __last && *__temp == '?')
4209 if (++__temp != __last)
4216 __exp.__flags_ = __flags_;
4217 __temp = __exp.__parse(++__temp, __last);
4218 unsigned __mexp = __exp.__marked_count_;
4219 __push_lookahead(_VSTD::move(__exp), false, __marked_count_);
4220 __marked_count_ += __mexp;
4221 #ifndef _LIBCPP_NO_EXCEPTIONS
4222 if (__temp == __last || *__temp != ')')
4223 throw regex_error(regex_constants::error_paren);
4224 #endif // _LIBCPP_NO_EXCEPTIONS
4231 __exp.__flags_ = __flags_;
4232 __temp = __exp.__parse(++__temp, __last);
4233 unsigned __mexp = __exp.__marked_count_;
4234 __push_lookahead(_VSTD::move(__exp), true, __marked_count_);
4235 __marked_count_ += __mexp;
4236 #ifndef _LIBCPP_NO_EXCEPTIONS
4237 if (__temp == __last || *__temp != ')')
4238 throw regex_error(regex_constants::error_paren);
4239 #endif // _LIBCPP_NO_EXCEPTIONS
4253 template <class _CharT, class _Traits>
4254 template <class _ForwardIterator>
4256 basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
4257 _ForwardIterator __last)
4259 if (__first != __last)
4264 __push_match_any_but_newline();
4268 __first = __parse_atom_escape(__first, __last);
4271 __first = __parse_bracket_expression(__first, __last);
4276 #ifndef _LIBCPP_NO_EXCEPTIONS
4277 if (__first == __last)
4278 throw regex_error(regex_constants::error_paren);
4279 #endif // _LIBCPP_NO_EXCEPTIONS
4280 _ForwardIterator __temp = _VSTD::next(__first);
4281 if (__temp != __last && *__first == '?' && *__temp == ':')
4284 __first = __parse_ecma_exp(++__temp, __last);
4285 #ifndef _LIBCPP_NO_EXCEPTIONS
4286 if (__first == __last || *__first != ')')
4287 throw regex_error(regex_constants::error_paren);
4288 #endif // _LIBCPP_NO_EXCEPTIONS
4294 __push_begin_marked_subexpression();
4295 unsigned __temp_count = __marked_count_;
4297 __first = __parse_ecma_exp(__first, __last);
4298 #ifndef _LIBCPP_NO_EXCEPTIONS
4299 if (__first == __last || *__first != ')')
4300 throw regex_error(regex_constants::error_paren);
4301 #endif // _LIBCPP_NO_EXCEPTIONS
4302 __push_end_marked_subexpression(__temp_count);
4309 __first = __parse_pattern_character(__first, __last);
4316 template <class _CharT, class _Traits>
4317 template <class _ForwardIterator>
4319 basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first,
4320 _ForwardIterator __last)
4322 if (__first != __last && *__first == '\\')
4324 _ForwardIterator __t1 = _VSTD::next(__first);
4325 _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
4330 __t2 = __parse_character_class_escape(__t1, __last);
4335 __t2 = __parse_character_escape(__t1, __last);
4344 template <class _CharT, class _Traits>
4345 template <class _ForwardIterator>
4347 basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
4348 _ForwardIterator __last)
4350 if (__first != __last)
4352 if (*__first == '0')
4354 __push_char(_CharT());
4357 else if ('1' <= *__first && *__first <= '9')
4359 unsigned __v = *__first - '0';
4360 for (++__first; '0' <= *__first && *__first <= '9'; ++__first)
4361 __v = 10 * __v + *__first - '0';
4362 #ifndef _LIBCPP_NO_EXCEPTIONS
4363 if (__v > mark_count())
4364 throw regex_error(regex_constants::error_backref);
4365 #endif // _LIBCPP_NO_EXCEPTIONS
4366 __push_back_ref(__v);
4372 template <class _CharT, class _Traits>
4373 template <class _ForwardIterator>
4375 basic_regex<_CharT, _Traits>::__parse_character_class_escape(_ForwardIterator __first,
4376 _ForwardIterator __last)
4378 if (__first != __last)
4380 __bracket_expression<_CharT, _Traits>* __ml;
4384 __ml = __start_matching_list(false);
4385 __ml->__add_class(ctype_base::digit);
4389 __ml = __start_matching_list(true);
4390 __ml->__add_class(ctype_base::digit);
4394 __ml = __start_matching_list(false);
4395 __ml->__add_class(ctype_base::space);
4399 __ml = __start_matching_list(true);
4400 __ml->__add_class(ctype_base::space);
4404 __ml = __start_matching_list(false);
4405 __ml->__add_class(ctype_base::alnum);
4406 __ml->__add_char('_');
4410 __ml = __start_matching_list(true);
4411 __ml->__add_class(ctype_base::alnum);
4412 __ml->__add_char('_');
4420 template <class _CharT, class _Traits>
4421 template <class _ForwardIterator>
4423 basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
4424 _ForwardIterator __last,
4425 basic_string<_CharT>* __str)
4427 if (__first != __last)
4429 _ForwardIterator __t;
4436 *__str = _CharT(0xC);
4438 __push_char(_CharT(0xC));
4443 *__str = _CharT(0xA);
4445 __push_char(_CharT(0xA));
4450 *__str = _CharT(0xD);
4452 __push_char(_CharT(0xD));
4457 *__str = _CharT(0x9);
4459 __push_char(_CharT(0x9));
4464 *__str = _CharT(0xB);
4466 __push_char(_CharT(0xB));
4470 if ((__t = _VSTD::next(__first)) != __last)
4472 if (('A' <= *__t && *__t <= 'Z') ||
4473 ('a' <= *__t && *__t <= 'z'))
4476 *__str = _CharT(*__t % 32);
4478 __push_char(_CharT(*__t % 32));
4481 #ifndef _LIBCPP_NO_EXCEPTIONS
4483 throw regex_error(regex_constants::error_escape);
4484 #endif // _LIBCPP_NO_EXCEPTIONS
4486 #ifndef _LIBCPP_NO_EXCEPTIONS
4488 throw regex_error(regex_constants::error_escape);
4489 #endif // _LIBCPP_NO_EXCEPTIONS
4493 #ifndef _LIBCPP_NO_EXCEPTIONS
4494 if (__first == __last)
4495 throw regex_error(regex_constants::error_escape);
4496 #endif // _LIBCPP_NO_EXCEPTIONS
4497 __hd = __traits_.value(*__first, 16);
4498 #ifndef _LIBCPP_NO_EXCEPTIONS
4500 throw regex_error(regex_constants::error_escape);
4501 #endif // _LIBCPP_NO_EXCEPTIONS
4502 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4504 #ifndef _LIBCPP_NO_EXCEPTIONS
4505 if (__first == __last)
4506 throw regex_error(regex_constants::error_escape);
4507 #endif // _LIBCPP_NO_EXCEPTIONS
4508 __hd = __traits_.value(*__first, 16);
4509 #ifndef _LIBCPP_NO_EXCEPTIONS
4511 throw regex_error(regex_constants::error_escape);
4512 #endif // _LIBCPP_NO_EXCEPTIONS
4513 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4517 #ifndef _LIBCPP_NO_EXCEPTIONS
4518 if (__first == __last)
4519 throw regex_error(regex_constants::error_escape);
4520 #endif // _LIBCPP_NO_EXCEPTIONS
4521 __hd = __traits_.value(*__first, 16);
4522 #ifndef _LIBCPP_NO_EXCEPTIONS
4524 throw regex_error(regex_constants::error_escape);
4525 #endif // _LIBCPP_NO_EXCEPTIONS
4526 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4528 #ifndef _LIBCPP_NO_EXCEPTIONS
4529 if (__first == __last)
4530 throw regex_error(regex_constants::error_escape);
4531 #endif // _LIBCPP_NO_EXCEPTIONS
4532 __hd = __traits_.value(*__first, 16);
4533 #ifndef _LIBCPP_NO_EXCEPTIONS
4535 throw regex_error(regex_constants::error_escape);
4536 #endif // _LIBCPP_NO_EXCEPTIONS
4537 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4539 *__str = _CharT(__sum);
4541 __push_char(_CharT(__sum));
4545 if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum))
4550 __push_char(*__first);
4553 #ifndef _LIBCPP_NO_EXCEPTIONS
4555 throw regex_error(regex_constants::error_escape);
4556 #endif // _LIBCPP_NO_EXCEPTIONS
4563 template <class _CharT, class _Traits>
4564 template <class _ForwardIterator>
4566 basic_regex<_CharT, _Traits>::__parse_pattern_character(_ForwardIterator __first,
4567 _ForwardIterator __last)
4569 if (__first != __last)
4589 __push_char(*__first);
4597 template <class _CharT, class _Traits>
4598 template <class _ForwardIterator>
4600 basic_regex<_CharT, _Traits>::__parse_grep(_ForwardIterator __first,
4601 _ForwardIterator __last)
4603 __owns_one_state<_CharT>* __sa = __end_;
4604 _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4605 if (__t1 != __first)
4606 __parse_basic_reg_exp(__first, __t1);
4610 if (__first != __last)
4612 while (__first != __last)
4614 __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4615 __owns_one_state<_CharT>* __sb = __end_;
4616 if (__t1 != __first)
4617 __parse_basic_reg_exp(__first, __t1);
4620 __push_alternation(__sa, __sb);
4622 if (__first != __last)
4628 template <class _CharT, class _Traits>
4629 template <class _ForwardIterator>
4631 basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first,
4632 _ForwardIterator __last)
4634 __owns_one_state<_CharT>* __sa = __end_;
4635 _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4636 if (__t1 != __first)
4637 __parse_extended_reg_exp(__first, __t1);
4641 if (__first != __last)
4643 while (__first != __last)
4645 __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4646 __owns_one_state<_CharT>* __sb = __end_;
4647 if (__t1 != __first)
4648 __parse_extended_reg_exp(__first, __t1);
4651 __push_alternation(__sa, __sb);
4653 if (__first != __last)
4659 template <class _CharT, class _Traits>
4661 basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max,
4662 __owns_one_state<_CharT>* __s, size_t __mexp_begin, size_t __mexp_end,
4665 unique_ptr<__empty_state<_CharT> > __e1(new __empty_state<_CharT>(__end_->first()));
4666 __end_->first() = nullptr;
4667 unique_ptr<__loop<_CharT> > __e2(new __loop<_CharT>(__loop_count_,
4668 __s->first(), __e1.get(), __mexp_begin, __mexp_end, __greedy,
4670 __s->first() = nullptr;
4672 __end_->first() = new __repeat_one_loop<_CharT>(__e2.get());
4673 __end_ = __e2->second();
4674 __s->first() = __e2.release();
4678 template <class _CharT, class _Traits>
4680 basic_regex<_CharT, _Traits>::__push_char(value_type __c)
4682 if (flags() & icase)
4683 __end_->first() = new __match_char_icase<_CharT, _Traits>
4684 (__traits_, __c, __end_->first());
4685 else if (flags() & collate)
4686 __end_->first() = new __match_char_collate<_CharT, _Traits>
4687 (__traits_, __c, __end_->first());
4689 __end_->first() = new __match_char<_CharT>(__c, __end_->first());
4690 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4693 template <class _CharT, class _Traits>
4695 basic_regex<_CharT, _Traits>::__push_begin_marked_subexpression()
4697 if (!(__flags_ & nosubs))
4700 new __begin_marked_subexpression<_CharT>(++__marked_count_,
4702 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4706 template <class _CharT, class _Traits>
4708 basic_regex<_CharT, _Traits>::__push_end_marked_subexpression(unsigned __sub)
4710 if (!(__flags_ & nosubs))
4713 new __end_marked_subexpression<_CharT>(__sub, __end_->first());
4714 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4718 template <class _CharT, class _Traits>
4720 basic_regex<_CharT, _Traits>::__push_l_anchor()
4722 __end_->first() = new __l_anchor<_CharT>(__end_->first());
4723 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4726 template <class _CharT, class _Traits>
4728 basic_regex<_CharT, _Traits>::__push_r_anchor()
4730 __end_->first() = new __r_anchor<_CharT>(__end_->first());
4731 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4734 template <class _CharT, class _Traits>
4736 basic_regex<_CharT, _Traits>::__push_match_any()
4738 __end_->first() = new __match_any<_CharT>(__end_->first());
4739 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4742 template <class _CharT, class _Traits>
4744 basic_regex<_CharT, _Traits>::__push_match_any_but_newline()
4746 __end_->first() = new __match_any_but_newline<_CharT>(__end_->first());
4747 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4750 template <class _CharT, class _Traits>
4752 basic_regex<_CharT, _Traits>::__push_empty()
4754 __end_->first() = new __empty_state<_CharT>(__end_->first());
4755 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4758 template <class _CharT, class _Traits>
4760 basic_regex<_CharT, _Traits>::__push_word_boundary(bool __invert)
4762 __end_->first() = new __word_boundary<_CharT, _Traits>(__traits_, __invert,
4764 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4767 template <class _CharT, class _Traits>
4769 basic_regex<_CharT, _Traits>::__push_back_ref(int __i)
4771 if (flags() & icase)
4772 __end_->first() = new __back_ref_icase<_CharT, _Traits>
4773 (__traits_, __i, __end_->first());
4774 else if (flags() & collate)
4775 __end_->first() = new __back_ref_collate<_CharT, _Traits>
4776 (__traits_, __i, __end_->first());
4778 __end_->first() = new __back_ref<_CharT>(__i, __end_->first());
4779 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4782 template <class _CharT, class _Traits>
4784 basic_regex<_CharT, _Traits>::__push_alternation(__owns_one_state<_CharT>* __sa,
4785 __owns_one_state<_CharT>* __ea)
4787 __sa->first() = new __alternate<_CharT>(
4788 static_cast<__owns_one_state<_CharT>*>(__sa->first()),
4789 static_cast<__owns_one_state<_CharT>*>(__ea->first()));
4790 __ea->first() = nullptr;
4791 __ea->first() = new __empty_state<_CharT>(__end_->first());
4792 __end_->first() = nullptr;
4793 __end_->first() = new __empty_non_own_state<_CharT>(__ea->first());
4794 __end_ = static_cast<__owns_one_state<_CharT>*>(__ea->first());
4797 template <class _CharT, class _Traits>
4798 __bracket_expression<_CharT, _Traits>*
4799 basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate)
4801 __bracket_expression<_CharT, _Traits>* __r =
4802 new __bracket_expression<_CharT, _Traits>(__traits_, __end_->first(),
4803 __negate, __flags_ & icase,
4804 __flags_ & collate);
4805 __end_->first() = __r;
4810 template <class _CharT, class _Traits>
4812 basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp,
4816 __end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert,
4817 __end_->first(), __mexp);
4818 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4821 typedef basic_regex<char> regex;
4822 typedef basic_regex<wchar_t> wregex;
4826 template <class _BidirectionalIterator>
4827 class _LIBCPP_TYPE_VIS_ONLY sub_match
4828 : public pair<_BidirectionalIterator, _BidirectionalIterator>
4831 typedef _BidirectionalIterator iterator;
4832 typedef typename iterator_traits<iterator>::value_type value_type;
4833 typedef typename iterator_traits<iterator>::difference_type difference_type;
4834 typedef basic_string<value_type> string_type;
4838 _LIBCPP_INLINE_VISIBILITY
4839 _LIBCPP_CONSTEXPR sub_match() : matched() {}
4841 _LIBCPP_INLINE_VISIBILITY
4842 difference_type length() const
4843 {return matched ? _VSTD::distance(this->first, this->second) : 0;}
4844 _LIBCPP_INLINE_VISIBILITY
4845 string_type str() const
4846 {return matched ? string_type(this->first, this->second) : string_type();}
4847 _LIBCPP_INLINE_VISIBILITY
4848 operator string_type() const
4851 _LIBCPP_INLINE_VISIBILITY
4852 int compare(const sub_match& __s) const
4853 {return str().compare(__s.str());}
4854 _LIBCPP_INLINE_VISIBILITY
4855 int compare(const string_type& __s) const
4856 {return str().compare(__s);}
4857 _LIBCPP_INLINE_VISIBILITY
4858 int compare(const value_type* __s) const
4859 {return str().compare(__s);}
4862 typedef sub_match<const char*> csub_match;
4863 typedef sub_match<const wchar_t*> wcsub_match;
4864 typedef sub_match<string::const_iterator> ssub_match;
4865 typedef sub_match<wstring::const_iterator> wssub_match;
4867 template <class _BiIter>
4868 inline _LIBCPP_INLINE_VISIBILITY
4870 operator==(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4872 return __x.compare(__y) == 0;
4875 template <class _BiIter>
4876 inline _LIBCPP_INLINE_VISIBILITY
4878 operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4880 return !(__x == __y);
4883 template <class _BiIter>
4884 inline _LIBCPP_INLINE_VISIBILITY
4886 operator<(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4888 return __x.compare(__y) < 0;
4891 template <class _BiIter>
4892 inline _LIBCPP_INLINE_VISIBILITY
4894 operator<=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4896 return !(__y < __x);
4899 template <class _BiIter>
4900 inline _LIBCPP_INLINE_VISIBILITY
4902 operator>=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4904 return !(__x < __y);
4907 template <class _BiIter>
4908 inline _LIBCPP_INLINE_VISIBILITY
4910 operator>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4915 template <class _BiIter, class _ST, class _SA>
4916 inline _LIBCPP_INLINE_VISIBILITY
4918 operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4919 const sub_match<_BiIter>& __y)
4921 return __y.compare(__x.c_str()) == 0;
4924 template <class _BiIter, class _ST, class _SA>
4925 inline _LIBCPP_INLINE_VISIBILITY
4927 operator!=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4928 const sub_match<_BiIter>& __y)
4930 return !(__x == __y);
4933 template <class _BiIter, class _ST, class _SA>
4934 inline _LIBCPP_INLINE_VISIBILITY
4936 operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4937 const sub_match<_BiIter>& __y)
4939 return __y.compare(__x.c_str()) > 0;
4942 template <class _BiIter, class _ST, class _SA>
4943 inline _LIBCPP_INLINE_VISIBILITY
4945 operator>(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4946 const sub_match<_BiIter>& __y)
4951 template <class _BiIter, class _ST, class _SA>
4952 inline _LIBCPP_INLINE_VISIBILITY
4953 bool operator>=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4954 const sub_match<_BiIter>& __y)
4956 return !(__x < __y);
4959 template <class _BiIter, class _ST, class _SA>
4960 inline _LIBCPP_INLINE_VISIBILITY
4962 operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4963 const sub_match<_BiIter>& __y)
4965 return !(__y < __x);
4968 template <class _BiIter, class _ST, class _SA>
4969 inline _LIBCPP_INLINE_VISIBILITY
4971 operator==(const sub_match<_BiIter>& __x,
4972 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4974 return __x.compare(__y.c_str()) == 0;
4977 template <class _BiIter, class _ST, class _SA>
4978 inline _LIBCPP_INLINE_VISIBILITY
4980 operator!=(const sub_match<_BiIter>& __x,
4981 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4983 return !(__x == __y);
4986 template <class _BiIter, class _ST, class _SA>
4987 inline _LIBCPP_INLINE_VISIBILITY
4989 operator<(const sub_match<_BiIter>& __x,
4990 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4992 return __x.compare(__y.c_str()) < 0;
4995 template <class _BiIter, class _ST, class _SA>
4996 inline _LIBCPP_INLINE_VISIBILITY
4997 bool operator>(const sub_match<_BiIter>& __x,
4998 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
5003 template <class _BiIter, class _ST, class _SA>
5004 inline _LIBCPP_INLINE_VISIBILITY
5006 operator>=(const sub_match<_BiIter>& __x,
5007 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
5009 return !(__x < __y);
5012 template <class _BiIter, class _ST, class _SA>
5013 inline _LIBCPP_INLINE_VISIBILITY
5015 operator<=(const sub_match<_BiIter>& __x,
5016 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
5018 return !(__y < __x);
5021 template <class _BiIter>
5022 inline _LIBCPP_INLINE_VISIBILITY
5024 operator==(typename iterator_traits<_BiIter>::value_type const* __x,
5025 const sub_match<_BiIter>& __y)
5027 return __y.compare(__x) == 0;
5030 template <class _BiIter>
5031 inline _LIBCPP_INLINE_VISIBILITY
5033 operator!=(typename iterator_traits<_BiIter>::value_type const* __x,
5034 const sub_match<_BiIter>& __y)
5036 return !(__x == __y);
5039 template <class _BiIter>
5040 inline _LIBCPP_INLINE_VISIBILITY
5042 operator<(typename iterator_traits<_BiIter>::value_type const* __x,
5043 const sub_match<_BiIter>& __y)
5045 return __y.compare(__x) > 0;
5048 template <class _BiIter>
5049 inline _LIBCPP_INLINE_VISIBILITY
5051 operator>(typename iterator_traits<_BiIter>::value_type const* __x,
5052 const sub_match<_BiIter>& __y)
5057 template <class _BiIter>
5058 inline _LIBCPP_INLINE_VISIBILITY
5060 operator>=(typename iterator_traits<_BiIter>::value_type const* __x,
5061 const sub_match<_BiIter>& __y)
5063 return !(__x < __y);
5066 template <class _BiIter>
5067 inline _LIBCPP_INLINE_VISIBILITY
5069 operator<=(typename iterator_traits<_BiIter>::value_type const* __x,
5070 const sub_match<_BiIter>& __y)
5072 return !(__y < __x);
5075 template <class _BiIter>
5076 inline _LIBCPP_INLINE_VISIBILITY
5078 operator==(const sub_match<_BiIter>& __x,
5079 typename iterator_traits<_BiIter>::value_type const* __y)
5081 return __x.compare(__y) == 0;
5084 template <class _BiIter>
5085 inline _LIBCPP_INLINE_VISIBILITY
5087 operator!=(const sub_match<_BiIter>& __x,
5088 typename iterator_traits<_BiIter>::value_type const* __y)
5090 return !(__x == __y);
5093 template <class _BiIter>
5094 inline _LIBCPP_INLINE_VISIBILITY
5096 operator<(const sub_match<_BiIter>& __x,
5097 typename iterator_traits<_BiIter>::value_type const* __y)
5099 return __x.compare(__y) < 0;
5102 template <class _BiIter>
5103 inline _LIBCPP_INLINE_VISIBILITY
5105 operator>(const sub_match<_BiIter>& __x,
5106 typename iterator_traits<_BiIter>::value_type const* __y)
5111 template <class _BiIter>
5112 inline _LIBCPP_INLINE_VISIBILITY
5114 operator>=(const sub_match<_BiIter>& __x,
5115 typename iterator_traits<_BiIter>::value_type const* __y)
5117 return !(__x < __y);
5120 template <class _BiIter>
5121 inline _LIBCPP_INLINE_VISIBILITY
5123 operator<=(const sub_match<_BiIter>& __x,
5124 typename iterator_traits<_BiIter>::value_type const* __y)
5126 return !(__y < __x);
5129 template <class _BiIter>
5130 inline _LIBCPP_INLINE_VISIBILITY
5132 operator==(typename iterator_traits<_BiIter>::value_type const& __x,
5133 const sub_match<_BiIter>& __y)
5135 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5136 return __y.compare(string_type(1, __x)) == 0;
5139 template <class _BiIter>
5140 inline _LIBCPP_INLINE_VISIBILITY
5142 operator!=(typename iterator_traits<_BiIter>::value_type const& __x,
5143 const sub_match<_BiIter>& __y)
5145 return !(__x == __y);
5148 template <class _BiIter>
5149 inline _LIBCPP_INLINE_VISIBILITY
5151 operator<(typename iterator_traits<_BiIter>::value_type const& __x,
5152 const sub_match<_BiIter>& __y)
5154 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5155 return __y.compare(string_type(1, __x)) > 0;
5158 template <class _BiIter>
5159 inline _LIBCPP_INLINE_VISIBILITY
5161 operator>(typename iterator_traits<_BiIter>::value_type const& __x,
5162 const sub_match<_BiIter>& __y)
5167 template <class _BiIter>
5168 inline _LIBCPP_INLINE_VISIBILITY
5170 operator>=(typename iterator_traits<_BiIter>::value_type const& __x,
5171 const sub_match<_BiIter>& __y)
5173 return !(__x < __y);
5176 template <class _BiIter>
5177 inline _LIBCPP_INLINE_VISIBILITY
5179 operator<=(typename iterator_traits<_BiIter>::value_type const& __x,
5180 const sub_match<_BiIter>& __y)
5182 return !(__y < __x);
5185 template <class _BiIter>
5186 inline _LIBCPP_INLINE_VISIBILITY
5188 operator==(const sub_match<_BiIter>& __x,
5189 typename iterator_traits<_BiIter>::value_type const& __y)
5191 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5192 return __x.compare(string_type(1, __y)) == 0;
5195 template <class _BiIter>
5196 inline _LIBCPP_INLINE_VISIBILITY
5198 operator!=(const sub_match<_BiIter>& __x,
5199 typename iterator_traits<_BiIter>::value_type const& __y)
5201 return !(__x == __y);
5204 template <class _BiIter>
5205 inline _LIBCPP_INLINE_VISIBILITY
5207 operator<(const sub_match<_BiIter>& __x,
5208 typename iterator_traits<_BiIter>::value_type const& __y)
5210 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5211 return __x.compare(string_type(1, __y)) < 0;
5214 template <class _BiIter>
5215 inline _LIBCPP_INLINE_VISIBILITY
5217 operator>(const sub_match<_BiIter>& __x,
5218 typename iterator_traits<_BiIter>::value_type const& __y)
5223 template <class _BiIter>
5224 inline _LIBCPP_INLINE_VISIBILITY
5226 operator>=(const sub_match<_BiIter>& __x,
5227 typename iterator_traits<_BiIter>::value_type const& __y)
5229 return !(__x < __y);
5232 template <class _BiIter>
5233 inline _LIBCPP_INLINE_VISIBILITY
5235 operator<=(const sub_match<_BiIter>& __x,
5236 typename iterator_traits<_BiIter>::value_type const& __y)
5238 return !(__y < __x);
5241 template <class _CharT, class _ST, class _BiIter>
5242 inline _LIBCPP_INLINE_VISIBILITY
5243 basic_ostream<_CharT, _ST>&
5244 operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m)
5246 return __os << __m.str();
5249 template <class _BidirectionalIterator, class _Allocator>
5250 class _LIBCPP_TYPE_VIS_ONLY match_results
5253 typedef _Allocator allocator_type;
5254 typedef sub_match<_BidirectionalIterator> value_type;
5256 typedef vector<value_type, allocator_type> __container_type;
5258 __container_type __matches_;
5259 value_type __unmatched_;
5260 value_type __prefix_;
5261 value_type __suffix_;
5264 _BidirectionalIterator __position_start_;
5265 typedef const value_type& const_reference;
5266 typedef value_type& reference;
5267 typedef typename __container_type::const_iterator const_iterator;
5268 typedef const_iterator iterator;
5269 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
5270 typedef typename allocator_traits<allocator_type>::size_type size_type;
5271 typedef typename iterator_traits<_BidirectionalIterator>::value_type char_type;
5272 typedef basic_string<char_type> string_type;
5274 // construct/copy/destroy:
5275 explicit match_results(const allocator_type& __a = allocator_type());
5276 // match_results(const match_results&) = default;
5277 // match_results& operator=(const match_results&) = default;
5278 // match_results(match_results&& __m) = default;
5279 // match_results& operator=(match_results&& __m) = default;
5280 // ~match_results() = default;
5282 _LIBCPP_INLINE_VISIBILITY
5283 bool ready() const {return __ready_;}
5286 _LIBCPP_INLINE_VISIBILITY
5287 size_type size() const {return __matches_.size();}
5288 _LIBCPP_INLINE_VISIBILITY
5289 size_type max_size() const {return __matches_.max_size();}
5290 _LIBCPP_INLINE_VISIBILITY
5291 bool empty() const {return size() == 0;}
5294 _LIBCPP_INLINE_VISIBILITY
5295 difference_type length(size_type __sub = 0) const
5296 {return (*this)[__sub].length();}
5297 _LIBCPP_INLINE_VISIBILITY
5298 difference_type position(size_type __sub = 0) const
5299 {return _VSTD::distance(__position_start_, (*this)[__sub].first);}
5300 _LIBCPP_INLINE_VISIBILITY
5301 string_type str(size_type __sub = 0) const
5302 {return (*this)[__sub].str();}
5303 _LIBCPP_INLINE_VISIBILITY
5304 const_reference operator[](size_type __n) const
5305 {return __n < __matches_.size() ? __matches_[__n] : __unmatched_;}
5307 _LIBCPP_INLINE_VISIBILITY
5308 const_reference prefix() const {return __prefix_;}
5309 _LIBCPP_INLINE_VISIBILITY
5310 const_reference suffix() const {return __suffix_;}
5312 _LIBCPP_INLINE_VISIBILITY
5313 const_iterator begin() const {return empty() ? __matches_.end() : __matches_.begin();}
5314 _LIBCPP_INLINE_VISIBILITY
5315 const_iterator end() const {return __matches_.end();}
5316 _LIBCPP_INLINE_VISIBILITY
5317 const_iterator cbegin() const {return empty() ? __matches_.end() : __matches_.begin();}
5318 _LIBCPP_INLINE_VISIBILITY
5319 const_iterator cend() const {return __matches_.end();}
5322 template <class _OutputIter>
5324 format(_OutputIter __out, const char_type* __fmt_first,
5325 const char_type* __fmt_last,
5326 regex_constants::match_flag_type __flags = regex_constants::format_default) const;
5327 template <class _OutputIter, class _ST, class _SA>
5328 _LIBCPP_INLINE_VISIBILITY
5330 format(_OutputIter __out, const basic_string<char_type, _ST, _SA>& __fmt,
5331 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5332 {return format(__out, __fmt.data(), __fmt.data() + __fmt.size(), __flags);}
5333 template <class _ST, class _SA>
5334 _LIBCPP_INLINE_VISIBILITY
5335 basic_string<char_type, _ST, _SA>
5336 format(const basic_string<char_type, _ST, _SA>& __fmt,
5337 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5339 basic_string<char_type, _ST, _SA> __r;
5340 format(back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(),
5344 _LIBCPP_INLINE_VISIBILITY
5346 format(const char_type* __fmt,
5347 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5350 format(back_inserter(__r), __fmt,
5351 __fmt + char_traits<char_type>::length(__fmt), __flags);
5356 _LIBCPP_INLINE_VISIBILITY
5357 allocator_type get_allocator() const {return __matches_.get_allocator();}
5360 void swap(match_results& __m);
5362 template <class _Bp, class _Ap>
5363 _LIBCPP_INLINE_VISIBILITY
5364 void __assign(_BidirectionalIterator __f, _BidirectionalIterator __l,
5365 const match_results<_Bp, _Ap>& __m, bool __no_update_pos)
5367 _Bp __mf = __m.prefix().first;
5368 __matches_.resize(__m.size());
5369 for (size_type __i = 0; __i < __matches_.size(); ++__i)
5371 __matches_[__i].first = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].first));
5372 __matches_[__i].second = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].second));
5373 __matches_[__i].matched = __m[__i].matched;
5375 __unmatched_.first = __l;
5376 __unmatched_.second = __l;
5377 __unmatched_.matched = false;
5378 __prefix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().first));
5379 __prefix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().second));
5380 __prefix_.matched = __m.prefix().matched;
5381 __suffix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().first));
5382 __suffix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().second));
5383 __suffix_.matched = __m.suffix().matched;
5384 if (!__no_update_pos)
5385 __position_start_ = __prefix_.first;
5386 __ready_ = __m.ready();
5390 void __init(unsigned __s,
5391 _BidirectionalIterator __f, _BidirectionalIterator __l,
5392 bool __no_update_pos = false);
5394 template <class, class> friend class basic_regex;
5396 template <class _Bp, class _Ap, class _Cp, class _Tp>
5399 regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
5400 regex_constants::match_flag_type);
5402 template <class _Bp, class _Ap>
5405 operator==(const match_results<_Bp, _Ap>&, const match_results<_Bp, _Ap>&);
5407 template <class, class> friend class __lookahead;
5410 template <class _BidirectionalIterator, class _Allocator>
5411 match_results<_BidirectionalIterator, _Allocator>::match_results(
5412 const allocator_type& __a)
5417 __position_start_(),
5422 template <class _BidirectionalIterator, class _Allocator>
5424 match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s,
5425 _BidirectionalIterator __f, _BidirectionalIterator __l,
5426 bool __no_update_pos)
5428 __unmatched_.first = __l;
5429 __unmatched_.second = __l;
5430 __unmatched_.matched = false;
5431 __matches_.assign(__s, __unmatched_);
5432 __prefix_.first = __f;
5433 __prefix_.second = __f;
5434 __prefix_.matched = false;
5435 __suffix_ = __unmatched_;
5436 if (!__no_update_pos)
5437 __position_start_ = __prefix_.first;
5441 template <class _BidirectionalIterator, class _Allocator>
5442 template <class _OutputIter>
5444 match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out,
5445 const char_type* __fmt_first, const char_type* __fmt_last,
5446 regex_constants::match_flag_type __flags) const
5448 if (__flags & regex_constants::format_sed)
5450 for (; __fmt_first != __fmt_last; ++__fmt_first)
5452 if (*__fmt_first == '&')
5453 __out = _VSTD::copy(__matches_[0].first, __matches_[0].second,
5455 else if (*__fmt_first == '\\' && __fmt_first + 1 != __fmt_last)
5458 if ('0' <= *__fmt_first && *__fmt_first <= '9')
5460 size_t __i = *__fmt_first - '0';
5461 __out = _VSTD::copy(__matches_[__i].first,
5462 __matches_[__i].second, __out);
5466 *__out = *__fmt_first;
5472 *__out = *__fmt_first;
5479 for (; __fmt_first != __fmt_last; ++__fmt_first)
5481 if (*__fmt_first == '$' && __fmt_first + 1 != __fmt_last)
5483 switch (__fmt_first[1])
5486 *__out = *++__fmt_first;
5491 __out = _VSTD::copy(__matches_[0].first, __matches_[0].second,
5496 __out = _VSTD::copy(__prefix_.first, __prefix_.second, __out);
5500 __out = _VSTD::copy(__suffix_.first, __suffix_.second, __out);
5503 if ('0' <= __fmt_first[1] && __fmt_first[1] <= '9')
5506 size_t __i = *__fmt_first - '0';
5507 if (__fmt_first + 1 != __fmt_last &&
5508 '0' <= __fmt_first[1] && __fmt_first[1] <= '9')
5511 __i = 10 * __i + *__fmt_first - '0';
5513 __out = _VSTD::copy(__matches_[__i].first,
5514 __matches_[__i].second, __out);
5518 *__out = *__fmt_first;
5526 *__out = *__fmt_first;
5534 template <class _BidirectionalIterator, class _Allocator>
5536 match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
5539 swap(__matches_, __m.__matches_);
5540 swap(__unmatched_, __m.__unmatched_);
5541 swap(__prefix_, __m.__prefix_);
5542 swap(__suffix_, __m.__suffix_);
5543 swap(__position_start_, __m.__position_start_);
5544 swap(__ready_, __m.__ready_);
5547 typedef match_results<const char*> cmatch;
5548 typedef match_results<const wchar_t*> wcmatch;
5549 typedef match_results<string::const_iterator> smatch;
5550 typedef match_results<wstring::const_iterator> wsmatch;
5552 template <class _BidirectionalIterator, class _Allocator>
5554 operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
5555 const match_results<_BidirectionalIterator, _Allocator>& __y)
5557 if (__x.__ready_ != __y.__ready_)
5561 return __x.__matches_ == __y.__matches_ &&
5562 __x.__prefix_ == __y.__prefix_ &&
5563 __x.__suffix_ == __y.__suffix_;
5566 template <class _BidirectionalIterator, class _Allocator>
5567 inline _LIBCPP_INLINE_VISIBILITY
5569 operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,
5570 const match_results<_BidirectionalIterator, _Allocator>& __y)
5572 return !(__x == __y);
5575 template <class _BidirectionalIterator, class _Allocator>
5576 inline _LIBCPP_INLINE_VISIBILITY
5578 swap(match_results<_BidirectionalIterator, _Allocator>& __x,
5579 match_results<_BidirectionalIterator, _Allocator>& __y)
5586 template <class _CharT, class _Traits>
5587 template <class _Allocator>
5589 basic_regex<_CharT, _Traits>::__match_at_start_ecma(
5590 const _CharT* __first, const _CharT* __last,
5591 match_results<const _CharT*, _Allocator>& __m,
5592 regex_constants::match_flag_type __flags, bool __at_first) const
5594 vector<__state> __states;
5595 __node* __st = __start_.get();
5598 __states.push_back(__state());
5599 __states.back().__do_ = 0;
5600 __states.back().__first_ = __first;
5601 __states.back().__current_ = __first;
5602 __states.back().__last_ = __last;
5603 __states.back().__sub_matches_.resize(mark_count());
5604 __states.back().__loop_data_.resize(__loop_count());
5605 __states.back().__node_ = __st;
5606 __states.back().__flags_ = __flags;
5607 __states.back().__at_first_ = __at_first;
5610 __state& __s = __states.back();
5612 __s.__node_->__exec(__s);
5615 case __state::__end_state:
5616 __m.__matches_[0].first = __first;
5617 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first);
5618 __m.__matches_[0].matched = true;
5619 for (unsigned __i = 0; __i < __s.__sub_matches_.size(); ++__i)
5620 __m.__matches_[__i+1] = __s.__sub_matches_[__i];
5622 case __state::__accept_and_consume:
5623 case __state::__repeat:
5624 case __state::__accept_but_not_consume:
5626 case __state::__split:
5628 __state __snext = __s;
5629 __s.__node_->__exec_split(true, __s);
5630 __snext.__node_->__exec_split(false, __snext);
5631 __states.push_back(_VSTD::move(__snext));
5634 case __state::__reject:
5635 __states.pop_back();
5638 #ifndef _LIBCPP_NO_EXCEPTIONS
5639 throw regex_error(regex_constants::__re_err_unknown);
5644 } while (!__states.empty());
5649 template <class _CharT, class _Traits>
5650 template <class _Allocator>
5652 basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
5653 const _CharT* __first, const _CharT* __last,
5654 match_results<const _CharT*, _Allocator>& __m,
5655 regex_constants::match_flag_type __flags, bool __at_first) const
5657 deque<__state> __states;
5658 ptrdiff_t __highest_j = 0;
5659 ptrdiff_t _Np = _VSTD::distance(__first, __last);
5660 __node* __st = __start_.get();
5663 __states.push_back(__state());
5664 __states.back().__do_ = 0;
5665 __states.back().__first_ = __first;
5666 __states.back().__current_ = __first;
5667 __states.back().__last_ = __last;
5668 __states.back().__loop_data_.resize(__loop_count());
5669 __states.back().__node_ = __st;
5670 __states.back().__flags_ = __flags;
5671 __states.back().__at_first_ = __at_first;
5672 bool __matched = false;
5675 __state& __s = __states.back();
5677 __s.__node_->__exec(__s);
5680 case __state::__end_state:
5681 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
5682 __highest_j = __s.__current_ - __s.__first_;
5684 if (__highest_j == _Np)
5687 __states.pop_back();
5689 case __state::__consume_input:
5691 case __state::__accept_and_consume:
5692 __states.push_front(_VSTD::move(__s));
5693 __states.pop_back();
5695 case __state::__repeat:
5696 case __state::__accept_but_not_consume:
5698 case __state::__split:
5700 __state __snext = __s;
5701 __s.__node_->__exec_split(true, __s);
5702 __snext.__node_->__exec_split(false, __snext);
5703 __states.push_back(_VSTD::move(__snext));
5706 case __state::__reject:
5707 __states.pop_back();
5710 #ifndef _LIBCPP_NO_EXCEPTIONS
5711 throw regex_error(regex_constants::__re_err_unknown);
5715 } while (!__states.empty());
5718 __m.__matches_[0].first = __first;
5719 __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
5720 __m.__matches_[0].matched = true;
5727 template <class _CharT, class _Traits>
5728 template <class _Allocator>
5730 basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
5731 const _CharT* __first, const _CharT* __last,
5732 match_results<const _CharT*, _Allocator>& __m,
5733 regex_constants::match_flag_type __flags, bool __at_first) const
5735 vector<__state> __states;
5736 __state __best_state;
5738 ptrdiff_t __highest_j = 0;
5739 ptrdiff_t _Np = _VSTD::distance(__first, __last);
5740 __node* __st = __start_.get();
5743 __states.push_back(__state());
5744 __states.back().__do_ = 0;
5745 __states.back().__first_ = __first;
5746 __states.back().__current_ = __first;
5747 __states.back().__last_ = __last;
5748 __states.back().__sub_matches_.resize(mark_count());
5749 __states.back().__loop_data_.resize(__loop_count());
5750 __states.back().__node_ = __st;
5751 __states.back().__flags_ = __flags;
5752 __states.back().__at_first_ = __at_first;
5753 const _CharT* __current = __first;
5754 bool __matched = false;
5757 __state& __s = __states.back();
5759 __s.__node_->__exec(__s);
5762 case __state::__end_state:
5763 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
5765 __highest_j = __s.__current_ - __s.__first_;
5769 if (__highest_j == _Np)
5772 __states.pop_back();
5774 case __state::__accept_and_consume:
5775 __j += __s.__current_ - __current;
5776 __current = __s.__current_;
5778 case __state::__repeat:
5779 case __state::__accept_but_not_consume:
5781 case __state::__split:
5783 __state __snext = __s;
5784 __s.__node_->__exec_split(true, __s);
5785 __snext.__node_->__exec_split(false, __snext);
5786 __states.push_back(_VSTD::move(__snext));
5789 case __state::__reject:
5790 __states.pop_back();
5793 #ifndef _LIBCPP_NO_EXCEPTIONS
5794 throw regex_error(regex_constants::__re_err_unknown);
5798 } while (!__states.empty());
5801 __m.__matches_[0].first = __first;
5802 __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
5803 __m.__matches_[0].matched = true;
5804 for (unsigned __i = 0; __i < __best_state.__sub_matches_.size(); ++__i)
5805 __m.__matches_[__i+1] = __best_state.__sub_matches_[__i];
5812 template <class _CharT, class _Traits>
5813 template <class _Allocator>
5815 basic_regex<_CharT, _Traits>::__match_at_start(
5816 const _CharT* __first, const _CharT* __last,
5817 match_results<const _CharT*, _Allocator>& __m,
5818 regex_constants::match_flag_type __flags, bool __at_first) const
5820 if ((__flags_ & 0x1F0) == ECMAScript)
5821 return __match_at_start_ecma(__first, __last, __m, __flags, __at_first);
5822 if (mark_count() == 0)
5823 return __match_at_start_posix_nosubs(__first, __last, __m, __flags, __at_first);
5824 return __match_at_start_posix_subs(__first, __last, __m, __flags, __at_first);
5827 template <class _CharT, class _Traits>
5828 template <class _Allocator>
5830 basic_regex<_CharT, _Traits>::__search(
5831 const _CharT* __first, const _CharT* __last,
5832 match_results<const _CharT*, _Allocator>& __m,
5833 regex_constants::match_flag_type __flags) const
5835 __m.__init(1 + mark_count(), __first, __last,
5836 __flags & regex_constants::__no_update_pos);
5837 if (__match_at_start(__first, __last, __m, __flags,
5838 !(__flags & regex_constants::__no_update_pos)))
5840 __m.__prefix_.second = __m[0].first;
5841 __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
5842 __m.__suffix_.first = __m[0].second;
5843 __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
5846 if (__first != __last && !(__flags & regex_constants::match_continuous))
5848 __flags |= regex_constants::match_prev_avail;
5849 for (++__first; __first != __last; ++__first)
5851 __m.__matches_.assign(__m.size(), __m.__unmatched_);
5852 if (__match_at_start(__first, __last, __m, __flags, false))
5854 __m.__prefix_.second = __m[0].first;
5855 __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
5856 __m.__suffix_.first = __m[0].second;
5857 __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
5860 __m.__matches_.assign(__m.size(), __m.__unmatched_);
5863 __m.__matches_.clear();
5867 template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
5868 inline _LIBCPP_INLINE_VISIBILITY
5870 regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
5871 match_results<_BidirectionalIterator, _Allocator>& __m,
5872 const basic_regex<_CharT, _Traits>& __e,
5873 regex_constants::match_flag_type __flags = regex_constants::match_default)
5875 int __offset = (__flags & regex_constants::match_prev_avail) ? 1 : 0;
5876 basic_string<_CharT> __s(_VSTD::prev(__first, __offset), __last);
5877 match_results<const _CharT*> __mc;
5878 bool __r = __e.__search(__s.data() + __offset, __s.data() + __s.size(), __mc, __flags);
5879 __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
5883 template <class _Iter, class _Allocator, class _CharT, class _Traits>
5884 inline _LIBCPP_INLINE_VISIBILITY
5886 regex_search(__wrap_iter<_Iter> __first,
5887 __wrap_iter<_Iter> __last,
5888 match_results<__wrap_iter<_Iter>, _Allocator>& __m,
5889 const basic_regex<_CharT, _Traits>& __e,
5890 regex_constants::match_flag_type __flags = regex_constants::match_default)
5892 match_results<const _CharT*> __mc;
5893 bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags);
5894 __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
5898 template <class _Allocator, class _CharT, class _Traits>
5899 inline _LIBCPP_INLINE_VISIBILITY
5901 regex_search(const _CharT* __first, const _CharT* __last,
5902 match_results<const _CharT*, _Allocator>& __m,
5903 const basic_regex<_CharT, _Traits>& __e,
5904 regex_constants::match_flag_type __flags = regex_constants::match_default)
5906 return __e.__search(__first, __last, __m, __flags);
5909 template <class _BidirectionalIterator, class _CharT, class _Traits>
5910 inline _LIBCPP_INLINE_VISIBILITY
5912 regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
5913 const basic_regex<_CharT, _Traits>& __e,
5914 regex_constants::match_flag_type __flags = regex_constants::match_default)
5916 basic_string<_CharT> __s(__first, __last);
5917 match_results<const _CharT*> __mc;
5918 return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
5921 template <class _CharT, class _Traits>
5922 inline _LIBCPP_INLINE_VISIBILITY
5924 regex_search(const _CharT* __first, const _CharT* __last,
5925 const basic_regex<_CharT, _Traits>& __e,
5926 regex_constants::match_flag_type __flags = regex_constants::match_default)
5928 match_results<const _CharT*> __mc;
5929 return __e.__search(__first, __last, __mc, __flags);
5932 template <class _CharT, class _Allocator, class _Traits>
5933 inline _LIBCPP_INLINE_VISIBILITY
5935 regex_search(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
5936 const basic_regex<_CharT, _Traits>& __e,
5937 regex_constants::match_flag_type __flags = regex_constants::match_default)
5939 return __e.__search(__str, __str + _Traits::length(__str), __m, __flags);
5942 template <class _CharT, class _Traits>
5943 inline _LIBCPP_INLINE_VISIBILITY
5945 regex_search(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
5946 regex_constants::match_flag_type __flags = regex_constants::match_default)
5948 match_results<const _CharT*> __m;
5949 return _VSTD::regex_search(__str, __m, __e, __flags);
5952 template <class _ST, class _SA, class _CharT, class _Traits>
5953 inline _LIBCPP_INLINE_VISIBILITY
5955 regex_search(const basic_string<_CharT, _ST, _SA>& __s,
5956 const basic_regex<_CharT, _Traits>& __e,
5957 regex_constants::match_flag_type __flags = regex_constants::match_default)
5959 match_results<const _CharT*> __mc;
5960 return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
5963 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
5964 inline _LIBCPP_INLINE_VISIBILITY
5966 regex_search(const basic_string<_CharT, _ST, _SA>& __s,
5967 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
5968 const basic_regex<_CharT, _Traits>& __e,
5969 regex_constants::match_flag_type __flags = regex_constants::match_default)
5971 match_results<const _CharT*> __mc;
5972 bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
5973 __m.__assign(__s.begin(), __s.end(), __mc, __flags & regex_constants::__no_update_pos);
5977 #if _LIBCPP_STD_VER > 11
5978 template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
5980 regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
5981 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
5982 const basic_regex<_Cp, _Tp>& __e,
5983 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
5988 template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
5990 regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
5991 match_results<_BidirectionalIterator, _Allocator>& __m,
5992 const basic_regex<_CharT, _Traits>& __e,
5993 regex_constants::match_flag_type __flags = regex_constants::match_default)
5995 bool __r = _VSTD::regex_search(__first, __last, __m, __e,
5996 __flags | regex_constants::match_continuous);
5999 __r = !__m.suffix().matched;
6001 __m.__matches_.clear();
6006 template <class _BidirectionalIterator, class _CharT, class _Traits>
6007 inline _LIBCPP_INLINE_VISIBILITY
6009 regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
6010 const basic_regex<_CharT, _Traits>& __e,
6011 regex_constants::match_flag_type __flags = regex_constants::match_default)
6013 match_results<_BidirectionalIterator> __m;
6014 return _VSTD::regex_match(__first, __last, __m, __e, __flags);
6017 template <class _CharT, class _Allocator, class _Traits>
6018 inline _LIBCPP_INLINE_VISIBILITY
6020 regex_match(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
6021 const basic_regex<_CharT, _Traits>& __e,
6022 regex_constants::match_flag_type __flags = regex_constants::match_default)
6024 return _VSTD::regex_match(__str, __str + _Traits::length(__str), __m, __e, __flags);
6027 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
6028 inline _LIBCPP_INLINE_VISIBILITY
6030 regex_match(const basic_string<_CharT, _ST, _SA>& __s,
6031 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
6032 const basic_regex<_CharT, _Traits>& __e,
6033 regex_constants::match_flag_type __flags = regex_constants::match_default)
6035 return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags);
6038 #if _LIBCPP_STD_VER > 11
6039 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
6040 inline _LIBCPP_INLINE_VISIBILITY
6042 regex_match(const basic_string<_CharT, _ST, _SA>&& __s,
6043 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
6044 const basic_regex<_CharT, _Traits>& __e,
6045 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
6048 template <class _CharT, class _Traits>
6049 inline _LIBCPP_INLINE_VISIBILITY
6051 regex_match(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
6052 regex_constants::match_flag_type __flags = regex_constants::match_default)
6054 return _VSTD::regex_match(__str, __str + _Traits::length(__str), __e, __flags);
6057 template <class _ST, class _SA, class _CharT, class _Traits>
6058 inline _LIBCPP_INLINE_VISIBILITY
6060 regex_match(const basic_string<_CharT, _ST, _SA>& __s,
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(), __e, __flags);
6069 template <class _BidirectionalIterator,
6070 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
6071 class _Traits = regex_traits<_CharT> >
6072 class _LIBCPP_TYPE_VIS_ONLY regex_iterator
6075 typedef basic_regex<_CharT, _Traits> regex_type;
6076 typedef match_results<_BidirectionalIterator> value_type;
6077 typedef ptrdiff_t difference_type;
6078 typedef const value_type* pointer;
6079 typedef const value_type& reference;
6080 typedef forward_iterator_tag iterator_category;
6083 _BidirectionalIterator __begin_;
6084 _BidirectionalIterator __end_;
6085 const regex_type* __pregex_;
6086 regex_constants::match_flag_type __flags_;
6087 value_type __match_;
6091 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6092 const regex_type& __re,
6093 regex_constants::match_flag_type __m
6094 = regex_constants::match_default);
6095 #if _LIBCPP_STD_VER > 11
6096 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6097 const regex_type&& __re,
6098 regex_constants::match_flag_type __m
6099 = regex_constants::match_default) = delete;
6102 bool operator==(const regex_iterator& __x) const;
6103 _LIBCPP_INLINE_VISIBILITY
6104 bool operator!=(const regex_iterator& __x) const {return !(*this == __x);}
6106 _LIBCPP_INLINE_VISIBILITY
6107 reference operator*() const {return __match_;}
6108 _LIBCPP_INLINE_VISIBILITY
6109 pointer operator->() const {return &__match_;}
6111 regex_iterator& operator++();
6112 _LIBCPP_INLINE_VISIBILITY
6113 regex_iterator operator++(int)
6115 regex_iterator __t(*this);
6121 template <class _BidirectionalIterator, class _CharT, class _Traits>
6122 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_iterator()
6123 : __begin_(), __end_(), __pregex_(nullptr), __flags_(), __match_()
6127 template <class _BidirectionalIterator, class _CharT, class _Traits>
6128 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
6129 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6130 const regex_type& __re, regex_constants::match_flag_type __m)
6136 _VSTD::regex_search(__begin_, __end_, __match_, *__pregex_, __flags_);
6139 template <class _BidirectionalIterator, class _CharT, class _Traits>
6141 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
6142 operator==(const regex_iterator& __x) const
6144 if (__match_.empty() && __x.__match_.empty())
6146 if (__match_.empty() || __x.__match_.empty())
6148 return __begin_ == __x.__begin_ &&
6149 __end_ == __x.__end_ &&
6150 __pregex_ == __x.__pregex_ &&
6151 __flags_ == __x.__flags_ &&
6152 __match_[0] == __x.__match_[0];
6155 template <class _BidirectionalIterator, class _CharT, class _Traits>
6156 regex_iterator<_BidirectionalIterator, _CharT, _Traits>&
6157 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6159 __flags_ |= regex_constants::__no_update_pos;
6160 _BidirectionalIterator __start = __match_[0].second;
6161 if (__match_.empty())
6163 if (__start == __end_)
6165 __match_ = value_type();
6168 else if (_VSTD::regex_search(__start, __end_, __match_, *__pregex_,
6169 __flags_ | regex_constants::match_not_null |
6170 regex_constants::match_continuous))
6175 __flags_ |= regex_constants::match_prev_avail;
6176 if (!_VSTD::regex_search(__start, __end_, __match_, *__pregex_, __flags_))
6177 __match_ = value_type();
6181 typedef regex_iterator<const char*> cregex_iterator;
6182 typedef regex_iterator<const wchar_t*> wcregex_iterator;
6183 typedef regex_iterator<string::const_iterator> sregex_iterator;
6184 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
6186 // regex_token_iterator
6188 template <class _BidirectionalIterator,
6189 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
6190 class _Traits = regex_traits<_CharT> >
6191 class _LIBCPP_TYPE_VIS_ONLY regex_token_iterator
6194 typedef basic_regex<_CharT, _Traits> regex_type;
6195 typedef sub_match<_BidirectionalIterator> value_type;
6196 typedef ptrdiff_t difference_type;
6197 typedef const value_type* pointer;
6198 typedef const value_type& reference;
6199 typedef forward_iterator_tag iterator_category;
6202 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position;
6204 _Position __position_;
6205 const value_type* __result_;
6206 value_type __suffix_;
6208 vector<int> __subs_;
6211 regex_token_iterator();
6212 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6213 const regex_type& __re, int __submatch = 0,
6214 regex_constants::match_flag_type __m =
6215 regex_constants::match_default);
6216 #if _LIBCPP_STD_VER > 11
6217 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6218 const regex_type&& __re, int __submatch = 0,
6219 regex_constants::match_flag_type __m =
6220 regex_constants::match_default) = delete;
6223 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6224 const regex_type& __re, const vector<int>& __submatches,
6225 regex_constants::match_flag_type __m =
6226 regex_constants::match_default);
6227 #if _LIBCPP_STD_VER > 11
6228 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6229 const regex_type&& __re, const vector<int>& __submatches,
6230 regex_constants::match_flag_type __m =
6231 regex_constants::match_default) = delete;
6234 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
6235 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6236 const regex_type& __re,
6237 initializer_list<int> __submatches,
6238 regex_constants::match_flag_type __m =
6239 regex_constants::match_default);
6241 #if _LIBCPP_STD_VER > 11
6242 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6243 const regex_type&& __re,
6244 initializer_list<int> __submatches,
6245 regex_constants::match_flag_type __m =
6246 regex_constants::match_default) = delete;
6248 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
6249 template <size_t _Np>
6250 regex_token_iterator(_BidirectionalIterator __a,
6251 _BidirectionalIterator __b,
6252 const regex_type& __re,
6253 const int (&__submatches)[_Np],
6254 regex_constants::match_flag_type __m =
6255 regex_constants::match_default);
6256 #if _LIBCPP_STD_VER > 11
6257 template <std::size_t _Np>
6258 regex_token_iterator(_BidirectionalIterator __a,
6259 _BidirectionalIterator __b,
6260 const regex_type&& __re,
6261 const int (&__submatches)[_Np],
6262 regex_constants::match_flag_type __m =
6263 regex_constants::match_default) = delete;
6266 regex_token_iterator(const regex_token_iterator&);
6267 regex_token_iterator& operator=(const regex_token_iterator&);
6269 bool operator==(const regex_token_iterator& __x) const;
6270 _LIBCPP_INLINE_VISIBILITY
6271 bool operator!=(const regex_token_iterator& __x) const {return !(*this == __x);}
6273 _LIBCPP_INLINE_VISIBILITY
6274 const value_type& operator*() const {return *__result_;}
6275 _LIBCPP_INLINE_VISIBILITY
6276 const value_type* operator->() const {return __result_;}
6278 regex_token_iterator& operator++();
6279 _LIBCPP_INLINE_VISIBILITY
6280 regex_token_iterator operator++(int)
6282 regex_token_iterator __t(*this);
6288 void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
6289 void __establish_result () {
6290 if (__subs_[_N_] == -1)
6291 __result_ = &__position_->prefix();
6293 __result_ = &(*__position_)[__subs_[_N_]];
6297 template <class _BidirectionalIterator, class _CharT, class _Traits>
6298 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6299 regex_token_iterator()
6300 : __result_(nullptr),
6306 template <class _BidirectionalIterator, class _CharT, class _Traits>
6308 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6309 __init(_BidirectionalIterator __a, _BidirectionalIterator __b)
6311 if (__position_ != _Position())
6312 __establish_result ();
6313 else if (__subs_[_N_] == -1)
6315 __suffix_.matched = true;
6316 __suffix_.first = __a;
6317 __suffix_.second = __b;
6318 __result_ = &__suffix_;
6321 __result_ = nullptr;
6324 template <class _BidirectionalIterator, class _CharT, class _Traits>
6325 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6326 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6327 const regex_type& __re, int __submatch,
6328 regex_constants::match_flag_type __m)
6329 : __position_(__a, __b, __re, __m),
6331 __subs_(1, __submatch)
6336 template <class _BidirectionalIterator, class _CharT, class _Traits>
6337 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6338 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6339 const regex_type& __re, const vector<int>& __submatches,
6340 regex_constants::match_flag_type __m)
6341 : __position_(__a, __b, __re, __m),
6343 __subs_(__submatches)
6348 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
6350 template <class _BidirectionalIterator, class _CharT, class _Traits>
6351 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6352 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6353 const regex_type& __re,
6354 initializer_list<int> __submatches,
6355 regex_constants::match_flag_type __m)
6356 : __position_(__a, __b, __re, __m),
6358 __subs_(__submatches)
6363 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
6365 template <class _BidirectionalIterator, class _CharT, class _Traits>
6366 template <size_t _Np>
6367 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6368 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6369 const regex_type& __re,
6370 const int (&__submatches)[_Np],
6371 regex_constants::match_flag_type __m)
6372 : __position_(__a, __b, __re, __m),
6374 __subs_(__submatches, __submatches + _Np)
6379 template <class _BidirectionalIterator, class _CharT, class _Traits>
6380 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6381 regex_token_iterator(const regex_token_iterator& __x)
6382 : __position_(__x.__position_),
6383 __result_(__x.__result_),
6384 __suffix_(__x.__suffix_),
6386 __subs_(__x.__subs_)
6388 if (__x.__result_ == &__x.__suffix_)
6389 __result_ = &__suffix_;
6390 else if ( __result_ != nullptr )
6391 __establish_result ();
6394 template <class _BidirectionalIterator, class _CharT, class _Traits>
6395 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
6396 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6397 operator=(const regex_token_iterator& __x)
6401 __position_ = __x.__position_;
6402 if (__x.__result_ == &__x.__suffix_)
6403 __result_ = &__suffix_;
6405 __result_ = __x.__result_;
6406 __suffix_ = __x.__suffix_;
6408 __subs_ = __x.__subs_;
6410 if ( __result_ != nullptr && __result_ != &__suffix_ )
6411 __establish_result();
6416 template <class _BidirectionalIterator, class _CharT, class _Traits>
6418 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6419 operator==(const regex_token_iterator& __x) const
6421 if (__result_ == nullptr && __x.__result_ == nullptr)
6423 if (__result_ == &__suffix_ && __x.__result_ == &__x.__suffix_ &&
6424 __suffix_ == __x.__suffix_)
6426 if (__result_ == nullptr || __x.__result_ == nullptr)
6428 if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_)
6430 return __position_ == __x.__position_ && _N_ == __x._N_ &&
6431 __subs_ == __x.__subs_;
6434 template <class _BidirectionalIterator, class _CharT, class _Traits>
6435 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
6436 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6438 _Position __prev = __position_;
6439 if (__result_ == &__suffix_)
6440 __result_ = nullptr;
6441 else if (_N_ + 1 < __subs_.size())
6444 __establish_result();
6450 if (__position_ != _Position())
6451 __establish_result();
6454 if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end()
6455 && __prev->suffix().length() != 0)
6457 __suffix_.matched = true;
6458 __suffix_.first = __prev->suffix().first;
6459 __suffix_.second = __prev->suffix().second;
6460 __result_ = &__suffix_;
6463 __result_ = nullptr;
6469 typedef regex_token_iterator<const char*> cregex_token_iterator;
6470 typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
6471 typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
6472 typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
6476 template <class _OutputIterator, class _BidirectionalIterator,
6477 class _Traits, class _CharT>
6479 regex_replace(_OutputIterator __out,
6480 _BidirectionalIterator __first, _BidirectionalIterator __last,
6481 const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
6482 regex_constants::match_flag_type __flags = regex_constants::match_default)
6484 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Iter;
6485 _Iter __i(__first, __last, __e, __flags);
6489 if (!(__flags & regex_constants::format_no_copy))
6490 __out = _VSTD::copy(__first, __last, __out);
6494 sub_match<_BidirectionalIterator> __lm;
6495 for (size_t __len = char_traits<_CharT>::length(__fmt); __i != __eof; ++__i)
6497 if (!(__flags & regex_constants::format_no_copy))
6498 __out = _VSTD::copy(__i->prefix().first, __i->prefix().second, __out);
6499 __out = __i->format(__out, __fmt, __fmt + __len, __flags);
6500 __lm = __i->suffix();
6501 if (__flags & regex_constants::format_first_only)
6504 if (!(__flags & regex_constants::format_no_copy))
6505 __out = _VSTD::copy(__lm.first, __lm.second, __out);
6510 template <class _OutputIterator, class _BidirectionalIterator,
6511 class _Traits, class _CharT, class _ST, class _SA>
6512 inline _LIBCPP_INLINE_VISIBILITY
6514 regex_replace(_OutputIterator __out,
6515 _BidirectionalIterator __first, _BidirectionalIterator __last,
6516 const basic_regex<_CharT, _Traits>& __e,
6517 const basic_string<_CharT, _ST, _SA>& __fmt,
6518 regex_constants::match_flag_type __flags = regex_constants::match_default)
6520 return _VSTD::regex_replace(__out, __first, __last, __e, __fmt.c_str(), __flags);
6523 template <class _Traits, class _CharT, class _ST, class _SA, class _FST,
6525 inline _LIBCPP_INLINE_VISIBILITY
6526 basic_string<_CharT, _ST, _SA>
6527 regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6528 const basic_regex<_CharT, _Traits>& __e,
6529 const basic_string<_CharT, _FST, _FSA>& __fmt,
6530 regex_constants::match_flag_type __flags = regex_constants::match_default)
6532 basic_string<_CharT, _ST, _SA> __r;
6533 _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6534 __fmt.c_str(), __flags);
6538 template <class _Traits, class _CharT, class _ST, class _SA>
6539 inline _LIBCPP_INLINE_VISIBILITY
6540 basic_string<_CharT, _ST, _SA>
6541 regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6542 const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
6543 regex_constants::match_flag_type __flags = regex_constants::match_default)
6545 basic_string<_CharT, _ST, _SA> __r;
6546 _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6551 template <class _Traits, class _CharT, class _ST, class _SA>
6552 inline _LIBCPP_INLINE_VISIBILITY
6553 basic_string<_CharT>
6554 regex_replace(const _CharT* __s,
6555 const basic_regex<_CharT, _Traits>& __e,
6556 const basic_string<_CharT, _ST, _SA>& __fmt,
6557 regex_constants::match_flag_type __flags = regex_constants::match_default)
6559 basic_string<_CharT> __r;
6560 _VSTD::regex_replace(back_inserter(__r), __s,
6561 __s + char_traits<_CharT>::length(__s), __e,
6562 __fmt.c_str(), __flags);
6566 template <class _Traits, class _CharT>
6567 inline _LIBCPP_INLINE_VISIBILITY
6568 basic_string<_CharT>
6569 regex_replace(const _CharT* __s,
6570 const basic_regex<_CharT, _Traits>& __e,
6571 const _CharT* __fmt,
6572 regex_constants::match_flag_type __flags = regex_constants::match_default)
6574 basic_string<_CharT> __r;
6575 _VSTD::regex_replace(back_inserter(__r), __s,
6576 __s + char_traits<_CharT>::length(__s), __e,
6581 _LIBCPP_END_NAMESPACE_STD
6583 #endif // _LIBCPP_REGEX