mirror of git://gcc.gnu.org/git/gcc.git
Default special members of regex types and add noexcept
* include/bits/regex.h (sub_match): Add noexcept to default constructor and length observer. (match_results): Add noexcept to default constructor and observers with no preconditions. Define destructor as defaulted. (operator==, operator!=, swap): Add noexcept. (regex_iterator): Add default member initializers and define default constructor and destructor as defaulted. Add noexcept to equality and dereference operators. From-SVN: r261266
This commit is contained in:
parent
ca6b7410dd
commit
c962b2c36f
|
|
@ -1,3 +1,14 @@
|
||||||
|
2018-06-07 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
* include/bits/regex.h (sub_match): Add noexcept to default
|
||||||
|
constructor and length observer.
|
||||||
|
(match_results): Add noexcept to default constructor and observers
|
||||||
|
with no preconditions. Define destructor as defaulted.
|
||||||
|
(operator==, operator!=, swap): Add noexcept.
|
||||||
|
(regex_iterator): Add default member initializers and define default
|
||||||
|
constructor and destructor as defaulted. Add noexcept to equality
|
||||||
|
and dereference operators.
|
||||||
|
|
||||||
2018-06-07 François Dumont <fdumont@gcc.gnu.org>
|
2018-06-07 François Dumont <fdumont@gcc.gnu.org>
|
||||||
|
|
||||||
* src/c++11/debug.cc
|
* src/c++11/debug.cc
|
||||||
|
|
|
||||||
|
|
@ -868,18 +868,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
public:
|
public:
|
||||||
typedef typename __iter_traits::value_type value_type;
|
typedef typename __iter_traits::value_type value_type;
|
||||||
typedef typename __iter_traits::difference_type difference_type;
|
typedef typename __iter_traits::difference_type difference_type;
|
||||||
typedef _BiIter iterator;
|
typedef _BiIter iterator;
|
||||||
typedef std::basic_string<value_type> string_type;
|
typedef basic_string<value_type> string_type;
|
||||||
|
|
||||||
bool matched;
|
bool matched;
|
||||||
|
|
||||||
constexpr sub_match() : matched() { }
|
constexpr sub_match() noexcept : matched() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the length of the matching sequence.
|
* Gets the length of the matching sequence.
|
||||||
*/
|
*/
|
||||||
difference_type
|
difference_type
|
||||||
length() const
|
length() const noexcept
|
||||||
{ return this->matched ? std::distance(this->first, this->second) : 0; }
|
{ return this->matched ? std::distance(this->first, this->second) : 0; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1602,37 +1602,36 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
* @post size() returns 0 and str() returns an empty string.
|
* @post size() returns 0 and str() returns an empty string.
|
||||||
*/
|
*/
|
||||||
explicit
|
explicit
|
||||||
match_results(const _Alloc& __a = _Alloc())
|
match_results(const _Alloc& __a = _Alloc()) noexcept
|
||||||
: _Base_type(__a)
|
: _Base_type(__a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Copy constructs a %match_results.
|
* @brief Copy constructs a %match_results.
|
||||||
*/
|
*/
|
||||||
match_results(const match_results& __rhs) = default;
|
match_results(const match_results&) = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Move constructs a %match_results.
|
* @brief Move constructs a %match_results.
|
||||||
*/
|
*/
|
||||||
match_results(match_results&& __rhs) noexcept = default;
|
match_results(match_results&&) noexcept = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Assigns rhs to *this.
|
* @brief Assigns rhs to *this.
|
||||||
*/
|
*/
|
||||||
match_results&
|
match_results&
|
||||||
operator=(const match_results& __rhs) = default;
|
operator=(const match_results&) = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Move-assigns rhs to *this.
|
* @brief Move-assigns rhs to *this.
|
||||||
*/
|
*/
|
||||||
match_results&
|
match_results&
|
||||||
operator=(match_results&& __rhs) = default;
|
operator=(match_results&&) = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroys a %match_results object.
|
* @brief Destroys a %match_results object.
|
||||||
*/
|
*/
|
||||||
~match_results()
|
~match_results() = default;
|
||||||
{ }
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
|
@ -1642,7 +1641,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
* @retval true The object has a fully-established result state.
|
* @retval true The object has a fully-established result state.
|
||||||
* @retval false The object is not ready.
|
* @retval false The object is not ready.
|
||||||
*/
|
*/
|
||||||
bool ready() const { return !_Base_type::empty(); }
|
bool ready() const noexcept { return !_Base_type::empty(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name 28.10.2 Size
|
* @name 28.10.2 Size
|
||||||
|
|
@ -1659,11 +1658,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
* @returns the number of matches found.
|
* @returns the number of matches found.
|
||||||
*/
|
*/
|
||||||
size_type
|
size_type
|
||||||
size() const
|
size() const noexcept
|
||||||
{ return _Base_type::empty() ? 0 : _Base_type::size() - 3; }
|
{ return _Base_type::empty() ? 0 : _Base_type::size() - 3; }
|
||||||
|
|
||||||
size_type
|
size_type
|
||||||
max_size() const
|
max_size() const noexcept
|
||||||
{ return _Base_type::max_size(); }
|
{ return _Base_type::max_size(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1672,7 +1671,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
* @retval false The %match_results object is not empty.
|
* @retval false The %match_results object is not empty.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
empty() const
|
empty() const noexcept
|
||||||
{ return size() == 0; }
|
{ return size() == 0; }
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
@ -1776,28 +1775,28 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
* @brief Gets an iterator to the start of the %sub_match collection.
|
* @brief Gets an iterator to the start of the %sub_match collection.
|
||||||
*/
|
*/
|
||||||
const_iterator
|
const_iterator
|
||||||
begin() const
|
begin() const noexcept
|
||||||
{ return _Base_type::begin(); }
|
{ return _Base_type::begin(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets an iterator to the start of the %sub_match collection.
|
* @brief Gets an iterator to the start of the %sub_match collection.
|
||||||
*/
|
*/
|
||||||
const_iterator
|
const_iterator
|
||||||
cbegin() const
|
cbegin() const noexcept
|
||||||
{ return this->begin(); }
|
{ return this->begin(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets an iterator to one-past-the-end of the collection.
|
* @brief Gets an iterator to one-past-the-end of the collection.
|
||||||
*/
|
*/
|
||||||
const_iterator
|
const_iterator
|
||||||
end() const
|
end() const noexcept
|
||||||
{ return _Base_type::end() - (empty() ? 0 : 3); }
|
{ return _Base_type::end() - (empty() ? 0 : 3); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets an iterator to one-past-the-end of the collection.
|
* @brief Gets an iterator to one-past-the-end of the collection.
|
||||||
*/
|
*/
|
||||||
const_iterator
|
const_iterator
|
||||||
cend() const
|
cend() const noexcept
|
||||||
{ return this->end(); }
|
{ return this->end(); }
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
@ -1872,7 +1871,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
* @brief Gets a copy of the allocator.
|
* @brief Gets a copy of the allocator.
|
||||||
*/
|
*/
|
||||||
allocator_type
|
allocator_type
|
||||||
get_allocator() const
|
get_allocator() const noexcept
|
||||||
{ return _Base_type::get_allocator(); }
|
{ return _Base_type::get_allocator(); }
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
@ -1886,7 +1885,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
* @brief Swaps the contents of two match_results.
|
* @brief Swaps the contents of two match_results.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
swap(match_results& __that)
|
swap(match_results& __that) noexcept
|
||||||
{
|
{
|
||||||
using std::swap;
|
using std::swap;
|
||||||
_Base_type::swap(__that);
|
_Base_type::swap(__that);
|
||||||
|
|
@ -1955,7 +1954,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
template<typename _Bi_iter, typename _Alloc>
|
template<typename _Bi_iter, typename _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator==(const match_results<_Bi_iter, _Alloc>& __m1,
|
operator==(const match_results<_Bi_iter, _Alloc>& __m1,
|
||||||
const match_results<_Bi_iter, _Alloc>& __m2)
|
const match_results<_Bi_iter, _Alloc>& __m2) noexcept
|
||||||
{
|
{
|
||||||
if (__m1.ready() != __m2.ready())
|
if (__m1.ready() != __m2.ready())
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1979,7 +1978,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
template<typename _Bi_iter, class _Alloc>
|
template<typename _Bi_iter, class _Alloc>
|
||||||
inline bool
|
inline bool
|
||||||
operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
|
operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
|
||||||
const match_results<_Bi_iter, _Alloc>& __m2)
|
const match_results<_Bi_iter, _Alloc>& __m2) noexcept
|
||||||
{ return !(__m1 == __m2); }
|
{ return !(__m1 == __m2); }
|
||||||
|
|
||||||
// [7.10.6] match_results swap
|
// [7.10.6] match_results swap
|
||||||
|
|
@ -1993,7 +1992,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
template<typename _Bi_iter, typename _Alloc>
|
template<typename _Bi_iter, typename _Alloc>
|
||||||
inline void
|
inline void
|
||||||
swap(match_results<_Bi_iter, _Alloc>& __lhs,
|
swap(match_results<_Bi_iter, _Alloc>& __lhs,
|
||||||
match_results<_Bi_iter, _Alloc>& __rhs)
|
match_results<_Bi_iter, _Alloc>& __rhs) noexcept
|
||||||
{ __lhs.swap(__rhs); }
|
{ __lhs.swap(__rhs); }
|
||||||
|
|
||||||
_GLIBCXX_END_NAMESPACE_CXX11
|
_GLIBCXX_END_NAMESPACE_CXX11
|
||||||
|
|
@ -2490,9 +2489,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
* @brief Provides a singular iterator, useful for indicating
|
* @brief Provides a singular iterator, useful for indicating
|
||||||
* one-past-the-end of a range.
|
* one-past-the-end of a range.
|
||||||
*/
|
*/
|
||||||
regex_iterator()
|
regex_iterator() = default;
|
||||||
: _M_pregex()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a %regex_iterator...
|
* Constructs a %regex_iterator...
|
||||||
|
|
@ -2515,42 +2512,41 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
regex_iterator(_Bi_iter, _Bi_iter, const regex_type&&,
|
regex_iterator(_Bi_iter, _Bi_iter, const regex_type&&,
|
||||||
regex_constants::match_flag_type
|
regex_constants::match_flag_type
|
||||||
= regex_constants::match_default) = delete;
|
= regex_constants::match_default) = delete;
|
||||||
/**
|
|
||||||
* Copy constructs a %regex_iterator.
|
|
||||||
*/
|
|
||||||
regex_iterator(const regex_iterator& __rhs) = default;
|
|
||||||
|
|
||||||
/**
|
/// Copy constructs a %regex_iterator.
|
||||||
* @brief Assigns one %regex_iterator to another.
|
regex_iterator(const regex_iterator&) = default;
|
||||||
*/
|
|
||||||
|
/// Copy assigns one %regex_iterator to another.
|
||||||
regex_iterator&
|
regex_iterator&
|
||||||
operator=(const regex_iterator& __rhs) = default;
|
operator=(const regex_iterator&) = default;
|
||||||
|
|
||||||
|
~regex_iterator() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Tests the equivalence of two regex iterators.
|
* @brief Tests the equivalence of two regex iterators.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
operator==(const regex_iterator& __rhs) const;
|
operator==(const regex_iterator&) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Tests the inequivalence of two regex iterators.
|
* @brief Tests the inequivalence of two regex iterators.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
operator!=(const regex_iterator& __rhs) const
|
operator!=(const regex_iterator& __rhs) const noexcept
|
||||||
{ return !(*this == __rhs); }
|
{ return !(*this == __rhs); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Dereferences a %regex_iterator.
|
* @brief Dereferences a %regex_iterator.
|
||||||
*/
|
*/
|
||||||
const value_type&
|
const value_type&
|
||||||
operator*() const
|
operator*() const noexcept
|
||||||
{ return _M_match; }
|
{ return _M_match; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Selects a %regex_iterator member.
|
* @brief Selects a %regex_iterator member.
|
||||||
*/
|
*/
|
||||||
const value_type*
|
const value_type*
|
||||||
operator->() const
|
operator->() const noexcept
|
||||||
{ return &_M_match; }
|
{ return &_M_match; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2571,10 +2567,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
_Bi_iter _M_begin;
|
_Bi_iter _M_begin {};
|
||||||
_Bi_iter _M_end;
|
_Bi_iter _M_end {};
|
||||||
const regex_type* _M_pregex;
|
const regex_type* _M_pregex = nullptr;
|
||||||
regex_constants::match_flag_type _M_flags;
|
regex_constants::match_flag_type _M_flags {};
|
||||||
match_results<_Bi_iter> _M_match;
|
match_results<_Bi_iter> _M_match;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue