summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2008-10-15 23:37:54 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2008-10-15 23:37:54 +0000
commitadc58de5f4760389ede9cf43e1cc0ea084d89c70 (patch)
treebe83331ac51cf92b266923d8171dd28aae9b9e99 /libstdc++-v3
parent2187027e82eed59b19ec922196ace909189d1900 (diff)
downloadgcc-adc58de5f4760389ede9cf43e1cc0ea084d89c70.tar.gz
2008-10-15 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/forward_list.h: Remove pointless const qualifiers in const_casts. * include/bits/forward_list.tcc: Likewise. * include/bits/forward_list.h (forward_list<>::pointer, const_pointer, reference, const_reference): Fix, use _Tp_alloc_type. * testsuite/23_containers/forward_list/requirements/ explicit_instantiation/1.cc: New. * testsuite/23_containers/forward_list/requirements/ explicit_instantiation/1.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141153 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog13
-rw-r--r--libstdc++-v3/include/bits/forward_list.h62
-rw-r--r--libstdc++-v3/include/bits/forward_list.tcc8
-rw-r--r--libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/1.cc36
-rw-r--r--libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/3.cc37
5 files changed, 120 insertions, 36 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index dd9e945d5eb..37863227499 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,18 @@
2008-10-15 Paolo Carlini <paolo.carlini@oracle.com>
+ * include/bits/forward_list.h: Remove pointless const qualifiers in
+ const_casts.
+ * include/bits/forward_list.tcc: Likewise.
+
+ * include/bits/forward_list.h (forward_list<>::pointer,
+ const_pointer, reference, const_reference): Fix, use _Tp_alloc_type.
+ * testsuite/23_containers/forward_list/requirements/
+ explicit_instantiation/1.cc: New.
+ * testsuite/23_containers/forward_list/requirements/
+ explicit_instantiation/1.cc: Likewise.
+
+2008-10-15 Paolo Carlini <paolo.carlini@oracle.com>
+
* include/bits/forward_list.h (forward_list<>::max_size): Use
Node_allocator; minor cosmetic changes.
* testsuite/23_containers/forward_list/capacity/1.cc: Adjust.
diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h
index 4e16b9c8c55..5e8cfec5ed5 100644
--- a/libstdc++-v3/include/bits/forward_list.h
+++ b/libstdc++-v3/include/bits/forward_list.h
@@ -31,8 +31,8 @@
* This is a Standard C++ Library header.
*/
-#ifndef _GLIBCXX_FORWARD_LIST_H
-#define _GLIBCXX_FORWARD_LIST_H 1
+#ifndef _FORWARD_LIST_H
+#define _FORWARD_LIST_H 1
#pragma GCC system_header
@@ -282,6 +282,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
typedef typename _Alloc::template rebind<_Fwd_list_node<_Tp>>::other
_Node_alloc_type;
+ typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
+
struct _Fwd_list_impl
: public _Node_alloc_type
{
@@ -300,7 +302,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_Fwd_list_impl _M_impl;
public:
- typedef _Alloc allocator_type;
typedef _Fwd_list_iterator<_Tp> iterator;
typedef _Fwd_list_const_iterator<_Tp> const_iterator;
@@ -314,15 +315,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_get_Node_allocator() const
{ return *static_cast<const _Node_alloc_type*>(&this->_M_impl); }
- allocator_type
- get_allocator() const
- { return this->_M_get_Node_allocator(); }
-
_Fwd_list_base()
: _M_impl()
{ this->_M_impl._M_head._M_next = 0; }
- _Fwd_list_base(const allocator_type& __a)
+ _Fwd_list_base(const _Alloc& __a)
: _M_impl(__a)
{ this->_M_impl._M_head._M_next = 0; }
@@ -371,7 +368,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_insert_after(const_iterator __pos, _Args&&... __args)
{
_Fwd_list_node_base* __to
- = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
+ = const_cast<_Fwd_list_node_base*>(__pos._M_node);
_Node* __thing = _M_create_node(std::forward<_Args>(__args)...);
__thing->_M_next = __to->_M_next;
__to->_M_next = __thing;
@@ -425,21 +422,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
class forward_list : private _Fwd_list_base<_Tp, _Alloc>
{
private:
- typedef _Fwd_list_base<_Tp, _Alloc> _Base;
- typedef _Fwd_list_node<_Tp> _Node;
+ typedef _Fwd_list_base<_Tp, _Alloc> _Base;
+ typedef _Fwd_list_node<_Tp> _Node;
+ typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
public:
// types:
- typedef typename _Alloc::reference reference;
- typedef typename _Alloc::const_reference const_reference;
- typedef _Fwd_list_iterator<_Tp> iterator;
- typedef _Fwd_list_const_iterator<_Tp> const_iterator;
- typedef std::size_t size_type;
- typedef std::ptrdiff_t difference_type;
- typedef _Tp value_type;
- typedef typename _Base::allocator_type allocator_type;
- typedef typename _Alloc::pointer pointer;
- typedef typename _Alloc::const_pointer const_pointer;
+ typedef _Tp value_type;
+ typedef typename _Tp_alloc_type::pointer pointer;
+ typedef typename _Tp_alloc_type::const_pointer const_pointer;
+ typedef typename _Tp_alloc_type::reference reference;
+ typedef typename _Tp_alloc_type::const_reference const_reference;
+ typedef _Fwd_list_iterator<_Tp> iterator;
+ typedef _Fwd_list_const_iterator<_Tp> const_iterator;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef _Alloc allocator_type;
// 23.2.3.1 construct/copy/destroy:
@@ -647,7 +645,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/// Get a copy of the memory allocation object.
allocator_type
get_allocator() const
- { return _Base::get_allocator(); }
+ { return this->_M_get_Node_allocator(); }
// 23.2.3.2 iterators:
@@ -858,7 +856,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
insert_after(const_iterator __pos, const _Tp& __val)
{
_Fwd_list_node_base* __to
- = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
+ = const_cast<_Fwd_list_node_base*>(__pos._M_node);
_Node* __thing = _M_create_node(__val);
__thing->_M_next = __to->_M_next;
__to->_M_next = __thing;
@@ -872,7 +870,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
insert_after(const_iterator __pos, _Tp&& __val)
{
_Fwd_list_node_base* __to
- = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
+ = const_cast<_Fwd_list_node_base*>(__pos._M_node);
_Node* __thing = _M_create_node(std::move(__val));
__thing->_M_next = __to->_M_next;
__to->_M_next = __thing;
@@ -950,7 +948,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
erase_after(const_iterator __pos)
{
_Fwd_list_node_base* __tmp
- = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
+ = const_cast<_Fwd_list_node_base*>(__pos._M_node);
if (__tmp)
return iterator(_Base::_M_erase_after(__tmp));
else
@@ -980,7 +978,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
erase_after(const_iterator __pos, iterator __last)
{
_Fwd_list_node_base* __tmp
- = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
+ = const_cast<_Fwd_list_node_base*>(__pos._M_node);
return iterator(_M_erase_after(__tmp, __last._M_node));
}
@@ -1060,9 +1058,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (!__list.empty() && &__list != this)
{
_Fwd_list_node_base* __tmp
- = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
+ = const_cast<_Fwd_list_node_base*>(__pos._M_node);
const_iterator __before = __list.cbefore_begin();
- __tmp->_M_transfer_after(const_cast<_Fwd_list_node_base* const>
+ __tmp->_M_transfer_after(const_cast<_Fwd_list_node_base*>
(__before._M_node));
}
}
@@ -1100,10 +1098,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const_iterator __before, const_iterator __last)
{
_Fwd_list_node_base* __tmp
- = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
- __tmp->_M_transfer_after(const_cast<_Fwd_list_node_base* const>
+ = const_cast<_Fwd_list_node_base*>(__pos._M_node);
+ __tmp->_M_transfer_after(const_cast<_Fwd_list_node_base*>
(__before._M_node),
- const_cast<_Fwd_list_node_base* const>
+ const_cast<_Fwd_list_node_base*>
(__last._M_node));
}
@@ -1335,4 +1333,4 @@ _GLIBCXX_END_NAMESPACE // namespace std
#endif // __GXX_EXPERIMENTAL_CXX0X__
-#endif // _GLIBCXX_FORWARD_LIST_H
+#endif // _FORWARD_LIST_H
diff --git a/libstdc++-v3/include/bits/forward_list.tcc b/libstdc++-v3/include/bits/forward_list.tcc
index 7a3a3d0beda..a7fabf83353 100644
--- a/libstdc++-v3/include/bits/forward_list.tcc
+++ b/libstdc++-v3/include/bits/forward_list.tcc
@@ -299,7 +299,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
size_type __n, const _Tp& __val)
{
_Fwd_list_node_base* __to
- = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
+ = const_cast<_Fwd_list_node_base*>(__pos._M_node);
_Fwd_list_node_base* __keep = __to->_M_next;
for (size_type __i = 0; __i < __n; ++__i)
{
@@ -317,7 +317,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_InputIterator __first, _InputIterator __last)
{
_Fwd_list_node_base* __to
- = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
+ = const_cast<_Fwd_list_node_base*>(__pos._M_node);
_Fwd_list_node_base* __keep = __to->_M_next;
_InputIterator __curr = __first;
while (__curr != __last)
@@ -335,7 +335,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
insert_after(const_iterator __pos, std::initializer_list<_Tp> __il)
{
_Fwd_list_node_base* __to
- = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
+ = const_cast<_Fwd_list_node_base*>(__pos._M_node);
_Fwd_list_node_base* __keep = __to->_M_next;
const _Tp* __item = __il.begin();
while (__item != __il.end())
@@ -431,7 +431,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
while (++__next != __last)
{
if (__binary_pred(*__first, *__next))
- erase_after(__first);
+ erase_after(__first);
else
__first = __next;
__next = __first;
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/1.cc
new file mode 100644
index 00000000000..2650632e26c
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/1.cc
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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 <forward_list>
+
+// { dg-do compile }
+
+template class std::forward_list<int>;
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/3.cc
new file mode 100644
index 00000000000..ca34423cc4d
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/explicit_instantiation/3.cc
@@ -0,0 +1,37 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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 <forward_list>
+
+// { dg-do compile }
+
+// libstdc++/21770
+template class std::forward_list<int, std::allocator<char> >;