[multiple changes]

2005-06-06  Paolo Carlini  <pcarlini@suse.de>

        Port from libstdcxx_so_7-branch:
	2004-09-24  Paolo Carlini  <pcarlini@suse.de>
		    Jonathan Wakely  <redi@gcc.gnu.org>

	* include/bits/stl_list.h (list::list(size_type, value_type,
	const allocator_type&): Implement according to the letter of the
	standard, i.e., don't use two overloads, not equivalent in case
	of non default constructible T.
	(list::resize(size_type, const value_type&)): Fix the signature:
	according to the standard the second argument is by value; also,
	don't use two overloads.
	* include/bits/list.tcc (list::resize(size_type, const value_type&)):
	Adjust consistently the signature.
	* include/bits/stl_deque.h (deque::deque(size_type, value_type,
	const allocator_type&)): Likewise.
	(deque::resize(size_type, const value_type&)): Likewise.
	* include/bits/stl_vector.h (vector::vector(size_type, value_type,
	const allocator_type&)): Likewise.
	(vector::resize(size_type, const value_type&)): Likewise.
	* testsuite/testsuite_hooks.h: Add NonDefaultConstructible test type.
	* testsuite/23_containers/deque/explicit_instantiation/2.cc: New.
	* testsuite/23_containers/list/explicit_instantiation/2.cc: New.
	* testsuite/23_containers/map/explicit_instantiation/2.cc: New.
	* testsuite/23_containers/multimap/explicit_instantiation/2.cc: New.
	* testsuite/23_containers/multiset/explicit_instantiation/2.cc: New.
	* testsuite/23_containers/set/explicit_instantiation/2.cc: New.
	* testsuite/23_containers/vector/explicit_instantiation/2.cc: New.

	* include/bits/deque.tcc: Minor formatting fix.

From-SVN: r100668
This commit is contained in:
Paolo Carlini 2005-06-06 16:59:55 +00:00 committed by Paolo Carlini
parent 1651a990f7
commit 2fecaef4af
14 changed files with 312 additions and 91 deletions

View File

@ -1,3 +1,35 @@
2005-06-06 Paolo Carlini <pcarlini@suse.de>
Port from libstdcxx_so_7-branch:
2004-09-24 Paolo Carlini <pcarlini@suse.de>
Jonathan Wakely <redi@gcc.gnu.org>
* include/bits/stl_list.h (list::list(size_type, value_type,
const allocator_type&): Implement according to the letter of the
standard, i.e., don't use two overloads, not equivalent in case
of non default constructible T.
(list::resize(size_type, const value_type&)): Fix the signature:
according to the standard the second argument is by value; also,
don't use two overloads.
* include/bits/list.tcc (list::resize(size_type, const value_type&)):
Adjust consistently the signature.
* include/bits/stl_deque.h (deque::deque(size_type, value_type,
const allocator_type&)): Likewise.
(deque::resize(size_type, const value_type&)): Likewise.
* include/bits/stl_vector.h (vector::vector(size_type, value_type,
const allocator_type&)): Likewise.
(vector::resize(size_type, const value_type&)): Likewise.
* testsuite/testsuite_hooks.h: Add NonDefaultConstructible test type.
* testsuite/23_containers/deque/explicit_instantiation/2.cc: New.
* testsuite/23_containers/list/explicit_instantiation/2.cc: New.
* testsuite/23_containers/map/explicit_instantiation/2.cc: New.
* testsuite/23_containers/multimap/explicit_instantiation/2.cc: New.
* testsuite/23_containers/multiset/explicit_instantiation/2.cc: New.
* testsuite/23_containers/set/explicit_instantiation/2.cc: New.
* testsuite/23_containers/vector/explicit_instantiation/2.cc: New.
* include/bits/deque.tcc: Minor formatting fix.
2005-06-06 Peter Doerfler <doerfler@techinfo.rwth-aachen.de>
* include/bits/stl_function.h: ... and another one.

View File

@ -201,9 +201,9 @@ namespace _GLIBCXX_STD
template <typename _Tp, class _Alloc>
template <typename _InputIterator>
void
deque<_Tp, _Alloc>
::_M_assign_aux(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag)
deque<_Tp, _Alloc>::
_M_assign_aux(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag)
{
iterator __cur = begin();
for (; __first != __last && __cur != end(); ++__cur, ++__first)

View File

@ -1,6 +1,6 @@
// List implementation (out of line) -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003, 2004, 2005 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
@ -102,7 +102,7 @@ namespace _GLIBCXX_STD
template<typename _Tp, typename _Alloc>
void
list<_Tp, _Alloc>::
resize(size_type __new_size, const value_type& __x)
resize(size_type __new_size, value_type __x)
{
iterator __i = begin();
size_type __len = 0;

View File

@ -669,23 +669,12 @@ namespace _GLIBCXX_STD
*
* This constructor fills the %deque with @a n copies of @a value.
*/
deque(size_type __n, const value_type& __value,
explicit
deque(size_type __n, const value_type& __value = value_type(),
const allocator_type& __a = allocator_type())
: _Base(__a, __n)
{ _M_fill_initialize(__value); }
/**
* @brief Create a %deque with default elements.
* @param n The number of elements to initially create.
*
* This constructor fills the %deque with @a n copies of a
* default-constructed element.
*/
explicit
deque(size_type __n)
: _Base(allocator_type(), __n)
{ _M_fill_initialize(value_type()); }
/**
* @brief %Deque copy constructor.
* @param x A %deque of identical element and allocator types.
@ -874,7 +863,7 @@ namespace _GLIBCXX_STD
* data.
*/
void
resize(size_type __new_size, const value_type& __x)
resize(size_type __new_size, value_type __x = value_type())
{
const size_type __len = size();
if (__new_size < __len)
@ -883,19 +872,6 @@ namespace _GLIBCXX_STD
insert(this->_M_impl._M_finish, __new_size - __len, __x);
}
/**
* @brief Resizes the %deque to the specified number of elements.
* @param new_size Number of elements the %deque should contain.
*
* This function will resize the %deque to the specified number
* of elements. If the number is smaller than the %deque's
* current size the %deque is truncated, otherwise the %deque
* is extended and new elements are default-constructed.
*/
void
resize(size_type new_size)
{ resize(new_size, value_type()); }
/**
* Returns true if the %deque is empty. (Thus begin() would
* equal end().)

View File

@ -472,23 +472,12 @@ namespace _GLIBCXX_STD
*
* This constructor fills the %list with @a n copies of @a value.
*/
list(size_type __n, const value_type& __value,
explicit
list(size_type __n, const value_type& __value = value_type(),
const allocator_type& __a = allocator_type())
: _Base(__a)
{ this->insert(begin(), __n, __value); }
/**
* @brief Create a %list with default elements.
* @param n The number of elements to initially create.
*
* This constructor fills the %list with @a n copies of a
* default-constructed element.
*/
explicit
list(size_type __n)
: _Base(allocator_type())
{ this->insert(begin(), __n, value_type()); }
/**
* @brief %List copy constructor.
* @param x A %list of identical element and allocator types.
@ -679,20 +668,7 @@ namespace _GLIBCXX_STD
* extended and new elements are populated with given data.
*/
void
resize(size_type __new_size, const value_type& __x);
/**
* @brief Resizes the %list to the specified number of elements.
* @param new_size Number of elements the %list should contain.
*
* This function will resize the %list to the specified number of
* elements. If the number is smaller than the %list's current
* size the %list is truncated, otherwise the %list is extended
* and new elements are default-constructed.
*/
void
resize(size_type __new_size)
{ this->resize(__new_size, value_type()); }
resize(size_type __new_size, value_type __x = value_type());
// element access
/**

View File

@ -206,7 +206,8 @@ namespace _GLIBCXX_STD
*
* This constructor fills the %vector with @a n copies of @a value.
*/
vector(size_type __n, const value_type& __value,
explicit
vector(size_type __n, const value_type& __value = value_type(),
const allocator_type& __a = allocator_type())
: _Base(__n, __a)
{
@ -215,22 +216,6 @@ namespace _GLIBCXX_STD
this->_M_impl._M_finish = this->_M_impl._M_start + __n;
}
/**
* @brief Create a %vector with default elements.
* @param n The number of elements to initially create.
*
* This constructor fills the %vector with @a n copies of a
* default-constructed element.
*/
explicit
vector(size_type __n)
: _Base(__n, allocator_type())
{
std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, value_type(),
_M_get_Tp_allocator());
this->_M_impl._M_finish = this->_M_impl._M_start + __n;
}
/**
* @brief %Vector copy constructor.
* @param x A %vector of identical element and allocator types.
@ -429,7 +414,7 @@ namespace _GLIBCXX_STD
* given data.
*/
void
resize(size_type __new_size, const value_type& __x)
resize(size_type __new_size, value_type __x = value_type())
{
if (__new_size < size())
erase(begin() + __new_size, end());
@ -437,20 +422,6 @@ namespace _GLIBCXX_STD
insert(end(), __new_size - size(), __x);
}
/**
* @brief Resizes the %vector to the specified number of elements.
* @param new_size Number of elements the %vector should contain.
*
* This function will resize the %vector to the specified
* number of elements. If the number is smaller than the
* %vector's current size the %vector is truncated, otherwise
* the %vector is extended and new elements are
* default-constructed.
*/
void
resize(size_type __new_size)
{ resize(__new_size, value_type()); }
/**
* Returns the total number of elements that the %vector can
* hold before needing to allocate more memory.

View File

@ -0,0 +1,35 @@
// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// This file tests explicit instantiation of library containers
#include <deque>
#include <testsuite_hooks.h>
// { dg-do compile }
template class std::deque<__gnu_test::NonDefaultConstructible>;

View File

@ -0,0 +1,35 @@
// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// This file tests explicit instantiation of library containers
#include <list>
#include <testsuite_hooks.h>
// { dg-do compile }
template class std::list<__gnu_test::NonDefaultConstructible>;

View File

@ -0,0 +1,37 @@
// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// This file tests explicit instantiation of library containers
#include <map>
#include <testsuite_hooks.h>
// { dg-do compile }
// N.B. We cannot instantiate with T == NonDefaultConstructible
// because of 23.3.1.2.
template class std::map<__gnu_test::NonDefaultConstructible, double>;

View File

@ -0,0 +1,36 @@
// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// This file tests explicit instantiation of library containers
#include <map>
#include <testsuite_hooks.h>
// { dg-do compile }
template class std::multimap<__gnu_test::NonDefaultConstructible,
__gnu_test::NonDefaultConstructible>;

View File

@ -0,0 +1,35 @@
// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// This file tests explicit instantiation of library containers
#include <set>
#include <testsuite_hooks.h>
// { dg-do compile }
template class std::multiset<__gnu_test::NonDefaultConstructible>;

View File

@ -0,0 +1,35 @@
// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// This file tests explicit instantiation of library containers
#include <set>
#include <testsuite_hooks.h>
// { dg-do compile }
template class std::set<__gnu_test::NonDefaultConstructible>;

View File

@ -0,0 +1,35 @@
// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// This file tests explicit instantiation of library containers
#include <vector>
#include <testsuite_hooks.h>
// { dg-do compile }
template class std::vector<__gnu_test::NonDefaultConstructible>;

View File

@ -160,6 +160,24 @@ namespace __gnu_test
void
run_tests_wrapped_env(const char*, const char*, const func_callback&);
// For containers (23.1/3).
struct NonDefaultConstructible
{
NonDefaultConstructible(int) { }
};
inline bool
operator==(const NonDefaultConstructible& lhs,
const NonDefaultConstructible& rhs)
{ return false; }
inline bool
operator<(const NonDefaultConstructible& lhs,
const NonDefaultConstructible& rhs)
{ return false; }
// Counting.
struct counter
{