Commit 875d0f10 by Benjamin Kosnik Committed by Benjamin Kosnik

14340.cc: Abstract list type.

2009-05-19  Benjamin Kosnik  <bkoz@redhat.com>

	* testsuite/23_containers/list/14340.cc: Abstract list type.
	* testsuite/23_containers/list/init-list.cc: Same.
	* testsuite/23_containers/list/pthread5.cc: Same.
	* testsuite/23_containers/list/invalidation/1.cc: Same.
	* testsuite/23_containers/list/invalidation/2.cc: Same.
	* testsuite/23_containers/list/invalidation/3.cc: Same.
	* testsuite/23_containers/list/invalidation/4.cc: Same.
	* testsuite/23_containers/list/modifiers/insert/25288.cc: Same.
	* testsuite/23_containers/list/modifiers/1.cc: Same.
	* testsuite/23_containers/list/modifiers/2.cc: Same.
	* testsuite/23_containers/list/modifiers/3.cc: Same.
	* testsuite/23_containers/list/modifiers/swap/1.cc: Same.
	* testsuite/23_containers/list/modifiers/swap/2.cc: Same.
	* testsuite/23_containers/list/modifiers/swap/3.cc: Same.
	* testsuite/23_containers/list/cons/1.cc: Same.
	* testsuite/23_containers/list/cons/2.cc: Same.
	* testsuite/23_containers/list/cons/3.cc: Same.
	* testsuite/23_containers/list/cons/4.cc: Same.
	* testsuite/23_containers/list/cons/5.cc: Same.
	* testsuite/23_containers/list/cons/6.cc: Same.
	* testsuite/23_containers/list/cons/7.cc: Same.
	* testsuite/23_containers/list/cons/clear_allocator.cc: Same.
	* testsuite/23_containers/list/cons/8.cc: Same.
	* testsuite/23_containers/list/cons/9.cc: Same.
	* testsuite/23_containers/list/operations/1.cc: Same.
	* testsuite/23_containers/list/operations/2.cc: Same.
	* testsuite/23_containers/list/operations/3.cc: Same.
	* testsuite/23_containers/list/operations/4.cc: Same.
	* testsuite/23_containers/list/operations/5.cc: Same.
	* testsuite/23_containers/list/requirements/citerators.cc: Same.
	* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
	* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
	* testsuite/23_containers/list/requirements/dr438/
	constructor_1_neg.cc: Same.
	* testsuite/23_containers/list/requirements/dr438/
	constructor_2_neg.cc: Same.
	* testsuite/23_containers/list/requirements/dr438/constructor.cc: Same.
	* testsuite/23_containers/list/requirements/
	partial_specialization/1.cc: Same.
	* testsuite/23_containers/list/23781.cc: Same.
	* testsuite/23_containers/list/pthread1.cc: Same.
	* testsuite/23_containers/list/capacity/1.cc: Same.
	* testsuite/23_containers/list/capacity/29134.cc: Same.
	* testsuite/23_containers/list/check_construct_destroy.cc: Same.
	* testsuite/23_containers/list/moveable.cc: Same.

	* testsuite/util/common_type/assoc/common_type.hpp: Re-break lines.

From-SVN: r147728
parent e36dc339
2009-05-19 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/23_containers/list/14340.cc: Abstract list type.
* testsuite/23_containers/list/init-list.cc: Same.
* testsuite/23_containers/list/pthread5.cc: Same.
* testsuite/23_containers/list/invalidation/1.cc: Same.
* testsuite/23_containers/list/invalidation/2.cc: Same.
* testsuite/23_containers/list/invalidation/3.cc: Same.
* testsuite/23_containers/list/invalidation/4.cc: Same.
* testsuite/23_containers/list/modifiers/insert/25288.cc: Same.
* testsuite/23_containers/list/modifiers/1.cc: Same.
* testsuite/23_containers/list/modifiers/2.cc: Same.
* testsuite/23_containers/list/modifiers/3.cc: Same.
* testsuite/23_containers/list/modifiers/swap/1.cc: Same.
* testsuite/23_containers/list/modifiers/swap/2.cc: Same.
* testsuite/23_containers/list/modifiers/swap/3.cc: Same.
* testsuite/23_containers/list/cons/1.cc: Same.
* testsuite/23_containers/list/cons/2.cc: Same.
* testsuite/23_containers/list/cons/3.cc: Same.
* testsuite/23_containers/list/cons/4.cc: Same.
* testsuite/23_containers/list/cons/5.cc: Same.
* testsuite/23_containers/list/cons/6.cc: Same.
* testsuite/23_containers/list/cons/7.cc: Same.
* testsuite/23_containers/list/cons/clear_allocator.cc: Same.
* testsuite/23_containers/list/cons/8.cc: Same.
* testsuite/23_containers/list/cons/9.cc: Same.
* testsuite/23_containers/list/operations/1.cc: Same.
* testsuite/23_containers/list/operations/2.cc: Same.
* testsuite/23_containers/list/operations/3.cc: Same.
* testsuite/23_containers/list/operations/4.cc: Same.
* testsuite/23_containers/list/operations/5.cc: Same.
* testsuite/23_containers/list/requirements/citerators.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/constructor.cc: Same.
* testsuite/23_containers/list/requirements/
partial_specialization/1.cc: Same.
* testsuite/23_containers/list/23781.cc: Same.
* testsuite/23_containers/list/pthread1.cc: Same.
* testsuite/23_containers/list/capacity/1.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/check_construct_destroy.cc: Same.
* testsuite/23_containers/list/moveable.cc: Same.
* testsuite/util/common_type/assoc/common_type.hpp: Re-break lines.
2009-05-19 Paolo Carlini <paolo.carlini@oracle.com> 2009-05-19 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/40184 PR libstdc++/40184
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
// libstdc++/14340 // libstdc++/14340
int main() int main()
{ {
typedef std::list<int> container; typedef std::list<int> list_type;
__gnu_test::conversion<container>::iterator_to_const_iterator(); __gnu_test::conversion<list_type>::iterator_to_const_iterator();
return 0; return 0;
} }
...@@ -23,5 +23,6 @@ ...@@ -23,5 +23,6 @@
// libstdc++/23781 // libstdc++/23781
#include <list> #include <list>
std::list<int>::iterator it = NULL; // { dg-error "conversion" } typedef std::list<int> list_type;
std::list<int>::const_iterator cit = NULL; // { dg-error "conversion" } list_type::iterator it = NULL; // { dg-error "conversion" }
list_type::const_iterator cit = NULL; // { dg-error "conversion" }
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// This test verifies the following. // This test verifies the following.
// //
// 23.2.2 bool empty() const // 23.2.2 bool empty() const
...@@ -32,10 +30,15 @@ bool test __attribute__((unused)) = true; ...@@ -32,10 +30,15 @@ bool test __attribute__((unused)) = true;
// 23.2.2 size_type max_size() const // 23.2.2 size_type max_size() const
// 23.2.2.2 void resize(size_type s, T c = T()) // 23.2.2.2 void resize(size_type s, T c = T())
// //
template<typename _Tp>
void void
test01() capacity01()
{ {
std::list<int> list0101; bool test __attribute__((unused)) = true;
typedef _Tp list_type;
typedef typename list_type::iterator iterator_type;
list_type list0101;
VERIFY(list0101.empty()); VERIFY(list0101.empty());
VERIFY(list0101.size() == 0); VERIFY(list0101.size() == 0);
...@@ -47,7 +50,7 @@ test01() ...@@ -47,7 +50,7 @@ test01()
VERIFY(!list0101.empty()); VERIFY(!list0101.empty());
VERIFY(list0101.size() == 3); VERIFY(list0101.size() == 3);
std::list<int>::iterator i = list0101.begin(); iterator_type i = list0101.begin();
VERIFY(*i == 1); ++i; VERIFY(*i == 1); ++i;
VERIFY(*i == 2); ++i; VERIFY(*i == 2); ++i;
VERIFY(*i == 2); ++i; VERIFY(*i == 2); ++i;
...@@ -61,8 +64,6 @@ test01() ...@@ -61,8 +64,6 @@ test01()
int int
main() main()
{ {
test01(); capacity01<std::list<int> >();
return 0; return 0;
} }
// vi:set sw=2 ts=2:
...@@ -25,7 +25,8 @@ void test01() ...@@ -25,7 +25,8 @@ void test01()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::list<int> l; typedef std::list<int> list_type;
list_type l;
#ifndef _GLIBCXX_DEBUG #ifndef _GLIBCXX_DEBUG
using std::_List_node; using std::_List_node;
......
...@@ -22,17 +22,21 @@ ...@@ -22,17 +22,21 @@
#include <iterator> #include <iterator>
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
using namespace __gnu_test;
int main() template<typename _Tp>
bool
construct_destroy()
{ {
typedef std::list<int, tracker_allocator<int> > Container; typedef _Tp list_type;
typedef typename list_type::iterator iterator_type;
using namespace __gnu_test;
const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 };
bool ok = true; bool ok = true;
tracker_allocator_counter::reset(); tracker_allocator_counter::reset();
{ {
Container c; list_type c;
ok = check_construct_destroy("empty container", 0, 0) && ok; ok = check_construct_destroy("empty container", 0, 0) && ok;
} }
ok = check_construct_destroy("empty container", 0, 0) && ok; ok = check_construct_destroy("empty container", 0, 0) && ok;
...@@ -40,13 +44,13 @@ int main() ...@@ -40,13 +44,13 @@ int main()
tracker_allocator_counter::reset(); tracker_allocator_counter::reset();
{ {
Container c(arr10, arr10 + 10); list_type c(arr10, arr10 + 10);
ok = check_construct_destroy("Construct from range", 10, 0) && ok; ok = check_construct_destroy("Construct from range", 10, 0) && ok;
} }
ok = check_construct_destroy("Construct from range", 10, 10) && ok; ok = check_construct_destroy("Construct from range", 10, 10) && ok;
{ {
Container c(arr10, arr10 + 10); list_type c(arr10, arr10 + 10);
tracker_allocator_counter::reset(); tracker_allocator_counter::reset();
c.insert(c.begin(), arr10[0]); c.insert(c.begin(), arr10[0]);
ok = check_construct_destroy("Insert element", 1, 0) && ok; ok = check_construct_destroy("Insert element", 1, 0) && ok;
...@@ -54,9 +58,9 @@ int main() ...@@ -54,9 +58,9 @@ int main()
ok = check_construct_destroy("Insert element", 1, 11) && ok; ok = check_construct_destroy("Insert element", 1, 11) && ok;
{ {
Container c(arr10, arr10 + 10); list_type c(arr10, arr10 + 10);
tracker_allocator_counter::reset(); tracker_allocator_counter::reset();
Container::iterator i5 = c.begin(); iterator_type i5 = c.begin();
std::advance(i5, 5); std::advance(i5, 5);
c.insert(i5, arr10, arr10+3); c.insert(i5, arr10, arr10+3);
ok = check_construct_destroy("Insert short range", 3, 0) && ok; ok = check_construct_destroy("Insert short range", 3, 0) && ok;
...@@ -64,9 +68,9 @@ int main() ...@@ -64,9 +68,9 @@ int main()
ok = check_construct_destroy("Insert short range", 3, 13) && ok; ok = check_construct_destroy("Insert short range", 3, 13) && ok;
{ {
Container c(arr10, arr10 + 10); list_type c(arr10, arr10 + 10);
tracker_allocator_counter::reset(); tracker_allocator_counter::reset();
Container::iterator i7 = c.begin(); iterator_type i7 = c.begin();
std::advance(i7, 5); std::advance(i7, 5);
c.insert(i7, arr10, arr10+10); c.insert(i7, arr10, arr10+10);
ok = check_construct_destroy("Insert long range", 10, 0) && ok; ok = check_construct_destroy("Insert long range", 10, 0) && ok;
...@@ -76,3 +80,8 @@ int main() ...@@ -76,3 +80,8 @@ int main()
return ok ? 0 : 1; return ok ? 0 : 1;
} }
int main()
{
construct_destroy<std::list<int, __gnu_test::tracker_allocator<int> > >();
return 0;
}
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// A nontrivial type. // A nontrivial type.
template<typename T> template<typename T>
struct A { }; struct A { };
...@@ -29,13 +27,6 @@ template<typename T> ...@@ -29,13 +27,6 @@ template<typename T>
// Another nontrivial type // Another nontrivial type
struct B { }; struct B { };
// A nontrivial type convertible from an int
struct C {
C(int i) : i_(i) { }
bool operator==(const C& rhs) { return i_ == rhs.i_; }
int i_;
};
// Default constructor, basic properties // Default constructor, basic properties
// //
// This test verifies the following. // This test verifies the following.
...@@ -46,32 +37,36 @@ struct C { ...@@ -46,32 +37,36 @@ struct C {
// 23.2.2 size_type size() const // 23.2.2 size_type size() const
// 23.2.2 existence of required typedefs // 23.2.2 existence of required typedefs
// //
template<typename _Tp>
void void
test01() cons01()
{ {
std::list< A<B> > list0101; bool test __attribute__((unused)) = true;
typedef _Tp list_type;
list_type list0101;
VERIFY(list0101.begin() == list0101.end()); VERIFY(list0101.begin() == list0101.end());
VERIFY(list0101.size() == 0); VERIFY(list0101.size() == 0);
// check type definitions -- will fail compile if missing // check type definitions -- will fail compile if missing
typedef std::list< A<B> >::reference reference; typedef typename list_type::reference reference;
typedef std::list< A<B> >::const_reference const_reference; typedef typename list_type::const_reference const_reference;
typedef std::list< A<B> >::iterator iterator; typedef typename list_type::iterator iterator;
typedef std::list< A<B> >::const_iterator const_iterator; typedef typename list_type::const_iterator const_iterator;
typedef std::list< A<B> >::size_type size_type; typedef typename list_type::size_type size_type;
typedef std::list< A<B> >::difference_type difference_type; typedef typename list_type::difference_type difference_type;
typedef std::list< A<B> >::value_type value_type; typedef typename list_type::value_type value_type;
typedef std::list< A<B> >::allocator_type allocator_type; typedef typename list_type::allocator_type allocator_type;
typedef std::list< A<B> >::pointer pointer; typedef typename list_type::pointer pointer;
typedef std::list< A<B> >::const_pointer const_pointer; typedef typename list_type::const_pointer const_pointer;
typedef std::list< A<B> >::reverse_iterator reverse_iterator; typedef typename list_type::reverse_iterator reverse_iterator;
typedef std::list< A<B> >::const_reverse_iterator const_reverse_iterator; typedef typename list_type::const_reverse_iterator const_reverse_iterator;
// allocator checks? // allocator checks?
} }
int main() int main()
{ {
test01(); cons01<std::list< A<B> > >();
return 0; return 0;
} }
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// A nontrivial type. // A nontrivial type.
template<typename T> template<typename T>
struct A { }; struct A { };
...@@ -29,13 +27,6 @@ template<typename T> ...@@ -29,13 +27,6 @@ template<typename T>
// Another nontrivial type // Another nontrivial type
struct B { }; struct B { };
// A nontrivial type convertible from an int
struct C {
C(int i) : i_(i) { }
bool operator==(const C& rhs) { return i_ == rhs.i_; }
int i_;
};
// Fill constructor // Fill constructor
// //
// This test verifies the following. // This test verifies the following.
...@@ -44,19 +35,21 @@ struct C { ...@@ -44,19 +35,21 @@ struct C {
// 23.2.2 const_iterator end() const // 23.2.2 const_iterator end() const
// 23.2.2 size_type size() const // 23.2.2 size_type size() const
// //
template<typename _Tp>
void void
test02() cons021()
{ {
bool test __attribute__((unused)) = true;
const std::size_t LIST_SIZE = 5; const std::size_t LIST_SIZE = 5;
const int INIT_VALUE = 7; const int INIT_VALUE = 7;
std::size_t count; std::size_t count;
std::list<int>::const_iterator i;
// nontrivial value_type typedef _Tp list_type;
std::list< A<B> > list0201(LIST_SIZE); typedef typename list_type::const_iterator const_iterator;
const_iterator i;
// default value // default value
std::list<int> list0202(LIST_SIZE); list_type list0202(LIST_SIZE);
for (i = list0202.begin(), count = 0; for (i = list0202.begin(), count = 0;
i != list0202.end(); i != list0202.end();
++i, ++count) ++i, ++count)
...@@ -65,7 +58,7 @@ test02() ...@@ -65,7 +58,7 @@ test02()
VERIFY(list0202.size() == LIST_SIZE); VERIFY(list0202.size() == LIST_SIZE);
// explicit value // explicit value
std::list<int> list0203(LIST_SIZE, INIT_VALUE); list_type list0203(LIST_SIZE, INIT_VALUE);
for (i = list0203.begin(), count = 0; for (i = list0203.begin(), count = 0;
i != list0203.end(); i != list0203.end();
++i, ++count) ++i, ++count)
...@@ -74,8 +67,19 @@ test02() ...@@ -74,8 +67,19 @@ test02()
VERIFY(list0203.size() == LIST_SIZE); VERIFY(list0203.size() == LIST_SIZE);
} }
template<typename _Tp>
void
cons022()
{
// nontrivial value_type
typedef _Tp list_type;
const std::size_t LIST_SIZE = 5;
list_type list0201(LIST_SIZE);
}
int main() int main()
{ {
test02(); cons021<std::list<int> >();
cons022<std::list< A<B> > >();
return 0; return 0;
} }
...@@ -20,31 +20,28 @@ ...@@ -20,31 +20,28 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// A nontrivial type.
template<typename T>
struct A { };
// Another nontrivial type
struct B { };
// A nontrivial type convertible from an int // A nontrivial type convertible from an int
struct C { struct C
{
C(int i) : i_(i) { } C(int i) : i_(i) { }
bool operator==(const C& rhs) { return i_ == rhs.i_; } bool operator==(const C& rhs) { return i_ == rhs.i_; }
int i_; int i_;
}; };
// Fill constructor disguised as a range constructor // Fill constructor disguised as a range constructor
template<typename _Tp>
void void
test02D() cons03()
{ {
bool test __attribute__((unused)) = true;
typedef _Tp list_type;
typedef typename list_type::iterator iterator;
const std::size_t LIST_SIZE = 5; const std::size_t LIST_SIZE = 5;
const int INIT_VALUE = 7; const int INIT_VALUE = 7;
std::size_t count = 0; std::size_t count = 0;
std::list<C> list0204(LIST_SIZE, INIT_VALUE); list_type list0204(LIST_SIZE, INIT_VALUE);
std::list<C>::iterator i = list0204.begin(); iterator i = list0204.begin();
for (; i != list0204.end(); ++i, ++count) for (; i != list0204.end(); ++i, ++count)
VERIFY(*i == INIT_VALUE); VERIFY(*i == INIT_VALUE);
VERIFY(count == LIST_SIZE); VERIFY(count == LIST_SIZE);
...@@ -53,7 +50,6 @@ test02D() ...@@ -53,7 +50,6 @@ test02D()
int main() int main()
{ {
test02D(); cons03<std::list<C> >();
return 0; return 0;
} }
// vi:set sw=2 ts=2:
...@@ -20,26 +20,30 @@ ...@@ -20,26 +20,30 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// Range constructor // Range constructor
// //
// This test verifies the following. // This test verifies the following.
// 23.2.2.1 template list(InputIterator f, InputIterator l, const Allocator& a = Allocator()) // 23.2.2.1 template list(InputIterator f, InputIterator l,
// const Allocator& a = Allocator())
// 23.2.2 const_iterator begin() const // 23.2.2 const_iterator begin() const
// 23.2.2 const_iterator end() const // 23.2.2 const_iterator end() const
// 23.2.2 size_type size() const // 23.2.2 size_type size() const
// //
template<typename _Tp>
void void
test03() cons04()
{ {
bool test __attribute__((unused)) = true;
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
const std::size_t N = sizeof(A) / sizeof(int); const std::size_t N = sizeof(A) / sizeof(int);
std::size_t count; std::size_t count;
std::list<int>::const_iterator i;
typedef std::list<int> list_type;
typedef typename list_type::const_iterator const_iterator;
const_iterator i;
// construct from a dissimilar range // construct from a dissimilar range
std::list<int> list0301(A, A + N); list_type list0301(A, A + N);
for (i = list0301.begin(), count = 0; for (i = list0301.begin(), count = 0;
i != list0301.end(); i != list0301.end();
++i, ++count) ++i, ++count)
...@@ -48,7 +52,7 @@ test03() ...@@ -48,7 +52,7 @@ test03()
VERIFY(list0301.size() == N); VERIFY(list0301.size() == N);
// construct from a similar range // construct from a similar range
std::list<int> list0302(list0301.begin(), list0301.end()); list_type list0302(list0301.begin(), list0301.end());
for (i = list0302.begin(), count = 0; for (i = list0302.begin(), count = 0;
i != list0302.end(); i != list0302.end();
++i, ++count) ++i, ++count)
...@@ -59,7 +63,7 @@ test03() ...@@ -59,7 +63,7 @@ test03()
int main() int main()
{ {
test03(); cons04<std::list<int> >();
return 0; return 0;
} }
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// Copy constructor // Copy constructor
// //
// This test verifies the following. // This test verifies the following.
...@@ -30,16 +28,21 @@ bool test __attribute__((unused)) = true; ...@@ -30,16 +28,21 @@ bool test __attribute__((unused)) = true;
// 23.2.2 reverse_iterator rend() // 23.2.2 reverse_iterator rend()
// 23.2.2 size_type size() const // 23.2.2 size_type size() const
// //
template<typename _Tp>
void void
test04() cons05()
{ {
bool test __attribute__((unused)) = true;
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
const std::size_t N = sizeof(A) / sizeof(int); const std::size_t N = sizeof(A) / sizeof(int);
int count; int count;
std::list<int>::reverse_iterator i;
std::list<int> list0401(A, A + N);
std::list<int> list0402(list0401); typedef _Tp list_type;
typedef typename list_type::reverse_iterator reverse_iterator;
reverse_iterator i;
list_type list0401(A, A + N);
list_type list0402(list0401);
for (i = list0401.rbegin(), count = N - 1; for (i = list0401.rbegin(), count = N - 1;
i != list0401.rend(); i != list0401.rend();
++i, --count) ++i, --count)
...@@ -50,7 +53,7 @@ test04() ...@@ -50,7 +53,7 @@ test04()
int main() int main()
{ {
test04(); cons05<std::list<int> >();
return 0; return 0;
} }
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// Range assign // Range assign
// //
// This test verifies the following. // This test verifies the following.
...@@ -30,17 +28,22 @@ bool test __attribute__((unused)) = true; ...@@ -30,17 +28,22 @@ bool test __attribute__((unused)) = true;
// 23.2.2 const_iterator end() const // 23.2.2 const_iterator end() const
// 23.2.2 size_type size() const // 23.2.2 size_type size() const
// //
template<typename _Tp>
void void
test05() cons05()
{ {
bool test __attribute__((unused)) = true;
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
const int B[] = {101, 102, 103, 104, 105}; const int B[] = {101, 102, 103, 104, 105};
const std::size_t N = sizeof(A) / sizeof(int); const std::size_t N = sizeof(A) / sizeof(int);
const std::size_t M = sizeof(B) / sizeof(int); const std::size_t M = sizeof(B) / sizeof(int);
std::size_t count; std::size_t count;
std::list<int>::const_iterator i;
std::list<int> list0501; typedef _Tp list_type;
typedef typename list_type::const_iterator const_iterator;
const_iterator i;
list_type list0501;
// make it bigger // make it bigger
list0501.assign(A, A + N); list0501.assign(A, A + N);
...@@ -63,7 +66,7 @@ test05() ...@@ -63,7 +66,7 @@ test05()
int main() int main()
{ {
test05(); cons05<std::list<int> >();
return 0; return 0;
} }
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// Fill assign // Fill assign
// //
// This test verifies the following. // This test verifies the following.
...@@ -30,17 +28,22 @@ bool test __attribute__((unused)) = true; ...@@ -30,17 +28,22 @@ bool test __attribute__((unused)) = true;
// 23.2.2 const_iterator end() const // 23.2.2 const_iterator end() const
// 23.2.2 size_type size() const // 23.2.2 size_type size() const
// //
template<typename _Tp>
void void
test06() cons07()
{ {
bool test __attribute__((unused)) = true;
const std::size_t BIG_LIST_SIZE = 11; const std::size_t BIG_LIST_SIZE = 11;
const int BIG_INIT_VALUE = 7; const int BIG_INIT_VALUE = 7;
const std::size_t SMALL_LIST_SIZE = 5; const std::size_t SMALL_LIST_SIZE = 5;
const int SMALL_INIT_VALUE = 17; const int SMALL_INIT_VALUE = 17;
std::size_t count; std::size_t count;
std::list<int>::const_iterator i;
std::list<int> list0601; typedef _Tp list_type;
typedef typename list_type::const_iterator const_iterator;
const_iterator i;
list_type list0601;
VERIFY(list0601.size() == 0); VERIFY(list0601.size() == 0);
// make it bigger // make it bigger
...@@ -64,7 +67,7 @@ test06() ...@@ -64,7 +67,7 @@ test06()
int main() int main()
{ {
test06(); cons07<std::list<int> >();
return 0; return 0;
} }
...@@ -20,35 +20,31 @@ ...@@ -20,35 +20,31 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// A nontrivial type.
template<typename T>
struct A { };
// Another nontrivial type
struct B { };
// A nontrivial type convertible from an int // A nontrivial type convertible from an int
struct C { struct C
{
C(int i) : i_(i) { } C(int i) : i_(i) { }
bool operator==(const C& rhs) { return i_ == rhs.i_; } bool operator==(const C& rhs) { return i_ == rhs.i_; }
int i_; int i_;
}; };
// Fill Assignment disguised as a Range Assignment // Fill Assignment disguised as a Range Assignment
template<typename _Tp>
void void
test06D() cons08()
{ {
typedef _Tp list_type;
typedef typename list_type::iterator iterator;
bool test __attribute__((unused)) = true;
const std::size_t LIST_SIZE = 5; const std::size_t LIST_SIZE = 5;
const int INIT_VALUE = 7; const int INIT_VALUE = 7;
std::size_t count = 0; std::size_t count = 0;
std::list<C> list0604;
list_type list0604;
VERIFY(list0604.size() == 0); VERIFY(list0604.size() == 0);
list0604.assign(LIST_SIZE, INIT_VALUE); list0604.assign(LIST_SIZE, INIT_VALUE);
std::list<C>::iterator i = list0604.begin(); iterator i = list0604.begin();
for (; i != list0604.end(); ++i, ++count) for (; i != list0604.end(); ++i, ++count)
VERIFY(*i == INIT_VALUE); VERIFY(*i == INIT_VALUE);
VERIFY(count == LIST_SIZE); VERIFY(count == LIST_SIZE);
...@@ -57,7 +53,7 @@ test06D() ...@@ -57,7 +53,7 @@ test06D()
int main() int main()
{ {
test06D(); cons08<std::list<C> >();
return 0; return 0;
} }
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// Assignment operator // Assignment operator
// //
// This test verifies the following. // This test verifies the following.
...@@ -31,18 +29,24 @@ bool test __attribute__((unused)) = true; ...@@ -31,18 +29,24 @@ bool test __attribute__((unused)) = true;
// 23.2.2 size_type size() const // 23.2.2 size_type size() const
// 23.2.2 bool operator==(const list& x, const list& y) // 23.2.2 bool operator==(const list& x, const list& y)
// //
template<typename _Tp>
void void
test07() cons09()
{ {
bool test __attribute__((unused)) = true;
typedef _Tp list_type;
typedef typename list_type::iterator iterator;
const int A[] = {701, 702, 703, 704, 705}; const int A[] = {701, 702, 703, 704, 705};
const std::size_t N = sizeof(A) / sizeof(int); const std::size_t N = sizeof(A) / sizeof(int);
std::size_t count; std::size_t count;
std::list<int>::iterator i;
std::list<int> list0701(A, A + N); iterator i;
list_type list0701(A, A + N);
VERIFY(list0701.size() == N); VERIFY(list0701.size() == N);
std::list<int> list0702; list_type list0702;
VERIFY(list0702.size() == 0); VERIFY(list0702.size() == 0);
list0702 = list0701; list0702 = list0701;
...@@ -57,7 +61,6 @@ test07() ...@@ -57,7 +61,6 @@ test07()
int main() int main()
{ {
test07(); cons09<std::list<int> >();
return 0; return 0;
} }
// vi:set sw=2 ts=2:
...@@ -81,7 +81,8 @@ template<typename Container> ...@@ -81,7 +81,8 @@ template<typename Container>
int main() int main()
{ {
Check_Container<std::list<int, clear_alloc<int> > >(); typedef std::list<int, clear_alloc<int> > list_type;
Check_Container<list_type>();
return 0; return 0;
} }
...@@ -21,28 +21,31 @@ ...@@ -21,28 +21,31 @@
#include <list> #include <list>
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
using namespace __gnu_test; template<typename _Tp>
bool
int main() init_list()
{ {
typedef std::list<int, tracker_allocator<int> > Container; using namespace __gnu_test;
typedef _Tp list_type;
typedef typename list_type::iterator iterator;
const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 };
bool ok = true; bool ok = true;
tracker_allocator_counter::reset(); tracker_allocator_counter::reset();
{ {
Container c({ 2, 4, 1 }); list_type c({ 2, 4, 1 });
ok = check_construct_destroy("Construct from init-list", 3, 0) && ok; ok = check_construct_destroy("Construct from init-list", 3, 0) && ok;
Container::iterator i = c.begin(); iterator i = c.begin();
ok &= (*i++ == 2); ok &= (*i++ == 2);
ok &= (*i++ == 4); ok &= (*i++ == 4);
} }
ok = check_construct_destroy("Construct from init-list", 3, 3) && ok; ok = check_construct_destroy("Construct from init-list", 3, 3) && ok;
{ {
Container c(arr10, arr10 + 10); list_type c(arr10, arr10 + 10);
tracker_allocator_counter::reset(); tracker_allocator_counter::reset();
Container::iterator i = c.begin(); iterator i = c.begin();
++i; ++i; ++i; ++i; ++i; ++i; ++i; ++i; ++i; ++i; ++i; ++i; ++i; ++i;
c.insert(i, { 234, 42, 1 }); c.insert(i, { 234, 42, 1 });
ok = check_construct_destroy("Insert init-list", 3, 0) && ok; ok = check_construct_destroy("Insert init-list", 3, 0) && ok;
...@@ -52,14 +55,23 @@ int main() ...@@ -52,14 +55,23 @@ int main()
ok = check_construct_destroy("Insert init-list", 3, 13) && ok; ok = check_construct_destroy("Insert init-list", 3, 13) && ok;
{ {
Container c; list_type c;
tracker_allocator_counter::reset(); tracker_allocator_counter::reset();
c = { 13, 0, 42 }; c = { 13, 0, 42 };
ok = check_construct_destroy("Assign init-list", 3, 0) && ok; ok = check_construct_destroy("Assign init-list", 3, 0) && ok;
Container::iterator i = c.begin(); iterator i = c.begin();
ok &= (*i++ == 13); ok &= (*i++ == 13);
} }
ok = check_construct_destroy("Assign init-list", 3, 3) && ok; ok = check_construct_destroy("Assign init-list", 3, 3) && ok;
return ok ? 0 : 1;; return ok ? 0 : 1;
}
int main()
{
typedef int value_type;
typedef __gnu_test::tracker_allocator<int> allocator_type;
typedef std::list<value_type, allocator_type> list_type;
init_list<list_type>();
return 0;
} }
...@@ -21,21 +21,21 @@ ...@@ -21,21 +21,21 @@
#include <iterator> #include <iterator>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
using __gnu_debug::list;
using std::advance;
bool test = true;
// Assignment // Assignment
void test01() void test01()
{ {
list<int> v1; using std::advance;
list<int> v2;
bool test = true;
typedef __gnu_debug::list<int> list_type;
list_type v1;
list_type v2;
v1.push_front(17); v1.push_front(17);
list<int>::iterator start = v1.begin(); list_type::iterator start = v1.begin();
list<int>::iterator finish = v1.end(); list_type::iterator finish = v1.end();
VERIFY(start._M_dereferenceable()); VERIFY(start._M_dereferenceable());
VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); VERIFY(!finish._M_dereferenceable() && !finish._M_singular());
......
...@@ -21,23 +21,24 @@ ...@@ -21,23 +21,24 @@
#include <iterator> #include <iterator>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
using __gnu_debug::list;
using std::advance;
bool test = true;
// Resize // Resize
void test02() void test02()
{ {
list<int> v(10, 17); using std::advance;
bool test = true;
typedef __gnu_debug::list<int> list_type;
list_type v(10, 17);
list<int>::iterator before = v.begin(); list_type::iterator before = v.begin();
advance(before, 6); advance(before, 6);
list<int>::iterator at = before; list_type::iterator at = before;
advance(at, 1); advance(at, 1);
list<int>::iterator after = at; list_type::iterator after = at;
advance(after, 1); advance(after, 1);
list<int>::iterator finish = v.end(); list_type::iterator finish = v.end();
// Shrink // Shrink
v.resize(7); v.resize(7);
......
...@@ -21,21 +21,21 @@ ...@@ -21,21 +21,21 @@
#include <iterator> #include <iterator>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
using __gnu_debug::list;
using std::advance;
bool test = true;
// Erase // Erase
void test03() void test03()
{ {
list<int> v(20, 42); using std::advance;
bool test = true;
typedef __gnu_debug::list<int> list_type;
list_type v(20, 42);
// Single element erase (middle) // Single element erase (middle)
list<int>::iterator before = v.begin(); list_type::iterator before = v.begin();
list<int>::iterator at = before; list_type::iterator at = before;
advance(at, 3); advance(at, 3);
list<int>::iterator after = at; list_type::iterator after = at;
at = v.erase(at); at = v.erase(at);
VERIFY(before._M_dereferenceable()); VERIFY(before._M_dereferenceable());
VERIFY(at._M_dereferenceable()); VERIFY(at._M_dereferenceable());
...@@ -63,7 +63,7 @@ void test03() ...@@ -63,7 +63,7 @@ void test03()
// clear() // clear()
before = v.begin(); before = v.begin();
list<int>::iterator finish = v.end(); list_type::iterator finish = v.end();
VERIFY(before._M_dereferenceable()); VERIFY(before._M_dereferenceable());
v.clear(); v.clear();
VERIFY(before._M_singular()); VERIFY(before._M_singular());
......
...@@ -21,21 +21,22 @@ ...@@ -21,21 +21,22 @@
#include <iterator> #include <iterator>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
using __gnu_debug::list;
using std::advance;
bool test = true;
// Splice // Splice
void test04() void test04()
{ {
list<int> l1(10, 17); using std::advance;
list<int> l2(10, 42);
bool test = true;
typedef __gnu_debug::list<int> list_type;
list_type l1(10, 17);
list_type l2(10, 42);
list<int>::iterator start2 = l2.begin(); list_type::iterator start2 = l2.begin();
list<int>::iterator end2 = start2; list_type::iterator end2 = start2;
advance(end2, 5); advance(end2, 5);
list<int>::iterator after2 = end2; list_type::iterator after2 = end2;
advance(after2, 2); advance(after2, 2);
l1.splice(l1.begin(), l2, start2, end2); l1.splice(l1.begin(), l2, start2, end2);
......
...@@ -20,99 +20,101 @@ ...@@ -20,99 +20,101 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
typedef __gnu_test::copy_tracker T;
bool test __attribute__((unused)) = true;
// range and fill insert/erase + clear // range and fill insert/erase + clear
// missing: o fill insert disguised as a range insert in all its variants // missing: o fill insert disguised as a range insert in all its variants
// o exception effects // o exception effects
template<typename _Tp>
void void
test03() modifiers1()
{ {
std::list<T> list0301; bool test __attribute__((unused)) = true;
T::reset(); typedef _Tp list_type;
typedef typename list_type::iterator iterator;
typedef typename list_type::value_type value_type;
list_type list0301;
value_type::reset();
// fill insert at beginning of list / empty list // fill insert at beginning of list / empty list
list0301.insert(list0301.begin(), 3, T(11)); // should be [11 11 11] list0301.insert(list0301.begin(), 3, value_type(11)); // should be [11 11 11]
VERIFY(list0301.size() == 3); VERIFY(list0301.size() == 3);
VERIFY(T::copyCount() == 3); VERIFY(value_type::copyCount() == 3);
// save iterators to verify post-insert validity // save iterators to verify post-insert validity
std::list<T>::iterator b = list0301.begin(); iterator b = list0301.begin();
std::list<T>::iterator m = list0301.end(); --m; iterator m = list0301.end(); --m;
std::list<T>::iterator e = list0301.end(); iterator e = list0301.end();
// fill insert at end of list // fill insert at end of list
T::reset(); value_type::reset();
list0301.insert(list0301.end(), 3, T(13)); // should be [11 11 11 13 13 13] list0301.insert(list0301.end(), 3, value_type(13)); // should be [11 11 11 13 13 13]
VERIFY(list0301.size() == 6); VERIFY(list0301.size() == 6);
VERIFY(T::copyCount() == 3); VERIFY(value_type::copyCount() == 3);
VERIFY(b == list0301.begin() && b->id() == 11); VERIFY(b == list0301.begin() && b->id() == 11);
VERIFY(e == list0301.end()); VERIFY(e == list0301.end());
VERIFY(m->id() == 11); VERIFY(m->id() == 11);
// fill insert in the middle of list // fill insert in the middle of list
++m; ++m;
T::reset(); value_type::reset();
list0301.insert(m, 3, T(12)); // should be [11 11 11 12 12 12 13 13 13] list0301.insert(m, 3, value_type(12)); // should be [11 11 11 12 12 12 13 13 13]
VERIFY(list0301.size() == 9); VERIFY(list0301.size() == 9);
VERIFY(T::copyCount() == 3); VERIFY(value_type::copyCount() == 3);
VERIFY(b == list0301.begin() && b->id() == 11); VERIFY(b == list0301.begin() && b->id() == 11);
VERIFY(e == list0301.end()); VERIFY(e == list0301.end());
VERIFY(m->id() == 13); VERIFY(m->id() == 13);
// single erase // single erase
T::reset(); value_type::reset();
m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13] m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13]
VERIFY(list0301.size() == 8); VERIFY(list0301.size() == 8);
VERIFY(T::dtorCount() == 1); VERIFY(value_type::dtorCount() == 1);
VERIFY(b == list0301.begin() && b->id() == 11); VERIFY(b == list0301.begin() && b->id() == 11);
VERIFY(e == list0301.end()); VERIFY(e == list0301.end());
VERIFY(m->id() == 13); VERIFY(m->id() == 13);
// range erase // range erase
T::reset(); value_type::reset();
m = list0301.erase(list0301.begin(), m); // should be [13 13] m = list0301.erase(list0301.begin(), m); // should be [13 13]
VERIFY(list0301.size() == 2); VERIFY(list0301.size() == 2);
VERIFY(T::dtorCount() == 6); VERIFY(value_type::dtorCount() == 6);
VERIFY(m->id() == 13); VERIFY(m->id() == 13);
// range fill at beginning // range fill at beginning
const int A[] = {321, 322, 333}; const int A[] = {321, 322, 333};
const int N = sizeof(A) / sizeof(int); const int N = sizeof(A) / sizeof(int);
T::reset(); value_type::reset();
b = list0301.begin(); b = list0301.begin();
list0301.insert(b, A, A + N); // should be [321 322 333 13 13] list0301.insert(b, A, A + N); // should be [321 322 333 13 13]
VERIFY(list0301.size() == 5); VERIFY(list0301.size() == 5);
VERIFY(T::copyCount() == 3); VERIFY(value_type::copyCount() == 3);
VERIFY(m->id() == 13); VERIFY(m->id() == 13);
// range fill at end // range fill at end
T::reset(); value_type::reset();
list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333] list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333]
VERIFY(list0301.size() == 8); VERIFY(list0301.size() == 8);
VERIFY(T::copyCount() == 3); VERIFY(value_type::copyCount() == 3);
VERIFY(e == list0301.end()); VERIFY(e == list0301.end());
VERIFY(m->id() == 13); VERIFY(m->id() == 13);
// range fill in middle // range fill in middle
T::reset(); value_type::reset();
list0301.insert(m, A, A + N); list0301.insert(m, A, A + N);
VERIFY(list0301.size() == 11); VERIFY(list0301.size() == 11);
VERIFY(T::copyCount() == 3); VERIFY(value_type::copyCount() == 3);
VERIFY(e == list0301.end()); VERIFY(e == list0301.end());
VERIFY(m->id() == 13); VERIFY(m->id() == 13);
T::reset(); value_type::reset();
list0301.clear(); list0301.clear();
VERIFY(list0301.size() == 0); VERIFY(list0301.size() == 0);
VERIFY(T::dtorCount() == 11); VERIFY(value_type::dtorCount() == 11);
VERIFY(e == list0301.end()); VERIFY(e == list0301.end());
} }
int main() int main()
{ {
test03(); modifiers1<std::list<__gnu_test::copy_tracker> >();
return 0; return 0;
} }
...@@ -20,71 +20,74 @@ ...@@ -20,71 +20,74 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
typedef __gnu_test::copy_tracker T;
bool test __attribute__((unused)) = true;
// general single insert/erase + swap // general single insert/erase + swap
template<typename _Tp>
void void
test02() modifiers2()
{ {
std::list<T> list0201; bool test __attribute__((unused)) = true;
T::reset(); typedef _Tp list_type;
typedef typename list_type::value_type value_type;
typedef typename list_type::iterator iterator;
typedef typename list_type::const_iterator const_iterator;
list_type list0201;
value_type::reset();
list0201.insert(list0201.begin(), T(1)); // list should be [1] list0201.insert(list0201.begin(), value_type(1)); // list should be [1]
VERIFY(list0201.size() == 1); VERIFY(list0201.size() == 1);
VERIFY(T::copyCount() == 1); VERIFY(value_type::copyCount() == 1);
list0201.insert(list0201.end(), T(2)); // list should be [1 2] list0201.insert(list0201.end(), value_type(2)); // list should be [1 2]
VERIFY(list0201.size() == 2); VERIFY(list0201.size() == 2);
VERIFY(T::copyCount() == 2); VERIFY(value_type::copyCount() == 2);
std::list<T>::iterator i = list0201.begin(); iterator i = list0201.begin();
std::list<T>::const_iterator j = i; const_iterator j = i;
VERIFY(i->id() == 1); ++i; VERIFY(i->id() == 1); ++i;
VERIFY(i->id() == 2); VERIFY(i->id() == 2);
list0201.insert(i, T(3)); // list should be [1 3 2] list0201.insert(i, value_type(3)); // list should be [1 3 2]
VERIFY(list0201.size() == 3); VERIFY(list0201.size() == 3);
VERIFY(T::copyCount() == 3); VERIFY(value_type::copyCount() == 3);
std::list<T>::const_iterator k = i; const_iterator k = i;
VERIFY(i->id() == 2); --i; VERIFY(i->id() == 2); --i;
VERIFY(i->id() == 3); --i; VERIFY(i->id() == 3); --i;
VERIFY(i->id() == 1); VERIFY(i->id() == 1);
VERIFY(j->id() == 1); VERIFY(j->id() == 1);
++i; // will point to '3' ++i; // will point to '3'
T::reset(); value_type::reset();
list0201.erase(i); // should be [1 2] list0201.erase(i); // should be [1 2]
VERIFY(list0201.size() == 2); VERIFY(list0201.size() == 2);
VERIFY(T::dtorCount() == 1); VERIFY(value_type::dtorCount() == 1);
VERIFY(k->id() == 2); VERIFY(k->id() == 2);
VERIFY(j->id() == 1); VERIFY(j->id() == 1);
std::list<T> list0202; list_type list0202;
T::reset(); value_type::reset();
VERIFY(list0202.size() == 0); VERIFY(list0202.size() == 0);
VERIFY(T::copyCount() == 0); VERIFY(value_type::copyCount() == 0);
VERIFY(T::dtorCount() == 0); VERIFY(value_type::dtorCount() == 0);
// member swap // member swap
list0202.swap(list0201); list0202.swap(list0201);
VERIFY(list0201.size() == 0); VERIFY(list0201.size() == 0);
VERIFY(list0202.size() == 2); VERIFY(list0202.size() == 2);
VERIFY(T::copyCount() == 0); VERIFY(value_type::copyCount() == 0);
VERIFY(T::dtorCount() == 0); VERIFY(value_type::dtorCount() == 0);
// specialized swap // specialized swap
swap(list0201, list0202); swap(list0201, list0202);
VERIFY(list0201.size() == 2); VERIFY(list0201.size() == 2);
VERIFY(list0202.size() == 0); VERIFY(list0202.size() == 0);
VERIFY(T::copyCount() == 0); VERIFY(value_type::copyCount() == 0);
VERIFY(T::dtorCount() == 0); VERIFY(value_type::dtorCount() == 0);
} }
int main() int main()
{ {
test02(); modifiers2<std::list<__gnu_test::copy_tracker> >();
return 0; return 0;
} }
...@@ -20,11 +20,6 @@ ...@@ -20,11 +20,6 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
typedef __gnu_test::copy_tracker T;
bool test __attribute__((unused)) = true;
// This test verifies the following. // This test verifies the following.
// //
// 23.2.2.3 void push_front(const T& x) // 23.2.2.3 void push_front(const T& x)
...@@ -46,18 +41,26 @@ bool test __attribute__((unused)) = true; ...@@ -46,18 +41,26 @@ bool test __attribute__((unused)) = true;
// 23.2.2 reference back() // 23.2.2 reference back()
// 23.2.2 const_reference back() const // 23.2.2 const_reference back() const
// //
template<typename _Tp>
void void
test01() modifiers3()
{ {
std::list<T> list0101; bool test __attribute__((unused)) = true;
std::list<T>::const_iterator i; typedef _Tp list_type;
std::list<T>::const_reverse_iterator j; typedef typename list_type::iterator iterator;
std::list<T>::iterator k; typedef typename list_type::value_type value_type;
T::reset(); typedef typename list_type::const_iterator const_iterator;
typedef typename list_type::const_reverse_iterator const_reverse_iterator;
list0101.push_back(T(1)); // list should be [1]
list_type list0101;
const_iterator i;
const_reverse_iterator j;
iterator k;
value_type::reset();
list0101.push_back(value_type(1)); // list should be [1]
VERIFY(list0101.size() == 1); VERIFY(list0101.size() == 1);
VERIFY(T::copyCount() == 1); VERIFY(value_type::copyCount() == 1);
k = list0101.end(); k = list0101.end();
--k; --k;
...@@ -65,25 +68,25 @@ test01() ...@@ -65,25 +68,25 @@ test01()
VERIFY(k->id() == list0101.front().id()); VERIFY(k->id() == list0101.front().id());
VERIFY(k->id() == list0101.back().id()); VERIFY(k->id() == list0101.back().id());
list0101.push_front(T(2)); // list should be [2 1] list0101.push_front(value_type(2)); // list should be [2 1]
VERIFY(list0101.size() == 2); VERIFY(list0101.size() == 2);
VERIFY(T::copyCount() == 2); VERIFY(value_type::copyCount() == 2);
VERIFY(k->id() == 1); VERIFY(k->id() == 1);
list0101.push_back(T(3)); // list should be [2 1 3] list0101.push_back(value_type(3)); // list should be [2 1 3]
VERIFY(list0101.size() == 3); VERIFY(list0101.size() == 3);
VERIFY(T::copyCount() == 3); VERIFY(value_type::copyCount() == 3);
VERIFY(k->id() == 1); VERIFY(k->id() == 1);
try try
{ {
list0101.push_back(T(4, true)); list0101.push_back(value_type(4, true));
VERIFY(false); VERIFY(false);
} }
catch (...) catch (...)
{ {
VERIFY(list0101.size() == 3); VERIFY(list0101.size() == 3);
VERIFY(T::copyCount() == 4); VERIFY(value_type::copyCount() == 4);
} }
i = list0101.begin(); i = list0101.begin();
...@@ -100,23 +103,23 @@ test01() ...@@ -100,23 +103,23 @@ test01()
++j; ++j;
VERIFY(j->id() == 1); VERIFY(j->id() == 1);
T::reset(); value_type::reset();
list0101.pop_back(); // list should be [2 1] list0101.pop_back(); // list should be [2 1]
VERIFY(list0101.size() == 2); VERIFY(list0101.size() == 2);
VERIFY(T::dtorCount() == 1); VERIFY(value_type::dtorCount() == 1);
VERIFY(i->id() == 1); VERIFY(i->id() == 1);
VERIFY(k->id() == 1); VERIFY(k->id() == 1);
list0101.pop_front(); // list should be [1] list0101.pop_front(); // list should be [1]
VERIFY(list0101.size() == 1); VERIFY(list0101.size() == 1);
VERIFY(T::dtorCount() == 2); VERIFY(value_type::dtorCount() == 2);
VERIFY(i->id() == 1); VERIFY(i->id() == 1);
VERIFY(k->id() == 1); VERIFY(k->id() == 1);
} }
int main() int main()
{ {
test01(); modifiers3<std::list<__gnu_test::copy_tracker> >();
return 0; return 0;
} }
...@@ -24,19 +24,21 @@ ...@@ -24,19 +24,21 @@
#include <ext/throw_allocator.h> #include <ext/throw_allocator.h>
// libstdc++/25288 // libstdc++/25288
void test01() template<typename _Tp>
void insert1()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
typedef int value_type; typedef _Tp list_type;
typedef __gnu_cxx::throw_allocator<value_type> allocator_type; typedef typename _Tp::value_type value_type;
typedef std::list<value_type, allocator_type> list_type; typedef typename _Tp::allocator_type allocator_type;
typedef typename _Tp::size_type size_type;
for (int j = 0; j < 10; ++j) for (int j = 0; j < 10; ++j)
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
{ {
allocator_type alloc1; allocator_type alloc1;
allocator_type::zero_throw_prob_adjustor adjust1; typename allocator_type::zero_throw_prob_adjustor adjust1;
list_type list1(alloc1); list_type list1(alloc1);
for (int k = 0; k < j; ++k) for (int k = 0; k < j; ++k)
...@@ -57,12 +59,12 @@ void test01() ...@@ -57,12 +59,12 @@ void test01()
VERIFY( false ); VERIFY( false );
} }
VERIFY( list1.size() == list_type::size_type(j) ); VERIFY( list1.size() == size_type(j) );
VERIFY( list1.size() == 0 || list1.back() == -j ); VERIFY( list1.size() == 0 || list1.back() == -j );
VERIFY( list1.size() == 0 || list1.front() == -1 ); VERIFY( list1.size() == 0 || list1.front() == -1 );
allocator_type alloc2; allocator_type alloc2;
allocator_type::zero_throw_prob_adjustor adjust2; typename allocator_type::zero_throw_prob_adjustor adjust2;
list_type list2(alloc2); list_type list2(alloc2);
const int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; const int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
...@@ -85,7 +87,7 @@ void test01() ...@@ -85,7 +87,7 @@ void test01()
VERIFY( false ); VERIFY( false );
} }
VERIFY( list2.size() == list_type::size_type(j) ); VERIFY( list2.size() == size_type(j) );
VERIFY( list2.size() == 0 || list2.back() == -j ); VERIFY( list2.size() == 0 || list2.back() == -j );
VERIFY( list2.size() == 0 || list2.front() == -1 ); VERIFY( list2.size() == 0 || list2.front() == -1 );
} }
...@@ -93,6 +95,10 @@ void test01() ...@@ -93,6 +95,10 @@ void test01()
int main() int main()
{ {
test01(); typedef int value_type;
typedef __gnu_cxx::throw_allocator<value_type> allocator_type;
typedef std::list<value_type, allocator_type> list_type;
insert1<list_type>();
return 0; return 0;
} }
...@@ -31,23 +31,31 @@ namespace std ...@@ -31,23 +31,31 @@ namespace std
} }
// Should use list specialization for swap. // Should use list specialization for swap.
void test01() template<typename _Tp>
void
swap11()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::list<T> A; typedef _Tp list_type;
std::list<T> B;
list_type A;
list_type B;
swap_calls = 0; swap_calls = 0;
std::swap(A, B); std::swap(A, B);
VERIFY(1 == swap_calls); VERIFY(1 == swap_calls);
} }
// Should use list specialization for swap. // Should use list specialization for swap.
void test02() template<typename _Tp>
void
swap12()
{ {
bool test __attribute__((unused)) = true;
using namespace std; using namespace std;
list<T> A; bool test __attribute__((unused)) = true;
list<T> B; typedef _Tp list_type;
list_type A;
list_type B;
swap_calls = 0; swap_calls = 0;
swap(A, B); swap(A, B);
VERIFY(1 == swap_calls); VERIFY(1 == swap_calls);
...@@ -60,7 +68,7 @@ template class __gnu_cxx::__mt_alloc<std::_List_node<T> >; ...@@ -60,7 +68,7 @@ template class __gnu_cxx::__mt_alloc<std::_List_node<T> >;
// See c++/13658 for background info. // See c++/13658 for background info.
int main() int main()
{ {
test01(); swap11<std::list<T> >();
test02(); swap12<std::list<T> >();
return 0; return 0;
} }
...@@ -24,14 +24,16 @@ ...@@ -24,14 +24,16 @@
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
// uneq_allocator as a non-empty allocator. // uneq_allocator as a non-empty allocator.
template<typename _Tp>
void void
test01() swap2()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
using namespace std; using namespace std;
typedef __gnu_test::uneq_allocator<char> my_alloc; typedef _Tp list_type;
typedef list<char, my_alloc> my_list; typedef typename list_type::allocator_type allocator_type;
typedef typename list_type::size_type size_type;
const char title01[] = "Rivers of sand"; const char title01[] = "Rivers of sand";
const char title02[] = "Concret PH"; const char title02[] = "Concret PH";
...@@ -43,13 +45,13 @@ test01() ...@@ -43,13 +45,13 @@ test01()
const size_t N3 = sizeof(title03); const size_t N3 = sizeof(title03);
const size_t N4 = sizeof(title04); const size_t N4 = sizeof(title04);
my_list::size_type size01, size02; size_type size01, size02;
my_alloc alloc01(1); allocator_type alloc01(1);
my_list lis01(alloc01); list_type lis01(alloc01);
size01 = lis01.size(); size01 = lis01.size();
my_list lis02(alloc01); list_type lis02(alloc01);
size02 = lis02.size(); size02 = lis02.size();
lis01.swap(lis02); lis01.swap(lis02);
...@@ -58,9 +60,9 @@ test01() ...@@ -58,9 +60,9 @@ test01()
VERIFY( lis02.size() == size01 ); VERIFY( lis02.size() == size01 );
VERIFY( lis02.empty() ); VERIFY( lis02.empty() );
my_list lis03(alloc01); list_type lis03(alloc01);
size01 = lis03.size(); size01 = lis03.size();
my_list lis04(title02, title02 + N2, alloc01); list_type lis04(title02, title02 + N2, alloc01);
size02 = lis04.size(); size02 = lis04.size();
lis03.swap(lis04); lis03.swap(lis04);
...@@ -69,9 +71,9 @@ test01() ...@@ -69,9 +71,9 @@ test01()
VERIFY( lis04.size() == size01 ); VERIFY( lis04.size() == size01 );
VERIFY( lis04.empty() ); VERIFY( lis04.empty() );
my_list lis05(title01, title01 + N1, alloc01); list_type lis05(title01, title01 + N1, alloc01);
size01 = lis05.size(); size01 = lis05.size();
my_list lis06(title02, title02 + N2, alloc01); list_type lis06(title02, title02 + N2, alloc01);
size02 = lis06.size(); size02 = lis06.size();
lis05.swap(lis06); lis05.swap(lis06);
...@@ -80,9 +82,9 @@ test01() ...@@ -80,9 +82,9 @@ test01()
VERIFY( lis06.size() == size01 ); VERIFY( lis06.size() == size01 );
VERIFY( equal(lis06.begin(), lis06.end(), title01) ); VERIFY( equal(lis06.begin(), lis06.end(), title01) );
my_list lis07(title01, title01 + N1, alloc01); list_type lis07(title01, title01 + N1, alloc01);
size01 = lis07.size(); size01 = lis07.size();
my_list lis08(title03, title03 + N3, alloc01); list_type lis08(title03, title03 + N3, alloc01);
size02 = lis08.size(); size02 = lis08.size();
lis07.swap(lis08); lis07.swap(lis08);
...@@ -91,9 +93,9 @@ test01() ...@@ -91,9 +93,9 @@ test01()
VERIFY( lis08.size() == size01 ); VERIFY( lis08.size() == size01 );
VERIFY( equal(lis08.begin(), lis08.end(), title01) ); VERIFY( equal(lis08.begin(), lis08.end(), title01) );
my_list lis09(title03, title03 + N3, alloc01); list_type lis09(title03, title03 + N3, alloc01);
size01 = lis09.size(); size01 = lis09.size();
my_list lis10(title04, title04 + N4, alloc01); list_type lis10(title04, title04 + N4, alloc01);
size02 = lis10.size(); size02 = lis10.size();
lis09.swap(lis10); lis09.swap(lis10);
...@@ -102,9 +104,9 @@ test01() ...@@ -102,9 +104,9 @@ test01()
VERIFY( lis10.size() == size01 ); VERIFY( lis10.size() == size01 );
VERIFY( equal(lis10.begin(), lis10.end(), title03) ); VERIFY( equal(lis10.begin(), lis10.end(), title03) );
my_list lis11(title04, title04 + N4, alloc01); list_type lis11(title04, title04 + N4, alloc01);
size01 = lis11.size(); size01 = lis11.size();
my_list lis12(title01, title01 + N1, alloc01); list_type lis12(title01, title01 + N1, alloc01);
size02 = lis12.size(); size02 = lis12.size();
lis11.swap(lis12); lis11.swap(lis12);
...@@ -113,9 +115,9 @@ test01() ...@@ -113,9 +115,9 @@ test01()
VERIFY( lis12.size() == size01 ); VERIFY( lis12.size() == size01 );
VERIFY( equal(lis12.begin(), lis12.end(), title04) ); VERIFY( equal(lis12.begin(), lis12.end(), title04) );
my_list lis13(title03, title03 + N3, alloc01); list_type lis13(title03, title03 + N3, alloc01);
size01 = lis13.size(); size01 = lis13.size();
my_list lis14(title03, title03 + N3, alloc01); list_type lis14(title03, title03 + N3, alloc01);
size02 = lis14.size(); size02 = lis14.size();
lis13.swap(lis14); lis13.swap(lis14);
...@@ -127,6 +129,10 @@ test01() ...@@ -127,6 +129,10 @@ test01()
int main() int main()
{ {
test01(); typedef char value_type;
typedef __gnu_test::uneq_allocator<value_type> allocator_type;
typedef std::list<value_type, allocator_type> list_type;
swap2<list_type>();
return 0; return 0;
} }
...@@ -24,14 +24,16 @@ ...@@ -24,14 +24,16 @@
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
// uneq_allocator, two different personalities. // uneq_allocator, two different personalities.
template<typename _Tp>
void void
test01() swap3()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
using namespace std; using namespace std;
typedef __gnu_test::uneq_allocator<char> my_alloc; typedef _Tp list_type;
typedef list<char, my_alloc> my_list; typedef typename list_type::allocator_type allocator_type;
typedef typename list_type::size_type size_type;
const char title01[] = "Rivers of sand"; const char title01[] = "Rivers of sand";
const char title02[] = "Concret PH"; const char title02[] = "Concret PH";
...@@ -43,15 +45,15 @@ test01() ...@@ -43,15 +45,15 @@ test01()
const size_t N3 = sizeof(title03); const size_t N3 = sizeof(title03);
const size_t N4 = sizeof(title04); const size_t N4 = sizeof(title04);
my_list::size_type size01, size02; size_type size01, size02;
my_alloc alloc01(1), alloc02(2); allocator_type alloc01(1), alloc02(2);
int personality01, personality02; int personality01, personality02;
my_list lis01(alloc01); list_type lis01(alloc01);
size01 = lis01.size(); size01 = lis01.size();
personality01 = lis01.get_allocator().get_personality(); personality01 = lis01.get_allocator().get_personality();
my_list lis02(alloc02); list_type lis02(alloc02);
size02 = lis02.size(); size02 = lis02.size();
personality02 = lis02.get_allocator().get_personality(); personality02 = lis02.get_allocator().get_personality();
...@@ -63,10 +65,10 @@ test01() ...@@ -63,10 +65,10 @@ test01()
VERIFY( lis01.get_allocator().get_personality() == personality02 ); VERIFY( lis01.get_allocator().get_personality() == personality02 );
VERIFY( lis02.get_allocator().get_personality() == personality01 ); VERIFY( lis02.get_allocator().get_personality() == personality01 );
my_list lis03(alloc02); list_type lis03(alloc02);
size01 = lis03.size(); size01 = lis03.size();
personality01 = lis03.get_allocator().get_personality(); personality01 = lis03.get_allocator().get_personality();
my_list lis04(title02, title02 + N2, alloc01); list_type lis04(title02, title02 + N2, alloc01);
size02 = lis04.size(); size02 = lis04.size();
personality02 = lis04.get_allocator().get_personality(); personality02 = lis04.get_allocator().get_personality();
...@@ -78,10 +80,10 @@ test01() ...@@ -78,10 +80,10 @@ test01()
VERIFY( lis03.get_allocator().get_personality() == personality02 ); VERIFY( lis03.get_allocator().get_personality() == personality02 );
VERIFY( lis04.get_allocator().get_personality() == personality01 ); VERIFY( lis04.get_allocator().get_personality() == personality01 );
my_list lis05(title01, title01 + N1, alloc01); list_type lis05(title01, title01 + N1, alloc01);
size01 = lis05.size(); size01 = lis05.size();
personality01 = lis05.get_allocator().get_personality(); personality01 = lis05.get_allocator().get_personality();
my_list lis06(title02, title02 + N2, alloc02); list_type lis06(title02, title02 + N2, alloc02);
size02 = lis06.size(); size02 = lis06.size();
personality02 = lis06.get_allocator().get_personality(); personality02 = lis06.get_allocator().get_personality();
...@@ -93,10 +95,10 @@ test01() ...@@ -93,10 +95,10 @@ test01()
VERIFY( lis05.get_allocator().get_personality() == personality02 ); VERIFY( lis05.get_allocator().get_personality() == personality02 );
VERIFY( lis06.get_allocator().get_personality() == personality01 ); VERIFY( lis06.get_allocator().get_personality() == personality01 );
my_list lis07(title01, title01 + N1, alloc02); list_type lis07(title01, title01 + N1, alloc02);
size01 = lis07.size(); size01 = lis07.size();
personality01 = lis07.get_allocator().get_personality(); personality01 = lis07.get_allocator().get_personality();
my_list lis08(title03, title03 + N3, alloc01); list_type lis08(title03, title03 + N3, alloc01);
size02 = lis08.size(); size02 = lis08.size();
personality02 = lis08.get_allocator().get_personality(); personality02 = lis08.get_allocator().get_personality();
...@@ -108,10 +110,10 @@ test01() ...@@ -108,10 +110,10 @@ test01()
VERIFY( lis07.get_allocator().get_personality() == personality02 ); VERIFY( lis07.get_allocator().get_personality() == personality02 );
VERIFY( lis08.get_allocator().get_personality() == personality01 ); VERIFY( lis08.get_allocator().get_personality() == personality01 );
my_list lis09(title03, title03 + N3, alloc01); list_type lis09(title03, title03 + N3, alloc01);
size01 = lis09.size(); size01 = lis09.size();
personality01 = lis09.get_allocator().get_personality(); personality01 = lis09.get_allocator().get_personality();
my_list lis10(title04, title04 + N4, alloc02); list_type lis10(title04, title04 + N4, alloc02);
size02 = lis10.size(); size02 = lis10.size();
personality02 = lis10.get_allocator().get_personality(); personality02 = lis10.get_allocator().get_personality();
...@@ -123,10 +125,10 @@ test01() ...@@ -123,10 +125,10 @@ test01()
VERIFY( lis09.get_allocator().get_personality() == personality02 ); VERIFY( lis09.get_allocator().get_personality() == personality02 );
VERIFY( lis10.get_allocator().get_personality() == personality01 ); VERIFY( lis10.get_allocator().get_personality() == personality01 );
my_list lis11(title04, title04 + N4, alloc02); list_type lis11(title04, title04 + N4, alloc02);
size01 = lis11.size(); size01 = lis11.size();
personality01 = lis11.get_allocator().get_personality(); personality01 = lis11.get_allocator().get_personality();
my_list lis12(title01, title01 + N1, alloc01); list_type lis12(title01, title01 + N1, alloc01);
size02 = lis12.size(); size02 = lis12.size();
personality02 = lis12.get_allocator().get_personality(); personality02 = lis12.get_allocator().get_personality();
...@@ -138,10 +140,10 @@ test01() ...@@ -138,10 +140,10 @@ test01()
VERIFY( lis11.get_allocator().get_personality() == personality02 ); VERIFY( lis11.get_allocator().get_personality() == personality02 );
VERIFY( lis12.get_allocator().get_personality() == personality01 ); VERIFY( lis12.get_allocator().get_personality() == personality01 );
my_list lis13(title03, title03 + N3, alloc01); list_type lis13(title03, title03 + N3, alloc01);
size01 = lis13.size(); size01 = lis13.size();
personality01 = lis13.get_allocator().get_personality(); personality01 = lis13.get_allocator().get_personality();
my_list lis14(title03, title03 + N3, alloc02); list_type lis14(title03, title03 + N3, alloc02);
size02 = lis14.size(); size02 = lis14.size();
personality02 = lis14.get_allocator().get_personality(); personality02 = lis14.get_allocator().get_personality();
...@@ -156,6 +158,10 @@ test01() ...@@ -156,6 +158,10 @@ test01()
int main() int main()
{ {
test01(); typedef char value_type;
typedef __gnu_test::uneq_allocator<value_type> allocator_type;
typedef std::list<value_type, allocator_type> list_type;
swap3<list_type>();
return 0; return 0;
} }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. // Copyright (C) 2009 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// NOTE: This makes use of the fact that we know how moveable // NOTE: This makes use of the fact that we know how moveable
// is implemented on list (via swap). If the implementation changed // is implemented on list (via swap). If the implementation changed
// this test may begin to fail. // this test may begin to fail.
...@@ -26,17 +25,26 @@ ...@@ -26,17 +25,26 @@
#include <utility> #include <utility>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
int main() template<typename _Tp>
{ void
test_moveable()
{
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::list<int> a,b; typedef _Tp list_type;
list_type a,b;
a.push_back(1); a.push_back(1);
b = std::move(a); b = std::move(a);
VERIFY( b.size() == 1 && *b.begin() == 1 && a.size() == 0 ); VERIFY( b.size() == 1 && *b.begin() == 1 && a.size() == 0 );
std::list<int> c(std::move(b)); list_type c(std::move(b));
VERIFY( c.size() == 1 && *c.begin() == 1 ); VERIFY( c.size() == 1 && *c.begin() == 1 );
VERIFY( b.size() == 0 ); VERIFY( b.size() == 0 );
}
int main()
{
test_moveable<std::list<int> >();
return 0; return 0;
} }
...@@ -20,21 +20,24 @@ ...@@ -20,21 +20,24 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// splice(p, x) + remove + reverse // splice(p, x) + remove + reverse
template<typename _Tp>
void void
test01() operations01()
{ {
bool test __attribute__((unused)) = true;
typedef _Tp list_type;
typedef typename list_type::iterator iterator;
const int K = 417; const int K = 417;
const int A[] = {1, 2, 3, 4, 5}; const int A[] = {1, 2, 3, 4, 5};
const int B[] = {K, K, K, K, K}; const int B[] = {K, K, K, K, K};
const std::size_t N = sizeof(A) / sizeof(int); const std::size_t N = sizeof(A) / sizeof(int);
const std::size_t M = sizeof(B) / sizeof(int); const std::size_t M = sizeof(B) / sizeof(int);
std::list<int> list0101(A, A + N); list_type list0101(A, A + N);
std::list<int> list0102(B, B + M); list_type list0102(B, B + M);
std::list<int>::iterator p = list0101.begin(); iterator p = list0101.begin();
VERIFY(list0101.size() == N); VERIFY(list0101.size() == N);
VERIFY(list0102.size() == M); VERIFY(list0102.size() == M);
...@@ -65,9 +68,9 @@ test01() ...@@ -65,9 +68,9 @@ test01()
VERIFY(p == list0101.end()); VERIFY(p == list0101.end());
} }
int main(void) int main()
{ {
test01(); operations01<std::list<int> >();
return 0; return 0;
} }
...@@ -20,21 +20,24 @@ ...@@ -20,21 +20,24 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// splice(p, x, i) + remove_if + operator== // splice(p, x, i) + remove_if + operator==
template<typename _Tp>
void void
test02() operations02()
{ {
bool test __attribute__((unused)) = true;
typedef _Tp list_type;
typedef typename list_type::iterator iterator;
const int A[] = {1, 2, 3, 4, 5}; const int A[] = {1, 2, 3, 4, 5};
const int B[] = {2, 1, 3, 4, 5}; const int B[] = {2, 1, 3, 4, 5};
const int C[] = {1, 3, 4, 5, 2}; const int C[] = {1, 3, 4, 5, 2};
const int N = sizeof(A) / sizeof(int); const int N = sizeof(A) / sizeof(int);
std::list<int> list0201(A, A + N); list_type list0201(A, A + N);
std::list<int> list0202(A, A + N); list_type list0202(A, A + N);
std::list<int> list0203(B, B + N); list_type list0203(B, B + N);
std::list<int> list0204(C, C + N); list_type list0204(C, C + N);
std::list<int>::iterator i = list0201.begin(); iterator i = list0201.begin();
// result should be unchanged // result should be unchanged
list0201.splice(list0201.begin(), list0201, i); list0201.splice(list0201.begin(), list0201, i);
...@@ -53,6 +56,6 @@ test02() ...@@ -53,6 +56,6 @@ test02()
int main() int main()
{ {
test02(); operations02<std::list<int> >();
return 0; return 0;
} }
...@@ -20,12 +20,15 @@ ...@@ -20,12 +20,15 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true;
// splice(p, x, f, l) + sort + merge + unique // splice(p, x, f, l) + sort + merge + unique
template<typename _Tp>
void void
test03() operations03()
{ {
bool test __attribute__((unused)) = true;
typedef _Tp list_type;
typedef typename list_type::iterator iterator;
const int A[] = {103, 203, 603, 303, 403, 503}; const int A[] = {103, 203, 603, 303, 403, 503};
const int B[] = {417, 417, 417, 417, 417}; const int B[] = {417, 417, 417, 417, 417};
const int E[] = {103, 417, 417, 203, 603, 303, 403, 503}; const int E[] = {103, 417, 417, 203, 603, 303, 403, 503};
...@@ -38,14 +41,14 @@ test03() ...@@ -38,14 +41,14 @@ test03()
const int Q = sizeof(D) / sizeof(int); const int Q = sizeof(D) / sizeof(int);
const int R = sizeof(E) / sizeof(int); const int R = sizeof(E) / sizeof(int);
std::list<int> list0301(A, A + N); list_type list0301(A, A + N);
std::list<int> list0302(B, B + M); list_type list0302(B, B + M);
std::list<int> list0303(C, C + P); list_type list0303(C, C + P);
std::list<int> list0304(D, D + Q); list_type list0304(D, D + Q);
std::list<int> list0305(E, E + R); list_type list0305(E, E + R);
std::list<int> list0306(F, F + R); list_type list0306(F, F + R);
std::list<int>::iterator p = list0301.begin(); iterator p = list0301.begin();
std::list<int>::iterator q = list0302.begin(); iterator q = list0302.begin();
++p; ++q; ++q; ++p; ++q; ++q;
list0301.splice(p, list0302, list0302.begin(), q); list0301.splice(p, list0302, list0302.begin(), q);
...@@ -67,6 +70,6 @@ test03() ...@@ -67,6 +70,6 @@ test03()
int main(void) int main(void)
{ {
test03(); operations03<std::list<int> >();
return 0; return 0;
} }
...@@ -20,10 +20,8 @@ ...@@ -20,10 +20,8 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
bool test __attribute__((unused)) = true; // A comparison predicate to order by rightmost digit. Tracks call
// counts for performance checks.
// A comparison predicate to order by rightmost digit. Tracks call counts for
// performance checks.
struct CompLastLt struct CompLastLt
{ {
bool operator()(const int x, const int y) bool operator()(const int x, const int y)
...@@ -48,9 +46,13 @@ int CompLastEq::itsCount; ...@@ -48,9 +46,13 @@ int CompLastEq::itsCount;
// sort(pred) + merge(pred) + unique(pred) // sort(pred) + merge(pred) + unique(pred)
// also checks performance requirements // also checks performance requirements
template<typename _Tp>
void void
test04() operations04()
{ {
bool test __attribute__((unused)) = true;
typedef _Tp list_type;
const int A[] = {1, 2, 3, 4, 5, 6}; const int A[] = {1, 2, 3, 4, 5, 6};
const int B[] = {12, 15, 13, 14, 11}; const int B[] = {12, 15, 13, 14, 11};
const int C[] = {11, 12, 13, 14, 15}; const int C[] = {11, 12, 13, 14, 15};
...@@ -59,11 +61,11 @@ test04() ...@@ -59,11 +61,11 @@ test04()
const int M = sizeof(B) / sizeof(int); const int M = sizeof(B) / sizeof(int);
const int Q = sizeof(D) / sizeof(int); const int Q = sizeof(D) / sizeof(int);
std::list<int> list0401(A, A + N); list_type list0401(A, A + N);
std::list<int> list0402(B, B + M); list_type list0402(B, B + M);
std::list<int> list0403(C, C + M); list_type list0403(C, C + M);
std::list<int> list0404(D, D + Q); list_type list0404(D, D + Q);
std::list<int> list0405(A, A + N); list_type list0405(A, A + N);
// sort B // sort B
CompLastLt lt; CompLastLt lt;
...@@ -91,7 +93,7 @@ test04() ...@@ -91,7 +93,7 @@ test04()
int main() int main()
{ {
test04(); operations04<std::list<int> >();
return 0; return 0;
} }
...@@ -25,26 +25,27 @@ ...@@ -25,26 +25,27 @@
#include <testsuite_allocator.h> #include <testsuite_allocator.h>
// Check the splice (and merge) bits of N1599. // Check the splice (and merge) bits of N1599.
template<typename _Tp>
void void
test01() operations05()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
typedef __gnu_test::uneq_allocator<int> my_alloc; typedef _Tp list_type;
typedef std::list<int, my_alloc> my_list; typedef typename list_type::allocator_type allocator_type;
const int data1[] = {1, 2, 3, 4, 5}; const int data1[] = {1, 2, 3, 4, 5};
const int data2[] = {6, 7, 8, 9, 10}; const int data2[] = {6, 7, 8, 9, 10};
const size_t N1 = sizeof(data1) / sizeof(int); const size_t N1 = sizeof(data1) / sizeof(int);
const size_t N2 = sizeof(data2) / sizeof(int); const size_t N2 = sizeof(data2) / sizeof(int);
my_alloc alloc01(1), alloc02(2); allocator_type alloc01(1), alloc02(2);
my_list l01(data1, data1 + N1, alloc01); list_type l01(data1, data1 + N1, alloc01);
const my_list l01_ref = l01; const list_type l01_ref = l01;
my_list l02(data2, data2 + N2, alloc02); list_type l02(data2, data2 + N2, alloc02);
const my_list l02_ref = l02; const list_type l02_ref = l02;
bool catched = false; bool catched = false;
...@@ -135,6 +136,10 @@ test01() ...@@ -135,6 +136,10 @@ test01()
int main() int main()
{ {
test01(); typedef int value_type;
typedef __gnu_test::uneq_allocator<value_type> allocator_type;
typedef std::list<value_type, allocator_type> list_type;
operations05<list_type>();
return 0; return 0;
} }
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
#include <cstdlib> #include <cstdlib>
#include <pthread.h> #include <pthread.h>
using namespace std;
const int thread_cycles = 10; const int thread_cycles = 10;
const int thread_pairs = 10; const int thread_pairs = 10;
const unsigned max_size = 100; const unsigned max_size = 100;
...@@ -42,6 +40,8 @@ const int iters = 10000; ...@@ -42,6 +40,8 @@ const int iters = 10000;
class task_queue class task_queue
{ {
typedef std::list<int> list_type;
public: public:
task_queue () task_queue ()
{ {
...@@ -55,14 +55,15 @@ public: ...@@ -55,14 +55,15 @@ public:
pthread_cond_destroy (&fooCond1); pthread_cond_destroy (&fooCond1);
pthread_cond_destroy (&fooCond2); pthread_cond_destroy (&fooCond2);
} }
list<int> foo;
list_type foo;
pthread_mutex_t fooLock; pthread_mutex_t fooLock;
pthread_cond_t fooCond1; pthread_cond_t fooCond1;
pthread_cond_t fooCond2; pthread_cond_t fooCond2;
}; };
void* void*
produce (void* t) produce(void* t)
{ {
task_queue& tq = *(static_cast<task_queue*> (t)); task_queue& tq = *(static_cast<task_queue*> (t));
int num = 0; int num = 0;
...@@ -79,7 +80,7 @@ produce (void* t) ...@@ -79,7 +80,7 @@ produce (void* t)
} }
void* void*
consume (void* t) consume(void* t)
{ {
task_queue& tq = *(static_cast<task_queue*> (t)); task_queue& tq = *(static_cast<task_queue*> (t));
int num = 0; int num = 0;
...@@ -98,7 +99,7 @@ consume (void* t) ...@@ -98,7 +99,7 @@ consume (void* t)
} }
int int
main () main()
{ {
pthread_t prod[thread_pairs]; pthread_t prod[thread_pairs];
pthread_t cons[thread_pairs]; pthread_t cons[thread_pairs];
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
#include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING #include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING
#endif #endif
using namespace std;
#define NTHREADS 8 #define NTHREADS 8
#define LOOPS 20 #define LOOPS 20
...@@ -48,19 +46,22 @@ struct tt_t ...@@ -48,19 +46,22 @@ struct tt_t
void* void*
thread_function (void* arg) thread_function (void* arg)
{ {
typedef std::vector<tt_t> vector_type;
typedef std::list<std::string*> list_type;
int myid __attribute__((unused)) = *(int*) arg; int myid __attribute__((unused)) = *(int*) arg;
for (int i = 0; i < LOOPS; i++) for (int i = 0; i < LOOPS; i++)
{ {
vector<tt_t> myvect1; vector_type myvect1;
for (int j = 0; j < 2000; j++) for (int j = 0; j < 2000; j++)
{ {
vector<tt_t> myvect2; vector_type myvect2;
tt_t v; tt_t v;
v.i = j; v.i = j;
myvect1.push_back (v); myvect1.push_back (v);
myvect2.push_back (v); myvect2.push_back (v);
list<std::string *> mylist; list_type mylist;
std::string string_array[4]; std::string string_array[4];
string_array[0] = "toto"; string_array[0] = "toto";
string_array[1] = "titi"; string_array[1] = "titi";
...@@ -70,7 +71,7 @@ thread_function (void* arg) ...@@ -70,7 +71,7 @@ thread_function (void* arg)
{ {
if (mylist.size ()) if (mylist.size ())
{ {
list<std::string *>::iterator aIt; list_type::iterator aIt;
for (aIt = mylist.begin (); aIt != mylist.end (); ++aIt) for (aIt = mylist.begin (); aIt != mylist.end (); ++aIt)
{ {
if ((*aIt) == &(string_array[k])) if ((*aIt) == &(string_array[k]))
......
...@@ -28,7 +28,9 @@ test01() ...@@ -28,7 +28,9 @@ test01()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
std::list<int> l(7); typedef std::list<int> list_type;
list_type l(7);
VERIFY( l.cbegin() == l.begin() ); VERIFY( l.cbegin() == l.begin() );
VERIFY( l.cend() == l.end() ); VERIFY( l.cend() == l.end() );
VERIFY( l.crbegin() == l.rbegin() ); VERIFY( l.crbegin() == l.rbegin() );
......
...@@ -30,6 +30,7 @@ struct A ...@@ -30,6 +30,7 @@ struct A
void f() void f()
{ {
std::list<A> l; typedef std::list<A> list_type;
list_type l;
l.assign(10, 1); l.assign(10, 1);
} }
...@@ -23,5 +23,6 @@ ...@@ -23,5 +23,6 @@
void f() void f()
{ {
std::list<int> l(10, 1); typedef std::list<int> list_type;
list_type l(10, 1);
} }
...@@ -25,5 +25,6 @@ ...@@ -25,5 +25,6 @@
void f() void f()
{ {
std::list<std::list<int> > l(10, 1); typedef std::list<std::list<int> > list_type;
list_type l(10, 1);
} }
...@@ -26,5 +26,6 @@ ...@@ -26,5 +26,6 @@
void f() void f()
{ {
std::list<std::list<std::pair<char, char> > > l('a', 'b'); typedef std::list<std::list<std::pair<char, char> > > list_type;
list_type l('a', 'b');
} }
...@@ -30,6 +30,7 @@ struct A ...@@ -30,6 +30,7 @@ struct A
void f() void f()
{ {
std::list<A> l; typedef std::list<A> list_type;
list_type l;
l.insert(l.begin(), 10, 1); l.insert(l.begin(), 10, 1);
} }
...@@ -29,5 +29,5 @@ struct user_type {}; ...@@ -29,5 +29,5 @@ struct user_type {};
namespace std namespace std
{ {
template<typename Allocator> template<typename Allocator>
class list<user_type, Allocator> {}; class list<user_type, Allocator> { };
} }
...@@ -674,9 +674,7 @@ namespace __gnu_pbds ...@@ -674,9 +674,7 @@ namespace __gnu_pbds
typedef typename __gnu_cxx::typelist::create1<cnt_5_u>::type lu_policy1; typedef typename __gnu_cxx::typelist::create1<cnt_5_u>::type lu_policy1;
typedef typedef
typename __gnu_cxx::typelist::create2< typename __gnu_cxx::typelist::create2<lu_policy0, lu_policy1>::type
lu_policy0,
lu_policy1>::type
lu_policies; lu_policies;
template<typename Policy_Tl> template<typename Policy_Tl>
...@@ -684,18 +682,12 @@ namespace __gnu_pbds ...@@ -684,18 +682,12 @@ namespace __gnu_pbds
{ {
private: private:
typedef typedef
typename __gnu_cxx::typelist::at_index< typename __gnu_cxx::typelist::at_index<Policy_Tl, 0>::type
Policy_Tl, 0>::type
update_policy_t; update_policy_t;
public: public:
typedef typedef
__gnu_pbds::list_update< __gnu_pbds::list_update<Key, Data, Eq_Fn, update_policy_t, Allocator>
Key,
Data,
Eq_Fn,
update_policy_t,
Allocator>
type; type;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment