re PR libstdc++/55979 ([C++11] std::list range construction imposes unnecessary conve...
authorPaolo Carlini <paolo.carlini@oracle.com>
Sun, 17 Mar 2013 18:27:52 +0000 (18:27 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 17 Mar 2013 18:27:52 +0000 (18:27 +0000)
2013-03-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR libstdc++/55979
* include/bits/stl_list.h (_M_initialize_dispatch(_InputIterator,
_InputIterator, __false_type)): Use emplace_back.
* testsuite/23_containers/list/cons/55979.cc: New.
* testsuite/23_containers/list/modifiers/1.h: Adjust.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.

From-SVN: r196755

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_list.h
libstdc++-v3/testsuite/23_containers/list/cons/55979.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/list/modifiers/1.h
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc

index 6de5bbbd2e6f0ce0175bf02240abb8d294101579..36c45b5125e252541d901e7c517a0bddf9a695b8 100644 (file)
@@ -1,3 +1,13 @@
+2013-03-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR libstdc++/55979
+       * include/bits/stl_list.h (_M_initialize_dispatch(_InputIterator,
+       _InputIterator, __false_type)): Use emplace_back.
+       * testsuite/23_containers/list/cons/55979.cc: New.
+       * testsuite/23_containers/list/modifiers/1.h: Adjust.
+       * testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
+       Adjust dg-error line number.
+
 2013-03-16  Jason Merrill  <jason@redhat.com>
 
        PR c++/55017
index cc6edb3da7fefea212db9ad9d0061ecb49b0c088..596760c2152426b4030be21ef8c188524a704688 100644 (file)
@@ -1487,7 +1487,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
                               __false_type)
         {
          for (; __first != __last; ++__first)
+#if __cplusplus >= 201103L
+           emplace_back(*__first);
+#else
            push_back(*__first);
+#endif
        }
 
       // Called by list(n,v,a), and the range constructor when it turns out
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/55979.cc b/libstdc++-v3/testsuite/23_containers/list/cons/55979.cc
new file mode 100644 (file)
index 0000000..6a069bf
--- /dev/null
@@ -0,0 +1,34 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <list>
+
+struct A
+{
+  A(int) { }
+  A(const A&) = delete;
+  A& operator=(const A&) = delete;
+};
+
+void foo()
+{
+  int i[] = {1, 2};
+  std::list<A> li(i, i + 2);
+}
index 326df4b43eed0b2f5267724edb2a1eecb41aced9..1e7767b4beebbf93b265d1d3b2303209f3064405 100644 (file)
@@ -89,14 +89,22 @@ modifiers1()
   b = list0301.begin();
   list0301.insert(b, A, A + N); // should be [321 322 333 13 13]
   VERIFY(list0301.size() == 5);
+#if __cplusplus >= 201103L
+  VERIFY(copy_constructor::count() == 0);
+#else
   VERIFY(copy_constructor::count() == 3);
+#endif
   VERIFY(m->id() == 13);
 
   // range fill at end
   value_type::reset();
   list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333]
   VERIFY(list0301.size() == 8);
+#if __cplusplus >= 201103L
+  VERIFY(copy_constructor::count() == 0);
+#else
   VERIFY(copy_constructor::count() == 3);
+#endif
   VERIFY(e == list0301.end());
   VERIFY(m->id() == 13);
 
@@ -104,7 +112,11 @@ modifiers1()
   value_type::reset();
   list0301.insert(m, A, A + N);
   VERIFY(list0301.size() == 11);
+#if __cplusplus >= 201103L
+  VERIFY(copy_constructor::count() == 0);
+#else
   VERIFY(copy_constructor::count() == 3);
+#endif
   VERIFY(e == list0301.end());
   VERIFY(m->id() == 13);
 
index 1fc5dfb47a5f063af0c12c24a16f52cf316f94d5..63216cb01c87c1b3154e9251cea99f0fd9fcfe54 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1525 }
+// { dg-error "no matching" "" { target *-*-* } 1529 }
 
 #include <list>