aboutsummaryrefslogtreecommitdiff
path: root/include/regex
diff options
context:
space:
mode:
Diffstat (limited to 'include/regex')
-rw-r--r--include/regex184
1 files changed, 144 insertions, 40 deletions
diff --git a/include/regex b/include/regex
index ffe39cf1cffa..690213a978d8 100644
--- a/include/regex
+++ b/include/regex
@@ -437,7 +437,7 @@ class match_results
public:
typedef sub_match<BidirectionalIterator> value_type;
typedef const value_type& const_reference;
- typedef const_reference reference;
+ typedef value_type& reference;
typedef /implementation-defined/ const_iterator;
typedef const_iterator iterator;
typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
@@ -546,6 +546,13 @@ template <class ST, class SA, class Allocator, class charT, class traits>
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
+template <class ST, class SA, class Allocator, class charT, class traits>
+ bool
+ regex_match(const basic_string<charT, ST, SA>&& s,
+ match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
+
template <class charT, class traits>
bool
regex_match(const charT* str, const basic_regex<charT, traits>& e,
@@ -594,6 +601,13 @@ template <class ST, class SA, class Allocator, class charT, class traits>
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
+template <class ST, class SA, class Allocator, class charT, class traits>
+ bool
+ regex_search(const basic_string<charT, ST, SA>&& s,
+ match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
+ const basic_regex<charT, traits>& e,
+ regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
+
template <class OutputIterator, class BidirectionalIterator,
class traits, class charT, class ST, class SA>
OutputIterator
@@ -655,6 +669,10 @@ public:
regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
regex_constants::match_flag_type m = regex_constants::match_default);
+ regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type&& __re,
+ regex_constants::match_flag_type __m
+ = regex_constants::match_default) = delete; // C++14
regex_iterator(const regex_iterator&);
regex_iterator& operator=(const regex_iterator&);
@@ -691,15 +709,28 @@ public:
const regex_type& re, int submatch = 0,
regex_constants::match_flag_type m = regex_constants::match_default);
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type&& re, int submatch = 0,
+ regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re, const vector<int>& submatches,
regex_constants::match_flag_type m = regex_constants::match_default);
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type&& re, const vector<int>& submatches,
+ regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re, initializer_list<int> submatches,
regex_constants::match_flag_type m = regex_constants::match_default);
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type&& re, initializer_list<int> submatches,
+ regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
template <size_t N>
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re, const int (&submatches)[N],
regex_constants::match_flag_type m = regex_constants::match_default);
+ template <size_t N>
+ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type& re, const int (&submatches)[N],
+ regex_constants::match_flag_type m = regex_constants::match_default) = delete // C++14;
regex_token_iterator(const regex_token_iterator&);
regex_token_iterator& operator=(const regex_token_iterator&);
@@ -1161,7 +1192,8 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
// lookup_classname
-ctype_base::mask _LIBCPP_FUNC_VIS __get_classname(const char* __s, bool __icase);
+regex_traits<char>::char_class_type _LIBCPP_FUNC_VIS
+__get_classname(const char* __s, bool __icase);
template <class _CharT>
template <class _ForwardIterator>
@@ -2153,8 +2185,8 @@ class __bracket_expression
vector<pair<string_type, string_type> > __ranges_;
vector<pair<_CharT, _CharT> > __digraphs_;
vector<string_type> __equivalences_;
- ctype_base::mask __mask_;
- ctype_base::mask __neg_mask_;
+ typename regex_traits<_CharT>::char_class_type __mask_;
+ typename regex_traits<_CharT>::char_class_type __neg_mask_;
bool __negate_;
bool __icase_;
bool __collate_;
@@ -2250,10 +2282,10 @@ public:
void __add_equivalence(const string_type& __s)
{__equivalences_.push_back(__s);}
_LIBCPP_INLINE_VISIBILITY
- void __add_class(ctype_base::mask __mask)
+ void __add_class(typename regex_traits<_CharT>::char_class_type __mask)
{__mask_ |= __mask;}
_LIBCPP_INLINE_VISIBILITY
- void __add_neg_class(ctype_base::mask __mask)
+ void __add_neg_class(typename regex_traits<_CharT>::char_class_type __mask)
{__neg_mask_ |= __mask;}
};
@@ -3310,10 +3342,14 @@ basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first,
_ForwardIterator __temp = _VSTD::next(__first);
if (__temp != __last)
{
- if (*__first == '\\' && '1' <= *__temp && *__temp <= '9')
- {
- __push_back_ref(*__temp - '0');
- __first = ++__temp;
+ if (*__first == '\\')
+ {
+ int __val = __traits_.value(*__temp, 10);
+ if (__val >= 1 && __val <= 9)
+ {
+ __push_back_ref(__val);
+ __first = ++__temp;
+ }
}
}
}
@@ -4052,14 +4088,19 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
_ForwardIterator __last,
int& __c)
{
- if (__first != __last && '0' <= *__first && *__first <= '9')
+ if (__first != __last )
{
- __c = *__first - '0';
- for (++__first; __first != __last && '0' <= *__first && *__first <= '9';
- ++__first)
+ int __val = __traits_.value(*__first, 10);
+ if ( __val != -1 )
{
- __c *= 10;
- __c += *__first - '0';
+ __c = __val;
+ for (++__first;
+ __first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
+ ++__first)
+ {
+ __c *= 10;
+ __c += __val;
+ }
}
}
return __first;
@@ -4501,6 +4542,13 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
__push_char(_CharT(__sum));
++__first;
break;
+ case '0':
+ if (__str)
+ *__str = _CharT(0);
+ else
+ __push_char(_CharT(0));
+ ++__first;
+ break;
default:
if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum))
{
@@ -4878,7 +4926,7 @@ bool
operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
const sub_match<_BiIter>& __y)
{
- return __y.compare(__x.c_str()) == 0;
+ return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0;
}
template <class _BiIter, class _ST, class _SA>
@@ -4896,7 +4944,7 @@ bool
operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
const sub_match<_BiIter>& __y)
{
- return __y.compare(__x.c_str()) > 0;
+ return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0;
}
template <class _BiIter, class _ST, class _SA>
@@ -4931,7 +4979,7 @@ bool
operator==(const sub_match<_BiIter>& __x,
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
{
- return __x.compare(__y.c_str()) == 0;
+ return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;
}
template <class _BiIter, class _ST, class _SA>
@@ -4949,7 +4997,7 @@ bool
operator<(const sub_match<_BiIter>& __x,
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
{
- return __x.compare(__y.c_str()) < 0;
+ return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0;
}
template <class _BiIter, class _ST, class _SA>
@@ -5223,7 +5271,7 @@ private:
public:
_BidirectionalIterator __position_start_;
typedef const value_type& const_reference;
- typedef const_reference reference;
+ typedef value_type& reference;
typedef typename __container_type::const_iterator const_iterator;
typedef const_iterator iterator;
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
@@ -5934,6 +5982,15 @@ regex_search(const basic_string<_CharT, _ST, _SA>& __s,
return __r;
}
+#if _LIBCPP_STD_VER > 11
+template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
+bool
+regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
+ match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
+ const basic_regex<_Cp, _Tp>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
+#endif
+
// regex_match
template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
@@ -5986,6 +6043,16 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,
return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags);
}
+#if _LIBCPP_STD_VER > 11
+template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(const basic_string<_CharT, _ST, _SA>&& __s,
+ match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
+ const basic_regex<_CharT, _Traits>& __e,
+ regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
+#endif
+
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
bool
@@ -6031,7 +6098,14 @@ public:
regex_iterator();
regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
const regex_type& __re,
- regex_constants::match_flag_type __m = regex_constants::match_default);
+ regex_constants::match_flag_type __m
+ = regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+ regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type&& __re,
+ regex_constants::match_flag_type __m
+ = regex_constants::match_default) = delete;
+#endif
bool operator==(const regex_iterator& __x) const;
_LIBCPP_INLINE_VISIBILITY
@@ -6147,16 +6221,38 @@ public:
const regex_type& __re, int __submatch = 0,
regex_constants::match_flag_type __m =
regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type&& __re, int __submatch = 0,
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default) = delete;
+#endif
+
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
const regex_type& __re, const vector<int>& __submatches,
regex_constants::match_flag_type __m =
regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type&& __re, const vector<int>& __submatches,
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default) = delete;
+#endif
+
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
const regex_type& __re,
initializer_list<int> __submatches,
regex_constants::match_flag_type __m =
regex_constants::match_default);
+
+#if _LIBCPP_STD_VER > 11
+ regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+ const regex_type&& __re,
+ initializer_list<int> __submatches,
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default) = delete;
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
template <size_t _Np>
regex_token_iterator(_BidirectionalIterator __a,
@@ -6165,6 +6261,16 @@ public:
const int (&__submatches)[_Np],
regex_constants::match_flag_type __m =
regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+ template <std::size_t _Np>
+ regex_token_iterator(_BidirectionalIterator __a,
+ _BidirectionalIterator __b,
+ const regex_type&& __re,
+ const int (&__submatches)[_Np],
+ regex_constants::match_flag_type __m =
+ regex_constants::match_default) = delete;
+#endif
+
regex_token_iterator(const regex_token_iterator&);
regex_token_iterator& operator=(const regex_token_iterator&);
@@ -6188,6 +6294,12 @@ public:
private:
void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
+ void __establish_result () {
+ if (__subs_[_N_] == -1)
+ __result_ = &__position_->prefix();
+ else
+ __result_ = &(*__position_)[__subs_[_N_]];
+ }
};
template <class _BidirectionalIterator, class _CharT, class _Traits>
@@ -6205,12 +6317,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
__init(_BidirectionalIterator __a, _BidirectionalIterator __b)
{
if (__position_ != _Position())
- {
- if (__subs_[_N_] == -1)
- __result_ = &__position_->prefix();
- else
- __result_ = &(*__position_)[__subs_[_N_]];
- }
+ __establish_result ();
else if (__subs_[_N_] == -1)
{
__suffix_.matched = true;
@@ -6287,7 +6394,9 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
__subs_(__x.__subs_)
{
if (__x.__result_ == &__x.__suffix_)
- __result_ == &__suffix_;
+ __result_ = &__suffix_;
+ else if ( __result_ != nullptr )
+ __establish_result ();
}
template <class _BidirectionalIterator, class _CharT, class _Traits>
@@ -6299,12 +6408,15 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
{
__position_ = __x.__position_;
if (__x.__result_ == &__x.__suffix_)
- __result_ == &__suffix_;
+ __result_ = &__suffix_;
else
__result_ = __x.__result_;
__suffix_ = __x.__suffix_;
_N_ = __x._N_;
__subs_ = __x.__subs_;
+
+ if ( __result_ != nullptr && __result_ != &__suffix_ )
+ __establish_result();
}
return *this;
}
@@ -6337,22 +6449,14 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
else if (_N_ + 1 < __subs_.size())
{
++_N_;
- if (__subs_[_N_] == -1)
- __result_ = &__position_->prefix();
- else
- __result_ = &(*__position_)[__subs_[_N_]];
+ __establish_result();
}
else
{
_N_ = 0;
++__position_;
if (__position_ != _Position())
- {
- if (__subs_[_N_] == -1)
- __result_ = &__position_->prefix();
- else
- __result_ = &(*__position_)[__subs_[_N_]];
- }
+ __establish_result();
else
{
if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end()