re PR libstdc++/55979 ([C++11] std::list range construction imposes unnecessary conversion constraints)

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
This commit is contained in:
Paolo Carlini 2013-03-17 18:27:52 +00:00 committed by Paolo Carlini
parent 9f4f1735d8
commit b4904956fa
5 changed files with 61 additions and 1 deletions

View 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

View 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

View File

@ -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);
}

View 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);

View 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>