summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/23_containers/vector/ext_pointer
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/23_containers/vector/ext_pointer
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/vector/ext_pointer')
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/ext_pointer/citerators.cc46
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/ext_pointer/data_access.cc53
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/1.cc27
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/3.cc28
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/element.cc77
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/erase.cc139
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/insert.cc67
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/ext_pointer/resize.cc65
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc61
9 files changed, 563 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/citerators.cc b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/citerators.cc
new file mode 100644
index 000000000..4037536ec
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/citerators.cc
@@ -0,0 +1,46 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <vector>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+// Ensures equivalence of iterators based on low-level comparison
+// between const / non-const Pointer types.
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> > v(7);
+ VERIFY( v.cbegin() == v.begin() );
+ VERIFY( v.cend() == v.end() );
+ VERIFY( v.crbegin() == v.rbegin() );
+ VERIFY( v.crend() == v.rend() );
+ VERIFY( v.cbegin() != v.cend() );
+ VERIFY( v.crbegin() != v.crend() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/data_access.cc b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/data_access.cc
new file mode 100644
index 000000000..a74f44c40
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/data_access.cc
@@ -0,0 +1,53 @@
+// Test for Container using non-standard pointer types.
+
+// Copyright (C) 2008, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <vector>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+// libstdc++/23578
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> > vector_type;
+
+ {
+ const int A[] = { 0, 1, 2, 3, 4 };
+ vector_type v(A, A + 5);
+ VERIFY( v.data() == &v.front() );
+ int* pi = &* v.data();
+ VERIFY( *pi == 0 );
+ }
+
+ {
+ const int A[] = { 4, 3, 2, 1, 0 };
+ const vector_type cv(A, A + 5);
+ VERIFY( cv.data() == &cv.front() );
+ const int* pci = &* cv.data();
+ VERIFY( *pci == 4 );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/1.cc
new file mode 100644
index 000000000..5f585e449
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/1.cc
@@ -0,0 +1,27 @@
+// Test for Container using non-standard pointer types.
+
+// Copyright (C) 2008, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <vector>
+#include <ext/extptr_allocator.h>
+
+// { dg-do compile }
+
+template class std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> >;
diff --git a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/3.cc
new file mode 100644
index 000000000..8c6d3dc55
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/explicit_instantiation/3.cc
@@ -0,0 +1,28 @@
+// Test for Container using non-standard pointer types.
+
+// Copyright (C) 2008, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <vector>
+#include <ext/extptr_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/21770
+template class std::vector<int, __gnu_cxx::_ExtPtr_allocator<char> >;
diff --git a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/element.cc b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/element.cc
new file mode 100644
index 000000000..c12b81cc2
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/element.cc
@@ -0,0 +1,77 @@
+// Test for Container using non-standard pointer types.
+
+// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <vector>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+// General tests element access and manipulation
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ int A[] = { 0, 1, 2, 3, 4 };
+ __gnu_cxx::_ExtPtr_allocator<int> alloc;
+ std::vector<int,__gnu_cxx::_ExtPtr_allocator<int> > mv( A, A+5, alloc );
+
+ VERIFY( mv.size() == 5 );
+ VERIFY( mv.front() == 0 );
+ VERIFY( mv.back() == 4 );
+ VERIFY( mv.at(2) == 2 );
+ VERIFY( mv[3] == 3);
+ mv.front() = 5;
+ mv.back() = 6;
+ mv.at(2) = 7;
+ mv[3] = 8;
+ VERIFY( mv.size() == 5 );
+ VERIFY( mv.front() == 5 );
+ VERIFY( mv.back() == 6 );
+ VERIFY( mv.at(2) == 7 );
+ VERIFY( mv[3] == 8 );
+
+ try
+ {
+ mv.at(100) = 8;
+ }
+ catch(std::out_of_range&)
+ {
+ VERIFY( true );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+
+ const std::vector<int,__gnu_cxx::_ExtPtr_allocator<int> > cmv( mv );
+ VERIFY( cmv.get_allocator() == mv.get_allocator() );
+ VERIFY( mv.size() == 5 );
+ VERIFY( mv.front() == 5 );
+ VERIFY( mv.back() == 6 );
+ VERIFY( mv.at(2) == 7 );
+ VERIFY( mv[3] == 8 );
+}
+
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/erase.cc b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/erase.cc
new file mode 100644
index 000000000..99008ce54
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/erase.cc
@@ -0,0 +1,139 @@
+// Bob Walters 10-2008
+
+// Test for Container using non-standard pointer types.
+
+// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <vector>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+const int A[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+const int A1[] = {0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+const int A2[] = {0, 2, 3, 4, 10, 11, 12, 13, 14, 15};
+const int A3[] = {0, 2, 3, 4, 10, 11};
+const int A4[] = {4, 10, 11};
+const int A5[] = {4, 10};
+const unsigned int N = sizeof(A) / sizeof(int);
+const unsigned int N1 = sizeof(A1) / sizeof(int);
+const unsigned int N2 = sizeof(A2) / sizeof(int);
+const unsigned int N3 = sizeof(A3) / sizeof(int);
+const unsigned int N4 = sizeof(A4) / sizeof(int);
+const unsigned int N5 = sizeof(A5) / sizeof(int);
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef std::vector<int,__gnu_cxx::_ExtPtr_allocator<int> > vec_type;
+ typedef vec_type::iterator iterator_type;
+
+ vec_type v(A, A + N);
+
+ iterator_type it1 = v.erase(v.begin() + 1);
+ VERIFY( it1 == v.begin() + 1 );
+ VERIFY( v.size() == N1 );
+ VERIFY( std::equal(v.begin(), v.end(), A1) );
+
+ iterator_type it2 = v.erase(v.begin() + 4, v.begin() + 9);
+ VERIFY( it2 == v.begin() + 4 );
+ VERIFY( v.size() == N2 );
+ VERIFY( std::equal(v.begin(), v.end(), A2) );
+
+ iterator_type it3 = v.erase(v.begin() + 6, v.end());
+ VERIFY( it3 == v.begin() + 6 );
+ VERIFY( v.size() == N3 );
+ VERIFY( std::equal(v.begin(), v.end(), A3) );
+
+ iterator_type it4 = v.erase(v.begin(), v.begin() + 3);
+ VERIFY( it4 == v.begin() );
+ VERIFY( v.size() == N4 );
+ VERIFY( std::equal(v.begin(), v.end(), A4) );
+
+ iterator_type it5 = v.erase(v.begin() + 2);
+ VERIFY( it5 == v.begin() + 2 );
+ VERIFY( v.size() == N5 );
+ VERIFY( std::equal(v.begin(), v.end(), A5) );
+
+ iterator_type it6 = v.erase(v.begin(), v.end());
+ VERIFY( it6 == v.begin() );
+ VERIFY( v.empty() );
+}
+
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef __gnu_cxx::_ExtPtr_allocator<int> int_alloc_type;
+ typedef __gnu_cxx::_ExtPtr_allocator< std::vector<int, int_alloc_type> > vec_alloc_type;
+ typedef std::vector<std::vector<int, int_alloc_type >,vec_alloc_type> vec_type;
+ typedef vec_type::iterator iterator_type;
+
+ vec_type v, v1, v2, v3, v4, v5;
+ for (unsigned int i = 0; i < N; ++i)
+ v.push_back(std::vector<int,int_alloc_type>(1, A[i]));
+ for (unsigned int i = 0; i < N1; ++i)
+ v1.push_back(std::vector<int,int_alloc_type>(1, A1[i]));
+ for (unsigned int i = 0; i < N2; ++i)
+ v2.push_back(std::vector<int,int_alloc_type>(1, A2[i]));
+ for (unsigned int i = 0; i < N3; ++i)
+ v3.push_back(std::vector<int,int_alloc_type>(1, A3[i]));
+ for (unsigned int i = 0; i < N4; ++i)
+ v4.push_back(std::vector<int,int_alloc_type>(1, A4[i]));
+ for (unsigned int i = 0; i < N5; ++i)
+ v5.push_back(std::vector<int,int_alloc_type>(1, A5[i]));
+
+ iterator_type it1 = v.erase(v.begin() + 1);
+ VERIFY( it1 == v.begin() + 1 );
+ VERIFY( v.size() == N1 );
+ VERIFY( std::equal(v.begin(), v.end(), v1.begin()) );
+
+ iterator_type it2 = v.erase(v.begin() + 4, v.begin() + 9);
+ VERIFY( it2 == v.begin() + 4 );
+ VERIFY( v.size() == N2 );
+ VERIFY( std::equal(v.begin(), v.end(), v2.begin()) );
+
+ iterator_type it3 = v.erase(v.begin() + 6, v.end());
+ VERIFY( it3 == v.begin() + 6 );
+ VERIFY( v.size() == N3 );
+ VERIFY( std::equal(v.begin(), v.end(), v3.begin()) );
+
+ iterator_type it4 = v.erase(v.begin(), v.begin() + 3);
+ VERIFY( it4 == v.begin() );
+ VERIFY( v.size() == N4 );
+ VERIFY( std::equal(v.begin(), v.end(), v4.begin()) );
+
+ iterator_type it5 = v.erase(v.begin() + 2);
+ VERIFY( it5 == v.begin() + 2 );
+ VERIFY( v.size() == N5 );
+ VERIFY( std::equal(v.begin(), v.end(), v5.begin()) );
+
+ iterator_type it6 = v.erase(v.begin(), v.end());
+ VERIFY( it6 == v.begin() );
+ VERIFY( v.empty() );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/insert.cc b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/insert.cc
new file mode 100644
index 000000000..6405287d1
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/modifiers/insert.cc
@@ -0,0 +1,67 @@
+// Test for Container using non-standard pointer types.
+
+// Copyright (C) 2008, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <vector>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+#include <stdexcept>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::_ExtPtr_allocator<int> alloc;
+ std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> > iv(alloc);
+ VERIFY( iv.get_allocator() == alloc );
+ VERIFY( iv.size() == 0 );
+
+ int A[] = { 0, 1, 2, 3, 4 };
+ int B[] = { 5, 5, 5, 5, 5 };
+ int C[] = { 6, 7 };
+ iv.insert(iv.end(), A, A+5 );
+ VERIFY( iv.size() == 5 );
+ iv.insert(iv.begin(), 5, 5 );
+ iv.insert(iv.begin()+5, 7);
+ iv.insert(iv.begin()+5, 6);
+ VERIFY( std::equal(iv.begin(), iv.begin()+5, B ));
+ VERIFY( std::equal(iv.begin()+5, iv.begin()+7, C));
+ VERIFY( std::equal(iv.begin()+7, iv.end(), A));
+ VERIFY( iv.size() == 12 );
+
+ try
+ {
+ iv.insert(iv.end(), iv.max_size() + 1, 1);
+ }
+ catch(std::length_error&)
+ {
+ VERIFY( true );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/resize.cc b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/resize.cc
new file mode 100644
index 000000000..432aca27c
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/resize.cc
@@ -0,0 +1,65 @@
+
+// Copyright (C) 2008, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <vector>
+#include <stdexcept>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+
+void test01()
+{
+ // non POD types
+ bool test __attribute__((unused)) = true;
+
+ std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> > vec01;
+ typedef std::vector<int, __gnu_cxx::_ExtPtr_allocator<int> >::size_type size_type;
+
+ VERIFY(vec01.empty());
+
+ const int A[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+
+ // Test resize of the vector based on reserve
+ size_type sz01 = vec01.capacity();
+ vec01.reserve(100);
+ size_type sz02 = vec01.capacity();
+ VERIFY(sz02 >= sz01);
+
+ // grow/shrink
+ vec01.assign( A, A+10 );
+ sz01 = vec01.size() + 100;
+ vec01.resize(sz01);
+ sz02 = vec01.size();
+ VERIFY(sz01 == sz02);
+ VERIFY(std::equal(vec01.begin(), vec01.begin()+10, A));
+
+ sz01 = vec01.size() - 100;
+ vec01.resize(sz01);
+ sz02 = vec01.size();
+ VERIFY(sz01 == sz02);
+ VERIFY(std::equal(vec01.begin(), vec01.end(), A));
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc
new file mode 100644
index 000000000..66fd2c8bb
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/ext_pointer/types/1.cc
@@ -0,0 +1,61 @@
+// Test for Container using non-standard pointer types.
+
+// Copyright (C) 2008, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// This is a copy of vector/types/1.cc with altered allocator.
+// The operator+()s in this test initially failed the test -
+// they stress the accurate recognition, by the compiler,
+// of _Pointer_adapter's own pointer arithmetic functions,
+// which have to match perfectly on the int type to get
+// chosen by the compiler when it sees: _Pointer_adapter<T> + int, etc.
+
+#include <vector>
+#include <ext/extptr_allocator.h>
+
+namespace N
+{
+ struct X { };
+
+ template<typename T>
+ X operator+(T, std::size_t)
+ { return X(); }
+
+ template<typename T>
+ X operator-(T, T)
+ { return X(); }
+}
+
+int main()
+{
+ std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > v(5);
+ const std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > w(1);
+
+ v[0];
+ w[0];
+ v.size();
+ v.capacity();
+ v.resize(1);
+ v.insert(v.begin(), N::X());
+ v.insert(v.begin(), 1, N::X());
+ v.insert(v.begin(), w.begin(), w.end());
+ v = w;
+
+ return 0;
+}