diff mbox series

PR libstdc++/83538 fix std::match_results<T>::reference (LWG 2306)

Message ID 20171227194450.GA8615@redhat.com
State New
Headers show
Series PR libstdc++/83538 fix std::match_results<T>::reference (LWG 2306) | expand

Commit Message

Jonathan Wakely Dec. 27, 2017, 7:44 p.m. UTC
This was changed between C++11 and C++14.

	PR libstdc++/83538
	* doc/xml/manual/intro.xml: Document LWG 2306 change.
	* include/bits/regex.h (match_results::reference): Change to
	non-const reference.
	* testsuite/28_regex/match_results/typedefs.cc: Check types are
	correct.

Tested powerpc64le-linux, committed to trunk.
commit a8f23351b969943ad91a097aaf21de858e259813
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Dec 27 19:32:31 2017 +0000

    PR libstdc++/83538 fix std::match_results<T>::reference (LWG 2306)
    
            PR libstdc++/83538
            * doc/xml/manual/intro.xml: Document LWG 2306 change.
            * include/bits/regex.h (match_results::reference): Change to
            non-const reference.
            * testsuite/28_regex/match_results/typedefs.cc: Check types are
            correct.
diff mbox series

Patch

diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml
index 2df9c5fa6a7..03d59f900ae 100644
--- a/libstdc++-v3/doc/xml/manual/intro.xml
+++ b/libstdc++-v3/doc/xml/manual/intro.xml
@@ -968,6 +968,12 @@  requirements of the license of GCC.
     <code>constexpr</code> to <code>addressof</code> for C++17 and later.
     </para></listitem></varlistentry>
 
+    <varlistentry xml:id="manual.bugs.dr2306"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#2306">2306</link>:
+	<emphasis><code>match_results::reference</code> should be <code>value_type&amp;</code>, not <code>const value_type&amp;</code></emphasis>
+    </term>
+    <listitem><para>Change typedef.
+    </para></listitem></varlistentry>
+
     <varlistentry xml:id="manual.bugs.dr2313"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#2313">2313</link>:
 	<emphasis><code>tuple_size</code> should always derive from <code>integral_constant&lt;size_t, N&gt;</code></emphasis>
     </term>
diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index 32e7159eec9..74c5100b524 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -1541,7 +1541,7 @@  _GLIBCXX_BEGIN_NAMESPACE_CXX11
       //@{
       typedef sub_match<_Bi_iter>			   value_type;
       typedef const value_type&				   const_reference;
-      typedef const_reference				   reference;
+      typedef value_type&				   reference;
       typedef typename _Base_type::const_iterator	   const_iterator;
       typedef const_iterator				   iterator;
       typedef typename __iter_traits::difference_type	   difference_type;
diff --git a/libstdc++-v3/testsuite/28_regex/match_results/typedefs.cc b/libstdc++-v3/testsuite/28_regex/match_results/typedefs.cc
index fb39b5be786..62c4cf71690 100644
--- a/libstdc++-v3/testsuite/28_regex/match_results/typedefs.cc
+++ b/libstdc++-v3/testsuite/28_regex/match_results/typedefs.cc
@@ -39,4 +39,11 @@  test01()
   typedef mr::allocator_type   allocator_type;
   typedef mr::char_type        char_type;
   typedef mr::string_type      string_type;
+
+  static_assert(std::is_same<value_type, std::sub_match<char*>>::value, "");
+  static_assert(std::is_same<const_reference, const value_type&>::value, "");
+  static_assert(std::is_same<reference, value_type&>::value, "DR 2306");
+  static_assert(std::is_same<const_iterator, iterator>::value, "");
+  static_assert(std::is_same<char_type, char>::value, "");
+  static_assert(std::is_same<string_type, std::string>::value, "");
 }