Re: [PATCH] Default special members of regex types and add noexcept
On 26/06/18 09:19 +0200, Stephan Bergmann wrote: On 08/06/18 13:01, Jonathan Wakely wrote: Nothing very exciting, just adding noexcept and defaulting some members. * 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. Tested powerpc64le-linux, committed to trunk. Looks like that forgot to also add noexcept to the definition of regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: operator==(const regex_iterator& __rhs) const in libstdc++-v3/include/bits/regex.tcc? Indeed I did, thanks. Tested x86_64-linux, committed to trunk. commit a3371eeaf2434550934a95f4f41a2a9ae31ead81 Author: Jonathan Wakely Date: Tue Jun 26 13:01:56 2018 +0100 Add missing noexcept on definition to match declaration * include/bits/regex.tcc (regex_iterator::operator==): Add missing noexcept. diff --git a/libstdc++-v3/include/bits/regex.tcc b/libstdc++-v3/include/bits/regex.tcc index b92edb9ab29..dcf660902bc 100644 --- a/libstdc++-v3/include/bits/regex.tcc +++ b/libstdc++-v3/include/bits/regex.tcc @@ -500,7 +500,7 @@ namespace __detail typename _Rx_traits> bool regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: -operator==(const regex_iterator& __rhs) const +operator==(const regex_iterator& __rhs) const noexcept { if (_M_pregex == nullptr && __rhs._M_pregex == nullptr) return true;
Re: [PATCH] Default special members of regex types and add noexcept
On 08/06/18 13:01, Jonathan Wakely wrote: Nothing very exciting, just adding noexcept and defaulting some members. * 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. Tested powerpc64le-linux, committed to trunk. Looks like that forgot to also add noexcept to the definition of regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: operator==(const regex_iterator& __rhs) const in libstdc++-v3/include/bits/regex.tcc?
[PATCH] Default special members of regex types and add noexcept
Nothing very exciting, just adding noexcept and defaulting some members. * 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. Tested powerpc64le-linux, committed to trunk. commit 786d6b032ca5fb4dd0bbeaa3cf8024d04c6022ad Author: redi Date: Thu Jun 7 08:56:45 2018 + 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. diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index 12e830b2c68..674be9ac50c 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -868,18 +868,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 public: typedef typename __iter_traits::value_type value_type; typedef typename __iter_traits::difference_type difference_type; - typedef _BiIter iterator; - typedef std::basic_string string_type; + typedef _BiIter iterator; + typedef basic_string string_type; bool matched; - constexpr sub_match() : matched() { } + constexpr sub_match() noexcept : matched() { } /** * Gets the length of the matching sequence. */ difference_type - length() const + length() const noexcept { 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. */ explicit - match_results(const _Alloc& __a = _Alloc()) + match_results(const _Alloc& __a = _Alloc()) noexcept : _Base_type(__a) { } /** * @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. */ - match_results(match_results&& __rhs) noexcept = default; + match_results(match_results&&) noexcept = default; /** * @brief Assigns rhs to *this. */ match_results& - operator=(const match_results& __rhs) = default; + operator=(const match_results&) = default; /** * @brief Move-assigns rhs to *this. */ match_results& - operator=(match_results&& __rhs) = default; + operator=(match_results&&) = default; /** * @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 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 @@ -1659,11 +1658,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @returns the number of matches found. */ size_type - size() const + size() const noexcept { return _Base_type::empty() ? 0 : _Base_type::size() - 3; } size_type - max_size() const + max_size() const noexcept { return _Base_type::max_size(); } /** @@ -1672,7 +1671,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @retval false The %match_results object is not empty. */ bool - empty() const + empty() const noexcept { return size() == 0; } //@} @@ -1776,28 +1775,28 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @brief Gets an iterator to the start of the %sub_match collection. */ const_iterator - begin() const + begin() const noexcept { return _Base_type::begin(); } /** * @brief Gets an iterator to the start of the %sub_match collection. */ const_iterator - cbegin() const + cbegin() const noexcept { return this->begin(); } /** * @brief
[PATCH] 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. Tested powerpc64le-linux, committed to trunk. commit beb6acb1686031f79c300028c91e3e1c971a51b1 Author: Jonathan Wakely Date: Wed Jun 6 21:19:24 2018 +0100 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. diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index 12e830b2c68..674be9ac50c 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -868,18 +868,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 public: typedef typename __iter_traits::value_type value_type; typedef typename __iter_traits::difference_type difference_type; - typedef _BiIter iterator; - typedef std::basic_string string_type; + typedef _BiIter iterator; + typedef basic_string string_type; bool matched; - constexpr sub_match() : matched() { } + constexpr sub_match() noexcept : matched() { } /** * Gets the length of the matching sequence. */ difference_type - length() const + length() const noexcept { 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. */ explicit - match_results(const _Alloc& __a = _Alloc()) + match_results(const _Alloc& __a = _Alloc()) noexcept : _Base_type(__a) { } /** * @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. */ - match_results(match_results&& __rhs) noexcept = default; + match_results(match_results&&) noexcept = default; /** * @brief Assigns rhs to *this. */ match_results& - operator=(const match_results& __rhs) = default; + operator=(const match_results&) = default; /** * @brief Move-assigns rhs to *this. */ match_results& - operator=(match_results&& __rhs) = default; + operator=(match_results&&) = default; /** * @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 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 @@ -1659,11 +1658,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @returns the number of matches found. */ size_type - size() const + size() const noexcept { return _Base_type::empty() ? 0 : _Base_type::size() - 3; } size_type - max_size() const + max_size() const noexcept { return _Base_type::max_size(); } /** @@ -1672,7 +1671,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @retval false The %match_results object is not empty. */ bool - empty() const + empty() const noexcept { return size() == 0; } //@} @@ -1776,28 +1775,28 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 * @brief Gets an iterator to the start of the %sub_match collection. */ const_iterator - begin() const + begin() const noexcept { return _Base_type::begin(); } /** * @brief Gets an iterator to the start of the %sub_match collection. */ const_iterator - cbegin() const + cbegin() const noexcept { return this->begin(); } /** * @brief Gets an iterator to one-past-the-end of the collection.