2 //===--------------------------- regex ------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
16 #include <initializer_list>
21 namespace regex_constants
24 emum syntax_option_type
28 optimize = unspecified,
29 collate = unspecified,
30 ECMAScript = unspecified,
32 extended = unspecified,
38 constexpr syntax_option_type operator~(syntax_option_type f);
39 constexpr syntax_option_type operator&(syntax_option_type lhs, syntax_option_type rhs);
40 constexpr syntax_option_type operator|(syntax_option_type lhs, syntax_option_type rhs);
45 match_not_bol = unspecified,
46 match_not_eol = unspecified,
47 match_not_bow = unspecified,
48 match_not_eow = unspecified,
49 match_any = unspecified,
50 match_not_null = unspecified,
51 match_continuous = unspecified,
52 match_prev_avail = unspecified,
54 format_sed = unspecified,
55 format_no_copy = unspecified,
56 format_first_only = unspecified
59 constexpr match_flag_type operator~(match_flag_type f);
60 constexpr match_flag_type operator&(match_flag_type lhs, match_flag_type rhs);
61 constexpr match_flag_type operator|(match_flag_type lhs, match_flag_type rhs);
65 error_collate = unspecified,
66 error_ctype = unspecified,
67 error_escape = unspecified,
68 error_backref = unspecified,
69 error_brack = unspecified,
70 error_paren = unspecified,
71 error_brace = unspecified,
72 error_badbrace = unspecified,
73 error_range = unspecified,
74 error_space = unspecified,
75 error_badrepeat = unspecified,
76 error_complexity = unspecified,
77 error_stack = unspecified
83 : public runtime_error
86 explicit regex_error(regex_constants::error_type ecode);
87 regex_constants::error_type code() const;
90 template <class charT>
94 typedef charT char_type;
95 typedef basic_string<char_type> string_type;
96 typedef locale locale_type;
97 typedef /bitmask_type/ char_class_type;
101 static size_t length(const char_type* p);
102 charT translate(charT c) const;
103 charT translate_nocase(charT c) const;
104 template <class ForwardIterator>
106 transform(ForwardIterator first, ForwardIterator last) const;
107 template <class ForwardIterator>
109 transform_primary( ForwardIterator first, ForwardIterator last) const;
110 template <class ForwardIterator>
112 lookup_collatename(ForwardIterator first, ForwardIterator last) const;
113 template <class ForwardIterator>
115 lookup_classname(ForwardIterator first, ForwardIterator last,
116 bool icase = false) const;
117 bool isctype(charT c, char_class_type f) const;
118 int value(charT ch, int radix) const;
119 locale_type imbue(locale_type l);
120 locale_type getloc()const;
123 template <class charT, class traits = regex_traits<charT>>
128 typedef charT value_type;
129 typedef traits traits_type;
130 typedef typename traits::string_type string_type;
131 typedef regex_constants::syntax_option_type flag_type;
132 typedef typename traits::locale_type locale_type;
135 static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
136 static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
137 static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
138 static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
139 static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
140 static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
141 static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
142 static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
143 static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
144 static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
146 // construct/copy/destroy:
148 explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
149 basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
150 basic_regex(const basic_regex&);
151 basic_regex(basic_regex&&) noexcept;
152 template <class ST, class SA>
153 explicit basic_regex(const basic_string<charT, ST, SA>& p,
154 flag_type f = regex_constants::ECMAScript);
155 template <class ForwardIterator>
156 basic_regex(ForwardIterator first, ForwardIterator last,
157 flag_type f = regex_constants::ECMAScript);
158 basic_regex(initializer_list<charT>, flag_type = regex_constants::ECMAScript);
162 basic_regex& operator=(const basic_regex&);
163 basic_regex& operator=(basic_regex&&) noexcept;
164 basic_regex& operator=(const charT* ptr);
165 basic_regex& operator=(initializer_list<charT> il);
166 template <class ST, class SA>
167 basic_regex& operator=(const basic_string<charT, ST, SA>& p);
170 basic_regex& assign(const basic_regex& that);
171 basic_regex& assign(basic_regex&& that) noexcept;
172 basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
173 basic_regex& assign(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
174 template <class string_traits, class A>
175 basic_regex& assign(const basic_string<charT, string_traits, A>& s,
176 flag_type f = regex_constants::ECMAScript);
177 template <class InputIterator>
178 basic_regex& assign(InputIterator first, InputIterator last,
179 flag_type f = regex_constants::ECMAScript);
180 basic_regex& assign(initializer_list<charT>, flag_type f = regex_constants::ECMAScript);
183 unsigned mark_count() const;
184 flag_type flags() const;
187 locale_type imbue(locale_type loc);
188 locale_type getloc() const;
191 void swap(basic_regex&);
194 template<class ForwardIterator>
195 basic_regex(ForwardIterator, ForwardIterator,
196 regex_constants::syntax_option_type = regex_constants::ECMAScript)
197 -> basic_regex<typename iterator_traits<ForwardIterator>::value_type>; // C++17
199 typedef basic_regex<char> regex;
200 typedef basic_regex<wchar_t> wregex;
202 template <class charT, class traits>
203 void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2);
205 template <class BidirectionalIterator>
207 : public pair<BidirectionalIterator, BidirectionalIterator>
210 typedef typename iterator_traits<BidirectionalIterator>::value_type value_type;
211 typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
212 typedef BidirectionalIterator iterator;
213 typedef basic_string<value_type> string_type;
217 constexpr sub_match();
219 difference_type length() const;
220 operator string_type() const;
221 string_type str() const;
223 int compare(const sub_match& s) const;
224 int compare(const string_type& s) const;
225 int compare(const value_type* s) const;
228 typedef sub_match<const char*> csub_match;
229 typedef sub_match<const wchar_t*> wcsub_match;
230 typedef sub_match<string::const_iterator> ssub_match;
231 typedef sub_match<wstring::const_iterator> wssub_match;
233 template <class BiIter>
235 operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
237 template <class BiIter>
239 operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
241 template <class BiIter>
243 operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
245 template <class BiIter>
247 operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
249 template <class BiIter>
251 operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
253 template <class BiIter>
255 operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
257 template <class BiIter, class ST, class SA>
259 operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
260 const sub_match<BiIter>& rhs);
262 template <class BiIter, class ST, class SA>
264 operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
265 const sub_match<BiIter>& rhs);
267 template <class BiIter, class ST, class SA>
269 operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
270 const sub_match<BiIter>& rhs);
272 template <class BiIter, class ST, class SA>
274 operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
275 const sub_match<BiIter>& rhs);
277 template <class BiIter, class ST, class SA>
278 bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
279 const sub_match<BiIter>& rhs);
281 template <class BiIter, class ST, class SA>
283 operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
284 const sub_match<BiIter>& rhs);
286 template <class BiIter, class ST, class SA>
288 operator==(const sub_match<BiIter>& lhs,
289 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
291 template <class BiIter, class ST, class SA>
293 operator!=(const sub_match<BiIter>& lhs,
294 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
296 template <class BiIter, class ST, class SA>
298 operator<(const sub_match<BiIter>& lhs,
299 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
301 template <class BiIter, class ST, class SA>
302 bool operator>(const sub_match<BiIter>& lhs,
303 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
305 template <class BiIter, class ST, class SA>
307 operator>=(const sub_match<BiIter>& lhs,
308 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
310 template <class BiIter, class ST, class SA>
312 operator<=(const sub_match<BiIter>& lhs,
313 const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
315 template <class BiIter>
317 operator==(typename iterator_traits<BiIter>::value_type const* lhs,
318 const sub_match<BiIter>& rhs);
320 template <class BiIter>
322 operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
323 const sub_match<BiIter>& rhs);
325 template <class BiIter>
327 operator<(typename iterator_traits<BiIter>::value_type const* lhs,
328 const sub_match<BiIter>& rhs);
330 template <class BiIter>
332 operator>(typename iterator_traits<BiIter>::value_type const* lhs,
333 const sub_match<BiIter>& rhs);
335 template <class BiIter>
337 operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
338 const sub_match<BiIter>& rhs);
340 template <class BiIter>
342 operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
343 const sub_match<BiIter>& rhs);
345 template <class BiIter>
347 operator==(const sub_match<BiIter>& lhs,
348 typename iterator_traits<BiIter>::value_type const* rhs);
350 template <class BiIter>
352 operator!=(const sub_match<BiIter>& lhs,
353 typename iterator_traits<BiIter>::value_type const* rhs);
355 template <class BiIter>
357 operator<(const sub_match<BiIter>& lhs,
358 typename iterator_traits<BiIter>::value_type const* rhs);
360 template <class BiIter>
362 operator>(const sub_match<BiIter>& lhs,
363 typename iterator_traits<BiIter>::value_type const* rhs);
365 template <class BiIter>
367 operator>=(const sub_match<BiIter>& lhs,
368 typename iterator_traits<BiIter>::value_type const* rhs);
370 template <class BiIter>
372 operator<=(const sub_match<BiIter>& lhs,
373 typename iterator_traits<BiIter>::value_type const* rhs);
375 template <class BiIter>
377 operator==(typename iterator_traits<BiIter>::value_type const& lhs,
378 const sub_match<BiIter>& rhs);
380 template <class BiIter>
382 operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
383 const sub_match<BiIter>& rhs);
385 template <class BiIter>
387 operator<(typename iterator_traits<BiIter>::value_type const& lhs,
388 const sub_match<BiIter>& rhs);
390 template <class BiIter>
392 operator>(typename iterator_traits<BiIter>::value_type const& lhs,
393 const sub_match<BiIter>& rhs);
395 template <class BiIter>
397 operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
398 const sub_match<BiIter>& rhs);
400 template <class BiIter>
402 operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
403 const sub_match<BiIter>& rhs);
405 template <class BiIter>
407 operator==(const sub_match<BiIter>& lhs,
408 typename iterator_traits<BiIter>::value_type const& rhs);
410 template <class BiIter>
412 operator!=(const sub_match<BiIter>& lhs,
413 typename iterator_traits<BiIter>::value_type const& rhs);
415 template <class BiIter>
417 operator<(const sub_match<BiIter>& lhs,
418 typename iterator_traits<BiIter>::value_type const& rhs);
420 template <class BiIter>
422 operator>(const sub_match<BiIter>& lhs,
423 typename iterator_traits<BiIter>::value_type const& rhs);
425 template <class BiIter>
427 operator>=(const sub_match<BiIter>& lhs,
428 typename iterator_traits<BiIter>::value_type const& rhs);
430 template <class BiIter>
432 operator<=(const sub_match<BiIter>& lhs,
433 typename iterator_traits<BiIter>::value_type const& rhs);
435 template <class charT, class ST, class BiIter>
436 basic_ostream<charT, ST>&
437 operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
439 template <class BidirectionalIterator,
440 class Allocator = allocator<sub_match<BidirectionalIterator>>>
444 typedef sub_match<BidirectionalIterator> value_type;
445 typedef const value_type& const_reference;
446 typedef value_type& reference;
447 typedef /implementation-defined/ const_iterator;
448 typedef const_iterator iterator;
449 typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
450 typedef typename allocator_traits<Allocator>::size_type size_type;
451 typedef Allocator allocator_type;
452 typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;
453 typedef basic_string<char_type> string_type;
455 // construct/copy/destroy:
456 explicit match_results(const Allocator& a = Allocator());
457 match_results(const match_results& m);
458 match_results(match_results&& m) noexcept;
459 match_results& operator=(const match_results& m);
460 match_results& operator=(match_results&& m);
466 size_type size() const;
467 size_type max_size() const;
471 difference_type length(size_type sub = 0) const;
472 difference_type position(size_type sub = 0) const;
473 string_type str(size_type sub = 0) const;
474 const_reference operator[](size_type n) const;
476 const_reference prefix() const;
477 const_reference suffix() const;
479 const_iterator begin() const;
480 const_iterator end() const;
481 const_iterator cbegin() const;
482 const_iterator cend() const;
485 template <class OutputIter>
487 format(OutputIter out, const char_type* fmt_first,
488 const char_type* fmt_last,
489 regex_constants::match_flag_type flags = regex_constants::format_default) const;
490 template <class OutputIter, class ST, class SA>
492 format(OutputIter out, const basic_string<char_type, ST, SA>& fmt,
493 regex_constants::match_flag_type flags = regex_constants::format_default) const;
494 template <class ST, class SA>
495 basic_string<char_type, ST, SA>
496 format(const basic_string<char_type, ST, SA>& fmt,
497 regex_constants::match_flag_type flags = regex_constants::format_default) const;
499 format(const char_type* fmt,
500 regex_constants::match_flag_type flags = regex_constants::format_default) const;
503 allocator_type get_allocator() const;
506 void swap(match_results& that);
509 typedef match_results<const char*> cmatch;
510 typedef match_results<const wchar_t*> wcmatch;
511 typedef match_results<string::const_iterator> smatch;
512 typedef match_results<wstring::const_iterator> wsmatch;
514 template <class BidirectionalIterator, class Allocator>
516 operator==(const match_results<BidirectionalIterator, Allocator>& m1,
517 const match_results<BidirectionalIterator, Allocator>& m2);
519 template <class BidirectionalIterator, class Allocator>
521 operator!=(const match_results<BidirectionalIterator, Allocator>& m1,
522 const match_results<BidirectionalIterator, Allocator>& m2);
524 template <class BidirectionalIterator, class Allocator>
526 swap(match_results<BidirectionalIterator, Allocator>& m1,
527 match_results<BidirectionalIterator, Allocator>& m2);
529 template <class BidirectionalIterator, class Allocator, class charT, class traits>
531 regex_match(BidirectionalIterator first, BidirectionalIterator last,
532 match_results<BidirectionalIterator, Allocator>& m,
533 const basic_regex<charT, traits>& e,
534 regex_constants::match_flag_type flags = regex_constants::match_default);
536 template <class BidirectionalIterator, class charT, class traits>
538 regex_match(BidirectionalIterator first, BidirectionalIterator last,
539 const basic_regex<charT, traits>& e,
540 regex_constants::match_flag_type flags = regex_constants::match_default);
542 template <class charT, class Allocator, class traits>
544 regex_match(const charT* str, match_results<const charT*, Allocator>& m,
545 const basic_regex<charT, traits>& e,
546 regex_constants::match_flag_type flags = regex_constants::match_default);
548 template <class ST, class SA, class Allocator, class charT, class traits>
550 regex_match(const basic_string<charT, ST, SA>& s,
551 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
552 const basic_regex<charT, traits>& e,
553 regex_constants::match_flag_type flags = regex_constants::match_default);
555 template <class ST, class SA, class Allocator, class charT, class traits>
557 regex_match(const basic_string<charT, ST, SA>&& s,
558 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
559 const basic_regex<charT, traits>& e,
560 regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
562 template <class charT, class traits>
564 regex_match(const charT* str, const basic_regex<charT, traits>& e,
565 regex_constants::match_flag_type flags = regex_constants::match_default);
567 template <class ST, class SA, class charT, class traits>
569 regex_match(const basic_string<charT, ST, SA>& s,
570 const basic_regex<charT, traits>& e,
571 regex_constants::match_flag_type flags = regex_constants::match_default);
573 template <class BidirectionalIterator, class Allocator, class charT, class traits>
575 regex_search(BidirectionalIterator first, BidirectionalIterator last,
576 match_results<BidirectionalIterator, Allocator>& m,
577 const basic_regex<charT, traits>& e,
578 regex_constants::match_flag_type flags = regex_constants::match_default);
580 template <class BidirectionalIterator, class charT, class traits>
582 regex_search(BidirectionalIterator first, BidirectionalIterator last,
583 const basic_regex<charT, traits>& e,
584 regex_constants::match_flag_type flags = regex_constants::match_default);
586 template <class charT, class Allocator, class traits>
588 regex_search(const charT* str, match_results<const charT*, Allocator>& m,
589 const basic_regex<charT, traits>& e,
590 regex_constants::match_flag_type flags = regex_constants::match_default);
592 template <class charT, class traits>
594 regex_search(const charT* str, const basic_regex<charT, traits>& e,
595 regex_constants::match_flag_type flags = regex_constants::match_default);
597 template <class ST, class SA, class charT, class traits>
599 regex_search(const basic_string<charT, ST, SA>& s,
600 const basic_regex<charT, traits>& e,
601 regex_constants::match_flag_type flags = regex_constants::match_default);
603 template <class ST, class SA, class Allocator, class charT, class traits>
605 regex_search(const basic_string<charT, ST, SA>& s,
606 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
607 const basic_regex<charT, traits>& e,
608 regex_constants::match_flag_type flags = regex_constants::match_default);
610 template <class ST, class SA, class Allocator, class charT, class traits>
612 regex_search(const basic_string<charT, ST, SA>&& s,
613 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
614 const basic_regex<charT, traits>& e,
615 regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
617 template <class OutputIterator, class BidirectionalIterator,
618 class traits, class charT, class ST, class SA>
620 regex_replace(OutputIterator out,
621 BidirectionalIterator first, BidirectionalIterator last,
622 const basic_regex<charT, traits>& e,
623 const basic_string<charT, ST, SA>& fmt,
624 regex_constants::match_flag_type flags = regex_constants::match_default);
626 template <class OutputIterator, class BidirectionalIterator,
627 class traits, class charT>
629 regex_replace(OutputIterator out,
630 BidirectionalIterator first, BidirectionalIterator last,
631 const basic_regex<charT, traits>& e, const charT* fmt,
632 regex_constants::match_flag_type flags = regex_constants::match_default);
634 template <class traits, class charT, class ST, class SA, class FST, class FSA>>
635 basic_string<charT, ST, SA>
636 regex_replace(const basic_string<charT, ST, SA>& s,
637 const basic_regex<charT, traits>& e,
638 const basic_string<charT, FST, FSA>& fmt,
639 regex_constants::match_flag_type flags = regex_constants::match_default);
641 template <class traits, class charT, class ST, class SA>
642 basic_string<charT, ST, SA>
643 regex_replace(const basic_string<charT, ST, SA>& s,
644 const basic_regex<charT, traits>& e, const charT* fmt,
645 regex_constants::match_flag_type flags = regex_constants::match_default);
647 template <class traits, class charT, class ST, class SA>
649 regex_replace(const charT* s,
650 const basic_regex<charT, traits>& e,
651 const basic_string<charT, ST, SA>& fmt,
652 regex_constants::match_flag_type flags = regex_constants::match_default);
654 template <class traits, class charT>
656 regex_replace(const charT* s,
657 const basic_regex<charT, traits>& e,
659 regex_constants::match_flag_type flags = regex_constants::match_default);
661 template <class BidirectionalIterator,
662 class charT = typename iterator_traits< BidirectionalIterator>::value_type,
663 class traits = regex_traits<charT>>
667 typedef basic_regex<charT, traits> regex_type;
668 typedef match_results<BidirectionalIterator> value_type;
669 typedef ptrdiff_t difference_type;
670 typedef const value_type* pointer;
671 typedef const value_type& reference;
672 typedef forward_iterator_tag iterator_category;
675 regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
676 const regex_type& re,
677 regex_constants::match_flag_type m = regex_constants::match_default);
678 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
679 const regex_type&& __re,
680 regex_constants::match_flag_type __m
681 = regex_constants::match_default) = delete; // C++14
682 regex_iterator(const regex_iterator&);
683 regex_iterator& operator=(const regex_iterator&);
685 bool operator==(const regex_iterator&) const;
686 bool operator!=(const regex_iterator&) const;
688 const value_type& operator*() const;
689 const value_type* operator->() const;
691 regex_iterator& operator++();
692 regex_iterator operator++(int);
695 typedef regex_iterator<const char*> cregex_iterator;
696 typedef regex_iterator<const wchar_t*> wcregex_iterator;
697 typedef regex_iterator<string::const_iterator> sregex_iterator;
698 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
700 template <class BidirectionalIterator,
701 class charT = typename iterator_traits< BidirectionalIterator>::value_type,
702 class traits = regex_traits<charT>>
703 class regex_token_iterator
706 typedef basic_regex<charT, traits> regex_type;
707 typedef sub_match<BidirectionalIterator> value_type;
708 typedef ptrdiff_t difference_type;
709 typedef const value_type* pointer;
710 typedef const value_type& reference;
711 typedef forward_iterator_tag iterator_category;
713 regex_token_iterator();
714 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
715 const regex_type& re, int submatch = 0,
716 regex_constants::match_flag_type m = regex_constants::match_default);
717 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
718 const regex_type&& re, int submatch = 0,
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, const vector<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, const vector<int>& submatches,
725 regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
726 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
727 const regex_type& re, initializer_list<int> submatches,
728 regex_constants::match_flag_type m = regex_constants::match_default);
729 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
730 const regex_type&& re, initializer_list<int> submatches,
731 regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
733 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
734 const regex_type& re, const int (&submatches)[N],
735 regex_constants::match_flag_type m = regex_constants::match_default);
737 regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
738 const regex_type& re, const int (&submatches)[N],
739 regex_constants::match_flag_type m = regex_constants::match_default) = delete // C++14;
740 regex_token_iterator(const regex_token_iterator&);
741 regex_token_iterator& operator=(const regex_token_iterator&);
743 bool operator==(const regex_token_iterator&) const;
744 bool operator!=(const regex_token_iterator&) const;
746 const value_type& operator*() const;
747 const value_type* operator->() const;
749 regex_token_iterator& operator++();
750 regex_token_iterator operator++(int);
753 typedef regex_token_iterator<const char*> cregex_token_iterator;
754 typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
755 typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
756 typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
764 #include <initializer_list>
773 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
774 #pragma GCC system_header
778 #include <__undef_macros>
781 #define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096
783 _LIBCPP_BEGIN_NAMESPACE_STD
785 namespace regex_constants
788 // syntax_option_type
790 enum syntax_option_type
796 #ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
808 inline _LIBCPP_CONSTEXPR
809 syntax_option_type __get_grammar(syntax_option_type __g)
811 #ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
812 return static_cast<syntax_option_type>(__g & 0x3F0);
814 return static_cast<syntax_option_type>(__g & 0x1F0);
818 inline _LIBCPP_INLINE_VISIBILITY
821 operator~(syntax_option_type __x)
823 return syntax_option_type(~int(__x) & 0x1FF);
826 inline _LIBCPP_INLINE_VISIBILITY
829 operator&(syntax_option_type __x, syntax_option_type __y)
831 return syntax_option_type(int(__x) & int(__y));
834 inline _LIBCPP_INLINE_VISIBILITY
837 operator|(syntax_option_type __x, syntax_option_type __y)
839 return syntax_option_type(int(__x) | int(__y));
842 inline _LIBCPP_INLINE_VISIBILITY
845 operator^(syntax_option_type __x, syntax_option_type __y)
847 return syntax_option_type(int(__x) ^ int(__y));
850 inline _LIBCPP_INLINE_VISIBILITY
852 operator&=(syntax_option_type& __x, syntax_option_type __y)
858 inline _LIBCPP_INLINE_VISIBILITY
860 operator|=(syntax_option_type& __x, syntax_option_type __y)
866 inline _LIBCPP_INLINE_VISIBILITY
868 operator^=(syntax_option_type& __x, syntax_option_type __y)
879 match_not_bol = 1 << 0,
880 match_not_eol = 1 << 1,
881 match_not_bow = 1 << 2,
882 match_not_eow = 1 << 3,
884 match_not_null = 1 << 5,
885 match_continuous = 1 << 6,
886 match_prev_avail = 1 << 7,
889 format_no_copy = 1 << 9,
890 format_first_only = 1 << 10,
891 __no_update_pos = 1 << 11,
892 __full_match = 1 << 12
895 inline _LIBCPP_INLINE_VISIBILITY
898 operator~(match_flag_type __x)
900 return match_flag_type(~int(__x) & 0x0FFF);
903 inline _LIBCPP_INLINE_VISIBILITY
906 operator&(match_flag_type __x, match_flag_type __y)
908 return match_flag_type(int(__x) & int(__y));
911 inline _LIBCPP_INLINE_VISIBILITY
914 operator|(match_flag_type __x, match_flag_type __y)
916 return match_flag_type(int(__x) | int(__y));
919 inline _LIBCPP_INLINE_VISIBILITY
922 operator^(match_flag_type __x, match_flag_type __y)
924 return match_flag_type(int(__x) ^ int(__y));
927 inline _LIBCPP_INLINE_VISIBILITY
929 operator&=(match_flag_type& __x, match_flag_type __y)
935 inline _LIBCPP_INLINE_VISIBILITY
937 operator|=(match_flag_type& __x, match_flag_type __y)
943 inline _LIBCPP_INLINE_VISIBILITY
945 operator^=(match_flag_type& __x, match_flag_type __y)
974 class _LIBCPP_EXCEPTION_ABI regex_error
975 : public runtime_error
977 regex_constants::error_type __code_;
979 explicit regex_error(regex_constants::error_type __ecode);
980 virtual ~regex_error() throw();
981 _LIBCPP_INLINE_VISIBILITY
982 regex_constants::error_type code() const {return __code_;}
985 template <regex_constants::error_type _Ev>
986 _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
987 void __throw_regex_error()
989 #ifndef _LIBCPP_NO_EXCEPTIONS
990 throw regex_error(_Ev);
996 template <class _CharT>
997 struct _LIBCPP_TEMPLATE_VIS regex_traits
1000 typedef _CharT char_type;
1001 typedef basic_string<char_type> string_type;
1002 typedef locale locale_type;
1003 typedef ctype_base::mask char_class_type;
1005 static const char_class_type __regex_word = ctype_base::__regex_word;
1008 const ctype<char_type>* __ct_;
1009 const collate<char_type>* __col_;
1014 _LIBCPP_INLINE_VISIBILITY
1015 static size_t length(const char_type* __p)
1016 {return char_traits<char_type>::length(__p);}
1017 _LIBCPP_INLINE_VISIBILITY
1018 char_type translate(char_type __c) const {return __c;}
1019 char_type translate_nocase(char_type __c) const;
1020 template <class _ForwardIterator>
1022 transform(_ForwardIterator __f, _ForwardIterator __l) const;
1023 template <class _ForwardIterator>
1024 _LIBCPP_INLINE_VISIBILITY
1026 transform_primary( _ForwardIterator __f, _ForwardIterator __l) const
1027 {return __transform_primary(__f, __l, char_type());}
1028 template <class _ForwardIterator>
1029 _LIBCPP_INLINE_VISIBILITY
1031 lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const
1032 {return __lookup_collatename(__f, __l, char_type());}
1033 template <class _ForwardIterator>
1034 _LIBCPP_INLINE_VISIBILITY
1036 lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1037 bool __icase = false) const
1038 {return __lookup_classname(__f, __l, __icase, char_type());}
1039 bool isctype(char_type __c, char_class_type __m) const;
1040 _LIBCPP_INLINE_VISIBILITY
1041 int value(char_type __ch, int __radix) const
1042 {return __regex_traits_value(__ch, __radix);}
1043 locale_type imbue(locale_type __l);
1044 _LIBCPP_INLINE_VISIBILITY
1045 locale_type getloc()const {return __loc_;}
1050 template <class _ForwardIterator>
1052 __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;
1053 template <class _ForwardIterator>
1055 __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1057 template <class _ForwardIterator>
1059 __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;
1060 template <class _ForwardIterator>
1062 __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1064 template <class _ForwardIterator>
1066 __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1067 bool __icase, char) const;
1068 template <class _ForwardIterator>
1070 __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
1071 bool __icase, wchar_t) const;
1073 static int __regex_traits_value(unsigned char __ch, int __radix);
1074 _LIBCPP_INLINE_VISIBILITY
1075 int __regex_traits_value(char __ch, int __radix) const
1076 {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);}
1077 _LIBCPP_INLINE_VISIBILITY
1078 int __regex_traits_value(wchar_t __ch, int __radix) const;
1081 template <class _CharT>
1082 const typename regex_traits<_CharT>::char_class_type
1083 regex_traits<_CharT>::__regex_word;
1085 template <class _CharT>
1086 regex_traits<_CharT>::regex_traits()
1091 template <class _CharT>
1092 typename regex_traits<_CharT>::char_type
1093 regex_traits<_CharT>::translate_nocase(char_type __c) const
1095 return __ct_->tolower(__c);
1098 template <class _CharT>
1099 template <class _ForwardIterator>
1100 typename regex_traits<_CharT>::string_type
1101 regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const
1103 string_type __s(__f, __l);
1104 return __col_->transform(__s.data(), __s.data() + __s.size());
1107 template <class _CharT>
1109 regex_traits<_CharT>::__init()
1111 __ct_ = &use_facet<ctype<char_type> >(__loc_);
1112 __col_ = &use_facet<collate<char_type> >(__loc_);
1115 template <class _CharT>
1116 typename regex_traits<_CharT>::locale_type
1117 regex_traits<_CharT>::imbue(locale_type __l)
1119 locale __r = __loc_;
1125 // transform_primary is very FreeBSD-specific
1127 template <class _CharT>
1128 template <class _ForwardIterator>
1129 typename regex_traits<_CharT>::string_type
1130 regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
1131 _ForwardIterator __l, char) const
1133 const string_type __s(__f, __l);
1134 string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
1149 template <class _CharT>
1150 template <class _ForwardIterator>
1151 typename regex_traits<_CharT>::string_type
1152 regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
1153 _ForwardIterator __l, wchar_t) const
1155 const string_type __s(__f, __l);
1156 string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
1171 // lookup_collatename is very FreeBSD-specific
1173 _LIBCPP_FUNC_VIS string __get_collation_name(const char* __s);
1175 template <class _CharT>
1176 template <class _ForwardIterator>
1177 typename regex_traits<_CharT>::string_type
1178 regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
1179 _ForwardIterator __l, char) const
1181 string_type __s(__f, __l);
1185 __r = __get_collation_name(__s.c_str());
1186 if (__r.empty() && __s.size() <= 2)
1188 __r = __col_->transform(__s.data(), __s.data() + __s.size());
1189 if (__r.size() == 1 || __r.size() == 12)
1198 template <class _CharT>
1199 template <class _ForwardIterator>
1200 typename regex_traits<_CharT>::string_type
1201 regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
1202 _ForwardIterator __l, wchar_t) const
1204 string_type __s(__f, __l);
1206 __n.reserve(__s.size());
1207 for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
1210 if (static_cast<unsigned>(*__i) >= 127)
1211 return string_type();
1212 __n.push_back(char(*__i));
1217 __n = __get_collation_name(__n.c_str());
1219 __r.assign(__n.begin(), __n.end());
1220 else if (__s.size() <= 2)
1222 __r = __col_->transform(__s.data(), __s.data() + __s.size());
1223 if (__r.size() == 1 || __r.size() == 3)
1234 regex_traits<char>::char_class_type _LIBCPP_FUNC_VIS
1235 __get_classname(const char* __s, bool __icase);
1237 template <class _CharT>
1238 template <class _ForwardIterator>
1239 typename regex_traits<_CharT>::char_class_type
1240 regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
1241 _ForwardIterator __l,
1242 bool __icase, char) const
1244 string_type __s(__f, __l);
1245 __ct_->tolower(&__s[0], &__s[0] + __s.size());
1246 return __get_classname(__s.c_str(), __icase);
1249 template <class _CharT>
1250 template <class _ForwardIterator>
1251 typename regex_traits<_CharT>::char_class_type
1252 regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
1253 _ForwardIterator __l,
1254 bool __icase, wchar_t) const
1256 string_type __s(__f, __l);
1257 __ct_->tolower(&__s[0], &__s[0] + __s.size());
1259 __n.reserve(__s.size());
1260 for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
1263 if (static_cast<unsigned>(*__i) >= 127)
1264 return char_class_type();
1265 __n.push_back(char(*__i));
1267 return __get_classname(__n.c_str(), __icase);
1270 template <class _CharT>
1272 regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const
1274 if (__ct_->is(__m, __c))
1276 return (__c == '_' && (__m & __regex_word));
1279 template <class _CharT>
1281 regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix)
1283 if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7'
1287 if ((__ch & 0xFEu) == 0x38) // '8' <= __ch && __ch <= '9'
1291 __ch |= 0x20; // tolower
1292 if ('a' <= __ch && __ch <= 'f')
1293 return __ch - ('a' - 10);
1299 template <class _CharT>
1302 regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const
1304 return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix);
1307 template <class _CharT> class __node;
1309 template <class _BidirectionalIterator> class _LIBCPP_TEMPLATE_VIS sub_match;
1311 template <class _BidirectionalIterator,
1312 class _Allocator = allocator<sub_match<_BidirectionalIterator> > >
1313 class _LIBCPP_TEMPLATE_VIS match_results;
1315 template <class _CharT>
1320 __end_state = -1000,
1321 __consume_input, // -999
1322 __begin_marked_expr, // -998
1323 __end_marked_expr, // -997
1324 __pop_state, // -996
1325 __accept_and_consume, // -995
1326 __accept_but_not_consume, // -994
1333 const _CharT* __first_;
1334 const _CharT* __current_;
1335 const _CharT* __last_;
1336 vector<sub_match<const _CharT*> > __sub_matches_;
1337 vector<pair<size_t, const _CharT*> > __loop_data_;
1338 const __node<_CharT>* __node_;
1339 regex_constants::match_flag_type __flags_;
1342 _LIBCPP_INLINE_VISIBILITY
1344 : __do_(0), __first_(nullptr), __current_(nullptr), __last_(nullptr),
1345 __node_(nullptr), __flags_() {}
1350 template <class _CharT>
1353 __node(const __node&);
1354 __node& operator=(const __node&);
1356 typedef _VSTD::__state<_CharT> __state;
1358 _LIBCPP_INLINE_VISIBILITY
1360 _LIBCPP_INLINE_VISIBILITY
1361 virtual ~__node() {}
1363 _LIBCPP_INLINE_VISIBILITY
1364 virtual void __exec(__state&) const {}
1365 _LIBCPP_INLINE_VISIBILITY
1366 virtual void __exec_split(bool, __state&) const {}
1371 template <class _CharT>
1373 : public __node<_CharT>
1376 typedef _VSTD::__state<_CharT> __state;
1378 _LIBCPP_INLINE_VISIBILITY
1381 virtual void __exec(__state&) const;
1384 template <class _CharT>
1386 __end_state<_CharT>::__exec(__state& __s) const
1388 __s.__do_ = __state::__end_state;
1393 template <class _CharT>
1394 class __has_one_state
1395 : public __node<_CharT>
1397 __node<_CharT>* __first_;
1400 _LIBCPP_INLINE_VISIBILITY
1401 explicit __has_one_state(__node<_CharT>* __s)
1404 _LIBCPP_INLINE_VISIBILITY
1405 __node<_CharT>* first() const {return __first_;}
1406 _LIBCPP_INLINE_VISIBILITY
1407 __node<_CharT>*& first() {return __first_;}
1412 template <class _CharT>
1413 class __owns_one_state
1414 : public __has_one_state<_CharT>
1416 typedef __has_one_state<_CharT> base;
1419 _LIBCPP_INLINE_VISIBILITY
1420 explicit __owns_one_state(__node<_CharT>* __s)
1423 virtual ~__owns_one_state();
1426 template <class _CharT>
1427 __owns_one_state<_CharT>::~__owns_one_state()
1429 delete this->first();
1434 template <class _CharT>
1436 : public __owns_one_state<_CharT>
1438 typedef __owns_one_state<_CharT> base;
1441 typedef _VSTD::__state<_CharT> __state;
1443 _LIBCPP_INLINE_VISIBILITY
1444 explicit __empty_state(__node<_CharT>* __s)
1447 virtual void __exec(__state&) const;
1450 template <class _CharT>
1452 __empty_state<_CharT>::__exec(__state& __s) const
1454 __s.__do_ = __state::__accept_but_not_consume;
1455 __s.__node_ = this->first();
1458 // __empty_non_own_state
1460 template <class _CharT>
1461 class __empty_non_own_state
1462 : public __has_one_state<_CharT>
1464 typedef __has_one_state<_CharT> base;
1467 typedef _VSTD::__state<_CharT> __state;
1469 _LIBCPP_INLINE_VISIBILITY
1470 explicit __empty_non_own_state(__node<_CharT>* __s)
1473 virtual void __exec(__state&) const;
1476 template <class _CharT>
1478 __empty_non_own_state<_CharT>::__exec(__state& __s) const
1480 __s.__do_ = __state::__accept_but_not_consume;
1481 __s.__node_ = this->first();
1484 // __repeat_one_loop
1486 template <class _CharT>
1487 class __repeat_one_loop
1488 : public __has_one_state<_CharT>
1490 typedef __has_one_state<_CharT> base;
1493 typedef _VSTD::__state<_CharT> __state;
1495 _LIBCPP_INLINE_VISIBILITY
1496 explicit __repeat_one_loop(__node<_CharT>* __s)
1499 virtual void __exec(__state&) const;
1502 template <class _CharT>
1504 __repeat_one_loop<_CharT>::__exec(__state& __s) const
1506 __s.__do_ = __state::__repeat;
1507 __s.__node_ = this->first();
1510 // __owns_two_states
1512 template <class _CharT>
1513 class __owns_two_states
1514 : public __owns_one_state<_CharT>
1516 typedef __owns_one_state<_CharT> base;
1521 _LIBCPP_INLINE_VISIBILITY
1522 explicit __owns_two_states(__node<_CharT>* __s1, base* __s2)
1523 : base(__s1), __second_(__s2) {}
1525 virtual ~__owns_two_states();
1527 _LIBCPP_INLINE_VISIBILITY
1528 base* second() const {return __second_;}
1529 _LIBCPP_INLINE_VISIBILITY
1530 base*& second() {return __second_;}
1533 template <class _CharT>
1534 __owns_two_states<_CharT>::~__owns_two_states()
1541 template <class _CharT>
1543 : public __owns_two_states<_CharT>
1545 typedef __owns_two_states<_CharT> base;
1549 unsigned __loop_id_;
1550 unsigned __mexp_begin_;
1551 unsigned __mexp_end_;
1555 typedef _VSTD::__state<_CharT> __state;
1557 _LIBCPP_INLINE_VISIBILITY
1558 explicit __loop(unsigned __loop_id,
1559 __node<_CharT>* __s1, __owns_one_state<_CharT>* __s2,
1560 unsigned __mexp_begin, unsigned __mexp_end,
1561 bool __greedy = true,
1563 size_t __max = numeric_limits<size_t>::max())
1564 : base(__s1, __s2), __min_(__min), __max_(__max), __loop_id_(__loop_id),
1565 __mexp_begin_(__mexp_begin), __mexp_end_(__mexp_end),
1566 __greedy_(__greedy) {}
1568 virtual void __exec(__state& __s) const;
1569 virtual void __exec_split(bool __second, __state& __s) const;
1572 _LIBCPP_INLINE_VISIBILITY
1573 void __init_repeat(__state& __s) const
1575 __s.__loop_data_[__loop_id_].second = __s.__current_;
1576 for (size_t __i = __mexp_begin_-1; __i != __mexp_end_-1; ++__i)
1578 __s.__sub_matches_[__i].first = __s.__last_;
1579 __s.__sub_matches_[__i].second = __s.__last_;
1580 __s.__sub_matches_[__i].matched = false;
1585 template <class _CharT>
1587 __loop<_CharT>::__exec(__state& __s) const
1589 if (__s.__do_ == __state::__repeat)
1591 bool __do_repeat = ++__s.__loop_data_[__loop_id_].first < __max_;
1592 bool __do_alt = __s.__loop_data_[__loop_id_].first >= __min_;
1593 if (__do_repeat && __do_alt &&
1594 __s.__loop_data_[__loop_id_].second == __s.__current_)
1595 __do_repeat = false;
1596 if (__do_repeat && __do_alt)
1597 __s.__do_ = __state::__split;
1598 else if (__do_repeat)
1600 __s.__do_ = __state::__accept_but_not_consume;
1601 __s.__node_ = this->first();
1606 __s.__do_ = __state::__accept_but_not_consume;
1607 __s.__node_ = this->second();
1612 __s.__loop_data_[__loop_id_].first = 0;
1613 bool __do_repeat = 0 < __max_;
1614 bool __do_alt = 0 >= __min_;
1615 if (__do_repeat && __do_alt)
1616 __s.__do_ = __state::__split;
1617 else if (__do_repeat)
1619 __s.__do_ = __state::__accept_but_not_consume;
1620 __s.__node_ = this->first();
1625 __s.__do_ = __state::__accept_but_not_consume;
1626 __s.__node_ = this->second();
1631 template <class _CharT>
1633 __loop<_CharT>::__exec_split(bool __second, __state& __s) const
1635 __s.__do_ = __state::__accept_but_not_consume;
1636 if (__greedy_ != __second)
1638 __s.__node_ = this->first();
1642 __s.__node_ = this->second();
1647 template <class _CharT>
1649 : public __owns_two_states<_CharT>
1651 typedef __owns_two_states<_CharT> base;
1654 typedef _VSTD::__state<_CharT> __state;
1656 _LIBCPP_INLINE_VISIBILITY
1657 explicit __alternate(__owns_one_state<_CharT>* __s1,
1658 __owns_one_state<_CharT>* __s2)
1659 : base(__s1, __s2) {}
1661 virtual void __exec(__state& __s) const;
1662 virtual void __exec_split(bool __second, __state& __s) const;
1665 template <class _CharT>
1667 __alternate<_CharT>::__exec(__state& __s) const
1669 __s.__do_ = __state::__split;
1672 template <class _CharT>
1674 __alternate<_CharT>::__exec_split(bool __second, __state& __s) const
1676 __s.__do_ = __state::__accept_but_not_consume;
1678 __s.__node_ = this->second();
1680 __s.__node_ = this->first();
1683 // __begin_marked_subexpression
1685 template <class _CharT>
1686 class __begin_marked_subexpression
1687 : public __owns_one_state<_CharT>
1689 typedef __owns_one_state<_CharT> base;
1693 typedef _VSTD::__state<_CharT> __state;
1695 _LIBCPP_INLINE_VISIBILITY
1696 explicit __begin_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
1697 : base(__s), __mexp_(__mexp) {}
1699 virtual void __exec(__state&) const;
1702 template <class _CharT>
1704 __begin_marked_subexpression<_CharT>::__exec(__state& __s) const
1706 __s.__do_ = __state::__accept_but_not_consume;
1707 __s.__sub_matches_[__mexp_-1].first = __s.__current_;
1708 __s.__node_ = this->first();
1711 // __end_marked_subexpression
1713 template <class _CharT>
1714 class __end_marked_subexpression
1715 : public __owns_one_state<_CharT>
1717 typedef __owns_one_state<_CharT> base;
1721 typedef _VSTD::__state<_CharT> __state;
1723 _LIBCPP_INLINE_VISIBILITY
1724 explicit __end_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
1725 : base(__s), __mexp_(__mexp) {}
1727 virtual void __exec(__state&) const;
1730 template <class _CharT>
1732 __end_marked_subexpression<_CharT>::__exec(__state& __s) const
1734 __s.__do_ = __state::__accept_but_not_consume;
1735 __s.__sub_matches_[__mexp_-1].second = __s.__current_;
1736 __s.__sub_matches_[__mexp_-1].matched = true;
1737 __s.__node_ = this->first();
1742 template <class _CharT>
1744 : public __owns_one_state<_CharT>
1746 typedef __owns_one_state<_CharT> base;
1750 typedef _VSTD::__state<_CharT> __state;
1752 _LIBCPP_INLINE_VISIBILITY
1753 explicit __back_ref(unsigned __mexp, __node<_CharT>* __s)
1754 : base(__s), __mexp_(__mexp) {}
1756 virtual void __exec(__state&) const;
1759 template <class _CharT>
1761 __back_ref<_CharT>::__exec(__state& __s) const
1763 if (__mexp_ > __s.__sub_matches_.size())
1764 __throw_regex_error<regex_constants::error_backref>();
1765 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1768 ptrdiff_t __len = __sm.second - __sm.first;
1769 if (__s.__last_ - __s.__current_ >= __len &&
1770 _VSTD::equal(__sm.first, __sm.second, __s.__current_))
1772 __s.__do_ = __state::__accept_but_not_consume;
1773 __s.__current_ += __len;
1774 __s.__node_ = this->first();
1778 __s.__do_ = __state::__reject;
1779 __s.__node_ = nullptr;
1784 __s.__do_ = __state::__reject;
1785 __s.__node_ = nullptr;
1791 template <class _CharT, class _Traits>
1792 class __back_ref_icase
1793 : public __owns_one_state<_CharT>
1795 typedef __owns_one_state<_CharT> base;
1800 typedef _VSTD::__state<_CharT> __state;
1802 _LIBCPP_INLINE_VISIBILITY
1803 explicit __back_ref_icase(const _Traits& __traits, unsigned __mexp,
1804 __node<_CharT>* __s)
1805 : base(__s), __traits_(__traits), __mexp_(__mexp) {}
1807 virtual void __exec(__state&) const;
1810 template <class _CharT, class _Traits>
1812 __back_ref_icase<_CharT, _Traits>::__exec(__state& __s) const
1814 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1817 ptrdiff_t __len = __sm.second - __sm.first;
1818 if (__s.__last_ - __s.__current_ >= __len)
1820 for (ptrdiff_t __i = 0; __i < __len; ++__i)
1822 if (__traits_.translate_nocase(__sm.first[__i]) !=
1823 __traits_.translate_nocase(__s.__current_[__i]))
1826 __s.__do_ = __state::__accept_but_not_consume;
1827 __s.__current_ += __len;
1828 __s.__node_ = this->first();
1832 __s.__do_ = __state::__reject;
1833 __s.__node_ = nullptr;
1839 __s.__do_ = __state::__reject;
1840 __s.__node_ = nullptr;
1844 // __back_ref_collate
1846 template <class _CharT, class _Traits>
1847 class __back_ref_collate
1848 : public __owns_one_state<_CharT>
1850 typedef __owns_one_state<_CharT> base;
1855 typedef _VSTD::__state<_CharT> __state;
1857 _LIBCPP_INLINE_VISIBILITY
1858 explicit __back_ref_collate(const _Traits& __traits, unsigned __mexp,
1859 __node<_CharT>* __s)
1860 : base(__s), __traits_(__traits), __mexp_(__mexp) {}
1862 virtual void __exec(__state&) const;
1865 template <class _CharT, class _Traits>
1867 __back_ref_collate<_CharT, _Traits>::__exec(__state& __s) const
1869 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
1872 ptrdiff_t __len = __sm.second - __sm.first;
1873 if (__s.__last_ - __s.__current_ >= __len)
1875 for (ptrdiff_t __i = 0; __i < __len; ++__i)
1877 if (__traits_.translate(__sm.first[__i]) !=
1878 __traits_.translate(__s.__current_[__i]))
1881 __s.__do_ = __state::__accept_but_not_consume;
1882 __s.__current_ += __len;
1883 __s.__node_ = this->first();
1887 __s.__do_ = __state::__reject;
1888 __s.__node_ = nullptr;
1894 __s.__do_ = __state::__reject;
1895 __s.__node_ = nullptr;
1901 template <class _CharT, class _Traits>
1902 class __word_boundary
1903 : public __owns_one_state<_CharT>
1905 typedef __owns_one_state<_CharT> base;
1910 typedef _VSTD::__state<_CharT> __state;
1912 _LIBCPP_INLINE_VISIBILITY
1913 explicit __word_boundary(const _Traits& __traits, bool __invert,
1914 __node<_CharT>* __s)
1915 : base(__s), __traits_(__traits), __invert_(__invert) {}
1917 virtual void __exec(__state&) const;
1920 template <class _CharT, class _Traits>
1922 __word_boundary<_CharT, _Traits>::__exec(__state& __s) const
1924 bool __is_word_b = false;
1925 if (__s.__first_ != __s.__last_)
1927 if (__s.__current_ == __s.__last_)
1929 if (!(__s.__flags_ & regex_constants::match_not_eow))
1931 _CharT __c = __s.__current_[-1];
1932 __is_word_b = __c == '_' ||
1933 __traits_.isctype(__c, ctype_base::alnum);
1936 else if (__s.__current_ == __s.__first_ &&
1937 !(__s.__flags_ & regex_constants::match_prev_avail))
1939 if (!(__s.__flags_ & regex_constants::match_not_bow))
1941 _CharT __c = *__s.__current_;
1942 __is_word_b = __c == '_' ||
1943 __traits_.isctype(__c, ctype_base::alnum);
1948 _CharT __c1 = __s.__current_[-1];
1949 _CharT __c2 = *__s.__current_;
1950 bool __is_c1_b = __c1 == '_' ||
1951 __traits_.isctype(__c1, ctype_base::alnum);
1952 bool __is_c2_b = __c2 == '_' ||
1953 __traits_.isctype(__c2, ctype_base::alnum);
1954 __is_word_b = __is_c1_b != __is_c2_b;
1957 if (__is_word_b != __invert_)
1959 __s.__do_ = __state::__accept_but_not_consume;
1960 __s.__node_ = this->first();
1964 __s.__do_ = __state::__reject;
1965 __s.__node_ = nullptr;
1971 template <class _CharT>
1973 : public __owns_one_state<_CharT>
1975 typedef __owns_one_state<_CharT> base;
1978 typedef _VSTD::__state<_CharT> __state;
1980 _LIBCPP_INLINE_VISIBILITY
1981 __l_anchor(__node<_CharT>* __s)
1984 virtual void __exec(__state&) const;
1987 template <class _CharT>
1989 __l_anchor<_CharT>::__exec(__state& __s) const
1991 if (__s.__at_first_ && __s.__current_ == __s.__first_ &&
1992 !(__s.__flags_ & regex_constants::match_not_bol))
1994 __s.__do_ = __state::__accept_but_not_consume;
1995 __s.__node_ = this->first();
1999 __s.__do_ = __state::__reject;
2000 __s.__node_ = nullptr;
2006 template <class _CharT>
2008 : public __owns_one_state<_CharT>
2010 typedef __owns_one_state<_CharT> base;
2013 typedef _VSTD::__state<_CharT> __state;
2015 _LIBCPP_INLINE_VISIBILITY
2016 __r_anchor(__node<_CharT>* __s)
2019 virtual void __exec(__state&) const;
2022 template <class _CharT>
2024 __r_anchor<_CharT>::__exec(__state& __s) const
2026 if (__s.__current_ == __s.__last_ &&
2027 !(__s.__flags_ & regex_constants::match_not_eol))
2029 __s.__do_ = __state::__accept_but_not_consume;
2030 __s.__node_ = this->first();
2034 __s.__do_ = __state::__reject;
2035 __s.__node_ = nullptr;
2041 template <class _CharT>
2043 : public __owns_one_state<_CharT>
2045 typedef __owns_one_state<_CharT> base;
2048 typedef _VSTD::__state<_CharT> __state;
2050 _LIBCPP_INLINE_VISIBILITY
2051 __match_any(__node<_CharT>* __s)
2054 virtual void __exec(__state&) const;
2057 template <class _CharT>
2059 __match_any<_CharT>::__exec(__state& __s) const
2061 if (__s.__current_ != __s.__last_ && *__s.__current_ != 0)
2063 __s.__do_ = __state::__accept_and_consume;
2065 __s.__node_ = this->first();
2069 __s.__do_ = __state::__reject;
2070 __s.__node_ = nullptr;
2074 // __match_any_but_newline
2076 template <class _CharT>
2077 class __match_any_but_newline
2078 : public __owns_one_state<_CharT>
2080 typedef __owns_one_state<_CharT> base;
2083 typedef _VSTD::__state<_CharT> __state;
2085 _LIBCPP_INLINE_VISIBILITY
2086 __match_any_but_newline(__node<_CharT>* __s)
2089 virtual void __exec(__state&) const;
2092 template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const;
2093 template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<wchar_t>::__exec(__state&) const;
2097 template <class _CharT>
2099 : public __owns_one_state<_CharT>
2101 typedef __owns_one_state<_CharT> base;
2105 __match_char(const __match_char&);
2106 __match_char& operator=(const __match_char&);
2108 typedef _VSTD::__state<_CharT> __state;
2110 _LIBCPP_INLINE_VISIBILITY
2111 __match_char(_CharT __c, __node<_CharT>* __s)
2112 : base(__s), __c_(__c) {}
2114 virtual void __exec(__state&) const;
2117 template <class _CharT>
2119 __match_char<_CharT>::__exec(__state& __s) const
2121 if (__s.__current_ != __s.__last_ && *__s.__current_ == __c_)
2123 __s.__do_ = __state::__accept_and_consume;
2125 __s.__node_ = this->first();
2129 __s.__do_ = __state::__reject;
2130 __s.__node_ = nullptr;
2134 // __match_char_icase
2136 template <class _CharT, class _Traits>
2137 class __match_char_icase
2138 : public __owns_one_state<_CharT>
2140 typedef __owns_one_state<_CharT> base;
2145 __match_char_icase(const __match_char_icase&);
2146 __match_char_icase& operator=(const __match_char_icase&);
2148 typedef _VSTD::__state<_CharT> __state;
2150 _LIBCPP_INLINE_VISIBILITY
2151 __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
2152 : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {}
2154 virtual void __exec(__state&) const;
2157 template <class _CharT, class _Traits>
2159 __match_char_icase<_CharT, _Traits>::__exec(__state& __s) const
2161 if (__s.__current_ != __s.__last_ &&
2162 __traits_.translate_nocase(*__s.__current_) == __c_)
2164 __s.__do_ = __state::__accept_and_consume;
2166 __s.__node_ = this->first();
2170 __s.__do_ = __state::__reject;
2171 __s.__node_ = nullptr;
2175 // __match_char_collate
2177 template <class _CharT, class _Traits>
2178 class __match_char_collate
2179 : public __owns_one_state<_CharT>
2181 typedef __owns_one_state<_CharT> base;
2186 __match_char_collate(const __match_char_collate&);
2187 __match_char_collate& operator=(const __match_char_collate&);
2189 typedef _VSTD::__state<_CharT> __state;
2191 _LIBCPP_INLINE_VISIBILITY
2192 __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
2193 : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {}
2195 virtual void __exec(__state&) const;
2198 template <class _CharT, class _Traits>
2200 __match_char_collate<_CharT, _Traits>::__exec(__state& __s) const
2202 if (__s.__current_ != __s.__last_ &&
2203 __traits_.translate(*__s.__current_) == __c_)
2205 __s.__do_ = __state::__accept_and_consume;
2207 __s.__node_ = this->first();
2211 __s.__do_ = __state::__reject;
2212 __s.__node_ = nullptr;
2216 // __bracket_expression
2218 template <class _CharT, class _Traits>
2219 class __bracket_expression
2220 : public __owns_one_state<_CharT>
2222 typedef __owns_one_state<_CharT> base;
2223 typedef typename _Traits::string_type string_type;
2226 vector<_CharT> __chars_;
2227 vector<_CharT> __neg_chars_;
2228 vector<pair<string_type, string_type> > __ranges_;
2229 vector<pair<_CharT, _CharT> > __digraphs_;
2230 vector<string_type> __equivalences_;
2231 typename regex_traits<_CharT>::char_class_type __mask_;
2232 typename regex_traits<_CharT>::char_class_type __neg_mask_;
2236 bool __might_have_digraph_;
2238 __bracket_expression(const __bracket_expression&);
2239 __bracket_expression& operator=(const __bracket_expression&);
2241 typedef _VSTD::__state<_CharT> __state;
2243 _LIBCPP_INLINE_VISIBILITY
2244 __bracket_expression(const _Traits& __traits, __node<_CharT>* __s,
2245 bool __negate, bool __icase, bool __collate)
2246 : base(__s), __traits_(__traits), __mask_(), __neg_mask_(),
2247 __negate_(__negate), __icase_(__icase), __collate_(__collate),
2248 __might_have_digraph_(__traits_.getloc().name() != "C") {}
2250 virtual void __exec(__state&) const;
2252 _LIBCPP_INLINE_VISIBILITY
2253 bool __negated() const {return __negate_;}
2255 _LIBCPP_INLINE_VISIBILITY
2256 void __add_char(_CharT __c)
2259 __chars_.push_back(__traits_.translate_nocase(__c));
2260 else if (__collate_)
2261 __chars_.push_back(__traits_.translate(__c));
2263 __chars_.push_back(__c);
2265 _LIBCPP_INLINE_VISIBILITY
2266 void __add_neg_char(_CharT __c)
2269 __neg_chars_.push_back(__traits_.translate_nocase(__c));
2270 else if (__collate_)
2271 __neg_chars_.push_back(__traits_.translate(__c));
2273 __neg_chars_.push_back(__c);
2275 _LIBCPP_INLINE_VISIBILITY
2276 void __add_range(string_type __b, string_type __e)
2282 for (size_t __i = 0; __i < __b.size(); ++__i)
2283 __b[__i] = __traits_.translate_nocase(__b[__i]);
2284 for (size_t __i = 0; __i < __e.size(); ++__i)
2285 __e[__i] = __traits_.translate_nocase(__e[__i]);
2289 for (size_t __i = 0; __i < __b.size(); ++__i)
2290 __b[__i] = __traits_.translate(__b[__i]);
2291 for (size_t __i = 0; __i < __e.size(); ++__i)
2292 __e[__i] = __traits_.translate(__e[__i]);
2294 __ranges_.push_back(make_pair(
2295 __traits_.transform(__b.begin(), __b.end()),
2296 __traits_.transform(__e.begin(), __e.end())));
2300 if (__b.size() != 1 || __e.size() != 1)
2301 __throw_regex_error<regex_constants::error_range>();
2304 __b[0] = __traits_.translate_nocase(__b[0]);
2305 __e[0] = __traits_.translate_nocase(__e[0]);
2307 __ranges_.push_back(make_pair(_VSTD::move(__b), _VSTD::move(__e)));
2310 _LIBCPP_INLINE_VISIBILITY
2311 void __add_digraph(_CharT __c1, _CharT __c2)
2314 __digraphs_.push_back(make_pair(__traits_.translate_nocase(__c1),
2315 __traits_.translate_nocase(__c2)));
2316 else if (__collate_)
2317 __digraphs_.push_back(make_pair(__traits_.translate(__c1),
2318 __traits_.translate(__c2)));
2320 __digraphs_.push_back(make_pair(__c1, __c2));
2322 _LIBCPP_INLINE_VISIBILITY
2323 void __add_equivalence(const string_type& __s)
2324 {__equivalences_.push_back(__s);}
2325 _LIBCPP_INLINE_VISIBILITY
2326 void __add_class(typename regex_traits<_CharT>::char_class_type __mask)
2327 {__mask_ |= __mask;}
2328 _LIBCPP_INLINE_VISIBILITY
2329 void __add_neg_class(typename regex_traits<_CharT>::char_class_type __mask)
2330 {__neg_mask_ |= __mask;}
2333 template <class _CharT, class _Traits>
2335 __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const
2337 bool __found = false;
2338 unsigned __consumed = 0;
2339 if (__s.__current_ != __s.__last_)
2342 if (__might_have_digraph_)
2344 const _CharT* __next = _VSTD::next(__s.__current_);
2345 if (__next != __s.__last_)
2347 pair<_CharT, _CharT> __ch2(*__s.__current_, *__next);
2350 __ch2.first = __traits_.translate_nocase(__ch2.first);
2351 __ch2.second = __traits_.translate_nocase(__ch2.second);
2353 else if (__collate_)
2355 __ch2.first = __traits_.translate(__ch2.first);
2356 __ch2.second = __traits_.translate(__ch2.second);
2358 if (!__traits_.lookup_collatename(&__ch2.first, &__ch2.first+2).empty())
2360 // __ch2 is a digraph in this locale
2362 for (size_t __i = 0; __i < __digraphs_.size(); ++__i)
2364 if (__ch2 == __digraphs_[__i])
2370 if (__collate_ && !__ranges_.empty())
2372 string_type __s2 = __traits_.transform(&__ch2.first,
2374 for (size_t __i = 0; __i < __ranges_.size(); ++__i)
2376 if (__ranges_[__i].first <= __s2 &&
2377 __s2 <= __ranges_[__i].second)
2384 if (!__equivalences_.empty())
2386 string_type __s2 = __traits_.transform_primary(&__ch2.first,
2388 for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
2390 if (__s2 == __equivalences_[__i])
2397 if (__traits_.isctype(__ch2.first, __mask_) &&
2398 __traits_.isctype(__ch2.second, __mask_))
2403 if (!__traits_.isctype(__ch2.first, __neg_mask_) &&
2404 !__traits_.isctype(__ch2.second, __neg_mask_))
2413 // test *__s.__current_ as not a digraph
2414 _CharT __ch = *__s.__current_;
2416 __ch = __traits_.translate_nocase(__ch);
2417 else if (__collate_)
2418 __ch = __traits_.translate(__ch);
2419 for (size_t __i = 0; __i < __chars_.size(); ++__i)
2421 if (__ch == __chars_[__i])
2427 // When there's at least one of __neg_chars_ and __neg_mask_, the set
2428 // of "__found" chars is
2429 // union(complement(union(__neg_chars_, __neg_mask_)),
2432 // It doesn't make sense to check this when there are no __neg_chars_
2433 // and no __neg_mask_.
2434 if (!(__neg_mask_ == 0 && __neg_chars_.empty()))
2436 const bool __in_neg_mask = __traits_.isctype(__ch, __neg_mask_);
2437 const bool __in_neg_chars =
2438 std::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) !=
2440 if (!(__in_neg_mask || __in_neg_chars))
2446 if (!__ranges_.empty())
2448 string_type __s2 = __collate_ ?
2449 __traits_.transform(&__ch, &__ch + 1) :
2450 string_type(1, __ch);
2451 for (size_t __i = 0; __i < __ranges_.size(); ++__i)
2453 if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second)
2460 if (!__equivalences_.empty())
2462 string_type __s2 = __traits_.transform_primary(&__ch, &__ch + 1);
2463 for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
2465 if (__s2 == __equivalences_[__i])
2472 if (__traits_.isctype(__ch, __mask_))
2479 __found = __negate_; // force reject
2481 if (__found != __negate_)
2483 __s.__do_ = __state::__accept_and_consume;
2484 __s.__current_ += __consumed;
2485 __s.__node_ = this->first();
2489 __s.__do_ = __state::__reject;
2490 __s.__node_ = nullptr;
2494 template <class _CharT, class _Traits> class __lookahead;
2496 template <class _CharT, class _Traits = regex_traits<_CharT> >
2497 class _LIBCPP_TEMPLATE_VIS basic_regex
2501 typedef _CharT value_type;
2502 typedef _Traits traits_type;
2503 typedef typename _Traits::string_type string_type;
2504 typedef regex_constants::syntax_option_type flag_type;
2505 typedef typename _Traits::locale_type locale_type;
2510 unsigned __marked_count_;
2511 unsigned __loop_count_;
2513 shared_ptr<__empty_state<_CharT> > __start_;
2514 __owns_one_state<_CharT>* __end_;
2516 typedef _VSTD::__state<_CharT> __state;
2517 typedef _VSTD::__node<_CharT> __node;
2521 static const regex_constants::syntax_option_type icase = regex_constants::icase;
2522 static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
2523 static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
2524 static const regex_constants::syntax_option_type collate = regex_constants::collate;
2525 static const regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
2526 static const regex_constants::syntax_option_type basic = regex_constants::basic;
2527 static const regex_constants::syntax_option_type extended = regex_constants::extended;
2528 static const regex_constants::syntax_option_type awk = regex_constants::awk;
2529 static const regex_constants::syntax_option_type grep = regex_constants::grep;
2530 static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
2532 // construct/copy/destroy:
2533 _LIBCPP_INLINE_VISIBILITY
2535 : __flags_(regex_constants::ECMAScript), __marked_count_(0), __loop_count_(0), __open_count_(0),
2538 _LIBCPP_INLINE_VISIBILITY
2539 explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
2540 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2543 __init(__p, __p + __traits_.length(__p));
2546 _LIBCPP_INLINE_VISIBILITY
2547 basic_regex(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
2548 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2551 __init(__p, __p + __len);
2554 // basic_regex(const basic_regex&) = default;
2555 // basic_regex(basic_regex&&) = default;
2556 template <class _ST, class _SA>
2557 _LIBCPP_INLINE_VISIBILITY
2558 explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p,
2559 flag_type __f = regex_constants::ECMAScript)
2560 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2563 __init(__p.begin(), __p.end());
2566 template <class _ForwardIterator>
2567 _LIBCPP_INLINE_VISIBILITY
2568 basic_regex(_ForwardIterator __first, _ForwardIterator __last,
2569 flag_type __f = regex_constants::ECMAScript)
2570 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2573 __init(__first, __last);
2575 #ifndef _LIBCPP_CXX03_LANG
2576 _LIBCPP_INLINE_VISIBILITY
2577 basic_regex(initializer_list<value_type> __il,
2578 flag_type __f = regex_constants::ECMAScript)
2579 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
2582 __init(__il.begin(), __il.end());
2584 #endif // _LIBCPP_CXX03_LANG
2586 // ~basic_regex() = default;
2588 // basic_regex& operator=(const basic_regex&) = default;
2589 // basic_regex& operator=(basic_regex&&) = default;
2590 _LIBCPP_INLINE_VISIBILITY
2591 basic_regex& operator=(const value_type* __p)
2592 {return assign(__p);}
2593 #ifndef _LIBCPP_CXX03_LANG
2594 _LIBCPP_INLINE_VISIBILITY
2595 basic_regex& operator=(initializer_list<value_type> __il)
2596 {return assign(__il);}
2597 #endif // _LIBCPP_CXX03_LANG
2598 template <class _ST, class _SA>
2599 _LIBCPP_INLINE_VISIBILITY
2600 basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p)
2601 {return assign(__p);}
2604 _LIBCPP_INLINE_VISIBILITY
2605 basic_regex& assign(const basic_regex& __that)
2606 {return *this = __that;}
2607 #ifndef _LIBCPP_CXX03_LANG
2608 _LIBCPP_INLINE_VISIBILITY
2609 basic_regex& assign(basic_regex&& __that) _NOEXCEPT
2610 {return *this = _VSTD::move(__that);}
2612 _LIBCPP_INLINE_VISIBILITY
2613 basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
2614 {return assign(__p, __p + __traits_.length(__p), __f);}
2615 _LIBCPP_INLINE_VISIBILITY
2616 basic_regex& assign(const value_type* __p, size_t __len, flag_type __f = regex_constants::ECMAScript)
2617 {return assign(__p, __p + __len, __f);}
2618 template <class _ST, class _SA>
2619 _LIBCPP_INLINE_VISIBILITY
2620 basic_regex& assign(const basic_string<value_type, _ST, _SA>& __s,
2621 flag_type __f = regex_constants::ECMAScript)
2622 {return assign(__s.begin(), __s.end(), __f);}
2624 template <class _InputIterator>
2625 _LIBCPP_INLINE_VISIBILITY
2628 __is_cpp17_input_iterator <_InputIterator>::value &&
2629 !__is_cpp17_forward_iterator<_InputIterator>::value,
2632 assign(_InputIterator __first, _InputIterator __last,
2633 flag_type __f = regex_constants::ECMAScript)
2635 basic_string<_CharT> __t(__first, __last);
2636 return assign(__t.begin(), __t.end(), __f);
2640 _LIBCPP_INLINE_VISIBILITY
2641 void __member_init(flag_type __f)
2644 __marked_count_ = 0;
2651 template <class _ForwardIterator>
2652 _LIBCPP_INLINE_VISIBILITY
2655 __is_cpp17_forward_iterator<_ForwardIterator>::value,
2658 assign(_ForwardIterator __first, _ForwardIterator __last,
2659 flag_type __f = regex_constants::ECMAScript)
2661 return assign(basic_regex(__first, __last, __f));
2664 #ifndef _LIBCPP_CXX03_LANG
2666 _LIBCPP_INLINE_VISIBILITY
2667 basic_regex& assign(initializer_list<value_type> __il,
2668 flag_type __f = regex_constants::ECMAScript)
2669 {return assign(__il.begin(), __il.end(), __f);}
2671 #endif // _LIBCPP_CXX03_LANG
2673 // const operations:
2674 _LIBCPP_INLINE_VISIBILITY
2675 unsigned mark_count() const {return __marked_count_;}
2676 _LIBCPP_INLINE_VISIBILITY
2677 flag_type flags() const {return __flags_;}
2680 _LIBCPP_INLINE_VISIBILITY
2681 locale_type imbue(locale_type __loc)
2683 __member_init(ECMAScript);
2685 return __traits_.imbue(__loc);
2687 _LIBCPP_INLINE_VISIBILITY
2688 locale_type getloc() const {return __traits_.getloc();}
2691 void swap(basic_regex& __r);
2694 _LIBCPP_INLINE_VISIBILITY
2695 unsigned __loop_count() const {return __loop_count_;}
2697 template <class _ForwardIterator>
2699 __init(_ForwardIterator __first, _ForwardIterator __last);
2700 template <class _ForwardIterator>
2702 __parse(_ForwardIterator __first, _ForwardIterator __last);
2703 template <class _ForwardIterator>
2705 __parse_basic_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
2706 template <class _ForwardIterator>
2708 __parse_RE_expression(_ForwardIterator __first, _ForwardIterator __last);
2709 template <class _ForwardIterator>
2711 __parse_simple_RE(_ForwardIterator __first, _ForwardIterator __last);
2712 template <class _ForwardIterator>
2714 __parse_nondupl_RE(_ForwardIterator __first, _ForwardIterator __last);
2715 template <class _ForwardIterator>
2717 __parse_one_char_or_coll_elem_RE(_ForwardIterator __first, _ForwardIterator __last);
2718 template <class _ForwardIterator>
2720 __parse_Back_open_paren(_ForwardIterator __first, _ForwardIterator __last);
2721 template <class _ForwardIterator>
2723 __parse_Back_close_paren(_ForwardIterator __first, _ForwardIterator __last);
2724 template <class _ForwardIterator>
2726 __parse_Back_open_brace(_ForwardIterator __first, _ForwardIterator __last);
2727 template <class _ForwardIterator>
2729 __parse_Back_close_brace(_ForwardIterator __first, _ForwardIterator __last);
2730 template <class _ForwardIterator>
2732 __parse_BACKREF(_ForwardIterator __first, _ForwardIterator __last);
2733 template <class _ForwardIterator>
2735 __parse_ORD_CHAR(_ForwardIterator __first, _ForwardIterator __last);
2736 template <class _ForwardIterator>
2738 __parse_QUOTED_CHAR(_ForwardIterator __first, _ForwardIterator __last);
2739 template <class _ForwardIterator>
2741 __parse_RE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
2742 __owns_one_state<_CharT>* __s,
2743 unsigned __mexp_begin, unsigned __mexp_end);
2744 template <class _ForwardIterator>
2746 __parse_ERE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
2747 __owns_one_state<_CharT>* __s,
2748 unsigned __mexp_begin, unsigned __mexp_end);
2749 template <class _ForwardIterator>
2751 __parse_bracket_expression(_ForwardIterator __first, _ForwardIterator __last);
2752 template <class _ForwardIterator>
2754 __parse_follow_list(_ForwardIterator __first, _ForwardIterator __last,
2755 __bracket_expression<_CharT, _Traits>* __ml);
2756 template <class _ForwardIterator>
2758 __parse_expression_term(_ForwardIterator __first, _ForwardIterator __last,
2759 __bracket_expression<_CharT, _Traits>* __ml);
2760 template <class _ForwardIterator>
2762 __parse_equivalence_class(_ForwardIterator __first, _ForwardIterator __last,
2763 __bracket_expression<_CharT, _Traits>* __ml);
2764 template <class _ForwardIterator>
2766 __parse_character_class(_ForwardIterator __first, _ForwardIterator __last,
2767 __bracket_expression<_CharT, _Traits>* __ml);
2768 template <class _ForwardIterator>
2770 __parse_collating_symbol(_ForwardIterator __first, _ForwardIterator __last,
2771 basic_string<_CharT>& __col_sym);
2772 template <class _ForwardIterator>
2774 __parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c);
2775 template <class _ForwardIterator>
2777 __parse_extended_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
2778 template <class _ForwardIterator>
2780 __parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last);
2781 template <class _ForwardIterator>
2783 __parse_ERE_expression(_ForwardIterator __first, _ForwardIterator __last);
2784 template <class _ForwardIterator>
2786 __parse_one_char_or_coll_elem_ERE(_ForwardIterator __first, _ForwardIterator __last);
2787 template <class _ForwardIterator>
2789 __parse_ORD_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
2790 template <class _ForwardIterator>
2792 __parse_QUOTED_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
2793 template <class _ForwardIterator>
2795 __parse_ecma_exp(_ForwardIterator __first, _ForwardIterator __last);
2796 template <class _ForwardIterator>
2798 __parse_alternative(_ForwardIterator __first, _ForwardIterator __last);
2799 template <class _ForwardIterator>
2801 __parse_term(_ForwardIterator __first, _ForwardIterator __last);
2802 template <class _ForwardIterator>
2804 __parse_assertion(_ForwardIterator __first, _ForwardIterator __last);
2805 template <class _ForwardIterator>
2807 __parse_atom(_ForwardIterator __first, _ForwardIterator __last);
2808 template <class _ForwardIterator>
2810 __parse_atom_escape(_ForwardIterator __first, _ForwardIterator __last);
2811 template <class _ForwardIterator>
2813 __parse_decimal_escape(_ForwardIterator __first, _ForwardIterator __last);
2814 template <class _ForwardIterator>
2816 __parse_character_class_escape(_ForwardIterator __first, _ForwardIterator __last);
2817 template <class _ForwardIterator>
2819 __parse_character_escape(_ForwardIterator __first, _ForwardIterator __last,
2820 basic_string<_CharT>* __str = nullptr);
2821 template <class _ForwardIterator>
2823 __parse_pattern_character(_ForwardIterator __first, _ForwardIterator __last);
2824 template <class _ForwardIterator>
2826 __parse_grep(_ForwardIterator __first, _ForwardIterator __last);
2827 template <class _ForwardIterator>
2829 __parse_egrep(_ForwardIterator __first, _ForwardIterator __last);
2830 template <class _ForwardIterator>
2832 __parse_class_escape(_ForwardIterator __first, _ForwardIterator __last,
2833 basic_string<_CharT>& __str,
2834 __bracket_expression<_CharT, _Traits>* __ml);
2835 template <class _ForwardIterator>
2837 __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last,
2838 basic_string<_CharT>* __str = nullptr);
2840 _LIBCPP_INLINE_VISIBILITY
2841 void __push_l_anchor();
2842 void __push_r_anchor();
2843 void __push_match_any();
2844 void __push_match_any_but_newline();
2845 _LIBCPP_INLINE_VISIBILITY
2846 void __push_greedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
2847 unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
2848 {__push_loop(__min, numeric_limits<size_t>::max(), __s,
2849 __mexp_begin, __mexp_end);}
2850 _LIBCPP_INLINE_VISIBILITY
2851 void __push_nongreedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
2852 unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
2853 {__push_loop(__min, numeric_limits<size_t>::max(), __s,
2854 __mexp_begin, __mexp_end, false);}
2855 void __push_loop(size_t __min, size_t __max, __owns_one_state<_CharT>* __s,
2856 size_t __mexp_begin = 0, size_t __mexp_end = 0,
2857 bool __greedy = true);
2858 __bracket_expression<_CharT, _Traits>* __start_matching_list(bool __negate);
2859 void __push_char(value_type __c);
2860 void __push_back_ref(int __i);
2861 void __push_alternation(__owns_one_state<_CharT>* __sa,
2862 __owns_one_state<_CharT>* __sb);
2863 void __push_begin_marked_subexpression();
2864 void __push_end_marked_subexpression(unsigned);
2865 void __push_empty();
2866 void __push_word_boundary(bool);
2867 void __push_lookahead(const basic_regex&, bool, unsigned);
2869 template <class _Allocator>
2871 __search(const _CharT* __first, const _CharT* __last,
2872 match_results<const _CharT*, _Allocator>& __m,
2873 regex_constants::match_flag_type __flags) const;
2875 template <class _Allocator>
2877 __match_at_start(const _CharT* __first, const _CharT* __last,
2878 match_results<const _CharT*, _Allocator>& __m,
2879 regex_constants::match_flag_type __flags, bool) const;
2880 template <class _Allocator>
2882 __match_at_start_ecma(const _CharT* __first, const _CharT* __last,
2883 match_results<const _CharT*, _Allocator>& __m,
2884 regex_constants::match_flag_type __flags, bool) const;
2885 template <class _Allocator>
2887 __match_at_start_posix_nosubs(const _CharT* __first, const _CharT* __last,
2888 match_results<const _CharT*, _Allocator>& __m,
2889 regex_constants::match_flag_type __flags, bool) const;
2890 template <class _Allocator>
2892 __match_at_start_posix_subs(const _CharT* __first, const _CharT* __last,
2893 match_results<const _CharT*, _Allocator>& __m,
2894 regex_constants::match_flag_type __flags, bool) const;
2896 template <class _Bp, class _Ap, class _Cp, class _Tp>
2899 regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
2900 regex_constants::match_flag_type);
2902 template <class _Ap, class _Cp, class _Tp>
2905 regex_search(const _Cp*, const _Cp*, match_results<const _Cp*, _Ap>&,
2906 const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
2908 template <class _Bp, class _Cp, class _Tp>
2911 regex_search(_Bp, _Bp, const basic_regex<_Cp, _Tp>&,
2912 regex_constants::match_flag_type);
2914 template <class _Cp, class _Tp>
2917 regex_search(const _Cp*, const _Cp*,
2918 const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
2920 template <class _Cp, class _Ap, class _Tp>
2923 regex_search(const _Cp*, match_results<const _Cp*, _Ap>&, const basic_regex<_Cp, _Tp>&,
2924 regex_constants::match_flag_type);
2926 template <class _ST, class _SA, class _Cp, class _Tp>
2929 regex_search(const basic_string<_Cp, _ST, _SA>& __s,
2930 const basic_regex<_Cp, _Tp>& __e,
2931 regex_constants::match_flag_type __flags);
2933 template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
2936 regex_search(const basic_string<_Cp, _ST, _SA>& __s,
2937 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
2938 const basic_regex<_Cp, _Tp>& __e,
2939 regex_constants::match_flag_type __flags);
2941 template <class _Iter, class _Ap, class _Cp, class _Tp>
2944 regex_search(__wrap_iter<_Iter> __first,
2945 __wrap_iter<_Iter> __last,
2946 match_results<__wrap_iter<_Iter>, _Ap>& __m,
2947 const basic_regex<_Cp, _Tp>& __e,
2948 regex_constants::match_flag_type __flags);
2950 template <class, class> friend class __lookahead;
2953 #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
2954 template <class _ForwardIterator,
2955 class = typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value, nullptr_t>::type
2957 basic_regex(_ForwardIterator, _ForwardIterator,
2958 regex_constants::syntax_option_type = regex_constants::ECMAScript)
2959 -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>;
2962 template <class _CharT, class _Traits>
2963 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;
2964 template <class _CharT, class _Traits>
2965 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::nosubs;
2966 template <class _CharT, class _Traits>
2967 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::optimize;
2968 template <class _CharT, class _Traits>
2969 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::collate;
2970 template <class _CharT, class _Traits>
2971 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::ECMAScript;
2972 template <class _CharT, class _Traits>
2973 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::basic;
2974 template <class _CharT, class _Traits>
2975 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::extended;
2976 template <class _CharT, class _Traits>
2977 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::awk;
2978 template <class _CharT, class _Traits>
2979 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::grep;
2980 template <class _CharT, class _Traits>
2981 const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::egrep;
2983 template <class _CharT, class _Traits>
2985 basic_regex<_CharT, _Traits>::swap(basic_regex& __r)
2988 swap(__traits_, __r.__traits_);
2989 swap(__flags_, __r.__flags_);
2990 swap(__marked_count_, __r.__marked_count_);
2991 swap(__loop_count_, __r.__loop_count_);
2992 swap(__open_count_, __r.__open_count_);
2993 swap(__start_, __r.__start_);
2994 swap(__end_, __r.__end_);
2997 template <class _CharT, class _Traits>
2998 inline _LIBCPP_INLINE_VISIBILITY
3000 swap(basic_regex<_CharT, _Traits>& __x, basic_regex<_CharT, _Traits>& __y)
3002 return __x.swap(__y);
3007 template <class _CharT, class _Traits>
3009 : public __owns_one_state<_CharT>
3011 typedef __owns_one_state<_CharT> base;
3013 basic_regex<_CharT, _Traits> __exp_;
3017 __lookahead(const __lookahead&);
3018 __lookahead& operator=(const __lookahead&);
3020 typedef _VSTD::__state<_CharT> __state;
3022 _LIBCPP_INLINE_VISIBILITY
3023 __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp)
3024 : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {}
3026 virtual void __exec(__state&) const;
3029 template <class _CharT, class _Traits>
3031 __lookahead<_CharT, _Traits>::__exec(__state& __s) const
3033 match_results<const _CharT*> __m;
3034 __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
3035 bool __matched = __exp_.__match_at_start_ecma(
3036 __s.__current_, __s.__last_,
3038 (__s.__flags_ | regex_constants::match_continuous) &
3039 ~regex_constants::__full_match,
3040 __s.__at_first_ && __s.__current_ == __s.__first_);
3041 if (__matched != __invert_)
3043 __s.__do_ = __state::__accept_but_not_consume;
3044 __s.__node_ = this->first();
3045 for (unsigned __i = 1; __i < __m.size(); ++__i) {
3046 __s.__sub_matches_[__mexp_ + __i - 1] = __m.__matches_[__i];
3051 __s.__do_ = __state::__reject;
3052 __s.__node_ = nullptr;
3056 template <class _CharT, class _Traits>
3057 template <class _ForwardIterator>
3059 basic_regex<_CharT, _Traits>::__init(_ForwardIterator __first, _ForwardIterator __last)
3061 if (__get_grammar(__flags_) == 0) __flags_ |= regex_constants::ECMAScript;
3062 _ForwardIterator __temp = __parse(__first, __last);
3063 if ( __temp != __last)
3064 __throw_regex_error<regex_constants::__re_err_parse>();
3067 template <class _CharT, class _Traits>
3068 template <class _ForwardIterator>
3070 basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
3071 _ForwardIterator __last)
3074 unique_ptr<__node> __h(new __end_state<_CharT>);
3075 __start_.reset(new __empty_state<_CharT>(__h.get()));
3077 __end_ = __start_.get();
3079 switch (__get_grammar(__flags_))
3082 __first = __parse_ecma_exp(__first, __last);
3085 __first = __parse_basic_reg_exp(__first, __last);
3089 __first = __parse_extended_reg_exp(__first, __last);
3092 __first = __parse_grep(__first, __last);
3095 __first = __parse_egrep(__first, __last);
3098 __throw_regex_error<regex_constants::__re_err_grammar>();
3103 template <class _CharT, class _Traits>
3104 template <class _ForwardIterator>
3106 basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first,
3107 _ForwardIterator __last)
3109 if (__first != __last)
3111 if (*__first == '^')
3116 if (__first != __last)
3118 __first = __parse_RE_expression(__first, __last);
3119 if (__first != __last)
3121 _ForwardIterator __temp = _VSTD::next(__first);
3122 if (__temp == __last && *__first == '$')
3129 if (__first != __last)
3130 __throw_regex_error<regex_constants::__re_err_empty>();
3135 template <class _CharT, class _Traits>
3136 template <class _ForwardIterator>
3138 basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
3139 _ForwardIterator __last)
3141 __owns_one_state<_CharT>* __sa = __end_;
3142 _ForwardIterator __temp = __parse_ERE_branch(__first, __last);
3143 if (__temp == __first)
3144 __throw_regex_error<regex_constants::__re_err_empty>();
3146 while (__first != __last && *__first == '|')
3148 __owns_one_state<_CharT>* __sb = __end_;
3149 __temp = __parse_ERE_branch(++__first, __last);
3150 if (__temp == __first)
3151 __throw_regex_error<regex_constants::__re_err_empty>();
3152 __push_alternation(__sa, __sb);
3158 template <class _CharT, class _Traits>
3159 template <class _ForwardIterator>
3161 basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first,
3162 _ForwardIterator __last)
3164 _ForwardIterator __temp = __parse_ERE_expression(__first, __last);
3165 if (__temp == __first)
3166 __throw_regex_error<regex_constants::__re_err_empty>();
3170 __temp = __parse_ERE_expression(__first, __last);
3171 } while (__temp != __first);
3175 template <class _CharT, class _Traits>
3176 template <class _ForwardIterator>
3178 basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first,
3179 _ForwardIterator __last)
3181 __owns_one_state<_CharT>* __e = __end_;
3182 unsigned __mexp_begin = __marked_count_;
3183 _ForwardIterator __temp = __parse_one_char_or_coll_elem_ERE(__first, __last);
3184 if (__temp == __first && __temp != __last)
3197 __push_begin_marked_subexpression();
3198 unsigned __temp_count = __marked_count_;
3200 __temp = __parse_extended_reg_exp(++__temp, __last);
3201 if (__temp == __last || *__temp != ')')
3202 __throw_regex_error<regex_constants::error_paren>();
3203 __push_end_marked_subexpression(__temp_count);
3209 if (__temp != __first)
3210 __temp = __parse_ERE_dupl_symbol(__temp, __last, __e, __mexp_begin+1,
3216 template <class _CharT, class _Traits>
3217 template <class _ForwardIterator>
3219 basic_regex<_CharT, _Traits>::__parse_RE_expression(_ForwardIterator __first,
3220 _ForwardIterator __last)
3224 _ForwardIterator __temp = __parse_simple_RE(__first, __last);
3225 if (__temp == __first)
3232 template <class _CharT, class _Traits>
3233 template <class _ForwardIterator>
3235 basic_regex<_CharT, _Traits>::__parse_simple_RE(_ForwardIterator __first,
3236 _ForwardIterator __last)
3238 if (__first != __last)
3240 __owns_one_state<_CharT>* __e = __end_;
3241 unsigned __mexp_begin = __marked_count_;
3242 _ForwardIterator __temp = __parse_nondupl_RE(__first, __last);
3243 if (__temp != __first)
3244 __first = __parse_RE_dupl_symbol(__temp, __last, __e,
3245 __mexp_begin+1, __marked_count_+1);
3250 template <class _CharT, class _Traits>
3251 template <class _ForwardIterator>
3253 basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first,
3254 _ForwardIterator __last)
3256 _ForwardIterator __temp = __first;
3257 __first = __parse_one_char_or_coll_elem_RE(__first, __last);
3258 if (__temp == __first)
3260 __temp = __parse_Back_open_paren(__first, __last);
3261 if (__temp != __first)
3263 __push_begin_marked_subexpression();
3264 unsigned __temp_count = __marked_count_;
3265 __first = __parse_RE_expression(__temp, __last);
3266 __temp = __parse_Back_close_paren(__first, __last);
3267 if (__temp == __first)
3268 __throw_regex_error<regex_constants::error_paren>();
3269 __push_end_marked_subexpression(__temp_count);
3273 __first = __parse_BACKREF(__first, __last);
3278 template <class _CharT, class _Traits>
3279 template <class _ForwardIterator>
3281 basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_RE(
3282 _ForwardIterator __first,
3283 _ForwardIterator __last)
3285 _ForwardIterator __temp = __parse_ORD_CHAR(__first, __last);
3286 if (__temp == __first)
3288 __temp = __parse_QUOTED_CHAR(__first, __last);
3289 if (__temp == __first)
3291 if (__temp != __last && *__temp == '.')
3297 __temp = __parse_bracket_expression(__first, __last);
3304 template <class _CharT, class _Traits>
3305 template <class _ForwardIterator>
3307 basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_ERE(
3308 _ForwardIterator __first,
3309 _ForwardIterator __last)
3311 _ForwardIterator __temp = __parse_ORD_CHAR_ERE(__first, __last);
3312 if (__temp == __first)
3314 __temp = __parse_QUOTED_CHAR_ERE(__first, __last);
3315 if (__temp == __first)
3317 if (__temp != __last && *__temp == '.')
3323 __temp = __parse_bracket_expression(__first, __last);
3330 template <class _CharT, class _Traits>
3331 template <class _ForwardIterator>
3333 basic_regex<_CharT, _Traits>::__parse_Back_open_paren(_ForwardIterator __first,
3334 _ForwardIterator __last)
3336 if (__first != __last)
3338 _ForwardIterator __temp = _VSTD::next(__first);
3339 if (__temp != __last)
3341 if (*__first == '\\' && *__temp == '(')
3348 template <class _CharT, class _Traits>
3349 template <class _ForwardIterator>
3351 basic_regex<_CharT, _Traits>::__parse_Back_close_paren(_ForwardIterator __first,
3352 _ForwardIterator __last)
3354 if (__first != __last)
3356 _ForwardIterator __temp = _VSTD::next(__first);
3357 if (__temp != __last)
3359 if (*__first == '\\' && *__temp == ')')
3366 template <class _CharT, class _Traits>
3367 template <class _ForwardIterator>
3369 basic_regex<_CharT, _Traits>::__parse_Back_open_brace(_ForwardIterator __first,
3370 _ForwardIterator __last)
3372 if (__first != __last)
3374 _ForwardIterator __temp = _VSTD::next(__first);
3375 if (__temp != __last)
3377 if (*__first == '\\' && *__temp == '{')
3384 template <class _CharT, class _Traits>
3385 template <class _ForwardIterator>
3387 basic_regex<_CharT, _Traits>::__parse_Back_close_brace(_ForwardIterator __first,
3388 _ForwardIterator __last)
3390 if (__first != __last)
3392 _ForwardIterator __temp = _VSTD::next(__first);
3393 if (__temp != __last)
3395 if (*__first == '\\' && *__temp == '}')
3402 template <class _CharT, class _Traits>
3403 template <class _ForwardIterator>
3405 basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first,
3406 _ForwardIterator __last)
3408 if (__first != __last)
3410 _ForwardIterator __temp = _VSTD::next(__first);
3411 if (__temp != __last)
3413 if (*__first == '\\')
3415 int __val = __traits_.value(*__temp, 10);
3416 if (__val >= 1 && __val <= 9)
3418 __push_back_ref(__val);
3427 template <class _CharT, class _Traits>
3428 template <class _ForwardIterator>
3430 basic_regex<_CharT, _Traits>::__parse_ORD_CHAR(_ForwardIterator __first,
3431 _ForwardIterator __last)
3433 if (__first != __last)
3435 _ForwardIterator __temp = _VSTD::next(__first);
3436 if (__temp == __last && *__first == '$')
3438 // Not called inside a bracket
3439 if (*__first == '.' || *__first == '\\' || *__first == '[')
3441 __push_char(*__first);
3447 template <class _CharT, class _Traits>
3448 template <class _ForwardIterator>
3450 basic_regex<_CharT, _Traits>::__parse_ORD_CHAR_ERE(_ForwardIterator __first,
3451 _ForwardIterator __last)
3453 if (__first != __last)
3470 if (__open_count_ == 0)
3472 __push_char(*__first);
3477 __push_char(*__first);
3485 template <class _CharT, class _Traits>
3486 template <class _ForwardIterator>
3488 basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR(_ForwardIterator __first,
3489 _ForwardIterator __last)
3491 if (__first != __last)
3493 _ForwardIterator __temp = _VSTD::next(__first);
3494 if (__temp != __last)
3496 if (*__first == '\\')
3506 __push_char(*__temp);
3516 template <class _CharT, class _Traits>
3517 template <class _ForwardIterator>
3519 basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first,
3520 _ForwardIterator __last)
3522 if (__first != __last)
3524 _ForwardIterator __temp = _VSTD::next(__first);
3525 if (__temp != __last)
3527 if (*__first == '\\')
3544 __push_char(*__temp);
3548 if (__get_grammar(__flags_) == awk)
3549 __first = __parse_awk_escape(++__first, __last);
3558 template <class _CharT, class _Traits>
3559 template <class _ForwardIterator>
3561 basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
3562 _ForwardIterator __last,
3563 __owns_one_state<_CharT>* __s,
3564 unsigned __mexp_begin,
3565 unsigned __mexp_end)
3567 if (__first != __last)
3569 if (*__first == '*')
3571 __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3576 _ForwardIterator __temp = __parse_Back_open_brace(__first, __last);
3577 if (__temp != __first)
3581 __temp = __parse_DUP_COUNT(__first, __last, __min);
3582 if (__temp == __first)
3583 __throw_regex_error<regex_constants::error_badbrace>();
3585 if (__first == __last)
3586 __throw_regex_error<regex_constants::error_brace>();
3587 if (*__first != ',')
3589 __temp = __parse_Back_close_brace(__first, __last);
3590 if (__temp == __first)
3591 __throw_regex_error<regex_constants::error_brace>();
3592 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end,
3598 ++__first; // consume ','
3600 __first = __parse_DUP_COUNT(__first, __last, __max);
3601 __temp = __parse_Back_close_brace(__first, __last);
3602 if (__temp == __first)
3603 __throw_regex_error<regex_constants::error_brace>();
3605 __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3609 __throw_regex_error<regex_constants::error_badbrace>();
3610 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end,
3621 template <class _CharT, class _Traits>
3622 template <class _ForwardIterator>
3624 basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
3625 _ForwardIterator __last,
3626 __owns_one_state<_CharT>* __s,
3627 unsigned __mexp_begin,
3628 unsigned __mexp_end)
3630 if (__first != __last)
3632 unsigned __grammar = __get_grammar(__flags_);
3637 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3640 __push_nongreedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3643 __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
3647 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3650 __push_nongreedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
3653 __push_greedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
3657 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3660 __push_loop(0, 1, __s, __mexp_begin, __mexp_end, false);
3663 __push_loop(0, 1, __s, __mexp_begin, __mexp_end);
3668 _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);
3669 if (__temp == __first)
3670 __throw_regex_error<regex_constants::error_badbrace>();
3672 if (__first == __last)
3673 __throw_regex_error<regex_constants::error_brace>();
3678 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3681 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, false);
3684 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end);
3688 if (__first == __last)
3689 __throw_regex_error<regex_constants::error_badbrace>();
3690 if (*__first == '}')
3693 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3696 __push_nongreedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3699 __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3704 __temp = __parse_DUP_COUNT(__first, __last, __max);
3705 if (__temp == __first)
3706 __throw_regex_error<regex_constants::error_brace>();
3708 if (__first == __last || *__first != '}')
3709 __throw_regex_error<regex_constants::error_brace>();
3712 __throw_regex_error<regex_constants::error_badbrace>();
3713 if (__grammar == ECMAScript && __first != __last && *__first == '?')
3716 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false);
3719 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end);
3723 __throw_regex_error<regex_constants::error_badbrace>();
3732 template <class _CharT, class _Traits>
3733 template <class _ForwardIterator>
3735 basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __first,
3736 _ForwardIterator __last)
3738 if (__first != __last && *__first == '[')
3741 if (__first == __last)
3742 __throw_regex_error<regex_constants::error_brack>();
3743 bool __negate = false;
3744 if (*__first == '^')
3749 __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);
3750 // __ml owned by *this
3751 if (__first == __last)
3752 __throw_regex_error<regex_constants::error_brack>();
3753 if (__get_grammar(__flags_) != ECMAScript && *__first == ']')
3755 __ml->__add_char(']');
3758 __first = __parse_follow_list(__first, __last, __ml);
3759 if (__first == __last)
3760 __throw_regex_error<regex_constants::error_brack>();
3761 if (*__first == '-')
3763 __ml->__add_char('-');
3766 if (__first == __last || *__first != ']')
3767 __throw_regex_error<regex_constants::error_brack>();
3773 template <class _CharT, class _Traits>
3774 template <class _ForwardIterator>
3776 basic_regex<_CharT, _Traits>::__parse_follow_list(_ForwardIterator __first,
3777 _ForwardIterator __last,
3778 __bracket_expression<_CharT, _Traits>* __ml)
3780 if (__first != __last)
3784 _ForwardIterator __temp = __parse_expression_term(__first, __last,
3786 if (__temp == __first)
3794 template <class _CharT, class _Traits>
3795 template <class _ForwardIterator>
3797 basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first,
3798 _ForwardIterator __last,
3799 __bracket_expression<_CharT, _Traits>* __ml)
3801 if (__first != __last && *__first != ']')
3803 _ForwardIterator __temp = _VSTD::next(__first);
3804 basic_string<_CharT> __start_range;
3805 if (__temp != __last && *__first == '[')
3808 return __parse_equivalence_class(++__temp, __last, __ml);
3809 else if (*__temp == ':')
3810 return __parse_character_class(++__temp, __last, __ml);
3811 else if (*__temp == '.')
3812 __first = __parse_collating_symbol(++__temp, __last, __start_range);
3814 unsigned __grammar = __get_grammar(__flags_);
3815 if (__start_range.empty())
3817 if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
3819 if (__grammar == ECMAScript)
3820 __first = __parse_class_escape(++__first, __last, __start_range, __ml);
3822 __first = __parse_awk_escape(++__first, __last, &__start_range);
3826 __start_range = *__first;
3830 if (__first != __last && *__first != ']')
3832 __temp = _VSTD::next(__first);
3833 if (__temp != __last && *__first == '-' && *__temp != ']')
3836 basic_string<_CharT> __end_range;
3839 if (__temp != __last && *__first == '[' && *__temp == '.')
3840 __first = __parse_collating_symbol(++__temp, __last, __end_range);
3843 if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
3845 if (__grammar == ECMAScript)
3846 __first = __parse_class_escape(++__first, __last,
3849 __first = __parse_awk_escape(++__first, __last,
3854 __end_range = *__first;
3858 __ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range));
3860 else if (!__start_range.empty())
3862 if (__start_range.size() == 1)
3863 __ml->__add_char(__start_range[0]);
3865 __ml->__add_digraph(__start_range[0], __start_range[1]);
3868 else if (!__start_range.empty())
3870 if (__start_range.size() == 1)
3871 __ml->__add_char(__start_range[0]);
3873 __ml->__add_digraph(__start_range[0], __start_range[1]);
3879 template <class _CharT, class _Traits>
3880 template <class _ForwardIterator>
3882 basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first,
3883 _ForwardIterator __last,
3884 basic_string<_CharT>& __str,
3885 __bracket_expression<_CharT, _Traits>* __ml)
3887 if (__first == __last)
3888 __throw_regex_error<regex_constants::error_escape>();
3898 __ml->__add_class(ctype_base::digit);
3901 __ml->__add_neg_class(ctype_base::digit);
3904 __ml->__add_class(ctype_base::space);
3907 __ml->__add_neg_class(ctype_base::space);
3910 __ml->__add_class(ctype_base::alnum);
3911 __ml->__add_char('_');
3914 __ml->__add_neg_class(ctype_base::alnum);
3915 __ml->__add_neg_char('_');
3918 __first = __parse_character_escape(__first, __last, &__str);
3922 template <class _CharT, class _Traits>
3923 template <class _ForwardIterator>
3925 basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
3926 _ForwardIterator __last,
3927 basic_string<_CharT>* __str)
3929 if (__first == __last)
3930 __throw_regex_error<regex_constants::error_escape>();
3939 __push_char(*__first);
3945 __push_char(_CharT(7));
3951 __push_char(_CharT(8));
3955 *__str = _CharT(0xC);
3957 __push_char(_CharT(0xC));
3961 *__str = _CharT(0xA);
3963 __push_char(_CharT(0xA));
3967 *__str = _CharT(0xD);
3969 __push_char(_CharT(0xD));
3973 *__str = _CharT(0x9);
3975 __push_char(_CharT(0x9));
3979 *__str = _CharT(0xB);
3981 __push_char(_CharT(0xB));
3984 if ('0' <= *__first && *__first <= '7')
3986 unsigned __val = *__first - '0';
3987 if (++__first != __last && ('0' <= *__first && *__first <= '7'))
3989 __val = 8 * __val + *__first - '0';
3990 if (++__first != __last && ('0' <= *__first && *__first <= '7'))
3991 __val = 8 * __val + *__first++ - '0';
3994 *__str = _CharT(__val);
3996 __push_char(_CharT(__val));
3999 __throw_regex_error<regex_constants::error_escape>();
4003 template <class _CharT, class _Traits>
4004 template <class _ForwardIterator>
4006 basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first,
4007 _ForwardIterator __last,
4008 __bracket_expression<_CharT, _Traits>* __ml)
4011 // This means =] must exist
4012 value_type _Equal_close[2] = {'=', ']'};
4013 _ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close,
4015 if (__temp == __last)
4016 __throw_regex_error<regex_constants::error_brack>();
4017 // [__first, __temp) contains all text in [= ... =]
4018 string_type __collate_name =
4019 __traits_.lookup_collatename(__first, __temp);
4020 if (__collate_name.empty())
4021 __throw_regex_error<regex_constants::error_collate>();
4022 string_type __equiv_name =
4023 __traits_.transform_primary(__collate_name.begin(),
4024 __collate_name.end());
4025 if (!__equiv_name.empty())
4026 __ml->__add_equivalence(__equiv_name);
4029 switch (__collate_name.size())
4032 __ml->__add_char(__collate_name[0]);
4035 __ml->__add_digraph(__collate_name[0], __collate_name[1]);
4038 __throw_regex_error<regex_constants::error_collate>();
4041 __first = _VSTD::next(__temp, 2);
4045 template <class _CharT, class _Traits>
4046 template <class _ForwardIterator>
4048 basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
4049 _ForwardIterator __last,
4050 __bracket_expression<_CharT, _Traits>* __ml)
4053 // This means :] must exist
4054 value_type _Colon_close[2] = {':', ']'};
4055 _ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close,
4057 if (__temp == __last)
4058 __throw_regex_error<regex_constants::error_brack>();
4059 // [__first, __temp) contains all text in [: ... :]
4060 typedef typename _Traits::char_class_type char_class_type;
4061 char_class_type __class_type =
4062 __traits_.lookup_classname(__first, __temp, __flags_ & icase);
4063 if (__class_type == 0)
4064 __throw_regex_error<regex_constants::error_ctype>();
4065 __ml->__add_class(__class_type);
4066 __first = _VSTD::next(__temp, 2);
4070 template <class _CharT, class _Traits>
4071 template <class _ForwardIterator>
4073 basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
4074 _ForwardIterator __last,
4075 basic_string<_CharT>& __col_sym)
4078 // This means .] must exist
4079 value_type _Dot_close[2] = {'.', ']'};
4080 _ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close,
4082 if (__temp == __last)
4083 __throw_regex_error<regex_constants::error_brack>();
4084 // [__first, __temp) contains all text in [. ... .]
4085 __col_sym = __traits_.lookup_collatename(__first, __temp);
4086 switch (__col_sym.size())
4092 __throw_regex_error<regex_constants::error_collate>();
4094 __first = _VSTD::next(__temp, 2);
4098 template <class _CharT, class _Traits>
4099 template <class _ForwardIterator>
4101 basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
4102 _ForwardIterator __last,
4105 if (__first != __last )
4107 int __val = __traits_.value(*__first, 10);
4112 __first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
4115 if (__c >= std::numeric_limits<int>::max() / 10)
4116 __throw_regex_error<regex_constants::error_badbrace>();
4125 template <class _CharT, class _Traits>
4126 template <class _ForwardIterator>
4128 basic_regex<_CharT, _Traits>::__parse_ecma_exp(_ForwardIterator __first,
4129 _ForwardIterator __last)
4131 __owns_one_state<_CharT>* __sa = __end_;
4132 _ForwardIterator __temp = __parse_alternative(__first, __last);
4133 if (__temp == __first)
4136 while (__first != __last && *__first == '|')
4138 __owns_one_state<_CharT>* __sb = __end_;
4139 __temp = __parse_alternative(++__first, __last);
4140 if (__temp == __first)
4142 __push_alternation(__sa, __sb);
4148 template <class _CharT, class _Traits>
4149 template <class _ForwardIterator>
4151 basic_regex<_CharT, _Traits>::__parse_alternative(_ForwardIterator __first,
4152 _ForwardIterator __last)
4156 _ForwardIterator __temp = __parse_term(__first, __last);
4157 if (__temp == __first)
4164 template <class _CharT, class _Traits>
4165 template <class _ForwardIterator>
4167 basic_regex<_CharT, _Traits>::__parse_term(_ForwardIterator __first,
4168 _ForwardIterator __last)
4170 _ForwardIterator __temp = __parse_assertion(__first, __last);
4171 if (__temp == __first)
4173 __owns_one_state<_CharT>* __e = __end_;
4174 unsigned __mexp_begin = __marked_count_;
4175 __temp = __parse_atom(__first, __last);
4176 if (__temp != __first)
4177 __first = __parse_ERE_dupl_symbol(__temp, __last, __e,
4178 __mexp_begin+1, __marked_count_+1);
4185 template <class _CharT, class _Traits>
4186 template <class _ForwardIterator>
4188 basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
4189 _ForwardIterator __last)
4191 if (__first != __last)
4205 _ForwardIterator __temp = _VSTD::next(__first);
4206 if (__temp != __last)
4210 __push_word_boundary(false);
4213 else if (*__temp == 'B')
4215 __push_word_boundary(true);
4223 _ForwardIterator __temp = _VSTD::next(__first);
4224 if (__temp != __last && *__temp == '?')
4226 if (++__temp != __last)
4233 __exp.__flags_ = __flags_;
4234 __temp = __exp.__parse(++__temp, __last);
4235 unsigned __mexp = __exp.__marked_count_;
4236 __push_lookahead(_VSTD::move(__exp), false, __marked_count_);
4237 __marked_count_ += __mexp;
4238 if (__temp == __last || *__temp != ')')
4239 __throw_regex_error<regex_constants::error_paren>();
4246 __exp.__flags_ = __flags_;
4247 __temp = __exp.__parse(++__temp, __last);
4248 unsigned __mexp = __exp.__marked_count_;
4249 __push_lookahead(_VSTD::move(__exp), true, __marked_count_);
4250 __marked_count_ += __mexp;
4251 if (__temp == __last || *__temp != ')')
4252 __throw_regex_error<regex_constants::error_paren>();
4266 template <class _CharT, class _Traits>
4267 template <class _ForwardIterator>
4269 basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
4270 _ForwardIterator __last)
4272 if (__first != __last)
4277 __push_match_any_but_newline();
4281 __first = __parse_atom_escape(__first, __last);
4284 __first = __parse_bracket_expression(__first, __last);
4289 if (__first == __last)
4290 __throw_regex_error<regex_constants::error_paren>();
4291 _ForwardIterator __temp = _VSTD::next(__first);
4292 if (__temp != __last && *__first == '?' && *__temp == ':')
4295 __first = __parse_ecma_exp(++__temp, __last);
4296 if (__first == __last || *__first != ')')
4297 __throw_regex_error<regex_constants::error_paren>();
4303 __push_begin_marked_subexpression();
4304 unsigned __temp_count = __marked_count_;
4306 __first = __parse_ecma_exp(__first, __last);
4307 if (__first == __last || *__first != ')')
4308 __throw_regex_error<regex_constants::error_paren>();
4309 __push_end_marked_subexpression(__temp_count);
4319 __throw_regex_error<regex_constants::error_badrepeat>();
4322 __first = __parse_pattern_character(__first, __last);
4329 template <class _CharT, class _Traits>
4330 template <class _ForwardIterator>
4332 basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first,
4333 _ForwardIterator __last)
4335 if (__first != __last && *__first == '\\')
4337 _ForwardIterator __t1 = _VSTD::next(__first);
4339 __throw_regex_error<regex_constants::error_escape>();
4341 _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
4346 __t2 = __parse_character_class_escape(__t1, __last);
4351 __t2 = __parse_character_escape(__t1, __last);
4360 template <class _CharT, class _Traits>
4361 template <class _ForwardIterator>
4363 basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
4364 _ForwardIterator __last)
4366 if (__first != __last)
4368 if (*__first == '0')
4370 __push_char(_CharT());
4373 else if ('1' <= *__first && *__first <= '9')
4375 unsigned __v = *__first - '0';
4377 __first != __last && '0' <= *__first && *__first <= '9'; ++__first)
4379 if (__v >= std::numeric_limits<unsigned>::max() / 10)
4380 __throw_regex_error<regex_constants::error_backref>();
4381 __v = 10 * __v + *__first - '0';
4383 if (__v == 0 || __v > mark_count())
4384 __throw_regex_error<regex_constants::error_backref>();
4385 __push_back_ref(__v);
4391 template <class _CharT, class _Traits>
4392 template <class _ForwardIterator>
4394 basic_regex<_CharT, _Traits>::__parse_character_class_escape(_ForwardIterator __first,
4395 _ForwardIterator __last)
4397 if (__first != __last)
4399 __bracket_expression<_CharT, _Traits>* __ml;
4403 __ml = __start_matching_list(false);
4404 __ml->__add_class(ctype_base::digit);
4408 __ml = __start_matching_list(true);
4409 __ml->__add_class(ctype_base::digit);
4413 __ml = __start_matching_list(false);
4414 __ml->__add_class(ctype_base::space);
4418 __ml = __start_matching_list(true);
4419 __ml->__add_class(ctype_base::space);
4423 __ml = __start_matching_list(false);
4424 __ml->__add_class(ctype_base::alnum);
4425 __ml->__add_char('_');
4429 __ml = __start_matching_list(true);
4430 __ml->__add_class(ctype_base::alnum);
4431 __ml->__add_char('_');
4439 template <class _CharT, class _Traits>
4440 template <class _ForwardIterator>
4442 basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
4443 _ForwardIterator __last,
4444 basic_string<_CharT>* __str)
4446 if (__first != __last)
4448 _ForwardIterator __t;
4455 *__str = _CharT(0xC);
4457 __push_char(_CharT(0xC));
4462 *__str = _CharT(0xA);
4464 __push_char(_CharT(0xA));
4469 *__str = _CharT(0xD);
4471 __push_char(_CharT(0xD));
4476 *__str = _CharT(0x9);
4478 __push_char(_CharT(0x9));
4483 *__str = _CharT(0xB);
4485 __push_char(_CharT(0xB));
4489 if ((__t = _VSTD::next(__first)) != __last)
4491 if (('A' <= *__t && *__t <= 'Z') ||
4492 ('a' <= *__t && *__t <= 'z'))
4495 *__str = _CharT(*__t % 32);
4497 __push_char(_CharT(*__t % 32));
4501 __throw_regex_error<regex_constants::error_escape>();
4504 __throw_regex_error<regex_constants::error_escape>();
4508 if (__first == __last)
4509 __throw_regex_error<regex_constants::error_escape>();
4510 __hd = __traits_.value(*__first, 16);
4512 __throw_regex_error<regex_constants::error_escape>();
4513 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4515 if (__first == __last)
4516 __throw_regex_error<regex_constants::error_escape>();
4517 __hd = __traits_.value(*__first, 16);
4519 __throw_regex_error<regex_constants::error_escape>();
4520 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4524 if (__first == __last)
4525 __throw_regex_error<regex_constants::error_escape>();
4526 __hd = __traits_.value(*__first, 16);
4528 __throw_regex_error<regex_constants::error_escape>();
4529 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4531 if (__first == __last)
4532 __throw_regex_error<regex_constants::error_escape>();
4533 __hd = __traits_.value(*__first, 16);
4535 __throw_regex_error<regex_constants::error_escape>();
4536 __sum = 16 * __sum + static_cast<unsigned>(__hd);
4538 *__str = _CharT(__sum);
4540 __push_char(_CharT(__sum));
4547 __push_char(_CharT(0));
4551 if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum))
4556 __push_char(*__first);
4560 __throw_regex_error<regex_constants::error_escape>();
4567 template <class _CharT, class _Traits>
4568 template <class _ForwardIterator>
4570 basic_regex<_CharT, _Traits>::__parse_pattern_character(_ForwardIterator __first,
4571 _ForwardIterator __last)
4573 if (__first != __last)
4593 __push_char(*__first);
4601 template <class _CharT, class _Traits>
4602 template <class _ForwardIterator>
4604 basic_regex<_CharT, _Traits>::__parse_grep(_ForwardIterator __first,
4605 _ForwardIterator __last)
4607 __owns_one_state<_CharT>* __sa = __end_;
4608 _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4609 if (__t1 != __first)
4610 __parse_basic_reg_exp(__first, __t1);
4614 if (__first != __last)
4616 while (__first != __last)
4618 __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4619 __owns_one_state<_CharT>* __sb = __end_;
4620 if (__t1 != __first)
4621 __parse_basic_reg_exp(__first, __t1);
4624 __push_alternation(__sa, __sb);
4626 if (__first != __last)
4632 template <class _CharT, class _Traits>
4633 template <class _ForwardIterator>
4635 basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first,
4636 _ForwardIterator __last)
4638 __owns_one_state<_CharT>* __sa = __end_;
4639 _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4640 if (__t1 != __first)
4641 __parse_extended_reg_exp(__first, __t1);
4645 if (__first != __last)
4647 while (__first != __last)
4649 __t1 = _VSTD::find(__first, __last, _CharT('\n'));
4650 __owns_one_state<_CharT>* __sb = __end_;
4651 if (__t1 != __first)
4652 __parse_extended_reg_exp(__first, __t1);
4655 __push_alternation(__sa, __sb);
4657 if (__first != __last)
4663 template <class _CharT, class _Traits>
4665 basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max,
4666 __owns_one_state<_CharT>* __s, size_t __mexp_begin, size_t __mexp_end,
4669 unique_ptr<__empty_state<_CharT> > __e1(new __empty_state<_CharT>(__end_->first()));
4670 __end_->first() = nullptr;
4671 unique_ptr<__loop<_CharT> > __e2(new __loop<_CharT>(__loop_count_,
4672 __s->first(), __e1.get(), __mexp_begin, __mexp_end, __greedy,
4674 __s->first() = nullptr;
4676 __end_->first() = new __repeat_one_loop<_CharT>(__e2.get());
4677 __end_ = __e2->second();
4678 __s->first() = __e2.release();
4682 template <class _CharT, class _Traits>
4684 basic_regex<_CharT, _Traits>::__push_char(value_type __c)
4686 if (flags() & icase)
4687 __end_->first() = new __match_char_icase<_CharT, _Traits>
4688 (__traits_, __c, __end_->first());
4689 else if (flags() & collate)
4690 __end_->first() = new __match_char_collate<_CharT, _Traits>
4691 (__traits_, __c, __end_->first());
4693 __end_->first() = new __match_char<_CharT>(__c, __end_->first());
4694 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4697 template <class _CharT, class _Traits>
4699 basic_regex<_CharT, _Traits>::__push_begin_marked_subexpression()
4701 if (!(__flags_ & nosubs))
4704 new __begin_marked_subexpression<_CharT>(++__marked_count_,
4706 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4710 template <class _CharT, class _Traits>
4712 basic_regex<_CharT, _Traits>::__push_end_marked_subexpression(unsigned __sub)
4714 if (!(__flags_ & nosubs))
4717 new __end_marked_subexpression<_CharT>(__sub, __end_->first());
4718 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4722 template <class _CharT, class _Traits>
4724 basic_regex<_CharT, _Traits>::__push_l_anchor()
4726 __end_->first() = new __l_anchor<_CharT>(__end_->first());
4727 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4730 template <class _CharT, class _Traits>
4732 basic_regex<_CharT, _Traits>::__push_r_anchor()
4734 __end_->first() = new __r_anchor<_CharT>(__end_->first());
4735 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4738 template <class _CharT, class _Traits>
4740 basic_regex<_CharT, _Traits>::__push_match_any()
4742 __end_->first() = new __match_any<_CharT>(__end_->first());
4743 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4746 template <class _CharT, class _Traits>
4748 basic_regex<_CharT, _Traits>::__push_match_any_but_newline()
4750 __end_->first() = new __match_any_but_newline<_CharT>(__end_->first());
4751 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4754 template <class _CharT, class _Traits>
4756 basic_regex<_CharT, _Traits>::__push_empty()
4758 __end_->first() = new __empty_state<_CharT>(__end_->first());
4759 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4762 template <class _CharT, class _Traits>
4764 basic_regex<_CharT, _Traits>::__push_word_boundary(bool __invert)
4766 __end_->first() = new __word_boundary<_CharT, _Traits>(__traits_, __invert,
4768 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4771 template <class _CharT, class _Traits>
4773 basic_regex<_CharT, _Traits>::__push_back_ref(int __i)
4775 if (flags() & icase)
4776 __end_->first() = new __back_ref_icase<_CharT, _Traits>
4777 (__traits_, __i, __end_->first());
4778 else if (flags() & collate)
4779 __end_->first() = new __back_ref_collate<_CharT, _Traits>
4780 (__traits_, __i, __end_->first());
4782 __end_->first() = new __back_ref<_CharT>(__i, __end_->first());
4783 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4786 template <class _CharT, class _Traits>
4788 basic_regex<_CharT, _Traits>::__push_alternation(__owns_one_state<_CharT>* __sa,
4789 __owns_one_state<_CharT>* __ea)
4791 __sa->first() = new __alternate<_CharT>(
4792 static_cast<__owns_one_state<_CharT>*>(__sa->first()),
4793 static_cast<__owns_one_state<_CharT>*>(__ea->first()));
4794 __ea->first() = nullptr;
4795 __ea->first() = new __empty_state<_CharT>(__end_->first());
4796 __end_->first() = nullptr;
4797 __end_->first() = new __empty_non_own_state<_CharT>(__ea->first());
4798 __end_ = static_cast<__owns_one_state<_CharT>*>(__ea->first());
4801 template <class _CharT, class _Traits>
4802 __bracket_expression<_CharT, _Traits>*
4803 basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate)
4805 __bracket_expression<_CharT, _Traits>* __r =
4806 new __bracket_expression<_CharT, _Traits>(__traits_, __end_->first(),
4807 __negate, __flags_ & icase,
4808 __flags_ & collate);
4809 __end_->first() = __r;
4814 template <class _CharT, class _Traits>
4816 basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp,
4820 __end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert,
4821 __end_->first(), __mexp);
4822 __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
4825 typedef basic_regex<char> regex;
4826 typedef basic_regex<wchar_t> wregex;
4830 template <class _BidirectionalIterator>
4831 class _LIBCPP_TEMPLATE_VIS sub_match
4832 : public pair<_BidirectionalIterator, _BidirectionalIterator>
4835 typedef _BidirectionalIterator iterator;
4836 typedef typename iterator_traits<iterator>::value_type value_type;
4837 typedef typename iterator_traits<iterator>::difference_type difference_type;
4838 typedef basic_string<value_type> string_type;
4842 _LIBCPP_INLINE_VISIBILITY
4843 _LIBCPP_CONSTEXPR sub_match() : matched() {}
4845 _LIBCPP_INLINE_VISIBILITY
4846 difference_type length() const
4847 {return matched ? _VSTD::distance(this->first, this->second) : 0;}
4848 _LIBCPP_INLINE_VISIBILITY
4849 string_type str() const
4850 {return matched ? string_type(this->first, this->second) : string_type();}
4851 _LIBCPP_INLINE_VISIBILITY
4852 operator string_type() const
4855 _LIBCPP_INLINE_VISIBILITY
4856 int compare(const sub_match& __s) const
4857 {return str().compare(__s.str());}
4858 _LIBCPP_INLINE_VISIBILITY
4859 int compare(const string_type& __s) const
4860 {return str().compare(__s);}
4861 _LIBCPP_INLINE_VISIBILITY
4862 int compare(const value_type* __s) const
4863 {return str().compare(__s);}
4866 typedef sub_match<const char*> csub_match;
4867 typedef sub_match<const wchar_t*> wcsub_match;
4868 typedef sub_match<string::const_iterator> ssub_match;
4869 typedef sub_match<wstring::const_iterator> wssub_match;
4871 template <class _BiIter>
4872 inline _LIBCPP_INLINE_VISIBILITY
4874 operator==(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4876 return __x.compare(__y) == 0;
4879 template <class _BiIter>
4880 inline _LIBCPP_INLINE_VISIBILITY
4882 operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4884 return !(__x == __y);
4887 template <class _BiIter>
4888 inline _LIBCPP_INLINE_VISIBILITY
4890 operator<(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4892 return __x.compare(__y) < 0;
4895 template <class _BiIter>
4896 inline _LIBCPP_INLINE_VISIBILITY
4898 operator<=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4900 return !(__y < __x);
4903 template <class _BiIter>
4904 inline _LIBCPP_INLINE_VISIBILITY
4906 operator>=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4908 return !(__x < __y);
4911 template <class _BiIter>
4912 inline _LIBCPP_INLINE_VISIBILITY
4914 operator>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
4919 template <class _BiIter, class _ST, class _SA>
4920 inline _LIBCPP_INLINE_VISIBILITY
4922 operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4923 const sub_match<_BiIter>& __y)
4925 return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0;
4928 template <class _BiIter, class _ST, class _SA>
4929 inline _LIBCPP_INLINE_VISIBILITY
4931 operator!=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4932 const sub_match<_BiIter>& __y)
4934 return !(__x == __y);
4937 template <class _BiIter, class _ST, class _SA>
4938 inline _LIBCPP_INLINE_VISIBILITY
4940 operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4941 const sub_match<_BiIter>& __y)
4943 return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0;
4946 template <class _BiIter, class _ST, class _SA>
4947 inline _LIBCPP_INLINE_VISIBILITY
4949 operator>(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4950 const sub_match<_BiIter>& __y)
4955 template <class _BiIter, class _ST, class _SA>
4956 inline _LIBCPP_INLINE_VISIBILITY
4957 bool operator>=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4958 const sub_match<_BiIter>& __y)
4960 return !(__x < __y);
4963 template <class _BiIter, class _ST, class _SA>
4964 inline _LIBCPP_INLINE_VISIBILITY
4966 operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
4967 const sub_match<_BiIter>& __y)
4969 return !(__y < __x);
4972 template <class _BiIter, class _ST, class _SA>
4973 inline _LIBCPP_INLINE_VISIBILITY
4975 operator==(const sub_match<_BiIter>& __x,
4976 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4978 return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;
4981 template <class _BiIter, class _ST, class _SA>
4982 inline _LIBCPP_INLINE_VISIBILITY
4984 operator!=(const sub_match<_BiIter>& __x,
4985 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4987 return !(__x == __y);
4990 template <class _BiIter, class _ST, class _SA>
4991 inline _LIBCPP_INLINE_VISIBILITY
4993 operator<(const sub_match<_BiIter>& __x,
4994 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
4996 return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0;
4999 template <class _BiIter, class _ST, class _SA>
5000 inline _LIBCPP_INLINE_VISIBILITY
5001 bool operator>(const sub_match<_BiIter>& __x,
5002 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
5007 template <class _BiIter, class _ST, class _SA>
5008 inline _LIBCPP_INLINE_VISIBILITY
5010 operator>=(const sub_match<_BiIter>& __x,
5011 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
5013 return !(__x < __y);
5016 template <class _BiIter, class _ST, class _SA>
5017 inline _LIBCPP_INLINE_VISIBILITY
5019 operator<=(const sub_match<_BiIter>& __x,
5020 const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
5022 return !(__y < __x);
5025 template <class _BiIter>
5026 inline _LIBCPP_INLINE_VISIBILITY
5028 operator==(typename iterator_traits<_BiIter>::value_type const* __x,
5029 const sub_match<_BiIter>& __y)
5031 return __y.compare(__x) == 0;
5034 template <class _BiIter>
5035 inline _LIBCPP_INLINE_VISIBILITY
5037 operator!=(typename iterator_traits<_BiIter>::value_type const* __x,
5038 const sub_match<_BiIter>& __y)
5040 return !(__x == __y);
5043 template <class _BiIter>
5044 inline _LIBCPP_INLINE_VISIBILITY
5046 operator<(typename iterator_traits<_BiIter>::value_type const* __x,
5047 const sub_match<_BiIter>& __y)
5049 return __y.compare(__x) > 0;
5052 template <class _BiIter>
5053 inline _LIBCPP_INLINE_VISIBILITY
5055 operator>(typename iterator_traits<_BiIter>::value_type const* __x,
5056 const sub_match<_BiIter>& __y)
5061 template <class _BiIter>
5062 inline _LIBCPP_INLINE_VISIBILITY
5064 operator>=(typename iterator_traits<_BiIter>::value_type const* __x,
5065 const sub_match<_BiIter>& __y)
5067 return !(__x < __y);
5070 template <class _BiIter>
5071 inline _LIBCPP_INLINE_VISIBILITY
5073 operator<=(typename iterator_traits<_BiIter>::value_type const* __x,
5074 const sub_match<_BiIter>& __y)
5076 return !(__y < __x);
5079 template <class _BiIter>
5080 inline _LIBCPP_INLINE_VISIBILITY
5082 operator==(const sub_match<_BiIter>& __x,
5083 typename iterator_traits<_BiIter>::value_type const* __y)
5085 return __x.compare(__y) == 0;
5088 template <class _BiIter>
5089 inline _LIBCPP_INLINE_VISIBILITY
5091 operator!=(const sub_match<_BiIter>& __x,
5092 typename iterator_traits<_BiIter>::value_type const* __y)
5094 return !(__x == __y);
5097 template <class _BiIter>
5098 inline _LIBCPP_INLINE_VISIBILITY
5100 operator<(const sub_match<_BiIter>& __x,
5101 typename iterator_traits<_BiIter>::value_type const* __y)
5103 return __x.compare(__y) < 0;
5106 template <class _BiIter>
5107 inline _LIBCPP_INLINE_VISIBILITY
5109 operator>(const sub_match<_BiIter>& __x,
5110 typename iterator_traits<_BiIter>::value_type const* __y)
5115 template <class _BiIter>
5116 inline _LIBCPP_INLINE_VISIBILITY
5118 operator>=(const sub_match<_BiIter>& __x,
5119 typename iterator_traits<_BiIter>::value_type const* __y)
5121 return !(__x < __y);
5124 template <class _BiIter>
5125 inline _LIBCPP_INLINE_VISIBILITY
5127 operator<=(const sub_match<_BiIter>& __x,
5128 typename iterator_traits<_BiIter>::value_type const* __y)
5130 return !(__y < __x);
5133 template <class _BiIter>
5134 inline _LIBCPP_INLINE_VISIBILITY
5136 operator==(typename iterator_traits<_BiIter>::value_type const& __x,
5137 const sub_match<_BiIter>& __y)
5139 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5140 return __y.compare(string_type(1, __x)) == 0;
5143 template <class _BiIter>
5144 inline _LIBCPP_INLINE_VISIBILITY
5146 operator!=(typename iterator_traits<_BiIter>::value_type const& __x,
5147 const sub_match<_BiIter>& __y)
5149 return !(__x == __y);
5152 template <class _BiIter>
5153 inline _LIBCPP_INLINE_VISIBILITY
5155 operator<(typename iterator_traits<_BiIter>::value_type const& __x,
5156 const sub_match<_BiIter>& __y)
5158 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5159 return __y.compare(string_type(1, __x)) > 0;
5162 template <class _BiIter>
5163 inline _LIBCPP_INLINE_VISIBILITY
5165 operator>(typename iterator_traits<_BiIter>::value_type const& __x,
5166 const sub_match<_BiIter>& __y)
5171 template <class _BiIter>
5172 inline _LIBCPP_INLINE_VISIBILITY
5174 operator>=(typename iterator_traits<_BiIter>::value_type const& __x,
5175 const sub_match<_BiIter>& __y)
5177 return !(__x < __y);
5180 template <class _BiIter>
5181 inline _LIBCPP_INLINE_VISIBILITY
5183 operator<=(typename iterator_traits<_BiIter>::value_type const& __x,
5184 const sub_match<_BiIter>& __y)
5186 return !(__y < __x);
5189 template <class _BiIter>
5190 inline _LIBCPP_INLINE_VISIBILITY
5192 operator==(const sub_match<_BiIter>& __x,
5193 typename iterator_traits<_BiIter>::value_type const& __y)
5195 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5196 return __x.compare(string_type(1, __y)) == 0;
5199 template <class _BiIter>
5200 inline _LIBCPP_INLINE_VISIBILITY
5202 operator!=(const sub_match<_BiIter>& __x,
5203 typename iterator_traits<_BiIter>::value_type const& __y)
5205 return !(__x == __y);
5208 template <class _BiIter>
5209 inline _LIBCPP_INLINE_VISIBILITY
5211 operator<(const sub_match<_BiIter>& __x,
5212 typename iterator_traits<_BiIter>::value_type const& __y)
5214 typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
5215 return __x.compare(string_type(1, __y)) < 0;
5218 template <class _BiIter>
5219 inline _LIBCPP_INLINE_VISIBILITY
5221 operator>(const sub_match<_BiIter>& __x,
5222 typename iterator_traits<_BiIter>::value_type const& __y)
5227 template <class _BiIter>
5228 inline _LIBCPP_INLINE_VISIBILITY
5230 operator>=(const sub_match<_BiIter>& __x,
5231 typename iterator_traits<_BiIter>::value_type const& __y)
5233 return !(__x < __y);
5236 template <class _BiIter>
5237 inline _LIBCPP_INLINE_VISIBILITY
5239 operator<=(const sub_match<_BiIter>& __x,
5240 typename iterator_traits<_BiIter>::value_type const& __y)
5242 return !(__y < __x);
5245 template <class _CharT, class _ST, class _BiIter>
5246 inline _LIBCPP_INLINE_VISIBILITY
5247 basic_ostream<_CharT, _ST>&
5248 operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m)
5250 return __os << __m.str();
5253 template <class _BidirectionalIterator, class _Allocator>
5254 class _LIBCPP_TEMPLATE_VIS match_results
5257 typedef _Allocator allocator_type;
5258 typedef sub_match<_BidirectionalIterator> value_type;
5260 typedef vector<value_type, allocator_type> __container_type;
5262 __container_type __matches_;
5263 value_type __unmatched_;
5264 value_type __prefix_;
5265 value_type __suffix_;
5268 _BidirectionalIterator __position_start_;
5269 typedef const value_type& const_reference;
5270 typedef value_type& reference;
5271 typedef typename __container_type::const_iterator const_iterator;
5272 typedef const_iterator iterator;
5273 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
5274 typedef typename allocator_traits<allocator_type>::size_type size_type;
5275 typedef typename iterator_traits<_BidirectionalIterator>::value_type char_type;
5276 typedef basic_string<char_type> string_type;
5278 // construct/copy/destroy:
5279 explicit match_results(const allocator_type& __a = allocator_type());
5280 // match_results(const match_results&) = default;
5281 // match_results& operator=(const match_results&) = default;
5282 // match_results(match_results&& __m) = default;
5283 // match_results& operator=(match_results&& __m) = default;
5284 // ~match_results() = default;
5286 _LIBCPP_INLINE_VISIBILITY
5287 bool ready() const {return __ready_;}
5290 _LIBCPP_INLINE_VISIBILITY
5291 size_type size() const _NOEXCEPT {return __matches_.size();}
5292 _LIBCPP_INLINE_VISIBILITY
5293 size_type max_size() const _NOEXCEPT {return __matches_.max_size();}
5294 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
5295 bool empty() const _NOEXCEPT {return size() == 0;}
5298 _LIBCPP_INLINE_VISIBILITY
5299 difference_type length(size_type __sub = 0) const
5301 _LIBCPP_ASSERT(ready(), "match_results::length() called when not ready");
5302 return (*this)[__sub].length();
5304 _LIBCPP_INLINE_VISIBILITY
5305 difference_type position(size_type __sub = 0) const
5307 _LIBCPP_ASSERT(ready(), "match_results::position() called when not ready");
5308 return _VSTD::distance(__position_start_, (*this)[__sub].first);
5310 _LIBCPP_INLINE_VISIBILITY
5311 string_type str(size_type __sub = 0) const
5313 _LIBCPP_ASSERT(ready(), "match_results::str() called when not ready");
5314 return (*this)[__sub].str();
5316 _LIBCPP_INLINE_VISIBILITY
5317 const_reference operator[](size_type __n) const
5319 _LIBCPP_ASSERT(ready(), "match_results::operator[]() called when not ready");
5320 return __n < __matches_.size() ? __matches_[__n] : __unmatched_;
5323 _LIBCPP_INLINE_VISIBILITY
5324 const_reference prefix() const
5326 _LIBCPP_ASSERT(ready(), "match_results::prefix() called when not ready");
5329 _LIBCPP_INLINE_VISIBILITY
5330 const_reference suffix() const
5332 _LIBCPP_ASSERT(ready(), "match_results::suffix() called when not ready");
5336 _LIBCPP_INLINE_VISIBILITY
5337 const_iterator begin() const {return empty() ? __matches_.end() : __matches_.begin();}
5338 _LIBCPP_INLINE_VISIBILITY
5339 const_iterator end() const {return __matches_.end();}
5340 _LIBCPP_INLINE_VISIBILITY
5341 const_iterator cbegin() const {return empty() ? __matches_.end() : __matches_.begin();}
5342 _LIBCPP_INLINE_VISIBILITY
5343 const_iterator cend() const {return __matches_.end();}
5346 template <class _OutputIter>
5348 format(_OutputIter __output_iter, const char_type* __fmt_first,
5349 const char_type* __fmt_last,
5350 regex_constants::match_flag_type __flags = regex_constants::format_default) const;
5351 template <class _OutputIter, class _ST, class _SA>
5352 _LIBCPP_INLINE_VISIBILITY
5354 format(_OutputIter __output_iter, const basic_string<char_type, _ST, _SA>& __fmt,
5355 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5356 {return format(__output_iter, __fmt.data(), __fmt.data() + __fmt.size(), __flags);}
5357 template <class _ST, class _SA>
5358 _LIBCPP_INLINE_VISIBILITY
5359 basic_string<char_type, _ST, _SA>
5360 format(const basic_string<char_type, _ST, _SA>& __fmt,
5361 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5363 basic_string<char_type, _ST, _SA> __r;
5364 format(back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(),
5368 _LIBCPP_INLINE_VISIBILITY
5370 format(const char_type* __fmt,
5371 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5374 format(back_inserter(__r), __fmt,
5375 __fmt + char_traits<char_type>::length(__fmt), __flags);
5380 _LIBCPP_INLINE_VISIBILITY
5381 allocator_type get_allocator() const {return __matches_.get_allocator();}
5384 void swap(match_results& __m);
5386 template <class _Bp, class _Ap>
5387 _LIBCPP_INLINE_VISIBILITY
5388 void __assign(_BidirectionalIterator __f, _BidirectionalIterator __l,
5389 const match_results<_Bp, _Ap>& __m, bool __no_update_pos)
5391 _Bp __mf = __m.prefix().first;
5392 __matches_.resize(__m.size());
5393 for (size_type __i = 0; __i < __matches_.size(); ++__i)
5395 __matches_[__i].first = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].first));
5396 __matches_[__i].second = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].second));
5397 __matches_[__i].matched = __m[__i].matched;
5399 __unmatched_.first = __l;
5400 __unmatched_.second = __l;
5401 __unmatched_.matched = false;
5402 __prefix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().first));
5403 __prefix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().second));
5404 __prefix_.matched = __m.prefix().matched;
5405 __suffix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().first));
5406 __suffix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().second));
5407 __suffix_.matched = __m.suffix().matched;
5408 if (!__no_update_pos)
5409 __position_start_ = __prefix_.first;
5410 __ready_ = __m.ready();
5414 void __init(unsigned __s,
5415 _BidirectionalIterator __f, _BidirectionalIterator __l,
5416 bool __no_update_pos = false);
5418 template <class, class> friend class basic_regex;
5420 template <class _Bp, class _Ap, class _Cp, class _Tp>
5423 regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
5424 regex_constants::match_flag_type);
5426 template <class _Bp, class _Ap>
5429 operator==(const match_results<_Bp, _Ap>&, const match_results<_Bp, _Ap>&);
5431 template <class, class> friend class __lookahead;
5434 template <class _BidirectionalIterator, class _Allocator>
5435 match_results<_BidirectionalIterator, _Allocator>::match_results(
5436 const allocator_type& __a)
5446 template <class _BidirectionalIterator, class _Allocator>
5448 match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s,
5449 _BidirectionalIterator __f, _BidirectionalIterator __l,
5450 bool __no_update_pos)
5452 __unmatched_.first = __l;
5453 __unmatched_.second = __l;
5454 __unmatched_.matched = false;
5455 __matches_.assign(__s, __unmatched_);
5456 __prefix_.first = __f;
5457 __prefix_.second = __f;
5458 __prefix_.matched = false;
5459 __suffix_ = __unmatched_;
5460 if (!__no_update_pos)
5461 __position_start_ = __prefix_.first;
5465 template <class _BidirectionalIterator, class _Allocator>
5466 template <class _OutputIter>
5468 match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output_iter,
5469 const char_type* __fmt_first, const char_type* __fmt_last,
5470 regex_constants::match_flag_type __flags) const
5472 _LIBCPP_ASSERT(ready(), "match_results::format() called when not ready");
5473 if (__flags & regex_constants::format_sed)
5475 for (; __fmt_first != __fmt_last; ++__fmt_first)
5477 if (*__fmt_first == '&')
5478 __output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second,
5480 else if (*__fmt_first == '\\' && __fmt_first + 1 != __fmt_last)
5483 if ('0' <= *__fmt_first && *__fmt_first <= '9')
5485 size_t __i = *__fmt_first - '0';
5486 __output_iter = _VSTD::copy((*this)[__i].first,
5487 (*this)[__i].second, __output_iter);
5491 *__output_iter = *__fmt_first;
5497 *__output_iter = *__fmt_first;
5504 for (; __fmt_first != __fmt_last; ++__fmt_first)
5506 if (*__fmt_first == '$' && __fmt_first + 1 != __fmt_last)
5508 switch (__fmt_first[1])
5511 *__output_iter = *++__fmt_first;
5516 __output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second,
5521 __output_iter = _VSTD::copy(__prefix_.first, __prefix_.second, __output_iter);
5525 __output_iter = _VSTD::copy(__suffix_.first, __suffix_.second, __output_iter);
5528 if ('0' <= __fmt_first[1] && __fmt_first[1] <= '9')
5531 size_t __idx = *__fmt_first - '0';
5532 if (__fmt_first + 1 != __fmt_last &&
5533 '0' <= __fmt_first[1] && __fmt_first[1] <= '9')
5536 if (__idx >= std::numeric_limits<size_t>::max() / 10)
5537 __throw_regex_error<regex_constants::error_escape>();
5538 __idx = 10 * __idx + *__fmt_first - '0';
5540 __output_iter = _VSTD::copy((*this)[__idx].first,
5541 (*this)[__idx].second, __output_iter);
5545 *__output_iter = *__fmt_first;
5553 *__output_iter = *__fmt_first;
5558 return __output_iter;
5561 template <class _BidirectionalIterator, class _Allocator>
5563 match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
5566 swap(__matches_, __m.__matches_);
5567 swap(__unmatched_, __m.__unmatched_);
5568 swap(__prefix_, __m.__prefix_);
5569 swap(__suffix_, __m.__suffix_);
5570 swap(__position_start_, __m.__position_start_);
5571 swap(__ready_, __m.__ready_);
5574 typedef match_results<const char*> cmatch;
5575 typedef match_results<const wchar_t*> wcmatch;
5576 typedef match_results<string::const_iterator> smatch;
5577 typedef match_results<wstring::const_iterator> wsmatch;
5579 template <class _BidirectionalIterator, class _Allocator>
5581 operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
5582 const match_results<_BidirectionalIterator, _Allocator>& __y)
5584 if (__x.__ready_ != __y.__ready_)
5588 return __x.__matches_ == __y.__matches_ &&
5589 __x.__prefix_ == __y.__prefix_ &&
5590 __x.__suffix_ == __y.__suffix_;
5593 template <class _BidirectionalIterator, class _Allocator>
5594 inline _LIBCPP_INLINE_VISIBILITY
5596 operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,
5597 const match_results<_BidirectionalIterator, _Allocator>& __y)
5599 return !(__x == __y);
5602 template <class _BidirectionalIterator, class _Allocator>
5603 inline _LIBCPP_INLINE_VISIBILITY
5605 swap(match_results<_BidirectionalIterator, _Allocator>& __x,
5606 match_results<_BidirectionalIterator, _Allocator>& __y)
5613 template <class _CharT, class _Traits>
5614 template <class _Allocator>
5616 basic_regex<_CharT, _Traits>::__match_at_start_ecma(
5617 const _CharT* __first, const _CharT* __last,
5618 match_results<const _CharT*, _Allocator>& __m,
5619 regex_constants::match_flag_type __flags, bool __at_first) const
5621 vector<__state> __states;
5622 __node* __st = __start_.get();
5625 sub_match<const _CharT*> __unmatched;
5626 __unmatched.first = __last;
5627 __unmatched.second = __last;
5628 __unmatched.matched = false;
5630 __states.push_back(__state());
5631 __states.back().__do_ = 0;
5632 __states.back().__first_ = __first;
5633 __states.back().__current_ = __first;
5634 __states.back().__last_ = __last;
5635 __states.back().__sub_matches_.resize(mark_count(), __unmatched);
5636 __states.back().__loop_data_.resize(__loop_count());
5637 __states.back().__node_ = __st;
5638 __states.back().__flags_ = __flags;
5639 __states.back().__at_first_ = __at_first;
5641 int __length = __last - __first;
5645 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
5646 __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
5647 __throw_regex_error<regex_constants::error_complexity>();
5648 __state& __s = __states.back();
5650 __s.__node_->__exec(__s);
5653 case __state::__end_state:
5654 if ((__flags & regex_constants::match_not_null) &&
5655 __s.__current_ == __first)
5657 __states.pop_back();
5660 if ((__flags & regex_constants::__full_match) &&
5661 __s.__current_ != __last)
5663 __states.pop_back();
5666 __m.__matches_[0].first = __first;
5667 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first);
5668 __m.__matches_[0].matched = true;
5669 for (unsigned __i = 0; __i < __s.__sub_matches_.size(); ++__i)
5670 __m.__matches_[__i+1] = __s.__sub_matches_[__i];
5672 case __state::__accept_and_consume:
5673 case __state::__repeat:
5674 case __state::__accept_but_not_consume:
5676 case __state::__split:
5678 __state __snext = __s;
5679 __s.__node_->__exec_split(true, __s);
5680 __snext.__node_->__exec_split(false, __snext);
5681 __states.push_back(_VSTD::move(__snext));
5684 case __state::__reject:
5685 __states.pop_back();
5688 __throw_regex_error<regex_constants::__re_err_unknown>();
5692 } while (!__states.empty());
5697 template <class _CharT, class _Traits>
5698 template <class _Allocator>
5700 basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
5701 const _CharT* __first, const _CharT* __last,
5702 match_results<const _CharT*, _Allocator>& __m,
5703 regex_constants::match_flag_type __flags, bool __at_first) const
5705 deque<__state> __states;
5706 ptrdiff_t __highest_j = 0;
5707 ptrdiff_t _Np = _VSTD::distance(__first, __last);
5708 __node* __st = __start_.get();
5711 __states.push_back(__state());
5712 __states.back().__do_ = 0;
5713 __states.back().__first_ = __first;
5714 __states.back().__current_ = __first;
5715 __states.back().__last_ = __last;
5716 __states.back().__loop_data_.resize(__loop_count());
5717 __states.back().__node_ = __st;
5718 __states.back().__flags_ = __flags;
5719 __states.back().__at_first_ = __at_first;
5720 bool __matched = false;
5722 int __length = __last - __first;
5726 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
5727 __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
5728 __throw_regex_error<regex_constants::error_complexity>();
5729 __state& __s = __states.back();
5731 __s.__node_->__exec(__s);
5734 case __state::__end_state:
5735 if ((__flags & regex_constants::match_not_null) &&
5736 __s.__current_ == __first)
5738 __states.pop_back();
5741 if ((__flags & regex_constants::__full_match) &&
5742 __s.__current_ != __last)
5744 __states.pop_back();
5747 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
5748 __highest_j = __s.__current_ - __s.__first_;
5750 if (__highest_j == _Np)
5753 __states.pop_back();
5755 case __state::__consume_input:
5757 case __state::__accept_and_consume:
5758 __states.push_front(_VSTD::move(__s));
5759 __states.pop_back();
5761 case __state::__repeat:
5762 case __state::__accept_but_not_consume:
5764 case __state::__split:
5766 __state __snext = __s;
5767 __s.__node_->__exec_split(true, __s);
5768 __snext.__node_->__exec_split(false, __snext);
5769 __states.push_back(_VSTD::move(__snext));
5772 case __state::__reject:
5773 __states.pop_back();
5776 __throw_regex_error<regex_constants::__re_err_unknown>();
5779 } while (!__states.empty());
5782 __m.__matches_[0].first = __first;
5783 __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
5784 __m.__matches_[0].matched = true;
5791 template <class _CharT, class _Traits>
5792 template <class _Allocator>
5794 basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
5795 const _CharT* __first, const _CharT* __last,
5796 match_results<const _CharT*, _Allocator>& __m,
5797 regex_constants::match_flag_type __flags, bool __at_first) const
5799 vector<__state> __states;
5800 __state __best_state;
5802 ptrdiff_t __highest_j = 0;
5803 ptrdiff_t _Np = _VSTD::distance(__first, __last);
5804 __node* __st = __start_.get();
5807 sub_match<const _CharT*> __unmatched;
5808 __unmatched.first = __last;
5809 __unmatched.second = __last;
5810 __unmatched.matched = false;
5812 __states.push_back(__state());
5813 __states.back().__do_ = 0;
5814 __states.back().__first_ = __first;
5815 __states.back().__current_ = __first;
5816 __states.back().__last_ = __last;
5817 __states.back().__sub_matches_.resize(mark_count(), __unmatched);
5818 __states.back().__loop_data_.resize(__loop_count());
5819 __states.back().__node_ = __st;
5820 __states.back().__flags_ = __flags;
5821 __states.back().__at_first_ = __at_first;
5822 const _CharT* __current = __first;
5823 bool __matched = false;
5825 int __length = __last - __first;
5829 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
5830 __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
5831 __throw_regex_error<regex_constants::error_complexity>();
5832 __state& __s = __states.back();
5834 __s.__node_->__exec(__s);
5837 case __state::__end_state:
5838 if ((__flags & regex_constants::match_not_null) &&
5839 __s.__current_ == __first)
5841 __states.pop_back();
5844 if ((__flags & regex_constants::__full_match) &&
5845 __s.__current_ != __last)
5847 __states.pop_back();
5850 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
5852 __highest_j = __s.__current_ - __s.__first_;
5856 if (__highest_j == _Np)
5859 __states.pop_back();
5861 case __state::__accept_and_consume:
5862 __j += __s.__current_ - __current;
5863 __current = __s.__current_;
5865 case __state::__repeat:
5866 case __state::__accept_but_not_consume:
5868 case __state::__split:
5870 __state __snext = __s;
5871 __s.__node_->__exec_split(true, __s);
5872 __snext.__node_->__exec_split(false, __snext);
5873 __states.push_back(_VSTD::move(__snext));
5876 case __state::__reject:
5877 __states.pop_back();
5880 __throw_regex_error<regex_constants::__re_err_unknown>();
5883 } while (!__states.empty());
5886 __m.__matches_[0].first = __first;
5887 __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
5888 __m.__matches_[0].matched = true;
5889 for (unsigned __i = 0; __i < __best_state.__sub_matches_.size(); ++__i)
5890 __m.__matches_[__i+1] = __best_state.__sub_matches_[__i];
5897 template <class _CharT, class _Traits>
5898 template <class _Allocator>
5900 basic_regex<_CharT, _Traits>::__match_at_start(
5901 const _CharT* __first, const _CharT* __last,
5902 match_results<const _CharT*, _Allocator>& __m,
5903 regex_constants::match_flag_type __flags, bool __at_first) const
5905 if (__get_grammar(__flags_) == ECMAScript)
5906 return __match_at_start_ecma(__first, __last, __m, __flags, __at_first);
5907 if (mark_count() == 0)
5908 return __match_at_start_posix_nosubs(__first, __last, __m, __flags, __at_first);
5909 return __match_at_start_posix_subs(__first, __last, __m, __flags, __at_first);
5912 template <class _CharT, class _Traits>
5913 template <class _Allocator>
5915 basic_regex<_CharT, _Traits>::__search(
5916 const _CharT* __first, const _CharT* __last,
5917 match_results<const _CharT*, _Allocator>& __m,
5918 regex_constants::match_flag_type __flags) const
5920 __m.__init(1 + mark_count(), __first, __last,
5921 __flags & regex_constants::__no_update_pos);
5922 if (__match_at_start(__first, __last, __m, __flags,
5923 !(__flags & regex_constants::__no_update_pos)))
5925 __m.__prefix_.second = __m[0].first;
5926 __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
5927 __m.__suffix_.first = __m[0].second;
5928 __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
5931 if (__first != __last && !(__flags & regex_constants::match_continuous))
5933 __flags |= regex_constants::match_prev_avail;
5934 for (++__first; __first != __last; ++__first)
5936 __m.__matches_.assign(__m.size(), __m.__unmatched_);
5937 if (__match_at_start(__first, __last, __m, __flags, false))
5939 __m.__prefix_.second = __m[0].first;
5940 __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
5941 __m.__suffix_.first = __m[0].second;
5942 __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
5945 __m.__matches_.assign(__m.size(), __m.__unmatched_);
5948 __m.__matches_.clear();
5952 template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
5953 inline _LIBCPP_INLINE_VISIBILITY
5955 regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
5956 match_results<_BidirectionalIterator, _Allocator>& __m,
5957 const basic_regex<_CharT, _Traits>& __e,
5958 regex_constants::match_flag_type __flags = regex_constants::match_default)
5960 int __offset = (__flags & regex_constants::match_prev_avail) ? 1 : 0;
5961 basic_string<_CharT> __s(_VSTD::prev(__first, __offset), __last);
5962 match_results<const _CharT*> __mc;
5963 bool __r = __e.__search(__s.data() + __offset, __s.data() + __s.size(), __mc, __flags);
5964 __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
5968 template <class _Iter, class _Allocator, class _CharT, class _Traits>
5969 inline _LIBCPP_INLINE_VISIBILITY
5971 regex_search(__wrap_iter<_Iter> __first,
5972 __wrap_iter<_Iter> __last,
5973 match_results<__wrap_iter<_Iter>, _Allocator>& __m,
5974 const basic_regex<_CharT, _Traits>& __e,
5975 regex_constants::match_flag_type __flags = regex_constants::match_default)
5977 match_results<const _CharT*> __mc;
5978 bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags);
5979 __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
5983 template <class _Allocator, class _CharT, class _Traits>
5984 inline _LIBCPP_INLINE_VISIBILITY
5986 regex_search(const _CharT* __first, const _CharT* __last,
5987 match_results<const _CharT*, _Allocator>& __m,
5988 const basic_regex<_CharT, _Traits>& __e,
5989 regex_constants::match_flag_type __flags = regex_constants::match_default)
5991 return __e.__search(__first, __last, __m, __flags);
5994 template <class _BidirectionalIterator, class _CharT, class _Traits>
5995 inline _LIBCPP_INLINE_VISIBILITY
5997 regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
5998 const basic_regex<_CharT, _Traits>& __e,
5999 regex_constants::match_flag_type __flags = regex_constants::match_default)
6001 basic_string<_CharT> __s(__first, __last);
6002 match_results<const _CharT*> __mc;
6003 return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
6006 template <class _CharT, class _Traits>
6007 inline _LIBCPP_INLINE_VISIBILITY
6009 regex_search(const _CharT* __first, const _CharT* __last,
6010 const basic_regex<_CharT, _Traits>& __e,
6011 regex_constants::match_flag_type __flags = regex_constants::match_default)
6013 match_results<const _CharT*> __mc;
6014 return __e.__search(__first, __last, __mc, __flags);
6017 template <class _CharT, class _Allocator, class _Traits>
6018 inline _LIBCPP_INLINE_VISIBILITY
6020 regex_search(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 __e.__search(__str, __str + _Traits::length(__str), __m, __flags);
6027 template <class _CharT, class _Traits>
6028 inline _LIBCPP_INLINE_VISIBILITY
6030 regex_search(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
6031 regex_constants::match_flag_type __flags = regex_constants::match_default)
6033 match_results<const _CharT*> __m;
6034 return _VSTD::regex_search(__str, __m, __e, __flags);
6037 template <class _ST, class _SA, class _CharT, class _Traits>
6038 inline _LIBCPP_INLINE_VISIBILITY
6040 regex_search(const basic_string<_CharT, _ST, _SA>& __s,
6041 const basic_regex<_CharT, _Traits>& __e,
6042 regex_constants::match_flag_type __flags = regex_constants::match_default)
6044 match_results<const _CharT*> __mc;
6045 return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
6048 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
6049 inline _LIBCPP_INLINE_VISIBILITY
6051 regex_search(const basic_string<_CharT, _ST, _SA>& __s,
6052 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
6053 const basic_regex<_CharT, _Traits>& __e,
6054 regex_constants::match_flag_type __flags = regex_constants::match_default)
6056 match_results<const _CharT*> __mc;
6057 bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
6058 __m.__assign(__s.begin(), __s.end(), __mc, __flags & regex_constants::__no_update_pos);
6062 #if _LIBCPP_STD_VER > 11
6063 template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
6065 regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
6066 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
6067 const basic_regex<_Cp, _Tp>& __e,
6068 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
6073 template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
6075 regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
6076 match_results<_BidirectionalIterator, _Allocator>& __m,
6077 const basic_regex<_CharT, _Traits>& __e,
6078 regex_constants::match_flag_type __flags = regex_constants::match_default)
6080 bool __r = _VSTD::regex_search(
6081 __first, __last, __m, __e,
6082 __flags | regex_constants::match_continuous |
6083 regex_constants::__full_match);
6086 __r = !__m.suffix().matched;
6088 __m.__matches_.clear();
6093 template <class _BidirectionalIterator, class _CharT, class _Traits>
6094 inline _LIBCPP_INLINE_VISIBILITY
6096 regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
6097 const basic_regex<_CharT, _Traits>& __e,
6098 regex_constants::match_flag_type __flags = regex_constants::match_default)
6100 match_results<_BidirectionalIterator> __m;
6101 return _VSTD::regex_match(__first, __last, __m, __e, __flags);
6104 template <class _CharT, class _Allocator, class _Traits>
6105 inline _LIBCPP_INLINE_VISIBILITY
6107 regex_match(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
6108 const basic_regex<_CharT, _Traits>& __e,
6109 regex_constants::match_flag_type __flags = regex_constants::match_default)
6111 return _VSTD::regex_match(__str, __str + _Traits::length(__str), __m, __e, __flags);
6114 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
6115 inline _LIBCPP_INLINE_VISIBILITY
6117 regex_match(const basic_string<_CharT, _ST, _SA>& __s,
6118 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
6119 const basic_regex<_CharT, _Traits>& __e,
6120 regex_constants::match_flag_type __flags = regex_constants::match_default)
6122 return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags);
6125 #if _LIBCPP_STD_VER > 11
6126 template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
6127 inline _LIBCPP_INLINE_VISIBILITY
6129 regex_match(const basic_string<_CharT, _ST, _SA>&& __s,
6130 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
6131 const basic_regex<_CharT, _Traits>& __e,
6132 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
6135 template <class _CharT, class _Traits>
6136 inline _LIBCPP_INLINE_VISIBILITY
6138 regex_match(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
6139 regex_constants::match_flag_type __flags = regex_constants::match_default)
6141 return _VSTD::regex_match(__str, __str + _Traits::length(__str), __e, __flags);
6144 template <class _ST, class _SA, class _CharT, class _Traits>
6145 inline _LIBCPP_INLINE_VISIBILITY
6147 regex_match(const basic_string<_CharT, _ST, _SA>& __s,
6148 const basic_regex<_CharT, _Traits>& __e,
6149 regex_constants::match_flag_type __flags = regex_constants::match_default)
6151 return _VSTD::regex_match(__s.begin(), __s.end(), __e, __flags);
6156 template <class _BidirectionalIterator,
6157 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
6158 class _Traits = regex_traits<_CharT> >
6159 class _LIBCPP_TEMPLATE_VIS regex_iterator
6162 typedef basic_regex<_CharT, _Traits> regex_type;
6163 typedef match_results<_BidirectionalIterator> value_type;
6164 typedef ptrdiff_t difference_type;
6165 typedef const value_type* pointer;
6166 typedef const value_type& reference;
6167 typedef forward_iterator_tag iterator_category;
6170 _BidirectionalIterator __begin_;
6171 _BidirectionalIterator __end_;
6172 const regex_type* __pregex_;
6173 regex_constants::match_flag_type __flags_;
6174 value_type __match_;
6178 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6179 const regex_type& __re,
6180 regex_constants::match_flag_type __m
6181 = regex_constants::match_default);
6182 #if _LIBCPP_STD_VER > 11
6183 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6184 const regex_type&& __re,
6185 regex_constants::match_flag_type __m
6186 = regex_constants::match_default) = delete;
6189 bool operator==(const regex_iterator& __x) const;
6190 _LIBCPP_INLINE_VISIBILITY
6191 bool operator!=(const regex_iterator& __x) const {return !(*this == __x);}
6193 _LIBCPP_INLINE_VISIBILITY
6194 reference operator*() const {return __match_;}
6195 _LIBCPP_INLINE_VISIBILITY
6196 pointer operator->() const {return _VSTD::addressof(__match_);}
6198 regex_iterator& operator++();
6199 _LIBCPP_INLINE_VISIBILITY
6200 regex_iterator operator++(int)
6202 regex_iterator __t(*this);
6208 template <class _BidirectionalIterator, class _CharT, class _Traits>
6209 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_iterator()
6210 : __begin_(), __end_(), __pregex_(nullptr), __flags_(), __match_()
6214 template <class _BidirectionalIterator, class _CharT, class _Traits>
6215 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
6216 regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6217 const regex_type& __re, regex_constants::match_flag_type __m)
6220 __pregex_(_VSTD::addressof(__re)),
6223 _VSTD::regex_search(__begin_, __end_, __match_, *__pregex_, __flags_);
6226 template <class _BidirectionalIterator, class _CharT, class _Traits>
6228 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
6229 operator==(const regex_iterator& __x) const
6231 if (__match_.empty() && __x.__match_.empty())
6233 if (__match_.empty() || __x.__match_.empty())
6235 return __begin_ == __x.__begin_ &&
6236 __end_ == __x.__end_ &&
6237 __pregex_ == __x.__pregex_ &&
6238 __flags_ == __x.__flags_ &&
6239 __match_[0] == __x.__match_[0];
6242 template <class _BidirectionalIterator, class _CharT, class _Traits>
6243 regex_iterator<_BidirectionalIterator, _CharT, _Traits>&
6244 regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6246 __flags_ |= regex_constants::__no_update_pos;
6247 _BidirectionalIterator __start = __match_[0].second;
6248 if (__match_[0].first == __match_[0].second)
6250 if (__start == __end_)
6252 __match_ = value_type();
6255 else if (_VSTD::regex_search(__start, __end_, __match_, *__pregex_,
6256 __flags_ | regex_constants::match_not_null |
6257 regex_constants::match_continuous))
6262 __flags_ |= regex_constants::match_prev_avail;
6263 if (!_VSTD::regex_search(__start, __end_, __match_, *__pregex_, __flags_))
6264 __match_ = value_type();
6268 typedef regex_iterator<const char*> cregex_iterator;
6269 typedef regex_iterator<const wchar_t*> wcregex_iterator;
6270 typedef regex_iterator<string::const_iterator> sregex_iterator;
6271 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
6273 // regex_token_iterator
6275 template <class _BidirectionalIterator,
6276 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
6277 class _Traits = regex_traits<_CharT> >
6278 class _LIBCPP_TEMPLATE_VIS regex_token_iterator
6281 typedef basic_regex<_CharT, _Traits> regex_type;
6282 typedef sub_match<_BidirectionalIterator> value_type;
6283 typedef ptrdiff_t difference_type;
6284 typedef const value_type* pointer;
6285 typedef const value_type& reference;
6286 typedef forward_iterator_tag iterator_category;
6289 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position;
6291 _Position __position_;
6292 const value_type* __result_;
6293 value_type __suffix_;
6295 vector<int> __subs_;
6298 regex_token_iterator();
6299 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6300 const regex_type& __re, int __submatch = 0,
6301 regex_constants::match_flag_type __m =
6302 regex_constants::match_default);
6303 #if _LIBCPP_STD_VER > 11
6304 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6305 const regex_type&& __re, int __submatch = 0,
6306 regex_constants::match_flag_type __m =
6307 regex_constants::match_default) = delete;
6310 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6311 const regex_type& __re, const vector<int>& __submatches,
6312 regex_constants::match_flag_type __m =
6313 regex_constants::match_default);
6314 #if _LIBCPP_STD_VER > 11
6315 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6316 const regex_type&& __re, const vector<int>& __submatches,
6317 regex_constants::match_flag_type __m =
6318 regex_constants::match_default) = delete;
6321 #ifndef _LIBCPP_CXX03_LANG
6322 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6323 const regex_type& __re,
6324 initializer_list<int> __submatches,
6325 regex_constants::match_flag_type __m =
6326 regex_constants::match_default);
6328 #if _LIBCPP_STD_VER > 11
6329 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6330 const regex_type&& __re,
6331 initializer_list<int> __submatches,
6332 regex_constants::match_flag_type __m =
6333 regex_constants::match_default) = delete;
6335 #endif // _LIBCPP_CXX03_LANG
6336 template <size_t _Np>
6337 regex_token_iterator(_BidirectionalIterator __a,
6338 _BidirectionalIterator __b,
6339 const regex_type& __re,
6340 const int (&__submatches)[_Np],
6341 regex_constants::match_flag_type __m =
6342 regex_constants::match_default);
6343 #if _LIBCPP_STD_VER > 11
6344 template <std::size_t _Np>
6345 regex_token_iterator(_BidirectionalIterator __a,
6346 _BidirectionalIterator __b,
6347 const regex_type&& __re,
6348 const int (&__submatches)[_Np],
6349 regex_constants::match_flag_type __m =
6350 regex_constants::match_default) = delete;
6353 regex_token_iterator(const regex_token_iterator&);
6354 regex_token_iterator& operator=(const regex_token_iterator&);
6356 bool operator==(const regex_token_iterator& __x) const;
6357 _LIBCPP_INLINE_VISIBILITY
6358 bool operator!=(const regex_token_iterator& __x) const {return !(*this == __x);}
6360 _LIBCPP_INLINE_VISIBILITY
6361 const value_type& operator*() const {return *__result_;}
6362 _LIBCPP_INLINE_VISIBILITY
6363 const value_type* operator->() const {return __result_;}
6365 regex_token_iterator& operator++();
6366 _LIBCPP_INLINE_VISIBILITY
6367 regex_token_iterator operator++(int)
6369 regex_token_iterator __t(*this);
6375 void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
6376 void __establish_result () {
6377 if (__subs_[__n_] == -1)
6378 __result_ = &__position_->prefix();
6380 __result_ = &(*__position_)[__subs_[__n_]];
6384 template <class _BidirectionalIterator, class _CharT, class _Traits>
6385 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6386 regex_token_iterator()
6387 : __result_(nullptr),
6393 template <class _BidirectionalIterator, class _CharT, class _Traits>
6395 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6396 __init(_BidirectionalIterator __a, _BidirectionalIterator __b)
6398 if (__position_ != _Position())
6399 __establish_result ();
6400 else if (__subs_[__n_] == -1)
6402 __suffix_.matched = true;
6403 __suffix_.first = __a;
6404 __suffix_.second = __b;
6405 __result_ = &__suffix_;
6408 __result_ = nullptr;
6411 template <class _BidirectionalIterator, class _CharT, class _Traits>
6412 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6413 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6414 const regex_type& __re, int __submatch,
6415 regex_constants::match_flag_type __m)
6416 : __position_(__a, __b, __re, __m),
6418 __subs_(1, __submatch)
6423 template <class _BidirectionalIterator, class _CharT, class _Traits>
6424 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6425 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6426 const regex_type& __re, const vector<int>& __submatches,
6427 regex_constants::match_flag_type __m)
6428 : __position_(__a, __b, __re, __m),
6430 __subs_(__submatches)
6435 #ifndef _LIBCPP_CXX03_LANG
6437 template <class _BidirectionalIterator, class _CharT, class _Traits>
6438 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6439 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6440 const regex_type& __re,
6441 initializer_list<int> __submatches,
6442 regex_constants::match_flag_type __m)
6443 : __position_(__a, __b, __re, __m),
6445 __subs_(__submatches)
6450 #endif // _LIBCPP_CXX03_LANG
6452 template <class _BidirectionalIterator, class _CharT, class _Traits>
6453 template <size_t _Np>
6454 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6455 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
6456 const regex_type& __re,
6457 const int (&__submatches)[_Np],
6458 regex_constants::match_flag_type __m)
6459 : __position_(__a, __b, __re, __m),
6461 __subs_(begin(__submatches), end(__submatches))
6466 template <class _BidirectionalIterator, class _CharT, class _Traits>
6467 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6468 regex_token_iterator(const regex_token_iterator& __x)
6469 : __position_(__x.__position_),
6470 __result_(__x.__result_),
6471 __suffix_(__x.__suffix_),
6473 __subs_(__x.__subs_)
6475 if (__x.__result_ == &__x.__suffix_)
6476 __result_ = &__suffix_;
6477 else if ( __result_ != nullptr )
6478 __establish_result ();
6481 template <class _BidirectionalIterator, class _CharT, class _Traits>
6482 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
6483 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6484 operator=(const regex_token_iterator& __x)
6488 __position_ = __x.__position_;
6489 if (__x.__result_ == &__x.__suffix_)
6490 __result_ = &__suffix_;
6492 __result_ = __x.__result_;
6493 __suffix_ = __x.__suffix_;
6495 __subs_ = __x.__subs_;
6497 if ( __result_ != nullptr && __result_ != &__suffix_ )
6498 __establish_result();
6503 template <class _BidirectionalIterator, class _CharT, class _Traits>
6505 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
6506 operator==(const regex_token_iterator& __x) const
6508 if (__result_ == nullptr && __x.__result_ == nullptr)
6510 if (__result_ == &__suffix_ && __x.__result_ == &__x.__suffix_ &&
6511 __suffix_ == __x.__suffix_)
6513 if (__result_ == nullptr || __x.__result_ == nullptr)
6515 if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_)
6517 return __position_ == __x.__position_ && __n_ == __x.__n_ &&
6518 __subs_ == __x.__subs_;
6521 template <class _BidirectionalIterator, class _CharT, class _Traits>
6522 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
6523 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
6525 _Position __prev = __position_;
6526 if (__result_ == &__suffix_)
6527 __result_ = nullptr;
6528 else if (static_cast<size_t>(__n_ + 1) < __subs_.size())
6531 __establish_result();
6537 if (__position_ != _Position())
6538 __establish_result();
6541 if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end()
6542 && __prev->suffix().length() != 0)
6544 __suffix_.matched = true;
6545 __suffix_.first = __prev->suffix().first;
6546 __suffix_.second = __prev->suffix().second;
6547 __result_ = &__suffix_;
6550 __result_ = nullptr;
6556 typedef regex_token_iterator<const char*> cregex_token_iterator;
6557 typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
6558 typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
6559 typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
6563 template <class _OutputIterator, class _BidirectionalIterator,
6564 class _Traits, class _CharT>
6566 regex_replace(_OutputIterator __output_iter,
6567 _BidirectionalIterator __first, _BidirectionalIterator __last,
6568 const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
6569 regex_constants::match_flag_type __flags = regex_constants::match_default)
6571 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Iter;
6572 _Iter __i(__first, __last, __e, __flags);
6576 if (!(__flags & regex_constants::format_no_copy))
6577 __output_iter = _VSTD::copy(__first, __last, __output_iter);
6581 sub_match<_BidirectionalIterator> __lm;
6582 for (size_t __len = char_traits<_CharT>::length(__fmt); __i != __eof; ++__i)
6584 if (!(__flags & regex_constants::format_no_copy))
6585 __output_iter = _VSTD::copy(__i->prefix().first, __i->prefix().second, __output_iter);
6586 __output_iter = __i->format(__output_iter, __fmt, __fmt + __len, __flags);
6587 __lm = __i->suffix();
6588 if (__flags & regex_constants::format_first_only)
6591 if (!(__flags & regex_constants::format_no_copy))
6592 __output_iter = _VSTD::copy(__lm.first, __lm.second, __output_iter);
6594 return __output_iter;
6597 template <class _OutputIterator, class _BidirectionalIterator,
6598 class _Traits, class _CharT, class _ST, class _SA>
6599 inline _LIBCPP_INLINE_VISIBILITY
6601 regex_replace(_OutputIterator __output_iter,
6602 _BidirectionalIterator __first, _BidirectionalIterator __last,
6603 const basic_regex<_CharT, _Traits>& __e,
6604 const basic_string<_CharT, _ST, _SA>& __fmt,
6605 regex_constants::match_flag_type __flags = regex_constants::match_default)
6607 return _VSTD::regex_replace(__output_iter, __first, __last, __e, __fmt.c_str(), __flags);
6610 template <class _Traits, class _CharT, class _ST, class _SA, class _FST,
6612 inline _LIBCPP_INLINE_VISIBILITY
6613 basic_string<_CharT, _ST, _SA>
6614 regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6615 const basic_regex<_CharT, _Traits>& __e,
6616 const basic_string<_CharT, _FST, _FSA>& __fmt,
6617 regex_constants::match_flag_type __flags = regex_constants::match_default)
6619 basic_string<_CharT, _ST, _SA> __r;
6620 _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6621 __fmt.c_str(), __flags);
6625 template <class _Traits, class _CharT, class _ST, class _SA>
6626 inline _LIBCPP_INLINE_VISIBILITY
6627 basic_string<_CharT, _ST, _SA>
6628 regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6629 const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
6630 regex_constants::match_flag_type __flags = regex_constants::match_default)
6632 basic_string<_CharT, _ST, _SA> __r;
6633 _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6638 template <class _Traits, class _CharT, class _ST, class _SA>
6639 inline _LIBCPP_INLINE_VISIBILITY
6640 basic_string<_CharT>
6641 regex_replace(const _CharT* __s,
6642 const basic_regex<_CharT, _Traits>& __e,
6643 const basic_string<_CharT, _ST, _SA>& __fmt,
6644 regex_constants::match_flag_type __flags = regex_constants::match_default)
6646 basic_string<_CharT> __r;
6647 _VSTD::regex_replace(back_inserter(__r), __s,
6648 __s + char_traits<_CharT>::length(__s), __e,
6649 __fmt.c_str(), __flags);
6653 template <class _Traits, class _CharT>
6654 inline _LIBCPP_INLINE_VISIBILITY
6655 basic_string<_CharT>
6656 regex_replace(const _CharT* __s,
6657 const basic_regex<_CharT, _Traits>& __e,
6658 const _CharT* __fmt,
6659 regex_constants::match_flag_type __flags = regex_constants::match_default)
6661 basic_string<_CharT> __r;
6662 _VSTD::regex_replace(back_inserter(__r), __s,
6663 __s + char_traits<_CharT>::length(__s), __e,
6668 _LIBCPP_END_NAMESPACE_STD
6672 #endif // _LIBCPP_REGEX