Patchwork [v3] minor simplification to std::list

login
register
mail settings
Submitter Jonathan Wakely
Date March 18, 2012, 11:27 p.m.
Message ID <CAH6eHdTN1Pb-ADgK49rLMe3xE1krjvWu5+3-iBbuyxYCimDTCA@mail.gmail.com>
Download mbox | patch
Permalink /patch/147446/
State New
Headers show

Comments

Jonathan Wakely - March 18, 2012, 11:27 p.m.
Now that G++ supports it we can use a NSDMI for std::list::_M_size to
avoid needing conditional compilation to set it in the constructors.
I think the attached patch is an improvement so I plan to commit it to
trunk soon unless I hear objections.

        * include/bits/stl_list.h (list::_M_size): Use NSDMI.
        * testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
        Adjust line numbers.
        * testsuite/23_containers/list/requirements/dr438/
        constructor_1_neg.cc: Likewise.
        * testsuite/23_containers/list/requirements/dr438/
        constructor_2_neg.cc: Likewise.
        * testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
        Likewise.

Tested x86_64.
Jonathan Wakely - March 20, 2012, 5:01 p.m.
On 18 March 2012 23:27, Jonathan Wakely wrote:
> Now that G++ supports it we can use a NSDMI for std::list::_M_size to
> avoid needing conditional compilation to set it in the constructors.
> I think the attached patch is an improvement so I plan to commit it to
> trunk soon unless I hear objections.
>
>        * include/bits/stl_list.h (list::_M_size): Use NSDMI.
>        * testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
>        Adjust line numbers.
>        * testsuite/23_containers/list/requirements/dr438/
>        constructor_1_neg.cc: Likewise.
>        * testsuite/23_containers/list/requirements/dr438/
>        constructor_2_neg.cc: Likewise.
>        * testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
>        Likewise.
>
> Tested x86_64.

Committed to trunk.

Patch

diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h
index 1e760ed..634b579 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -314,26 +314,20 @@  _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	__detail::_List_node_base _M_node;
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
-	size_t                    _M_size;
+	size_t                    _M_size = 0;
 #endif
 
 	_List_impl()
 	: _Node_alloc_type(), _M_node()
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-	, _M_size(0)
-#endif
 	{ }
 
 	_List_impl(const _Node_alloc_type& __a)
 	: _Node_alloc_type(__a), _M_node()
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-	, _M_size(0)
-#endif
 	{ }
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 	_List_impl(_Node_alloc_type&& __a)
-	: _Node_alloc_type(std::move(__a)), _M_node(), _M_size(0)
+	: _Node_alloc_type(std::move(__a)), _M_node()
 	{ }
 #endif
       };
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
index c088e6c..05664b9 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
@@ -18,7 +18,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1574 }
+// { dg-error "no matching" "" { target *-*-* } 1568 }
 
 #include <list>
 
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
index 94fbe9a..0ef8da8 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
@@ -18,7 +18,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1530 }
+// { dg-error "no matching" "" { target *-*-* } 1524 }
 
 #include <list>
 
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
index c02d5a5..f0836f6 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
@@ -18,7 +18,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1530 }
+// { dg-error "no matching" "" { target *-*-* } 1524 }
 
 #include <list>
 #include <utility>
diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
index c2fa737..db63e39 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
@@ -18,7 +18,7 @@ 
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1530 }
+// { dg-error "no matching" "" { target *-*-* } 1524 }
 
 #include <list>