aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/regex.h
diff options
context:
space:
mode:
authorTim Shen <timshen@google.com>2014-12-13 22:19:18 +0000
committerTim Shen <timshen@gcc.gnu.org>2014-12-13 22:19:18 +0000
commitbc2738455bf4e405cf0ad3d61482b49cd4382113 (patch)
tree8fbd14b1bfca1e100c674f1a08fca314b98923e6 /libstdc++-v3/include/bits/regex.h
parent6554581713da6cc9bb96cf86cf7a0cece80a448e (diff)
re PR libstdc++/64239 (regex_iterator::operator= should copy match_results::position)
PR libstdc++/64239 * include/bits/regex.h (match_results<>::match_results, match_results<>::operator=, match_results<>::position, match_results<>::swap): Remove match_results::_M_in_iterator. Fix ctor/assign/swap. * include/bits/regex.tcc: (__regex_algo_impl<>, regex_iterator<>::operator++): Set match_results::_M_begin as "start position". * testsuite/28_regex/iterators/regex_iterator/char/ string_position_01.cc: Test cases. From-SVN: r218710
Diffstat (limited to 'libstdc++-v3/include/bits/regex.h')
-rw-r--r--libstdc++-v3/include/bits/regex.h37
1 files changed, 11 insertions, 26 deletions
diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index cb6bc93251a..3afec37ab16 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -1563,42 +1563,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
explicit
match_results(const _Alloc& __a = _Alloc())
- : _Base_type(__a), _M_in_iterator(false)
+ : _Base_type(__a)
{ }
/**
* @brief Copy constructs a %match_results.
*/
- match_results(const match_results& __rhs)
- : _Base_type(__rhs), _M_in_iterator(false)
- { }
+ match_results(const match_results& __rhs) = default;
/**
* @brief Move constructs a %match_results.
*/
- match_results(match_results&& __rhs) noexcept
- : _Base_type(std::move(__rhs)), _M_in_iterator(false)
- { }
+ match_results(match_results&& __rhs) noexcept = default;
/**
* @brief Assigns rhs to *this.
*/
match_results&
- operator=(const match_results& __rhs)
- {
- match_results(__rhs).swap(*this);
- return *this;
- }
+ operator=(const match_results& __rhs) = default;
/**
* @brief Move-assigns rhs to *this.
*/
match_results&
- operator=(match_results&& __rhs)
- {
- match_results(std::move(__rhs)).swap(*this);
- return *this;
- }
+ operator=(match_results&& __rhs) = default;
/**
* @brief Destroys a %match_results object.
@@ -1685,13 +1673,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
difference_type
position(size_type __sub = 0) const
{
- // [28.12.1.4.5]
- if (_M_in_iterator)
- return __sub < size() ? std::distance(_M_begin,
- (*this)[__sub].first) : -1;
- else
- return __sub < size() ? std::distance(this->prefix().first,
- (*this)[__sub].first) : -1;
+ return __sub < size() ? std::distance(_M_begin,
+ (*this)[__sub].first) : -1;
}
/**
@@ -1876,7 +1859,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
void
swap(match_results& __that)
- { _Base_type::swap(__that); }
+ {
+ _Base_type::swap(__that);
+ swap(_M_begin, __that._M_begin);
+ }
//@}
private:
@@ -1894,7 +1880,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
regex_constants::match_flag_type);
_Bi_iter _M_begin;
- bool _M_in_iterator;
};
typedef match_results<const char*> cmatch;