diff options
author | Dhruv Matani <dhruvbird@gmx.net> | 2004-03-25 17:12:16 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@redhat.com> | 2004-03-25 17:12:16 +0000 |
commit | 4231767dcb5a63277c7cb89c7c9efc34a20352ad (patch) | |
tree | 4e905f4034e27bf84968849536241d115590f92d /libstdc++-v3/testsuite/23_containers | |
parent | e2e641971be2268fad5aaa09d288c1167b4aa781 (diff) |
2004-03-25 Dhruv Matani <dhruvbird@gmx.net>
* include/bits/stl_list.h: Created a _List_impl class and made it
derive from the allocator, instead of the list deriving from the
allocator class, which was not conformant. Changed all references
from this->_M_node to this->_M_impl._M_node * bits/list.tcc: Same
as above (changed all references to the concerned variables).
2004-03-25 Dhruv Matani <dhruvbird@gmx.net>
* include/bits/stl_deque.h: Created a _Deque_impl class and made
it derive from the allocator, instead of the deque deriving from
the allocator class, which was not conformant. Changed all
references to the _M_start, _M_finish, _M_map, and _M_map_size to
_M_impl.*.
(_Deque_base<_Tp,_Alloc>::~_Deque_base()): Added this->
qualification in 2 places where it was missing.
(_Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t)): Same as
above.
* include/bits/deque.tcc: Same as above (changed all references to
the concerned variables).
2004-03-25 Dhruv Matani <dhruvbird@gmx.net>
* include/bits/stl_vector.h: Created a _Vector_impl class and made
it derive from the allocator, instead of the _Vector_base class,
deriving from the allocator which was not conformant. Changed all
references to the _M_start, _M_finish, and _M_end_of_storage to
_M_impl.*.
* include/bits/vector.tcc: Same as above (changed all references
to the concerned variables).
2004-03-25 Dhruv Matani <dhruvbird@gmx.net>
* testsuite/23_containers/deque/cons/clear_allocator.cc: New.
* testsuite/23_containers/list/cons/clear_allocator.cc: New.
* testsuite/23_containers/vector/cons/clear_allocator.cc: New.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@79957 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers')
3 files changed, 264 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc new file mode 100644 index 00000000000..8103928a1e3 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/cons/clear_allocator.cc @@ -0,0 +1,88 @@ +// 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. + +#include <deque> +#include <ext/new_allocator.h> + +using namespace std; +using __gnu_cxx::new_allocator; + +template<typename T> + class clear_alloc : public new_allocator<T> + { + public: + + template <typename T1> + struct rebind + { typedef clear_alloc<T1> other; }; + + virtual void clear() + { } + + clear_alloc() + { } + + clear_alloc(clear_alloc const& _wa) + { } + + template<typename T1> + clear_alloc(clear_alloc<T1> const& _wa) + { } + + virtual ~clear_alloc() + { this->clear(); } + + T* allocate(typename new_allocator<T>::size_type n, const void *hint = 0) + { + this->clear(); + return new_allocator<T>::allocate(n, hint); + } + + void deallocate(T *ptr, typename new_allocator<T>::size_type n) + { + this->clear(); + new_allocator<T>::deallocate(ptr, n); + } + }; + +template<typename Container> + void Check_Container() + { + Container* pic = new Container; + int x = 230; + + while (x--) + { + pic->push_back(x); + } + + pic->get_allocator(); + + // The following has led to infinite recursions or cores. + pic->clear(); + + delete pic; + } + + +int main() +{ + Check_Container<std::deque<int, clear_alloc<int> > >(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc b/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc new file mode 100644 index 00000000000..c74fc085ffb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc @@ -0,0 +1,88 @@ +// 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. + +#include <list> +#include <ext/new_allocator.h> + +using namespace std; +using __gnu_cxx::new_allocator; + +template<typename T> + class clear_alloc : public new_allocator<T> + { + public: + + template <typename T1> + struct rebind + { typedef clear_alloc<T1> other; }; + + virtual void clear() + { } + + clear_alloc() + { } + + clear_alloc(clear_alloc const& _wa) + { } + + template<typename T1> + clear_alloc(clear_alloc<T1> const& _wa) + { } + + virtual ~clear_alloc() + { this->clear(); } + + T* allocate(typename new_allocator<T>::size_type n, const void *hint = 0) + { + this->clear(); + return new_allocator<T>::allocate(n, hint); + } + + void deallocate(T *ptr, typename new_allocator<T>::size_type n) + { + this->clear(); + new_allocator<T>::deallocate(ptr, n); + } + }; + +template<typename Container> + void Check_Container() + { + Container* pic = new Container; + int x = 230; + + while (x--) + { + pic->push_back(x); + } + + pic->get_allocator(); + + // The following has led to infinite recursions or cores. + pic->clear(); + + delete pic; + } + + +int main() +{ + Check_Container<std::list<int, clear_alloc<int> > >(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/clear_allocator.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/clear_allocator.cc new file mode 100644 index 00000000000..5cc878e6c59 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/clear_allocator.cc @@ -0,0 +1,88 @@ +// 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. + +#include <vector> +#include <ext/new_allocator.h> + +using namespace std; +using __gnu_cxx::new_allocator; + +template<typename T> + class clear_alloc : public new_allocator<T> + { + public: + + template <typename T1> + struct rebind + { typedef clear_alloc<T1> other; }; + + virtual void clear() + { } + + clear_alloc() + { } + + clear_alloc(clear_alloc const& _wa) + { } + + template<typename T1> + clear_alloc(clear_alloc<T1> const& _wa) + { } + + virtual ~clear_alloc() + { this->clear(); } + + T* allocate(typename new_allocator<T>::size_type n, const void *hint = 0) + { + this->clear(); + return new_allocator<T>::allocate(n, hint); + } + + void deallocate(T *ptr, typename new_allocator<T>::size_type n) + { + this->clear(); + new_allocator<T>::deallocate(ptr, n); + } + }; + +template<typename Container> + void Check_Container() + { + Container* pic = new Container; + int x = 230; + + while (x--) + { + pic->push_back(x); + } + + pic->get_allocator(); + + // The following has led to infinite recursions or cores. + pic->clear(); + + delete pic; + } + + +int main() +{ + Check_Container<std::vector<int, clear_alloc<int> > >(); + return 0; +} + |