summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/ext
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/ext')
-rw-r--r--libstdc++-v3/testsuite/ext/array_allocator/1.cc58
-rw-r--r--libstdc++-v3/testsuite/ext/array_allocator/2.cc64
-rw-r--r--libstdc++-v3/testsuite/ext/array_allocator/26875.cc45
-rw-r--r--libstdc++-v3/testsuite/ext/array_allocator/3.cc59
-rw-r--r--libstdc++-v3/testsuite/ext/array_allocator/check_allocate_max_size.cc30
-rw-r--r--libstdc++-v3/testsuite/ext/array_allocator/check_deallocate_null.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/array_allocator/check_delete.cc35
-rw-r--r--libstdc++-v3/testsuite/ext/array_allocator/check_new.cc35
-rw-r--r--libstdc++-v3/testsuite/ext/array_allocator/variadic_construct.cc49
-rw-r--r--libstdc++-v3/testsuite/ext/bitmap_allocator/check_allocate_max_size.cc36
-rw-r--r--libstdc++-v3/testsuite/ext/bitmap_allocator/check_deallocate_null.cc38
-rw-r--r--libstdc++-v3/testsuite/ext/bitmap_allocator/check_delete.cc29
-rw-r--r--libstdc++-v3/testsuite/ext/bitmap_allocator/check_new.cc29
-rw-r--r--libstdc++-v3/testsuite/ext/bitmap_allocator/variadic_construct.cc45
-rw-r--r--libstdc++-v3/testsuite/ext/codecvt/1.cc58
-rw-r--r--libstdc++-v3/testsuite/ext/codecvt/char-1.cc141
-rw-r--r--libstdc++-v3/testsuite/ext/codecvt/char-2.cc139
-rw-r--r--libstdc++-v3/testsuite/ext/codecvt/wchar_t.cc127
-rw-r--r--libstdc++-v3/testsuite/ext/concept_checks.cc82
-rw-r--r--libstdc++-v3/testsuite/ext/concurrence_lock_error/cons_virtual_derivation.cc28
-rw-r--r--libstdc++-v3/testsuite/ext/concurrence_unlock_error/cons_virtual_derivation.cc28
-rw-r--r--libstdc++-v3/testsuite/ext/debug_allocator/check_deallocate_null.cc47
-rw-r--r--libstdc++-v3/testsuite/ext/debug_allocator/check_delete.cc33
-rw-r--r--libstdc++-v3/testsuite/ext/debug_allocator/check_new.cc33
-rw-r--r--libstdc++-v3/testsuite/ext/debug_allocator/explicit_instantiation.cc28
-rw-r--r--libstdc++-v3/testsuite/ext/enc_filebuf/char/13189.cc54
-rw-r--r--libstdc++-v3/testsuite/ext/enc_filebuf/char/13598.cc53
-rw-r--r--libstdc++-v3/testsuite/ext/enc_filebuf/wchar_t/13189.cc54
-rw-r--r--libstdc++-v3/testsuite/ext/ext_pointer/1.cc199
-rw-r--r--libstdc++-v3/testsuite/ext/ext_pointer/1_neg.cc94
-rw-r--r--libstdc++-v3/testsuite/ext/forced_error/cons_virtual_derivation.cc30
-rw-r--r--libstdc++-v3/testsuite/ext/headers.cc62
-rw-r--r--libstdc++-v3/testsuite/ext/iota/cxx0x.cc28
-rw-r--r--libstdc++-v3/testsuite/ext/is_heap/1.cc45
-rw-r--r--libstdc++-v3/testsuite/ext/is_heap/47709.cc29
-rw-r--r--libstdc++-v3/testsuite/ext/is_heap/check_type.cc46
-rw-r--r--libstdc++-v3/testsuite/ext/is_sorted/cxx0x.cc28
-rw-r--r--libstdc++-v3/testsuite/ext/malloc_allocator/check_allocate_max_size.cc30
-rw-r--r--libstdc++-v3/testsuite/ext/malloc_allocator/check_deallocate_null.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/malloc_allocator/check_delete.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/malloc_allocator/check_new.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/malloc_allocator/deallocate_global.cc35
-rw-r--r--libstdc++-v3/testsuite/ext/malloc_allocator/deallocate_local.cc39
-rw-r--r--libstdc++-v3/testsuite/ext/malloc_allocator/explicit_instantiation.cc27
-rw-r--r--libstdc++-v3/testsuite/ext/malloc_allocator/variadic_construct.cc45
-rw-r--r--libstdc++-v3/testsuite/ext/median.cc41
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc99
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_big_per_type.cc54
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc30
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null.cc33
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null_thread.cc33
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/check_new.cc32
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-2.cc46
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-4.cc46
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-1.cc46
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-3.cc46
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-2.cc43
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-4.cc44
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-6.cc55
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-8.cc56
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-1.cc43
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-3.cc44
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-5.cc54
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-7.cc56
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/explicit_instantiation.cc34
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/tune-1.cc70
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/tune-2.cc72
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/tune-3.cc94
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/tune-4.cc111
-rw-r--r--libstdc++-v3/testsuite/ext/mt_allocator/variadic_construct.cc45
-rw-r--r--libstdc++-v3/testsuite/ext/new_allocator/check_allocate_max_size.cc30
-rw-r--r--libstdc++-v3/testsuite/ext/new_allocator/check_deallocate_null.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/new_allocator/check_delete.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/new_allocator/check_new.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/new_allocator/deallocate_global.cc37
-rw-r--r--libstdc++-v3/testsuite/ext/new_allocator/deallocate_local.cc39
-rw-r--r--libstdc++-v3/testsuite/ext/new_allocator/instantiate.cc27
-rw-r--r--libstdc++-v3/testsuite/ext/new_allocator/variadic_construct.cc45
-rw-r--r--libstdc++-v3/testsuite/ext/numeric_traits/numeric_traits.cc27
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/assoc_container_traits.cc230
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/basic_map.cc119
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/basic_multimap.cc152
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/basic_multiset.cc165
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/basic_priority_queue.cc119
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/basic_set.cc126
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/erase_if.cc122
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/hash_find_neg.cc69
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/hash_illegal_resize.cc135
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/hash_initial_size.cc110
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/hash_load_set_change.cc131
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/hash_mod.cc86
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/hash_resize.cc125
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/hash_resize_neg.cc63
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/hash_shift_mask.cc108
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_container_traits.cc200
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_dijkstra.cc157
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_erase_if.cc67
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_split_join.cc124
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_xref.cc210
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/ranged_hash.cc151
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/store_hash.cc97
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/tree_intervals.cc212
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/tree_join.cc112
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/tree_order_statistics.cc124
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/tree_order_statistics_join.cc90
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/trie_dna.cc118
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/trie_prefix_search.cc110
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/example/trie_split.cc85
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/regression/associative_containers.cc165
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/regression/hash_data_map_rand.cc73
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/regression/hash_no_data_map_rand.cc72
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_data_map_rand.cc54
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_no_data_map_rand.cc54
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queue_rand.cc61
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queues.cc184
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/regression/tree_data_map_rand.cc72
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/regression/tree_no_data_map_rand.cc73
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/regression/trie_data_map_rand.cc72
-rw-r--r--libstdc++-v3/testsuite/ext/pb_ds/regression/trie_no_data_map_rand.cc72
-rw-r--r--libstdc++-v3/testsuite/ext/pod_char_traits.cc68
-rw-r--r--libstdc++-v3/testsuite/ext/pool_allocator/allocate_chunk.cc62
-rw-r--r--libstdc++-v3/testsuite/ext/pool_allocator/check_allocate_max_size.cc30
-rw-r--r--libstdc++-v3/testsuite/ext/pool_allocator/check_deallocate_null.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/pool_allocator/check_delete.cc32
-rw-r--r--libstdc++-v3/testsuite/ext/pool_allocator/check_new.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/pool_allocator/explicit_instantiation.cc27
-rw-r--r--libstdc++-v3/testsuite/ext/pool_allocator/variadic_construct.cc45
-rw-r--r--libstdc++-v3/testsuite/ext/profile/all.cc52
-rw-r--r--libstdc++-v3/testsuite/ext/profile/mh.cc67
-rw-r--r--libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc28
-rw-r--r--libstdc++-v3/testsuite/ext/profile/profiler_algos.cc147
-rw-r--r--libstdc++-v3/testsuite/ext/rope/1.cc37
-rw-r--r--libstdc++-v3/testsuite/ext/rope/2.cc49
-rw-r--r--libstdc++-v3/testsuite/ext/rope/3.cc99
-rw-r--r--libstdc++-v3/testsuite/ext/rope/36832.cc35
-rw-r--r--libstdc++-v3/testsuite/ext/rope/4.cc39
-rw-r--r--libstdc++-v3/testsuite/ext/rope/40299.cc27
-rw-r--r--libstdc++-v3/testsuite/ext/rope/44708.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/rope/44963.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/rope/pthread7-rope.cc103
-rw-r--r--libstdc++-v3/testsuite/ext/slist/23781_neg.cc28
-rw-r--r--libstdc++-v3/testsuite/ext/slist/check_construct_destroy.cc78
-rw-r--r--libstdc++-v3/testsuite/ext/slist/requirements/explicit_instantiation.cc25
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-1.cc57
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-2.cc63
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-3.cc62
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_filebuf/char/2.cc62
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_filebuf/requirements/explicit_instantiation.cc34
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/1.cc66
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-1.cc47
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-2.cc47
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-3.cc47
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-4.cc47
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/35209.cc39
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc66
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12077.cc81
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc45
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc45
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc45
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc45
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/35209.cc39
-rw-r--r--libstdc++-v3/testsuite/ext/throw_allocator/check_allocate_max_size.cc30
-rw-r--r--libstdc++-v3/testsuite/ext/throw_allocator/check_deallocate_null.cc37
-rw-r--r--libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc30
-rw-r--r--libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc30
-rw-r--r--libstdc++-v3/testsuite/ext/throw_allocator/deallocate_global.cc40
-rw-r--r--libstdc++-v3/testsuite/ext/throw_allocator/deallocate_local.cc43
-rw-r--r--libstdc++-v3/testsuite/ext/throw_allocator/explicit_instantiation.cc25
-rw-r--r--libstdc++-v3/testsuite/ext/throw_allocator/variadic_construct.cc47
-rw-r--r--libstdc++-v3/testsuite/ext/throw_value/cons.cc43
-rw-r--r--libstdc++-v3/testsuite/ext/type_traits/add_unsigned.cc48
-rw-r--r--libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc38
-rw-r--r--libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc39
-rw-r--r--libstdc++-v3/testsuite/ext/type_traits/remove_unsigned.cc48
-rw-r--r--libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc38
-rw-r--r--libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc39
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/assign/move_assign.cc54
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/capacity/29134.cc37
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/capacity/shrink_to_fit.cc42
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/cons/moveable.cc63
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/element_access/char/front_back.cc44
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/element_access/wchar_t/front_back.cc44
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/hash/char/1.cc54
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/hash/wchar_t/1.cc54
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/init-list.cc71
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/inserters_extractors/char/28277.cc53
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc53
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/operators/1.cc93
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/operators/2.cc79
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/range_access.cc37
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/citerators.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/dr438/constructor.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/exception/basic.cc55
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/exception/generation_prohibited.cc52
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/exception/propagation_consistent.cc55
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/1.cc27
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/2.cc32
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char/1.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char16_t/1.cc34
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char32_t/1.cc34
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/wchar_t/1.cc31
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/requirements/typedefs.cc25
-rw-r--r--libstdc++-v3/testsuite/ext/vstring/types/23767.cc43
204 files changed, 12616 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/ext/array_allocator/1.cc b/libstdc++-v3/testsuite/ext/array_allocator/1.cc
new file mode 100644
index 000000000..83abe08c2
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/array_allocator/1.cc
@@ -0,0 +1,58 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 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 <ext/vstring.h>
+#include <ext/array_allocator.h>
+#include <testsuite_hooks.h>
+
+typedef char char_type;
+typedef std::char_traits<char_type> traits_type;
+typedef std::tr1::array<char_type, 4> array_type;
+
+array_type extern_array;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ using __gnu_cxx::__versa_string;
+ typedef __gnu_cxx::array_allocator<char_type, array_type> allocator_type;
+ typedef __versa_string<char_type, traits_type, allocator_type> string_type;
+
+ allocator_type a(&extern_array);
+ string_type s(a);
+
+ try
+ {
+ s.reserve(4); // Actually need 4 + 1 + sizeof(std::string::_Rep).
+ }
+ catch(std::bad_alloc& obj)
+ {
+ VERIFY( true );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/array_allocator/2.cc b/libstdc++-v3/testsuite/ext/array_allocator/2.cc
new file mode 100644
index 000000000..f1c484f12
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/array_allocator/2.cc
@@ -0,0 +1,64 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 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 <iostream>
+#include <ext/vstring.h>
+#include <ext/array_allocator.h>
+#include <testsuite_hooks.h>
+
+typedef char char_type;
+typedef std::char_traits<char_type> traits_type;
+typedef std::tr1::array<char_type, 32> array_type;
+
+array_type extern_array;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ using __gnu_cxx::__versa_string;
+ typedef __gnu_cxx::array_allocator<char_type, array_type> allocator_type;
+ typedef __versa_string<char_type, traits_type, allocator_type> string_type;
+
+ allocator_type a(&extern_array);
+ string_type s(a);
+
+ try
+ {
+ s.reserve(4); // Actually need 4 + 1 + sizeof(std::string::_Rep).
+ }
+ catch(std::bad_alloc& obj)
+ {
+ VERIFY( false );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+
+ s.append(1, 'c');
+ s.append(2, 'b');
+
+ std::cout << s.c_str() << std::endl;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/array_allocator/26875.cc b/libstdc++-v3/testsuite/ext/array_allocator/26875.cc
new file mode 100644
index 000000000..17636a19d
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/array_allocator/26875.cc
@@ -0,0 +1,45 @@
+//
+// Copyright (C) 2006, 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 <ext/array_allocator.h>
+
+// libstdc++/26875
+int main()
+{
+ typedef std::tr1::array<int, 1> array_type;
+ array_type Array1;
+ array_type Array2;
+
+ typedef __gnu_cxx::array_allocator<int> allocator_type;
+ allocator_type Allocator1(&Array1);
+ allocator_type Allocator2(&Array2);
+
+ try
+ {
+ Allocator1.allocate(1);
+ Allocator2.allocate(1);
+ }
+ catch (std::bad_alloc& ex)
+ {
+ // fail, rethrow
+ throw;
+ }
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/array_allocator/3.cc b/libstdc++-v3/testsuite/ext/array_allocator/3.cc
new file mode 100644
index 000000000..b5bffad7a
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/array_allocator/3.cc
@@ -0,0 +1,59 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 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 <ext/vstring.h>
+#include <ext/array_allocator.h>
+#include <testsuite_hooks.h>
+
+typedef char char_type;
+typedef std::char_traits<char_type> traits_type;
+typedef std::tr1::array<char_type, 4> array_type;
+
+array_type extern_array;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ using __gnu_cxx::__versa_string;
+ typedef __gnu_cxx::array_allocator<char_type, array_type> allocator_type;
+ typedef __versa_string<char_type, traits_type, allocator_type> string_type;
+
+ // Construct array_allocator without underlying array.
+ allocator_type a;
+ string_type s(a);
+
+ try
+ {
+ s.reserve(4); // Actually need 4 + 1 + sizeof(std::string::_Rep).
+ }
+ catch(std::bad_alloc& obj)
+ {
+ VERIFY( true );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/array_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/array_allocator/check_allocate_max_size.cc
new file mode 100644
index 000000000..6b8236a10
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/array_allocator/check_allocate_max_size.cc
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/array_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::array_allocator<value_type> allocator_type;
+ __gnu_test::check_allocate_max_size<allocator_type>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/array_allocator/check_deallocate_null.cc b/libstdc++-v3/testsuite/ext/array_allocator/check_deallocate_null.cc
new file mode 100644
index 000000000..5a9395116
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/array_allocator/check_deallocate_null.cc
@@ -0,0 +1,31 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/array_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::array_allocator<value_type> allocator_type;
+ __gnu_test::check_deallocate_null<allocator_type>();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/array_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/array_allocator/check_delete.cc
new file mode 100644
index 000000000..9e6f32d13
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/array_allocator/check_delete.cc
@@ -0,0 +1,35 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/array_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef unsigned int value_type;
+ typedef std::tr1::array<value_type, 15> array_type;
+ typedef __gnu_cxx::array_allocator<value_type, array_type> allocator_type;
+ array_type store;
+ allocator_type a(&store);
+ __gnu_test::check_delete<allocator_type, false>(a);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/array_allocator/check_new.cc b/libstdc++-v3/testsuite/ext/array_allocator/check_new.cc
new file mode 100644
index 000000000..2d51a0250
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/array_allocator/check_new.cc
@@ -0,0 +1,35 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/array_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef unsigned int value_type;
+ typedef std::tr1::array<value_type, 15> array_type;
+ typedef __gnu_cxx::array_allocator<value_type, array_type> allocator_type;
+ array_type store;
+ allocator_type a(&store);
+ __gnu_test::check_new<allocator_type, false>(a);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/array_allocator/variadic_construct.cc b/libstdc++-v3/testsuite/ext/array_allocator/variadic_construct.cc
new file mode 100644
index 000000000..8ddf9c018
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/array_allocator/variadic_construct.cc
@@ -0,0 +1,49 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2007-10-27 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/array_allocator.h>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::pair<int, char> pair_type;
+ typedef std::tr1::array<pair_type, 3> array_type;
+ array_type store;
+
+ __gnu_cxx::array_allocator<pair_type, array_type> alloc1(&store);
+ pair_type* ptp1 = alloc1.allocate(1);
+ alloc1.construct(ptp1, 3, 'a');
+
+ VERIFY( ptp1->first == 3 );
+ VERIFY( ptp1->second == 'a' );
+
+ alloc1.deallocate(ptp1, 1);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/bitmap_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_allocate_max_size.cc
new file mode 100644
index 000000000..5f379e99c
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_allocate_max_size.cc
@@ -0,0 +1,36 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/bitmap_allocator.h>
+#include <testsuite_allocator.h>
+
+typedef int value_type;
+
+int main()
+{
+ typedef __gnu_cxx::bitmap_allocator<value_type> allocator_type;
+ __gnu_test::check_allocate_max_size<allocator_type>();
+ return 0;
+}
+
+#if !__GXX_WEAK
+// Explicitly instantiatiate for systems without weak symbols.
+template class __gnu_cxx::bitmap_allocator<value_type>;
+#endif
diff --git a/libstdc++-v3/testsuite/ext/bitmap_allocator/check_deallocate_null.cc b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_deallocate_null.cc
new file mode 100644
index 000000000..4fd49e3f0
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_deallocate_null.cc
@@ -0,0 +1,38 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/bitmap_allocator.h>
+#include <testsuite_allocator.h>
+
+typedef int value_type;
+
+int main()
+{
+ typedef __gnu_cxx::bitmap_allocator<value_type> allocator_type;
+ __gnu_test::check_deallocate_null<allocator_type>();
+ return 0;
+}
+
+#if !__GXX_WEAK
+// Explicitly instantiatiate for systems without weak symbols.
+template class __gnu_cxx::bitmap_allocator<value_type>;
+#endif
+
+
diff --git a/libstdc++-v3/testsuite/ext/bitmap_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_delete.cc
new file mode 100644
index 000000000..a82bcc7f9
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_delete.cc
@@ -0,0 +1,29 @@
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/bitmap_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef __gnu_cxx::bitmap_allocator<unsigned int> allocator_type;
+ __gnu_test::check_delete<allocator_type, true>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/bitmap_allocator/check_new.cc b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_new.cc
new file mode 100644
index 000000000..205fa3a17
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/bitmap_allocator/check_new.cc
@@ -0,0 +1,29 @@
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/bitmap_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef __gnu_cxx::bitmap_allocator<unsigned int> allocator_type;
+ __gnu_test::check_new<allocator_type, true>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/bitmap_allocator/variadic_construct.cc b/libstdc++-v3/testsuite/ext/bitmap_allocator/variadic_construct.cc
new file mode 100644
index 000000000..a23bdce85
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/bitmap_allocator/variadic_construct.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 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 <ext/bitmap_allocator.h>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::pair<int, char> pair_type;
+ __gnu_cxx::bitmap_allocator<pair_type> alloc1;
+
+ pair_type* ptp1 = alloc1.allocate(1);
+ alloc1.construct(ptp1, 3, 'a');
+
+ VERIFY( ptp1->first == 3 );
+ VERIFY( ptp1->second == 'a' );
+
+ alloc1.deallocate(ptp1, 1);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/codecvt/1.cc b/libstdc++-v3/testsuite/ext/codecvt/1.cc
new file mode 100644
index 000000000..7ee6bed12
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/codecvt/1.cc
@@ -0,0 +1,58 @@
+// { dg-require-iconv "UCS-2BE" }
+// { dg-require-iconv "ISO-8859-15" }
+// 2003-02-06 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation
+//
+// 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/>.
+
+// 22.2.1.5 - Template class codecvt [lib.locale.codecvt]
+
+#include <locale>
+#include <cstring>
+#include <testsuite_hooks.h>
+#include <ext/codecvt_specializations.h>
+
+// Partial specialization using encoding_state
+// codecvt<unicode_t, char, encoding_state>
+// UNICODE - UCS2 (big endian)
+void test01()
+{
+ using namespace std;
+ typedef unsigned short int_type;
+ typedef char ext_type;
+ typedef __gnu_cxx::encoding_state state_type;
+ typedef codecvt<int_type, ext_type, state_type> unicode_codecvt;
+
+ bool test __attribute__((unused)) = true;
+ const ext_type* e_lit = "black pearl jasmine tea";
+ int size = strlen(e_lit);
+
+ // construct a locale object with the specialized facet.
+ locale loc(locale::classic(), new unicode_codecvt);
+ // sanity check the constructed locale has the specialized facet.
+ VERIFY( has_facet<unicode_codecvt>(loc) );
+ const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc);
+
+ unicode_codecvt::state_type state04("UCS-2BE", "ISO-8859-15", 0xfeff, 0);
+ cvt.length(state04, e_lit, e_lit + size, 5);
+}
+
+int main ()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/codecvt/char-1.cc b/libstdc++-v3/testsuite/ext/codecvt/char-1.cc
new file mode 100644
index 000000000..733dff8a0
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/codecvt/char-1.cc
@@ -0,0 +1,141 @@
+// { dg-require-iconv "UCS-2BE" }
+// { dg-require-iconv "ISO-8859-15" }
+
+// 2000-08-22 Benjamin Kosnik <bkoz@cygnus.com>
+
+// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+// Free Software Foundation
+//
+// 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/>.
+
+// 22.2.1.5 - Template class codecvt [lib.locale.codecvt]
+#include <locale>
+#include <cstring>
+#include <testsuite_hooks.h>
+#include <ext/codecvt_specializations.h>
+
+/*
+> how do I check that these conversions are correct?
+Very easy. Since all the characters are from ASCII you simply
+zero-extend the values.
+
+drepper$ echo 'black pearl jasmine tea' | od -t x1
+0000000 62 6c 61 63 6b 20 70 65 61 72 6c 20 6a 61 73 6d
+0000020 69 6e 65 20 74 65 61 0a
+
+So the UCS-2 string is
+
+0x0062, 0x006c, 0x0061, ...
+
+You get the idea. With iconv() you have to take care of the
+byte-order, though. UCS-2 can mean little- or big endian. Looking at
+your result
+
+> $9 = 25856
+
+it shows that the other byte-order is used (25856 == 0x6500).
+*/
+
+// Partial specialization using encoding_state.
+// codecvt<unicode_t, char, encoding_state>
+// UNICODE - UCS2 (big endian)
+void test01()
+{
+ using namespace std;
+ typedef codecvt_base::result result;
+ typedef unsigned short int_type;
+ typedef char ext_type;
+ typedef __gnu_cxx::encoding_state state_type;
+ typedef codecvt<int_type, ext_type, state_type> unicode_codecvt;
+ typedef char_traits<int_type> int_traits;
+ typedef char_traits<ext_type> ext_traits;
+
+ bool test __attribute__((unused)) = true;
+ const ext_type* e_lit = "black pearl jasmine tea";
+ int size = strlen(e_lit);
+
+ char i_lit_base[50] __attribute__((aligned(__alignof__(int_type)))) =
+ {
+ 0x00, 0x62, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x63, 0x00, 0x6b, 0x00, 0x20,
+ 0x00, 0x70, 0x00, 0x65, 0x00, 0x61, 0x00, 0x72, 0x00, 0x6c, 0x00, 0x20,
+ 0x00, 0x6a, 0x00, 0x61, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x69, 0x00, 0x6e,
+ 0x00, 0x65, 0x00, 0x20, 0x00, 0x74, 0x00, 0x65, 0x00, 0x61, 0x00, 0xa0
+ };
+ const int_type* i_lit = reinterpret_cast<int_type*>(i_lit_base);
+
+ const ext_type* efrom_next;
+ const int_type* ifrom_next;
+ ext_type* e_arr = new ext_type[size + 1];
+ ext_type* eto_next;
+ int_type* i_arr = new int_type[size + 1];
+ int_type* ito_next;
+
+ // construct a locale object with the specialized facet.
+ locale loc(locale::classic(), new unicode_codecvt);
+ // sanity check the constructed locale has the specialized facet.
+ VERIFY( has_facet<unicode_codecvt>(loc) );
+ const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc);
+
+ // in
+ // unicode_codecvt::state_type state01("UCS-2BE", "ISO-8859-15", 0xfeff, 0);
+ unicode_codecvt::state_type state01("UCS-2BE", "ISO-8859-15", 0, 0);
+
+ // internal encoding is bigger because of bom
+ result r1 = cvt.in(state01, e_lit, e_lit + size, efrom_next,
+ i_arr, i_arr + size + 1, ito_next);
+ VERIFY( r1 == codecvt_base::ok );
+ VERIFY( !int_traits::compare(i_arr, i_lit, size) );
+ VERIFY( efrom_next == e_lit + size );
+ VERIFY( ito_next == i_arr + size );
+
+ // out
+ unicode_codecvt::state_type state02("UCS-2BE", "ISO-8859-15", 0, 0);
+ result r2 = cvt.out(state02, i_lit, i_lit + size, ifrom_next,
+ e_arr, e_arr + size, eto_next);
+ VERIFY( r2 == codecvt_base::ok );
+ VERIFY( !ext_traits::compare(e_arr, e_lit, size) );
+ VERIFY( ifrom_next == i_lit + size );
+ VERIFY( eto_next == e_arr + size );
+
+ // unshift
+ ext_traits::copy(e_arr, e_lit, size);
+ unicode_codecvt::state_type state03("UCS-2BE", "ISO-8859-15", 0, 0);
+ result r3 = cvt.unshift(state03, e_arr, e_arr + size, eto_next);
+ VERIFY( r3 == codecvt_base::noconv );
+ VERIFY( !ext_traits::compare(e_arr, e_lit, size) );
+ VERIFY( eto_next == e_arr );
+
+ int i = cvt.encoding();
+ VERIFY( i == 2 ); // Target-dependent.
+
+ VERIFY( !cvt.always_noconv() );
+
+ unicode_codecvt::state_type state04("UCS-2BE", "ISO-8859-15", 0, 0);
+ int j = cvt.length(state03, e_lit, e_lit + size, 5);
+ VERIFY( j == 5 );
+
+ int k = cvt.max_length();
+ VERIFY( k == 1 );
+
+ delete [] e_arr;
+ delete [] i_arr;
+}
+
+int main ()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/codecvt/char-2.cc b/libstdc++-v3/testsuite/ext/codecvt/char-2.cc
new file mode 100644
index 000000000..b6bfde01e
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/codecvt/char-2.cc
@@ -0,0 +1,139 @@
+// { dg-require-iconv "UCS-2LE" }
+// { dg-require-iconv "ISO-8859-15" }
+
+// 2000-08-22 Benjamin Kosnik <bkoz@cygnus.com>
+
+// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+// Free Software Foundation
+//
+// 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/>.
+
+// 22.2.1.5 - Template class codecvt [lib.locale.codecvt]
+#include <locale>
+#include <cstring>
+#include <testsuite_hooks.h>
+#include <ext/codecvt_specializations.h>
+
+/*
+> how do I check that these conversions are correct?
+Very easy. Since all the characters are from ASCII you simply
+zero-extend the values.
+
+drepper$ echo 'black pearl jasmine tea' | od -t x1
+0000000 62 6c 61 63 6b 20 70 65 61 72 6c 20 6a 61 73 6d
+0000020 69 6e 65 20 74 65 61 0a
+
+So the UCS-2 string is
+
+0x0062, 0x006c, 0x0061, ...
+
+You get the idea. With iconv() you have to take care of the
+byte-order, though. UCS-2 can mean little- or big endian. Looking at
+your result
+
+> $9 = 25856
+
+it shows that the other byte-order is used (25856 == 0x6500).
+*/
+
+// Partial specialization using encoding_state.
+// codecvt<unicode_t, char, encoding_state>
+// UNICODE - UCS2 (little endian)
+void test02()
+{
+ using namespace std;
+ typedef codecvt_base::result result;
+ typedef unsigned short int_type;
+ typedef char ext_type;
+ typedef __gnu_cxx::encoding_state state_type;
+ typedef codecvt<int_type, ext_type, state_type> unicode_codecvt;
+ typedef char_traits<int_type> int_traits;
+ typedef char_traits<ext_type> ext_traits;
+
+ bool test __attribute__((unused)) = true;
+ const ext_type* e_lit = "black pearl jasmine tea";
+ int size = strlen(e_lit);
+
+ char i_lit_base[50] __attribute__((aligned(__alignof__(int_type)))) =
+ {
+ 0x62, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x63, 0x00, 0x6b, 0x00, 0x20, 0x00,
+ 0x70, 0x00, 0x65, 0x00, 0x61, 0x00, 0x72, 0x00, 0x6c, 0x00, 0x20, 0x00,
+ 0x6a, 0x00, 0x61, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x69, 0x00, 0x6e, 0x00,
+ 0x65, 0x00, 0x20, 0x00, 0x74, 0x00, 0x65, 0x00, 0x61, 0x00, 0xa0, 0x00
+ };
+ const int_type* i_lit = reinterpret_cast<int_type*>(i_lit_base);
+
+ const ext_type* efrom_next;
+ const int_type* ifrom_next;
+ ext_type* e_arr = new ext_type[size + 1];
+ ext_type* eto_next;
+ int_type* i_arr = new int_type[size + 1];
+ int_type* ito_next;
+
+ // construct a locale object with the specialized facet.
+ locale loc(locale::classic(), new unicode_codecvt);
+ // sanity check the constructed locale has the specialized facet.
+ VERIFY( has_facet<unicode_codecvt>(loc) );
+ const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc);
+
+ // in
+ unicode_codecvt::state_type state01("UCS-2LE", "ISO-8859-15", 0, 0);
+ // internal encoding is bigger because of bom
+ result r1 = cvt.in(state01, e_lit, e_lit + size, efrom_next,
+ i_arr, i_arr + size + 1, ito_next);
+ VERIFY( r1 == codecvt_base::ok );
+ VERIFY( !int_traits::compare(i_arr, i_lit, size) );
+ VERIFY( efrom_next == e_lit + size );
+ VERIFY( ito_next == i_arr + size );
+
+ // out
+ unicode_codecvt::state_type state02("UCS-2LE", "ISO-8859-15", 0, 0);
+ result r2 = cvt.out(state02, i_lit, i_lit + size, ifrom_next,
+ e_arr, e_arr + size, eto_next);
+ VERIFY( r2 == codecvt_base::ok );
+ VERIFY( !ext_traits::compare(e_arr, e_lit, size) );
+ VERIFY( ifrom_next == i_lit + size );
+ VERIFY( eto_next == e_arr + size );
+
+ // unshift
+ ext_traits::copy(e_arr, e_lit, size);
+ unicode_codecvt::state_type state03("UCS-2LE", "ISO-8859-15", 0, 0);
+ result r3 = cvt.unshift(state03, e_arr, e_arr + size, eto_next);
+ VERIFY( r3 == codecvt_base::noconv );
+ VERIFY( !ext_traits::compare(e_arr, e_lit, size) );
+ VERIFY( eto_next == e_arr );
+
+ int i = cvt.encoding();
+ VERIFY( i == 2 ); // Target-dependent.
+
+ VERIFY( !cvt.always_noconv() );
+
+ unicode_codecvt::state_type state04("UCS-2LE", "ISO-8859-15", 0, 0);
+ int j = cvt.length(state03, e_lit, e_lit + size, 5);
+ VERIFY( j == 5 );
+
+ int k = cvt.max_length();
+ VERIFY( k == 1 );
+
+ delete [] e_arr;
+ delete [] i_arr;
+}
+
+int main ()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/codecvt/wchar_t.cc b/libstdc++-v3/testsuite/ext/codecvt/wchar_t.cc
new file mode 100644
index 000000000..4040f876b
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/codecvt/wchar_t.cc
@@ -0,0 +1,127 @@
+// { dg-require-iconv "UCS-2BE" }
+// { dg-require-iconv "UCS-4BE" }
+
+// 2000-08-23 Benjamin Kosnik <bkoz@cygnus.com>
+
+// Copyright (C) 2000, 2001, 2002, 2003, 2007, 2009 Free Software Foundation
+//
+// 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/>.
+
+// 22.2.1.5 - Template class codecvt [lib.locale.codecvt]
+
+#include <locale>
+#include <testsuite_hooks.h>
+#include <ext/codecvt_specializations.h>
+
+// Partial specialization using encoding_state.
+// codecvt<unicode_t, wchar_t, encoding_state>
+void test01()
+{
+ using namespace std;
+ typedef codecvt_base::result result;
+ typedef unsigned short int_type;
+ typedef wchar_t ext_type;
+ typedef __gnu_cxx::encoding_state state_type;
+ typedef codecvt<int_type, ext_type, state_type> unicode_codecvt;
+ typedef char_traits<int_type> int_traits;
+ typedef char_traits<ext_type> ext_traits;
+
+ bool test __attribute__((unused)) = true;
+ int size = 23;
+ char e_lit_base[96] __attribute__((aligned(__alignof__(ext_type)))) =
+ {
+ 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x61,
+ 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x61,
+ 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x73,
+ 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x6e,
+ 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x74,
+ 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0xa0
+ };
+ const ext_type* e_lit = reinterpret_cast<ext_type*>(e_lit_base);
+
+ char i_lit_base[48] __attribute__((aligned(__alignof__(int_type)))) =
+ {
+ 0x00, 0x62, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x63, 0x00, 0x6b, 0x00, 0x20,
+ 0x00, 0x70, 0x00, 0x65, 0x00, 0x61, 0x00, 0x72, 0x00, 0x6c, 0x00, 0x20,
+ 0x00, 0x6a, 0x00, 0x61, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x69, 0x00, 0x6e,
+ 0x00, 0x65, 0x00, 0x20, 0x00, 0x74, 0x00, 0x65, 0x00, 0x61, 0x00, 0xa0
+ };
+ const int_type* i_lit = reinterpret_cast<int_type*>(i_lit_base);
+
+ const ext_type* efrom_next;
+ const int_type* ifrom_next;
+ ext_type* e_arr = new ext_type[size + 1];
+ ext_type* eto_next;
+ int_type* i_arr = new int_type[size + 1];
+ int_type* ito_next;
+
+ // construct a locale object with the specialized facet.
+ locale loc(locale::classic(), new unicode_codecvt);
+ // sanity check the constructed locale has the specialized facet.
+ VERIFY( has_facet<unicode_codecvt>(loc) );
+ const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc);
+
+ // in
+ // unicode_codecvt::state_type state01("UCS-2BE", "UCS-4BE", 0xfeff, 0);
+ unicode_codecvt::state_type state01("UCS-2BE", "UCS-4BE", 0, 0);
+ result r1 = cvt.in(state01, e_lit, e_lit + size, efrom_next,
+ i_arr, i_arr + size + 1, ito_next);
+ VERIFY( r1 == codecvt_base::ok );
+ VERIFY( !int_traits::compare(i_arr, i_lit, size) );
+ VERIFY( efrom_next == e_lit + size );
+ VERIFY( ito_next == i_arr + size );
+
+ // out
+ unicode_codecvt::state_type state02("UCS-2BE", "UCS-4BE", 0, 0);
+ result r2 = cvt.out(state02, i_lit, i_lit + size, ifrom_next,
+ e_arr, e_arr + size, eto_next);
+ VERIFY( r2 == codecvt_base::ok ); // XXX?
+ VERIFY( !ext_traits::compare(e_arr, e_lit, size) );
+ VERIFY( ifrom_next == i_lit + size );
+ VERIFY( eto_next == e_arr + size );
+
+ // unshift
+ ext_traits::copy(e_arr, e_lit, size);
+ unicode_codecvt::state_type state03("UCS-2BE", "UCS-4BE", 0, 0);
+ result r3 = cvt.unshift(state03, e_arr, e_arr + size, eto_next);
+ VERIFY( r3 == codecvt_base::noconv );
+ VERIFY( !ext_traits::compare(e_arr, e_lit, size) );
+ VERIFY( eto_next == e_arr );
+
+ int i = cvt.encoding();
+ VERIFY( i == 0 );
+
+ VERIFY( !cvt.always_noconv() );
+
+ unicode_codecvt::state_type state04("UCS-2BE", "UCS-4BE", 0, 0);
+ int j = cvt.length(state03, e_lit, e_lit + size, 5);
+ VERIFY( j == 5 );
+
+ int k = cvt.max_length();
+ VERIFY( k == 1 );
+
+ delete [] e_arr;
+ delete [] i_arr;
+}
+
+int main ()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/concept_checks.cc b/libstdc++-v3/testsuite/ext/concept_checks.cc
new file mode 100644
index 000000000..158a91479
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/concept_checks.cc
@@ -0,0 +1,82 @@
+// 2001-12-28 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2002, 2004, 2005, 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/>.
+
+// Concept checking must remain sane.
+
+// { dg-options "-D_GLIBCXX_CONCEPT_CHECKS" }
+
+#include <vector>
+#include <string>
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+
+// PR libstdc++/2054 and follow-up discussion
+struct indirectCompare
+{
+ indirectCompare(const vector<string>& v) : V(v) {}
+
+ bool operator()( int x, int y) const
+ {
+ return V[x] < V[y];
+ }
+
+ bool operator()( int x, const string& a) const
+ {
+ return V[x] < a;
+ }
+
+ bool operator()( const string& a, int x) const
+ {
+ return V[x] < a;
+ }
+
+ const vector<string>& V;
+};
+
+void
+test2054( )
+{
+ const int Maxi = 1022;
+
+ vector<string> Words(Maxi);
+ vector<int> Index(Maxi);
+
+ for(size_t i = 0; i < Index.size(); i++)
+ Index[i] = i;
+
+ indirectCompare aComparison(Words);
+
+ sort(Index.begin(), Index.end(), aComparison);
+
+ string SearchTerm;
+
+ lower_bound(Index.begin(), Index.end(), SearchTerm, aComparison);
+ upper_bound(Index.begin(), Index.end(), SearchTerm, aComparison);
+ equal_range(Index.begin(), Index.end(), SearchTerm, aComparison);
+ binary_search(Index.begin(), Index.end(), SearchTerm, aComparison);
+}
+
+int main()
+{
+ test2054();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/concurrence_lock_error/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/ext/concurrence_lock_error/cons_virtual_derivation.cc
new file mode 100644
index 000000000..8c26f505f
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/concurrence_lock_error/cons_virtual_derivation.cc
@@ -0,0 +1,28 @@
+// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 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 <ext/concurrence.h>
+#include <testsuite_api.h>
+
+int main()
+{
+ typedef __gnu_cxx::__concurrence_lock_error test_type;
+ __gnu_test::diamond_derivation<test_type, true>::test();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/concurrence_unlock_error/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/ext/concurrence_unlock_error/cons_virtual_derivation.cc
new file mode 100644
index 000000000..2503724bc
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/concurrence_unlock_error/cons_virtual_derivation.cc
@@ -0,0 +1,28 @@
+// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 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 <ext/concurrence.h>
+#include <testsuite_api.h>
+
+int main()
+{
+ typedef __gnu_cxx::__concurrence_unlock_error test_type;
+ __gnu_test::diamond_derivation<test_type, true>::test();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/debug_allocator/check_deallocate_null.cc b/libstdc++-v3/testsuite/ext/debug_allocator/check_deallocate_null.cc
new file mode 100644
index 000000000..c3db649f9
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/debug_allocator/check_deallocate_null.cc
@@ -0,0 +1,47 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <memory>
+#include <ext/debug_allocator.h>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef std::allocator<value_type> debug_type;
+ typedef __gnu_cxx::debug_allocator<debug_type> allocator_type;
+
+ try
+ {
+ __gnu_test::check_deallocate_null<allocator_type>();
+ }
+ catch (std::runtime_error& obj)
+ {
+ // Ok.
+ }
+ catch (...)
+ {
+ // Shouldn't get here.
+ throw;
+ }
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/debug_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/debug_allocator/check_delete.cc
new file mode 100644
index 000000000..5b9d06142
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/debug_allocator/check_delete.cc
@@ -0,0 +1,33 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/debug_allocator.h>
+#include <ext/malloc_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ using namespace __gnu_cxx;
+ typedef debug_allocator<malloc_allocator<unsigned int> > allocator_type;
+ __gnu_test::check_delete<allocator_type, false>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/debug_allocator/check_new.cc b/libstdc++-v3/testsuite/ext/debug_allocator/check_new.cc
new file mode 100644
index 000000000..105bf2889
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/debug_allocator/check_new.cc
@@ -0,0 +1,33 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/debug_allocator.h>
+#include <ext/malloc_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ using namespace __gnu_cxx;
+ typedef debug_allocator<malloc_allocator<unsigned int> > allocator_type;
+ __gnu_test::check_new<allocator_type, false>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/debug_allocator/explicit_instantiation.cc b/libstdc++-v3/testsuite/ext/debug_allocator/explicit_instantiation.cc
new file mode 100644
index 000000000..7cdd95d93
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/debug_allocator/explicit_instantiation.cc
@@ -0,0 +1,28 @@
+// { dg-do compile }
+
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/debug_allocator.h>
+#include <ext/malloc_allocator.h>
+
+template class __gnu_cxx::debug_allocator<__gnu_cxx::malloc_allocator<int> >;
diff --git a/libstdc++-v3/testsuite/ext/enc_filebuf/char/13189.cc b/libstdc++-v3/testsuite/ext/enc_filebuf/char/13189.cc
new file mode 100644
index 000000000..d7e9b322f
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/enc_filebuf/char/13189.cc
@@ -0,0 +1,54 @@
+// { dg-require-iconv "ISO-8859-1" }
+
+// Copyright (C) 2003, 2004, 2005, 2007, 2009 Free Software Foundation
+//
+// 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 <testsuite_hooks.h>
+#include <ext/enc_filebuf.h>
+
+void test01()
+{
+ using namespace std;
+ typedef char char_type;
+ typedef __gnu_cxx::enc_filebuf<char_type> filebuf_type;
+ typedef filebuf_type::state_type state_type;
+ typedef codecvt<char_type, char, state_type> enc_codecvt;
+
+ bool test __attribute__((unused)) = true;
+ ios_base::openmode mode = ios_base::in | ios_base::out | ios_base::trunc;
+ try
+ {
+ state_type st;
+ filebuf_type fbuf(st);
+ locale loc(locale::classic(), new enc_codecvt);
+ fbuf.pubimbue(loc);
+ fbuf.open("tmp_13189c", mode);
+ fbuf.sputc('a');
+ fbuf.pubseekoff(0, ios_base::beg);
+ fbuf.sgetc();
+ fbuf.close();
+ }
+ catch(...)
+ {
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/enc_filebuf/char/13598.cc b/libstdc++-v3/testsuite/ext/enc_filebuf/char/13598.cc
new file mode 100644
index 000000000..0030000f7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/enc_filebuf/char/13598.cc
@@ -0,0 +1,53 @@
+// Before Solaris 11, iconv -f ISO-8859-1 -t ISO-8859-1 fails with
+// Not supported ISO-8859-1 to ISO-8859-1
+//
+// { dg-do run { xfail *-*-solaris2.[89] *-*-solaris2.10 } }
+// { dg-require-iconv "ISO-8859-1" }
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation
+//
+// 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 <locale>
+#include <cstring>
+#include <cstddef>
+#include <testsuite_hooks.h>
+#include <ext/enc_filebuf.h>
+
+int main()
+{
+ bool test __attribute__((unused)) = true;
+ typedef char char_type;
+ typedef __gnu_cxx::enc_filebuf<char_type> filebuf_type;
+ typedef filebuf_type::state_type state_type;
+
+ const char* str = "Hello, world!\n";
+ std::locale loc(std::locale::classic(),
+ new std::codecvt<char, char, __gnu_cxx::encoding_state>());
+ state_type st("ISO-8859-1", "ISO-8859-1");
+ filebuf_type fb(st);
+ fb.pubimbue(loc);
+
+ fb.open("tmp_13598", std::ios_base::out);
+ std::streamsize n = fb.sputn(str, std::strlen(str));
+ int s = fb.pubsync();
+ fb.close();
+
+ VERIFY( std::size_t(n) == std::strlen(str) );
+ VERIFY( s == 0 );
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/enc_filebuf/wchar_t/13189.cc b/libstdc++-v3/testsuite/ext/enc_filebuf/wchar_t/13189.cc
new file mode 100644
index 000000000..275f66949
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/enc_filebuf/wchar_t/13189.cc
@@ -0,0 +1,54 @@
+// { dg-require-iconv "ISO-8859-1" }
+
+// Copyright (C) 2003, 2004, 2005, 2007, 2009 Free Software Foundation
+//
+// 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 <testsuite_hooks.h>
+#include <ext/enc_filebuf.h>
+
+void test01()
+{
+ using namespace std;
+ typedef wchar_t char_type;
+ typedef __gnu_cxx::enc_filebuf<char_type> filebuf_type;
+ typedef filebuf_type::state_type state_type;
+ typedef codecvt<char_type, char, state_type> enc_codecvt;
+
+ bool test __attribute__((unused)) = true;
+ ios_base::openmode mode = ios_base::in | ios_base::out | ios_base::trunc;
+ try
+ {
+ state_type st;
+ filebuf_type fbuf(st);
+ locale loc(locale::classic(), new enc_codecvt);
+ fbuf.pubimbue(loc);
+ fbuf.open("tmp_13189w", mode);
+ fbuf.sputc(L'a');
+ fbuf.pubseekoff(0, ios_base::beg);
+ fbuf.sgetc();
+ fbuf.close();
+ }
+ catch(...)
+ {
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/ext_pointer/1.cc b/libstdc++-v3/testsuite/ext/ext_pointer/1.cc
new file mode 100644
index 000000000..d68ca5f85
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/ext_pointer/1.cc
@@ -0,0 +1,199 @@
+// 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 <algorithm>
+#include <testsuite_hooks.h>
+#include <ext/cast.h>
+#include <ext/pointer.h>
+
+using __gnu_cxx::_Pointer_adapter;
+using __gnu_cxx::_Relative_pointer_impl;
+using __gnu_cxx::__static_pointer_cast;
+using __gnu_cxx::__const_pointer_cast;
+
+
+void
+test01() {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Pointer_adapter<_Relative_pointer_impl<int> > pointer;
+ typedef _Pointer_adapter<_Relative_pointer_impl<const int> > const_pointer;
+
+ int A[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+
+ // basic pointer assignment/access tests.
+ pointer x = &A[0];
+ VERIFY(*x == 0);
+ VERIFY(std::equal(x, x+10, A));
+ pointer y(&A[9]);
+ VERIFY(*y == 9);
+
+ // assignability
+ pointer z(x);
+ VERIFY(z==x);
+ VERIFY(*z == 0);
+
+ z = y;
+ VERIFY(z==y);
+ VERIFY(z!=x);
+ VERIFY(z>x);
+ VERIFY(*z == 9);
+
+ // pointer arithmetic
+ VERIFY(*++x == 1);
+ VERIFY(*--x == 0);
+ VERIFY(*(x++) == 0);
+ VERIFY(*(x--) == 1);
+ VERIFY(*(x+2) == 2);
+ VERIFY(*(2+x) == 2);
+ VERIFY(*(y-2) == 7);
+ VERIFY(y - x == 9);
+ VERIFY(&*y - x == 9);
+ VERIFY(y - &*x == 9);
+
+ size_t s(y - x);
+ VERIFY(s == 9);
+}
+
+
+struct A {
+ mutable int i;
+};
+struct B : public A{
+ mutable int j;
+};
+typedef _Pointer_adapter<_Relative_pointer_impl<B> > B_pointer;
+typedef _Pointer_adapter<_Relative_pointer_impl<A> > A_pointer;
+typedef _Pointer_adapter<_Relative_pointer_impl<const A> > const_A_pointer;
+typedef _Pointer_adapter<_Relative_pointer_impl<const B> > const_B_pointer;
+
+
+// Test implicit conversion from B* to A*
+void inc(_Pointer_adapter<_Relative_pointer_impl<A> > a) {
+ a->i++;
+}
+// Test implicit conversion from B* to const B*
+void inc2(_Pointer_adapter<_Relative_pointer_impl<const B> > b) {
+ b->i++;
+ b->j++;
+}
+// Test implicit conversion from B* to const A*
+void inc3(_Pointer_adapter<_Relative_pointer_impl<const A> > a) {
+ a->i++;
+}
+
+void test02() {
+ bool test __attribute__((unused)) = true;
+
+ B b;
+ b.i = 2;
+ b.j = 2;
+
+ B_pointer Bptr(&b);
+ VERIFY(Bptr->i == 2);
+ Bptr->i++;
+ VERIFY(b.i == 3);
+
+ const_B_pointer cBptr(&b);
+ b.i++;
+ VERIFY(cBptr->i == 4);
+
+ A_pointer Aptr(&b);
+ b.i++;
+ VERIFY(Aptr->i == 5);
+ Aptr->i++;
+ VERIFY(b.i == 6);
+
+ const_A_pointer cAptr(&b);
+ b.i++;
+ VERIFY(cAptr->i == 7);
+
+ const_B_pointer cBptr2(Bptr);
+ b.i++;
+ VERIFY(cBptr2->i == 8);
+
+ A_pointer Aptr2(Bptr);
+ b.i++;
+ VERIFY(Aptr2->i == 9);
+ Aptr2->i++;
+ VERIFY(b.i == 10);
+
+ const_A_pointer cAptr2(Bptr);
+ b.i++;
+ VERIFY(cAptr2->i == 11);
+
+ // Implicit casting during invocation
+ inc(Bptr);
+ VERIFY(Bptr->i == 12);
+ inc2(Bptr);
+ VERIFY(Bptr->i == 13);
+ VERIFY(Bptr->j == 3);
+ inc3(Bptr);
+ VERIFY(Bptr->i == 14);
+}
+
+void test03() {
+ bool test __attribute__((unused)) = true;
+
+ B b;
+ B* bPtr = &b;
+ A* aPtr __attribute__((unused)) = __static_pointer_cast<A*>(bPtr);
+ const A *caPtr __attribute__((unused)) = __static_pointer_cast<const A*>(bPtr);
+ const B *cbPtr __attribute__((unused)) = __static_pointer_cast<const B*>(bPtr);
+
+ B_pointer Bptr2 = &b;
+
+ const A* caPtr2 __attribute__((unused)) = __static_pointer_cast<const A*>(Bptr2);
+ A * aPtr2 __attribute__((unused)) = __static_pointer_cast<A*>(Bptr2);
+ const B* cbPtr2 __attribute__((unused)) = __const_pointer_cast<const B*>(Bptr2);
+
+ const_A_pointer caPtr3 __attribute__((unused)) = __static_pointer_cast<const A*>(Bptr2);
+ A_pointer aPtr3 __attribute__((unused)) = __static_pointer_cast<A*>(Bptr2);
+ const_B_pointer cbPtr3 __attribute__((unused)) = __const_pointer_cast<const B*>(Bptr2);
+}
+
+// Confirm the usability of the __static_pointer_cast<> template function
+// to transform between _Pointer_adapter and standard versions.
+void test04() {
+ bool test __attribute__((unused)) = true;
+
+ B b;
+ B_pointer bPtr = &b;
+
+ A_pointer aPtr = __static_pointer_cast<A_pointer>(bPtr);
+ VERIFY(aPtr == bPtr);
+ B_pointer bPtr2 = __static_pointer_cast<B_pointer>(aPtr);
+ VERIFY(bPtr2 == aPtr);
+
+ A* aPtr3 = __static_pointer_cast<A*>(bPtr);
+ VERIFY(aPtr3 == bPtr);
+ B* bPtr3 = __static_pointer_cast<B*>(aPtr);
+ VERIFY(bPtr3 == aPtr);
+}
+
+int main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/ext_pointer/1_neg.cc b/libstdc++-v3/testsuite/ext/ext_pointer/1_neg.cc
new file mode 100644
index 000000000..0ceb9a659
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/ext_pointer/1_neg.cc
@@ -0,0 +1,94 @@
+// 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/>.
+
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <ext/pointer.h>
+
+using __gnu_cxx::_Pointer_adapter;
+using __gnu_cxx::_Relative_pointer_impl;
+using __gnu_cxx::__static_pointer_cast;
+using __gnu_cxx::__const_pointer_cast;
+
+
+struct A {
+ int i;
+};
+struct B : public A{
+ int j;
+};
+typedef _Pointer_adapter<_Relative_pointer_impl<B> > B_pointer;
+typedef _Pointer_adapter<_Relative_pointer_impl<const B> > const_B_pointer;
+typedef _Pointer_adapter<_Relative_pointer_impl<A> > A_pointer;
+typedef _Pointer_adapter<_Relative_pointer_impl<const A> > const_A_pointer;
+
+
+void test01(void) {
+ bool test __attribute__((unused)) = true;
+
+ A a;
+ B b;
+
+ A_pointer aptr( &a );
+
+ // Can't implicitly cast from A* to B*
+ B_pointer bptr1(aptr); // { dg-error "instantiated from here" 31 }
+ B_pointer bptr2(&a); // { dg-error "instantiated from here" 32 }
+
+ // but explicit cast/conversion is OK.
+ B_pointer bptr3(__static_pointer_cast<B_pointer>(aptr)); // ok
+ B_pointer bptr4(__static_pointer_cast<B_pointer>(&a)); // ok
+
+ // Can't implicitly cast from A* to B*
+ bptr1 = aptr; // { dg-error "instantiated from here" 39 }
+ bptr1 = &a; // { dg-error "instantiated from here" 40 }
+
+ // but explicit cast/conversion is OK.
+ bptr1 = __static_pointer_cast<B_pointer>(aptr); // ok
+ bptr1 = __static_pointer_cast<B_pointer>(&a); // ok
+
+ // Similarly, can't shed constness via implicit cast
+ const_A_pointer captr(&a);
+ A_pointer aptr2(captr); // { dg-error "instantiated from here" 48 }
+
+ // but explicit cast/conversion is OK.
+ A_pointer aptr3(__const_pointer_cast<A_pointer>(captr)); // ok
+
+ // Similarly, can't shed constness via implicit cast
+ aptr2 = captr; // { dg-error "instantiated from here" 54 }
+
+ // but explicit cast/conversion is OK.
+ aptr3 = __const_pointer_cast<A_pointer>(captr); // ok
+
+ // Combine explicit const cast with implicit downcast.
+ const_B_pointer cbptr(&b);
+ A_pointer aptr4(cbptr); // { dg-error "instantiated from here" 61 }
+ aptr4 = cbptr; // { dg-error "instantiated from here" 62 }
+
+ A_pointer aptr5(__const_pointer_cast<B_pointer>(cbptr)); // ok
+ aptr5 = __const_pointer_cast<B_pointer>(cbptr); // ok
+}
+
+// { dg-prune-output "include" }
diff --git a/libstdc++-v3/testsuite/ext/forced_error/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/ext/forced_error/cons_virtual_derivation.cc
new file mode 100644
index 000000000..f505a796e
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/forced_error/cons_virtual_derivation.cc
@@ -0,0 +1,30 @@
+// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 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/>.
+
+// { dg-require-time "" }
+
+#include <ext/throw_allocator.h>
+#include <testsuite_api.h>
+
+int main()
+{
+ typedef __gnu_cxx::forced_error test_type;
+ __gnu_test::diamond_derivation<test_type, true>::test();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/headers.cc b/libstdc++-v3/testsuite/ext/headers.cc
new file mode 100644
index 000000000..826bdc5c7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/headers.cc
@@ -0,0 +1,62 @@
+// { dg-do compile }
+// 1999-06-23 bkoz
+
+// Copyright (C) 1999, 2001, 2003, 2007, 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/>.
+
+// extension headers
+
+// This should include a list of all headers in the extension
+// subdirectory that are meant to be directly included.
+
+#include <ext/algorithm>
+#include <ext/array_allocator.h>
+#include <ext/atomicity.h>
+#include <ext/bitmap_allocator.h>
+#if _GLIBCXX_HAVE_ICONV
+#include <ext/codecvt_specializations.h>
+#endif
+#include <ext/concurrence.h>
+#include <ext/debug_allocator.h>
+#if _GLIBCXX_HAVE_ICONV
+#include <ext/enc_filebuf.h>
+#endif
+#include <ext/functional>
+#include <ext/iterator>
+#include <ext/malloc_allocator.h>
+#include <ext/memory>
+#include <ext/mt_allocator.h>
+#include <ext/new_allocator.h>
+#include <ext/numeric>
+#include <ext/pod_char_traits.h>
+#include <ext/pool_allocator.h>
+#include <ext/rb_tree>
+#include <ext/rope>
+#include <ext/slist>
+#include <ext/stdio_filebuf.h>
+#include <ext/stdio_sync_filebuf.h>
+#include <ext/throw_allocator.h>
+#include <ext/typelist.h>
+#include <ext/type_traits.h>
+#include <ext/vstring.h>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/priority_queue.hpp>
+#include <ext/pb_ds/exception.hpp>
+#include <ext/pb_ds/hash_policy.hpp>
+#include <ext/pb_ds/list_update_policy.hpp>
+#include <ext/pb_ds/tree_policy.hpp>
+#include <ext/pb_ds/trie_policy.hpp>
diff --git a/libstdc++-v3/testsuite/ext/iota/cxx0x.cc b/libstdc++-v3/testsuite/ext/iota/cxx0x.cc
new file mode 100644
index 000000000..84917adb4
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/iota/cxx0x.cc
@@ -0,0 +1,28 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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 <ext/numeric>
+#include <vector>
+
+void foo()
+{
+ std::vector<int> v;
+ iota(v.begin(), v.end(), 0);
+}
diff --git a/libstdc++-v3/testsuite/ext/is_heap/1.cc b/libstdc++-v3/testsuite/ext/is_heap/1.cc
new file mode 100644
index 000000000..79a190f8c
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/is_heap/1.cc
@@ -0,0 +1,45 @@
+// Copyright (C) 2005, 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 <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::random_access_iterator_wrapper;
+
+typedef test_container<int, random_access_iterator_wrapper> container;
+
+void
+test1()
+{
+ int array[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ for(int i = 0; i < 10; ++i)
+ {
+ container con(array, array + i);
+ std::make_heap(con.begin(), con.end());
+ VERIFY(std::__is_heap(con.begin(), con.end()));
+ VERIFY(std::__is_heap(con.begin(), i));
+ }
+}
+
+int
+main()
+{
+ test1();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/is_heap/47709.cc b/libstdc++-v3/testsuite/ext/is_heap/47709.cc
new file mode 100644
index 000000000..5eeaf582c
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/is_heap/47709.cc
@@ -0,0 +1,29 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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 <ext/algorithm>
+#include <vector>
+
+// libstdc++/47709
+void foo()
+{
+ std::vector<int> v;
+ is_heap(v.begin(), v.end());
+}
diff --git a/libstdc++-v3/testsuite/ext/is_heap/check_type.cc b/libstdc++-v3/testsuite/ext/is_heap/check_type.cc
new file mode 100644
index 000000000..e019ea4cc
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/is_heap/check_type.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2005, 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/>.
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+using __gnu_test::random_access_iterator_wrapper;
+
+struct S { };
+
+bool
+operator<(const S&, const S&) {return true;}
+
+struct X { };
+
+bool
+predicate(const X&, const X&) {return true;}
+
+bool
+test1(random_access_iterator_wrapper<S>& start,
+ random_access_iterator_wrapper<S>& end)
+{ return std::__is_heap(start, end) && std::__is_heap(start, 1); }
+
+bool
+test2(random_access_iterator_wrapper<X>& start,
+ random_access_iterator_wrapper<X>& end)
+{
+ return std::__is_heap(start, end, predicate) &&
+ std::__is_heap(start, predicate, 1);
+}
diff --git a/libstdc++-v3/testsuite/ext/is_sorted/cxx0x.cc b/libstdc++-v3/testsuite/ext/is_sorted/cxx0x.cc
new file mode 100644
index 000000000..518716c51
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/is_sorted/cxx0x.cc
@@ -0,0 +1,28 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 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 <ext/algorithm>
+#include <vector>
+
+void foo()
+{
+ std::vector<int> v;
+ is_sorted(v.begin(), v.end());
+}
diff --git a/libstdc++-v3/testsuite/ext/malloc_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/malloc_allocator/check_allocate_max_size.cc
new file mode 100644
index 000000000..b8111e3e7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/malloc_allocator/check_allocate_max_size.cc
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/malloc_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::malloc_allocator<value_type> allocator_type;
+ __gnu_test::check_allocate_max_size<allocator_type>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/malloc_allocator/check_deallocate_null.cc b/libstdc++-v3/testsuite/ext/malloc_allocator/check_deallocate_null.cc
new file mode 100644
index 000000000..085b953ad
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/malloc_allocator/check_deallocate_null.cc
@@ -0,0 +1,31 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/malloc_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::malloc_allocator<value_type> allocator_type;
+ __gnu_test::check_deallocate_null<allocator_type>();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/malloc_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/malloc_allocator/check_delete.cc
new file mode 100644
index 000000000..2ed8d0454
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/malloc_allocator/check_delete.cc
@@ -0,0 +1,31 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/malloc_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef __gnu_cxx::malloc_allocator<unsigned int> allocator_type;
+ __gnu_test::check_delete<allocator_type, false>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/malloc_allocator/check_new.cc b/libstdc++-v3/testsuite/ext/malloc_allocator/check_new.cc
new file mode 100644
index 000000000..fac139f2b
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/malloc_allocator/check_new.cc
@@ -0,0 +1,31 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/malloc_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef __gnu_cxx::malloc_allocator<unsigned int> allocator_type;
+ __gnu_test::check_new<allocator_type, false>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/malloc_allocator/deallocate_global.cc b/libstdc++-v3/testsuite/ext/malloc_allocator/deallocate_global.cc
new file mode 100644
index 000000000..67041f548
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/malloc_allocator/deallocate_global.cc
@@ -0,0 +1,35 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 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 <string>
+#include <stdexcept>
+#include <ext/malloc_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char char_t;
+typedef std::char_traits<char_t> traits_t;
+typedef __gnu_cxx::malloc_allocator<char_t> allocator_t;
+typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
+
+string_t s("bayou bend");
+
+int main()
+{
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/malloc_allocator/deallocate_local.cc b/libstdc++-v3/testsuite/ext/malloc_allocator/deallocate_local.cc
new file mode 100644
index 000000000..76ae1995f
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/malloc_allocator/deallocate_local.cc
@@ -0,0 +1,39 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 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 <string>
+#include <ext/malloc_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char char_t;
+typedef std::char_traits<char_t> traits_t;
+typedef __gnu_cxx::malloc_allocator<char_t> allocator_t;
+typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
+
+int main()
+{
+ {
+ string_t s;
+ s += "bayou bend";
+ }
+
+ if (__gnu_test::counter::count() != 0)
+ throw std::runtime_error("count not zero");
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/malloc_allocator/explicit_instantiation.cc b/libstdc++-v3/testsuite/ext/malloc_allocator/explicit_instantiation.cc
new file mode 100644
index 000000000..8a06c4d51
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/malloc_allocator/explicit_instantiation.cc
@@ -0,0 +1,27 @@
+// { dg-do compile }
+
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/malloc_allocator.h>
+
+template class __gnu_cxx::malloc_allocator<int>;
diff --git a/libstdc++-v3/testsuite/ext/malloc_allocator/variadic_construct.cc b/libstdc++-v3/testsuite/ext/malloc_allocator/variadic_construct.cc
new file mode 100644
index 000000000..1f0a35090
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/malloc_allocator/variadic_construct.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 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 <ext/malloc_allocator.h>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::pair<int, char> pair_type;
+ __gnu_cxx::malloc_allocator<pair_type> alloc1;
+
+ pair_type* ptp1 = alloc1.allocate(1);
+ alloc1.construct(ptp1, 3, 'a');
+
+ VERIFY( ptp1->first == 3 );
+ VERIFY( ptp1->second == 'a' );
+
+ alloc1.deallocate(ptp1, 1);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/median.cc b/libstdc++-v3/testsuite/ext/median.cc
new file mode 100644
index 000000000..fe220d8ad
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/median.cc
@@ -0,0 +1,41 @@
+// Copyright (C) 2005, 2009, 2010 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/>.
+
+// median - SGI extension
+
+#include <ext/algorithm>
+#include <testsuite_hooks.h>
+
+bool pred(const int& l, const int& r)
+{
+ return l<r;
+}
+
+using __gnu_cxx::__median;
+
+int main()
+{
+ const int i=1;
+ const int j=2;
+ const int k=3;
+ VERIFY(__median(i, j, k) == j && __median(i, j, k, pred) == j);
+ VERIFY(__median(i, k, j) == j && __median(i, k, j, pred) == j);
+ VERIFY(__median(j, i, k) == j && __median(j, i, k, pred) == j);
+ VERIFY(__median(j, k, i) == j && __median(j, k, i, pred) == j);
+ VERIFY(__median(k, i, j) == j && __median(k, i, j, pred) == j);
+ VERIFY(__median(k, j, i) == j && __median(k, j, i, pred) == j);
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc b/libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc
new file mode 100644
index 000000000..609f188aa
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/22309_thread.cc
@@ -0,0 +1,99 @@
+// { dg-require-sharedlib "" }
+// { dg-options "-g -O2 -pthread -ldl" { target *-*-linux* } }
+
+// Copyright (C) 2004, 2005, 2009, 2010 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 <dlfcn.h>
+#include <pthread.h>
+#include <cstdlib>
+#include <stdexcept>
+
+void
+check_dlopen(void*& h)
+{
+ dlerror();
+ void* tmp = dlopen("./testsuite_shared.so", RTLD_LAZY);
+ if (!tmp)
+ {
+ try
+ {
+ // Throws std::logic_error on NULL string.
+ std::string error(dlerror());
+ throw std::runtime_error(error);
+ }
+ catch (const std::logic_error&)
+ { }
+ }
+ h = tmp;
+}
+
+void
+check_dlsym(void*& h)
+{
+ dlerror();
+
+ typedef void (*function_type) (void);
+ function_type fn;
+ fn = reinterpret_cast<function_type>(dlsym(h, "try_allocation"));
+
+ try
+ {
+ std::string error(dlerror());
+ throw std::runtime_error(error);
+ }
+ catch (const std::logic_error&)
+ { }
+
+ fn();
+}
+
+void
+check_dlclose(void*& h)
+{
+ dlerror();
+ if (dlclose(h) != 0)
+ {
+ try
+ {
+ std::string error(dlerror());
+ throw std::runtime_error(error);
+ }
+ catch (const std::logic_error&)
+ { }
+ }
+}
+
+void*
+tf(void* arg)
+{
+ void* h;
+ check_dlopen(h);
+ check_dlsym(h);
+ check_dlclose(h);
+ return 0;
+}
+
+// libstdc++/22309
+int
+main (void)
+{
+ pthread_t th;
+ pthread_create(&th, 0, tf, 0);
+ pthread_join(th, 0);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_big_per_type.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_big_per_type.cc
new file mode 100644
index 000000000..eaea215a0
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_big_per_type.cc
@@ -0,0 +1,54 @@
+// 2005-01-26 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005, 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 <memory>
+#include <ext/mt_allocator.h>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+struct big { char array[256]; };
+
+// __per_type_pool_policy
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef big value_type;
+
+ using __gnu_cxx::__pool;
+ using __gnu_cxx::__per_type_pool_policy;
+
+#ifdef __GTHREADS
+ typedef __per_type_pool_policy<value_type, __pool, true> policy_type;
+#else
+ typedef __per_type_pool_policy<value_type, __pool, false> policy_type;
+#endif
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+
+ allocator_type a;
+ allocator_type::pointer p1 = a.allocate(64);
+ std::memset((void*)p1, 0, sizeof(big) * 64);
+ a.deallocate(p1, 64);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc
new file mode 100644
index 000000000..9cde43b8e
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_allocate_max_size.cc
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/mt_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::__mt_alloc<value_type> allocator_type;
+ __gnu_test::check_allocate_max_size<allocator_type>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null.cc
new file mode 100644
index 000000000..46d1d8548
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null.cc
@@ -0,0 +1,33 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/mt_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ using __gnu_cxx::__pool;
+ typedef __gnu_cxx::__common_pool_policy<__pool, false> policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+ __gnu_test::check_deallocate_null<allocator_type>();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null_thread.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null_thread.cc
new file mode 100644
index 000000000..94000ab98
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_deallocate_null_thread.cc
@@ -0,0 +1,33 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/mt_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ using __gnu_cxx::__pool;
+ typedef __gnu_cxx::__common_pool_policy<__pool, true> policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+ __gnu_test::check_deallocate_null<allocator_type>();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc
new file mode 100644
index 000000000..374c56706
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_delete.cc
@@ -0,0 +1,31 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef __gnu_cxx::__mt_alloc<unsigned int> allocator_type;
+ __gnu_test::check_delete<allocator_type, false>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/check_new.cc b/libstdc++-v3/testsuite/ext/mt_allocator/check_new.cc
new file mode 100644
index 000000000..527932640
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/check_new.cc
@@ -0,0 +1,32 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ // Uses new but delete only optionally.
+ typedef __gnu_cxx::__mt_alloc<unsigned int> allocator_type;
+ __gnu_test::check_new<allocator_type, true>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-2.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-2.cc
new file mode 100644
index 000000000..fcc5006bd
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-2.cc
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <list>
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef std::string value_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__common_pool_policy;
+typedef __common_pool_policy<__pool, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::char_traits<value_type> traits_type;
+typedef std::list<value_type, allocator_type> list_type;
+
+list_type l;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ l.push_back("bayou bend");
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-4.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-4.cc
new file mode 100644
index 000000000..cafbffb34
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-4.cc
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <list>
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef std::string value_t;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_t, __pool, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_t, policy_type> allocator_type;
+typedef std::char_traits<value_t> traits_type;
+typedef std::list<value_t, allocator_type> list_type;
+
+list_type l;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ l.push_back("bayou bend");
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-1.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-1.cc
new file mode 100644
index 000000000..f61cd38b7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-1.cc
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <list>
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef std::string value_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__common_pool_policy;
+typedef __common_pool_policy<__pool, true> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::char_traits<value_type> traits_type;
+typedef std::list<value_type, allocator_type> list_type;
+
+list_type l;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ l.push_back("bayou bend");
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-3.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-3.cc
new file mode 100644
index 000000000..62074f0a4
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-3.cc
@@ -0,0 +1,46 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <list>
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef std::string value_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_type, __pool, true> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::char_traits<value_type> traits_type;
+typedef std::list<value_type, allocator_type> list_type;
+
+list_type l;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ l.push_back("bayou bend");
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-2.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-2.cc
new file mode 100644
index 000000000..9ccebd57e
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-2.cc
@@ -0,0 +1,43 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+typedef __gnu_cxx::__common_pool_policy<__pool, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ string_type s;
+ s += "bayou bend";
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-4.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-4.cc
new file mode 100644
index 000000000..9265a15a9
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-4.cc
@@ -0,0 +1,44 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_type, __pool, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ string_type s;
+ s += "bayou bend";
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-6.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-6.cc
new file mode 100644
index 000000000..017557138
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-6.cc
@@ -0,0 +1,55 @@
+// { dg-require-cxa-atexit "" }
+
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+template<bool _Thread>
+ struct cleanup_pool : public __gnu_cxx::__pool<false>
+ {
+ cleanup_pool() : __gnu_cxx::__pool<false>() { }
+
+ cleanup_pool(const __gnu_cxx::__pool_base::_Tune& t)
+ : __gnu_cxx::__pool<false>(t) { }
+
+ ~cleanup_pool() throw() { this->_M_destroy(); }
+ };
+
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+typedef __gnu_cxx::__common_pool_policy<cleanup_pool, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ string_type s;
+ s += "bayou bend";
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-8.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-8.cc
new file mode 100644
index 000000000..34005e4b0
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-8.cc
@@ -0,0 +1,56 @@
+// { dg-require-cxa-atexit "" }
+
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+template<bool _Thread>
+ struct cleanup_pool : public __gnu_cxx::__pool<false>
+ {
+ cleanup_pool() : __gnu_cxx::__pool<false>() { }
+
+ cleanup_pool(const __gnu_cxx::__pool_base::_Tune& t)
+ : __gnu_cxx::__pool<false>(t) { }
+
+ ~cleanup_pool() throw() { this->_M_destroy(); }
+ };
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_type, cleanup_pool, false> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ string_type s;
+ s += "bayou bend";
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-1.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-1.cc
new file mode 100644
index 000000000..012a7585a
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-1.cc
@@ -0,0 +1,43 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+typedef __gnu_cxx::__common_pool_policy<__pool, true> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ string_type s;
+ s += "bayou bend";
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-3.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-3.cc
new file mode 100644
index 000000000..0a9fde02b
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-3.cc
@@ -0,0 +1,44 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_type, __pool, true> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ string_type s;
+ s += "bayou bend";
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-5.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-5.cc
new file mode 100644
index 000000000..a812aecf2
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-5.cc
@@ -0,0 +1,54 @@
+// { dg-require-cxa-atexit "" }
+
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+template<bool _Thread>
+ struct cleanup_pool : public __gnu_cxx::__pool<true>
+ {
+ cleanup_pool() : __gnu_cxx::__pool<true>() { }
+
+ cleanup_pool(const __gnu_cxx::__pool_base::_Tune& t)
+ : __gnu_cxx::__pool<true>(t) { }
+
+ ~cleanup_pool() throw() { this->_M_destroy(); }
+ };
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+typedef __gnu_cxx::__common_pool_policy<cleanup_pool, true> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ string_type s;
+ s += "bayou bend";
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-7.cc b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-7.cc
new file mode 100644
index 000000000..ac8426ee9
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-7.cc
@@ -0,0 +1,56 @@
+// { dg-require-cxa-atexit "" }
+
+// Copyright (C) 2004, 2005, 2006, 2007, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <string>
+#include <stdexcept>
+#include <cstdio>
+#include <ext/mt_allocator.h>
+#include <replacement_memory_operators.h>
+
+template<bool _Thread>
+ struct cleanup_pool : public __gnu_cxx::__pool<true>
+ {
+ cleanup_pool() : __gnu_cxx::__pool<true>() { }
+
+ cleanup_pool(const __gnu_cxx::__pool_base::_Tune& t)
+ : __gnu_cxx::__pool<true>(t) { }
+
+ ~cleanup_pool() throw() { this->_M_destroy(); }
+ };
+
+typedef char value_type;
+typedef std::char_traits<value_type> traits_type;
+using __gnu_cxx::__pool;
+using __gnu_cxx::__per_type_pool_policy;
+typedef __per_type_pool_policy<value_type, cleanup_pool, true> policy_type;
+typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+typedef std::basic_string<value_type, traits_type, allocator_type> string_type;
+
+int main()
+{
+ // NB: __mt_allocator doesn't clean itself up. Thus, the count will
+ // not be zero.
+ __gnu_test::counter::exceptions(false);
+ string_type s;
+ s += "bayou bend";
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/explicit_instantiation.cc b/libstdc++-v3/testsuite/ext/mt_allocator/explicit_instantiation.cc
new file mode 100644
index 000000000..03be65d01
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// { dg-do compile }
+
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/mt_allocator.h>
+
+using namespace __gnu_cxx;
+template class __mt_alloc<int>;
+template class __mt_alloc<short, __common_pool_policy<__pool, false> >;
+template class __mt_alloc<short, __per_type_pool_policy<short, __pool, false> >;
+#ifdef __GTHREADS
+template class __mt_alloc<short, __common_pool_policy<__pool, true> >;
+template class __mt_alloc<short, __per_type_pool_policy<short, __pool, true> >;
+#endif
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/tune-1.cc b/libstdc++-v3/testsuite/ext/mt_allocator/tune-1.cc
new file mode 100644
index 000000000..9630accbe
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/tune-1.cc
@@ -0,0 +1,70 @@
+// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
+//
+// Copyright (C) 2004, 2005, 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 <memory>
+#include <ext/mt_allocator.h>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+#ifdef __GTHREADS
+#define __cxxthread true
+#else
+#define __cxxthread false
+#endif
+
+// Tune characteristics.
+// __common_pool_policy
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ using __gnu_cxx::__pool;
+ using __gnu_cxx::__common_pool_policy;
+
+ typedef __gnu_test::pod_int value_type;
+ typedef __common_pool_policy<__pool, __cxxthread> policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+ typedef __gnu_cxx::__pool_base::_Tune tune_type;
+
+ allocator_type a;
+ tune_type t_default = a._M_get_options();
+ tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
+ tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
+
+ tune_type t1 = t_default;
+ a._M_set_options(t_opt);
+ tune_type t2 = a._M_get_options();
+ VERIFY( t1._M_align != t2._M_align );
+
+ allocator_type::pointer p1 = a.allocate(128);
+ allocator_type::pointer p2 = a.allocate(5128);
+ a._M_set_options(t_small);
+ tune_type t3 = a._M_get_options();
+ VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
+ VERIFY( t3._M_chunk_size == t_opt._M_chunk_size );
+
+ a.deallocate(p1, 128);
+ a.deallocate(p2, 5128);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/tune-2.cc b/libstdc++-v3/testsuite/ext/mt_allocator/tune-2.cc
new file mode 100644
index 000000000..c3f6b3b68
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/tune-2.cc
@@ -0,0 +1,72 @@
+// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
+//
+// Copyright (C) 2004, 2005, 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 <memory>
+#include <ext/mt_allocator.h>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+#ifdef __GTHREADS
+#define __cxxthread true
+#else
+#define __cxxthread false
+#endif
+
+// Tune characteristics.
+// __per_type_pool_policy
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef __gnu_test::pod_int value_type;
+
+ using __gnu_cxx::__pool;
+ using __gnu_cxx::__per_type_pool_policy;
+
+ typedef __per_type_pool_policy<value_type, __pool, __cxxthread> policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+ typedef __gnu_cxx::__pool_base::_Tune tune_type;
+
+ allocator_type a;
+ tune_type t_default = a._M_get_options();
+ tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
+ tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
+
+ tune_type t1 = t_default;
+ a._M_set_options(t_opt);
+ tune_type t2 = a._M_get_options();
+ VERIFY( t1._M_align != t2._M_align );
+
+ allocator_type::pointer p1 = a.allocate(128);
+ allocator_type::pointer p2 = a.allocate(5128);
+ a._M_set_options(t_small);
+ tune_type t3 = a._M_get_options();
+ VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
+ VERIFY( t3._M_chunk_size == t_opt._M_chunk_size );
+
+ a.deallocate(p1, 128);
+ a.deallocate(p2, 5128);
+}
+
+int main()
+{
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/tune-3.cc b/libstdc++-v3/testsuite/ext/mt_allocator/tune-3.cc
new file mode 100644
index 000000000..b4e822d27
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/tune-3.cc
@@ -0,0 +1,94 @@
+// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
+//
+// Copyright (C) 2004, 2005, 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 <testsuite_hooks.h>
+#include <memory>
+#include <ext/mt_allocator.h>
+
+// Tune characteristics, two of same type
+template<typename _Tp>
+struct test_policy
+{ static bool per_type() { return true; } };
+
+using __gnu_cxx::__pool;
+using __gnu_cxx::__common_pool_policy;
+
+template<>
+struct test_policy<__common_pool_policy<__pool, true> >
+{ static bool per_type() { return false; } };
+
+template<>
+struct test_policy<__common_pool_policy<__pool, false> >
+{ static bool per_type() { return false; } };
+
+// Tune characteristics, two of different types
+template<typename _Tp, typename _Cp>
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef __gnu_cxx::__pool_base::_Tune tune_type;
+ typedef _Tp value_type;
+ typedef _Cp policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+
+ allocator_type a;
+ tune_type t_default = a._M_get_options();
+ tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
+ tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
+
+ // First instances assured.
+ tune_type t1 = t_default;
+ if (test_policy<policy_type>::per_type())
+ {
+ a._M_set_options(t_opt);
+ t1 = a._M_get_options();
+ VERIFY( t1._M_align != t_default._M_align );
+ }
+
+ // Lock tune settings.
+ typename allocator_type::pointer p1 = a.allocate(128);
+
+ allocator_type a2;
+ tune_type t2 = a2._M_get_options();
+ VERIFY( t2._M_chunk_size == t1._M_chunk_size );
+
+ typename allocator_type::pointer p2 = a2.allocate(5128);
+
+ a2._M_set_options(t_small);
+ tune_type t3 = a2._M_get_options();
+ VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
+ VERIFY( t3._M_chunk_size == t2._M_chunk_size );
+
+ a.deallocate(p1, 128);
+ a2.deallocate(p2, 5128);
+}
+
+int main()
+{
+#ifdef __GTHREADS
+ test03<int, __gnu_cxx::__per_type_pool_policy<int, __pool, true> >();
+ test03<int, __gnu_cxx::__common_pool_policy<__pool, true> >();
+#endif
+
+ test03<int, __gnu_cxx::__per_type_pool_policy<int, __pool, false> >();
+ test03<int, __gnu_cxx::__common_pool_policy<__pool, false> >();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/tune-4.cc b/libstdc++-v3/testsuite/ext/mt_allocator/tune-4.cc
new file mode 100644
index 000000000..4d3c81181
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/tune-4.cc
@@ -0,0 +1,111 @@
+// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
+//
+// Copyright (C) 2004, 2005, 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 <testsuite_hooks.h>
+#include <memory>
+#include <ext/mt_allocator.h>
+
+// Tune characteristics, two of same type
+template<typename _Tp>
+struct test_policy
+{ static bool per_type() { return true; } };
+
+using __gnu_cxx::__pool;
+using __gnu_cxx::__common_pool_policy;
+
+template<>
+struct test_policy<__common_pool_policy<__pool, true> >
+{ static bool per_type() { return false; } };
+
+template<>
+struct test_policy<__common_pool_policy<__pool, false> >
+{ static bool per_type() { return false; } };
+
+struct pod2
+{
+ int i;
+ int j;
+ int k;
+};
+
+// Tune characteristics, two of different instantiations
+template<typename _Tp, typename _Cp>
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef __gnu_cxx::__pool_base::_Tune tune_type;
+ typedef _Tp value_type;
+ typedef _Cp policy_type;
+ typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
+
+ allocator_type a;
+ tune_type t_default = a._M_get_options();
+ tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
+ tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
+
+ // First instance of local type assured.
+ tune_type t1 = t_default;
+ if (test_policy<policy_type>::per_type())
+ {
+ a._M_set_options(t_opt);
+ t1 = a._M_get_options();
+ VERIFY( t1._M_align != t_default._M_align );
+ }
+
+ // Lock tune settings.
+ typename allocator_type::pointer p1 = a.allocate(128);
+
+ typedef pod2 value2_type;
+ typedef typename allocator_type::template rebind<value2_type>::other rebind_type;
+
+ rebind_type a2;
+ tune_type t2 = a2._M_get_options();
+
+ // Both policy_type and rebind_type::policy_type have same characteristics.
+ if (test_policy<policy_type>::per_type())
+ {
+ a2._M_set_options(t_opt);
+ tune_type t = a2._M_get_options();
+ VERIFY( t2._M_align != t._M_align );
+ t2 = t;
+ }
+
+ typename rebind_type::pointer p2 = a2.allocate(5128);
+
+ a2._M_set_options(t_small);
+ tune_type t4 = a2._M_get_options();
+ VERIFY( t4._M_chunk_size != t_small._M_chunk_size );
+ VERIFY( t4._M_chunk_size == t2._M_chunk_size );
+
+ a.deallocate(p1, 128);
+ a2.deallocate(p2, 5128);
+}
+
+int main()
+{
+#ifdef __GTHREADS
+ test04<float, __gnu_cxx::__common_pool_policy<__pool, true> >();
+ test04<double, __gnu_cxx::__per_type_pool_policy<double, __pool, true> >();
+#endif
+ test04<float, __gnu_cxx::__common_pool_policy<__pool, false> >();
+ test04<double, __gnu_cxx::__per_type_pool_policy<double, __pool, false> >();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/mt_allocator/variadic_construct.cc b/libstdc++-v3/testsuite/ext/mt_allocator/variadic_construct.cc
new file mode 100644
index 000000000..d4c2315f3
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/mt_allocator/variadic_construct.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 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 <ext/mt_allocator.h>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::pair<int, char> pair_type;
+ __gnu_cxx::__mt_alloc<pair_type> alloc1;
+
+ pair_type* ptp1 = alloc1.allocate(1);
+ alloc1.construct(ptp1, 3, 'a');
+
+ VERIFY( ptp1->first == 3 );
+ VERIFY( ptp1->second == 'a' );
+
+ alloc1.deallocate(ptp1, 1);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/new_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/new_allocator/check_allocate_max_size.cc
new file mode 100644
index 000000000..0717c1961
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/new_allocator/check_allocate_max_size.cc
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/new_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::new_allocator<value_type> allocator_type;
+ __gnu_test::check_allocate_max_size<allocator_type>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/new_allocator/check_deallocate_null.cc b/libstdc++-v3/testsuite/ext/new_allocator/check_deallocate_null.cc
new file mode 100644
index 000000000..45c2999dc
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/new_allocator/check_deallocate_null.cc
@@ -0,0 +1,31 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/new_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::new_allocator<value_type> allocator_type;
+ __gnu_test::check_deallocate_null<allocator_type>();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/new_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/new_allocator/check_delete.cc
new file mode 100644
index 000000000..cff31c892
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/new_allocator/check_delete.cc
@@ -0,0 +1,31 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/new_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef __gnu_cxx::new_allocator<unsigned int> allocator_type;
+ __gnu_test::check_delete<allocator_type, true>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/new_allocator/check_new.cc b/libstdc++-v3/testsuite/ext/new_allocator/check_new.cc
new file mode 100644
index 000000000..098b624d1
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/new_allocator/check_new.cc
@@ -0,0 +1,31 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/new_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef __gnu_cxx::new_allocator<unsigned int> allocator_type;
+ __gnu_test::check_new<allocator_type, true>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/new_allocator/deallocate_global.cc b/libstdc++-v3/testsuite/ext/new_allocator/deallocate_global.cc
new file mode 100644
index 000000000..76b79e6e9
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/new_allocator/deallocate_global.cc
@@ -0,0 +1,37 @@
+// { dg-require-cxa-atexit "" }
+
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// 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 <string>
+#include <stdexcept>
+#include <ext/new_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char char_t;
+typedef std::char_traits<char_t> traits_t;
+typedef __gnu_cxx::new_allocator<char_t> allocator_t;
+typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
+
+string_t s("bayou bend");
+
+int main()
+{
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/new_allocator/deallocate_local.cc b/libstdc++-v3/testsuite/ext/new_allocator/deallocate_local.cc
new file mode 100644
index 000000000..dd7c634e0
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/new_allocator/deallocate_local.cc
@@ -0,0 +1,39 @@
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 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 <string>
+#include <ext/new_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char char_t;
+typedef std::char_traits<char_t> traits_t;
+typedef __gnu_cxx::new_allocator<char_t> allocator_t;
+typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
+
+int main()
+{
+ {
+ string_t s;
+ s += "bayou bend";
+ }
+
+ if (__gnu_test::counter::count() != 0)
+ throw std::runtime_error("count not zero");
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/new_allocator/instantiate.cc b/libstdc++-v3/testsuite/ext/new_allocator/instantiate.cc
new file mode 100644
index 000000000..874870ce7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/new_allocator/instantiate.cc
@@ -0,0 +1,27 @@
+// { dg-do compile }
+
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/new_allocator.h>
+
+template class __gnu_cxx::new_allocator<int>;
diff --git a/libstdc++-v3/testsuite/ext/new_allocator/variadic_construct.cc b/libstdc++-v3/testsuite/ext/new_allocator/variadic_construct.cc
new file mode 100644
index 000000000..9935af0f4
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/new_allocator/variadic_construct.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 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 <ext/new_allocator.h>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::pair<int, char> pair_type;
+ __gnu_cxx::new_allocator<pair_type> alloc1;
+
+ pair_type* ptp1 = alloc1.allocate(1);
+ alloc1.construct(ptp1, 3, 'a');
+
+ VERIFY( ptp1->first == 3 );
+ VERIFY( ptp1->second == 'a' );
+
+ alloc1.deallocate(ptp1, 1);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/numeric_traits/numeric_traits.cc b/libstdc++-v3/testsuite/ext/numeric_traits/numeric_traits.cc
new file mode 100644
index 000000000..59bfe35c2
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/numeric_traits/numeric_traits.cc
@@ -0,0 +1,27 @@
+// { dg-do compile }
+// { dg-options "-pedantic" }
+// -*- C++ -*-
+
+// Copyright (C) 2006, 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 <ext/numeric_traits.h>
+
+using __gnu_cxx::__numeric_traits;
+template struct __numeric_traits<short>;
+template struct __numeric_traits<unsigned short>;
+template struct __numeric_traits<double>;
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/assoc_container_traits.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/assoc_container_traits.cc
new file mode 100644
index 000000000..050ac3e04
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/assoc_container_traits.cc
@@ -0,0 +1,230 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file assoc_container_traits_example.cpp
+ * A basic example showing how to use container_traits for querying container types
+ * for their behavior.
+ */
+
+/**
+ * The following example shows how to use container_traits in order to print
+ * out information on an associative container's behavior, e.g., its underlying
+ * data structure, or whether its objects guarantee storing entries sorted
+ * by key order.
+ */
+
+#include <iostream>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+template<class DS_Category>
+void
+print_container_category(DS_Category);
+
+template<>
+void
+print_container_category(cc_hash_tag)
+{
+ cout << "Collision-chaining hash based associative-container:" << endl;
+}
+
+template<>
+void
+print_container_category(gp_hash_tag)
+{
+ cout << "Probing hash based associative-container:" << endl;
+}
+
+template<>
+void
+print_container_category(rb_tree_tag)
+{
+ cout << "Red-black tree associative-container:" << endl;
+}
+
+template<>
+void
+print_container_category(splay_tree_tag)
+{
+ cout << "Splay tree associative-container:" << endl;
+}
+
+template<>
+void
+print_container_category(ov_tree_tag)
+{
+ cout << "Ordered-vector tree associative-container:" << endl;
+}
+
+template<>
+void
+print_container_category(list_update_tag)
+{
+ cout << "List-based associative-container:" << endl;
+}
+
+void
+print_erase_can_throw(bool can)
+{
+ if (can)
+ {
+ cout << "Erase can throw" << endl;
+ return;
+ }
+ cout << "Erase cannot throw" << endl;
+}
+
+void
+print_order_preserving(bool does)
+{
+ if (does)
+ {
+ cout << "Preserves order" << endl;
+ return;
+ }
+ cout << "Does not preserve order" << endl;
+}
+
+template<class Invalidation_Guarantee>
+void
+print_invalidation_guarantee(Invalidation_Guarantee);
+
+template<>
+void
+print_invalidation_guarantee(basic_invalidation_guarantee)
+{
+ cout << "Guarantees only that found references, pointers, and "
+ "iterators are valid as long as the container object is not "
+ "modified" << endl;
+}
+
+template<>
+void
+print_invalidation_guarantee(point_invalidation_guarantee)
+{
+ cout << "Guarantees that found references, pointers, and "
+ "point_iterators are valid even if the container object "
+ "is modified" << endl;
+}
+
+template<>
+void
+print_invalidation_guarantee(range_invalidation_guarantee)
+{
+ cout << "Guarantees that iterators remain valid even if the "
+ "container object is modified" << endl;
+}
+
+void
+print_reverse_iteration(bool does)
+{
+ if (does)
+ {
+ cout << "Supports reverse iteration" << endl;
+ return;
+ }
+ cout << "Does not support reverse iteration" << endl;
+}
+
+template<class DS_Traits>
+void
+print_container_attributes()
+{
+ // First print out the data structure category.
+ print_container_category(typename DS_Traits::container_category());
+
+ // Now print the attributes of the container.
+ print_erase_can_throw(DS_Traits::erase_can_throw);
+ print_order_preserving(DS_Traits::order_preserving);
+ print_invalidation_guarantee(typename DS_Traits::invalidation_guarantee());
+ print_reverse_iteration(DS_Traits::reverse_iteration);
+
+ cout << endl << endl;
+}
+
+int
+main()
+{
+ {
+ // Print the attributes of a collision-chaining hash table.
+ typedef cc_hash_table< int, char> t;
+ print_container_attributes<container_traits<t> >();
+ }
+
+ {
+ // Print the attributes of a (general) probing hash table.
+ typedef gp_hash_table< int, char> t;
+ print_container_attributes<container_traits<t> >();
+ }
+
+ {
+ // Print the attributes of a red-black tree.
+ typedef tree< int, char> t;
+ print_container_attributes<container_traits<t> >();
+ }
+
+ {
+ // Print the attributes of a splay tree.
+ typedef
+ tree<
+ int,
+ char,
+ less<int>,
+ splay_tree_tag>
+ t;
+
+ print_container_attributes<container_traits<t> >();
+ }
+
+ {
+ // Print the attributes of an ordered-vector tree.
+ typedef
+ tree<
+ int,
+ char,
+ less<int>,
+ ov_tree_tag>
+ t;
+ print_container_attributes<container_traits<t> >();
+ }
+
+ {
+ // Print the attributes of an list-based container.
+ typedef list_update< int, char> t;
+ print_container_attributes<container_traits<t> >();
+ }
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/basic_map.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/basic_map.cc
new file mode 100644
index 000000000..bc629d8d7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/basic_map.cc
@@ -0,0 +1,119 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file basic_map_example.cpp
+ * A basic example showing how to use maps.
+ */
+
+/**
+ * This example shows how to use "maps". It defines a
+ * function performing a sequence of operations on
+ * a generic container. It then calls this function with some containers.
+ */
+
+#include <iostream>
+#include <cassert>
+#include <ext/pb_ds/assoc_container.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// The following function performs a sequence of operations on an
+// associative container object mapping integers to characters.
+template<class Cntnr>
+void
+some_op_sequence(Cntnr& r_c)
+{
+ assert(r_c.empty());
+ assert(r_c.size() == 0);
+
+ r_c.insert(make_pair(1, 'a'));
+
+ r_c[2] = 'b';
+
+ assert(!r_c.empty());
+ assert(r_c.size() == 2);
+
+ cout << "Key 1 is mapped to " << r_c[1] << endl;
+ cout << "Key 2 is mapped to " << r_c[2] << endl;
+
+ cout << endl << "All value types in the container:" << endl;
+
+ typedef typename Cntnr::const_iterator const_iterator;
+ for (const_iterator it = r_c.begin(); it != r_c.end(); ++it)
+ cout << it->first << " -> " << it->second << endl;
+ cout << endl;
+
+ r_c.clear();
+
+ assert(r_c.empty());
+ assert(r_c.size() == 0);
+}
+
+int main()
+{
+ {
+ // Perform operations on a collision-chaining hash map.
+ cc_hash_table<int, char> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a general-probing hash map.
+ gp_hash_table<int, char> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a red-black tree map.
+ tree<int, char> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a splay tree map.
+ tree<int, char, less<int>, splay_tree_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on an ov tree map.
+ tree<int, char, less<int>, ov_tree_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a list-update map.
+ list_update<int, char> c;
+ some_op_sequence(c);
+ }
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/basic_multimap.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/basic_multimap.cc
new file mode 100644
index 000000000..bdc423a26
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/basic_multimap.cc
@@ -0,0 +1,152 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file basic_multimap_example.cpp
+ * A basic example showing how to use multimaps.
+ */
+
+/**
+ * This example shows how to use "multimaps" in the context of a simple
+ * bank account application. Each customer holds a bank account
+ * (or more than one) which holds some balance.
+ */
+
+#include <iostream>
+#include <string>
+#include <cassert>
+#include <ext/pb_ds/assoc_container.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A simple hash functor.
+// hash could serve instead of this functor, but it is not yet
+// standard everywhere.
+struct string_hash : public unary_function<string, size_t>
+{
+ inline size_t
+ operator()(const string& r_s) const
+ {
+ size_t ret = 0;
+ string::const_iterator b = r_s.begin();
+ string::const_iterator e = r_s.end();
+ while (b != e)
+ {
+ ret *= 5;
+ ret += static_cast<size_t>(*(b++));
+ }
+ return ret;
+ }
+};
+
+int main()
+{
+ // Each customer is identified by a string.
+ typedef string customer;
+
+ // Each account is identified by an unsigned long.
+ typedef unsigned long account_id;
+
+ // The balance in the account is a floating point.
+ typedef float balance_t;
+
+ /*
+ * This is the data structure type used for storing information
+ * about accounts. In this case the primary key is the customer,
+ * and the secondary key is the account id.
+ *
+ * A hash-based container maps each customer to a list-based
+ * container that maps each account to the balance it holds.
+ *
+ * Note that we could use any combination of primary and secondary
+ * associative-containers. In this case we choose a hash-based
+ * container for the primary keys, since we do not need to store
+ * customers in a sorted order; we choos a list-based container for
+ * the secondary keys, since we expect that the average number of
+ * accounts per customer will be small.
+ */
+ typedef
+ cc_hash_table<
+ customer,
+ list_update<
+ account_id,
+ balance_t>,
+ string_hash>
+ accounts_t;
+
+ // This object will hold all information.
+ accounts_t acc;
+
+ // Customer "a" opens empty account 12.
+ acc["a"][12] = 0;
+
+ // Customer "a" deposits 45 into account 12.
+ acc["a"][12] += 45;
+
+ // Customer "b" opens account 13 with balance 12.3.
+ acc["b"][13] = 12.3;
+
+ // Customer "c" opens empty account 14.
+ acc["c"][14] = 0;
+
+ // Customer "a" opens account 160 with balance 142.
+ // Note that "a" already holds account 12.
+ acc["a"][160] = 142;
+
+ // Verify the number of accounts that "a" holds.
+ accounts_t::const_point_iterator it = acc.find("a");
+ assert(it != acc.end());
+ assert(it->second.size() == 2);
+
+ // The begining of the month has arrived. We need to give a 3%
+ // interest to all accounts with a positive balance.
+
+ // First we loop over all customers.
+ accounts_t::iterator cust_it;
+ for (cust_it = acc.begin(); cust_it != acc.end(); ++cust_it)
+ {
+ // For each customer, we loop over the customer's accounts.
+ accounts_t::mapped_type::iterator it;
+ for (it = cust_it->second.begin(); it != cust_it->second.end(); ++it)
+ if (it->second > 0)
+ it->second *= 1.03;
+ }
+
+ // Customer "a" closes all accounts.
+ acc.erase("a");
+
+ // The bank now has only 2 customers.
+ assert(acc.size() == 2);
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/basic_multiset.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/basic_multiset.cc
new file mode 100644
index 000000000..1127f7591
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/basic_multiset.cc
@@ -0,0 +1,165 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file basic_multiset_example.cpp
+ * A basic example showing how to use multisets.
+ */
+
+
+// This example shows how to use "multisets".
+
+// In this example we build a very simple priority queue that also can
+// be queried if an entry contains (i.e., it is slightly similar to an
+// associative container as well as a priority queue). The priority
+// queue adapts a "multiset".
+
+// (Note that there are more efficient ways for implementing this than
+// by adapting an associative container. This is just an example for
+// "multisets".)
+
+#include <iostream>
+#include <cassert>
+#include <ext/pb_ds/assoc_container.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A simple priority queue that also supports an "contains" query.
+class contains_pq
+{
+public:
+ // Pushes an integer.
+ void
+ push(int i);
+
+ // Pops the largest integer and returns it.
+ int
+ pop();
+
+ // Returns true iff i is contained in the container.
+ bool
+ contains(int i) const
+ { return m_tree.find(i) != m_tree.end(); }
+
+ // Returns true iff empty.
+ bool
+ empty() const
+ { return m_tree.empty(); }
+
+private:
+ // This is the container type we adapt - a "multiset".
+ // It maps each integer to the number of times it logically appears.
+ typedef
+ tree<
+ int,
+ size_t,
+ greater<
+ int> >
+ tree_t;
+
+private:
+ tree_t m_tree;
+};
+
+void
+contains_pq::
+push(int i)
+{
+ // To push i, we insert to the "multiset" that i appears 0 times
+ // (which is a no-op if i already is contained), then increment the
+ // number of times i is contained by 1.
+ ++m_tree.insert(make_pair(i, 0)).first->second;
+}
+
+int
+contains_pq::
+pop()
+{
+ assert(!empty());
+
+ // The element we need to pop must be the first one, since tree_t is
+ // an ordered container.
+ tree_t::iterator it = m_tree.begin();
+
+ const int i = it->first;
+
+ // Decrease the number of times the popped element appears in the
+ // container object. If it is 0 - we erase it.
+ if (--it->second == 0)
+ m_tree.erase(it);
+
+ return i;
+}
+
+int main()
+{
+ contains_pq cpq;
+
+ // First we push some elements.
+ cpq.push(4);
+ cpq.push(3);
+ cpq.push(2);
+ cpq.push(1);
+ cpq.push(4);
+
+ // Note that logically, 4 appears 2 times, and each of 1, 2, and 3
+ // appear once.
+ assert(cpq.contains(4));
+ assert(cpq.contains(3));
+ assert(cpq.contains(2));
+ assert(cpq.contains(1));
+
+ // Now pop the topmost element - it should be 4.
+ assert(cpq.pop() == 4);
+
+ // Now logically, each of 1, 2, 3, and 4 appear once.
+ assert(cpq.contains(4));
+
+ // We pop the topmost element - it should be 4.
+ assert(cpq.pop() == 4);
+
+ // 4 should not be contained any more.
+ assert(!cpq.contains(4));
+
+ assert(cpq.contains(3));
+ assert(cpq.contains(2));
+ assert(cpq.contains(1));
+
+ assert(cpq.pop() == 3);
+ assert(cpq.pop() == 2);
+ assert(cpq.pop() == 1);
+
+ assert(cpq.empty());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/basic_priority_queue.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/basic_priority_queue.cc
new file mode 100644
index 000000000..24ebe2e28
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/basic_priority_queue.cc
@@ -0,0 +1,119 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file basic_priority_queue_example.cpp
+ * A basic example showing how to use priority queues.
+ */
+
+/**
+ * This example shows how to use priority queues. It defines a
+ * function performing a sequence of operations on
+ * a generic container. It then calls this function with some containers.
+ */
+
+#include <cassert>
+#include <iostream>
+#include <ext/pb_ds/priority_queue.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// The following function performs a sequence of operations on a
+// priority queue object storing integers.
+template<class Cntnr>
+void
+some_op_sequence(Cntnr& r_c)
+{
+ assert(r_c.empty());
+ assert(r_c.size() == 0);
+
+ for (size_t i = 0; i < 10; ++i)
+ r_c.push(i);
+ cout << endl << "All values in the container:" << endl;
+
+ typedef typename Cntnr::const_iterator const_iterator;
+ for (const_iterator it = r_c.begin(); it != r_c.end(); ++it)
+ cout <<* it << endl;
+ assert(!r_c.empty());
+ assert(r_c.size() == 10);
+
+ cout << "Popping all values: " << endl;
+ while (!r_c.empty())
+ {
+ cout << r_c.top() << endl;
+ r_c.pop();
+ }
+ assert(r_c.empty());
+ assert(r_c.size() == 0);
+
+ cout << endl;
+}
+
+int main()
+{
+ {
+ // Perform operations on a pairing-heap queue.
+ cout << "Pairing heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, pairing_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a binomial-heap queue.
+ cout << "Binomial heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, binomial_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a binomial-heap queue.
+ cout << "Redundant-counter binomial heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, rc_binomial_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a binomial-heap queue.
+ cout << "Binary heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, binary_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a thin-heap queue.
+ cout << "Thin heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, thin_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/basic_set.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/basic_set.cc
new file mode 100644
index 000000000..3d2cf14db
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/basic_set.cc
@@ -0,0 +1,126 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file basic_set_example.cpp
+ * A basic example showing how to use sets.
+ */
+
+/**
+ * This example shows how to use "sets". It defines a
+ * function performing a sequence of operations on
+ * a generic container. It then calls this function with some containers.
+ */
+
+#include <iostream>
+#include <cassert>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// The following function performs a sequence of operations on an
+// associative container object storing integers.
+template<class Cntnr>
+void
+some_op_sequence(Cntnr& r_c)
+{
+ assert(r_c.empty());
+ assert(r_c.size() == 0);
+
+ r_c.insert(1);
+ r_c.insert(2);
+
+ assert(!r_c.empty());
+ assert(r_c.size() == 2);
+
+ cout << "All value types in the container:" << endl;
+ for (typename Cntnr::const_iterator it = r_c.begin(); it != r_c.end();
+ ++it)
+ cout <<* it << " ";
+
+ cout << endl;
+
+ r_c.clear();
+
+ assert(r_c.empty());
+ assert(r_c.size() == 0);
+}
+
+int main()
+{
+ {
+ // Perform operations on a collision-chaining hash set.
+ cc_hash_table<int, null_mapped_type> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a general-probing hash set.
+ gp_hash_table<int, null_mapped_type> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a red-black tree set.
+ tree<int, null_mapped_type> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a splay tree set.
+ tree<
+ int,
+ null_mapped_type,
+ less<int>,
+ splay_tree_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a splay tree set.
+ tree<
+ int,
+ null_mapped_type,
+ less<int>,
+ ov_tree_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a list-update set.
+ list_update<int, null_mapped_type> c;
+ some_op_sequence(c);
+ }
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/erase_if.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/erase_if.cc
new file mode 100644
index 000000000..3f14f6d08
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/erase_if.cc
@@ -0,0 +1,122 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file erase_if_example.cpp
+ * A basic example showing how to use erase_if.
+ */
+
+/**
+ * The following example shows how to use a conditional-erase
+ * method of associative containers to erase some of their entries.
+ */
+
+#include <iostream>
+#include <cassert>
+#include <ext/pb_ds/assoc_container.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// The following functor takes a map's value-type object and returns
+// whether its key is between two numbers.
+struct between : public unary_function<pair<const int, char>, bool>
+{
+ // Constructor taking two numbers determining a range.
+ between(int b, int e) : m_b(b), m_e(e)
+ { assert(m_b < m_e); }
+
+ // Operator determining whether a value-type object's key is within
+ // the range.
+ inline bool
+ operator()(const pair<const int, char>& r_val)
+ { return r_val.first >= m_b&& r_val.first < m_e; }
+
+private:
+ const int m_b;
+ const int m_e;
+};
+
+/**
+ * The following function performs a sequence of operations on an
+ * associative container object mapping integers to characters. Specifically
+ * it inserts 100 values and then uses a conditional-erase method to erase
+ * the values whose key is between 10 and 90.
+ */
+template<class Cntnr>
+void
+some_op_sequence(Cntnr r_c)
+{
+ assert(r_c.empty());
+ assert(r_c.size() == 0);
+
+ for (int i = 0; i < 100; ++i)
+ r_c.insert(make_pair(i, static_cast<char>(i)));
+ assert(r_c.size() == 100);
+
+ // Erase all values whose key is between 10 (inclusive) and 90
+ // (non-inclusive).
+ r_c.erase_if(between(10 , 90));
+
+ assert(!r_c.empty());
+ assert(r_c.size() == 20);
+}
+
+int main()
+{
+ // Perform operations on a list-update set.
+ some_op_sequence(list_update<int, char>());
+
+ // Perform operations on a collision-chaining hash set.
+ some_op_sequence(cc_hash_table<int, char>());
+
+ // Perform operations on a general-probing hash set.
+ some_op_sequence(gp_hash_table<int, char>());
+
+ // Perform operations on a red-black tree set.
+ some_op_sequence(tree<int, char>());
+
+ // Perform operations on a splay tree set.
+ some_op_sequence(tree<
+ int,
+ char,
+ less<int>,
+ splay_tree_tag>());
+
+ // Perform operations on a splay tree set.
+ some_op_sequence(tree<
+ int,
+ char,
+ less<int>,
+ ov_tree_tag>());
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/hash_find_neg.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_find_neg.cc
new file mode 100644
index 000000000..e2781a03e
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_find_neg.cc
@@ -0,0 +1,69 @@
+// { dg-do compile }
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_bad_find_example.cpp
+ * An example showing how *not* to use unordered containers.
+ */
+
+/**
+ * This non-compiling example shows wrong use of unordered
+ * associative-containers. These types of containers have distinct
+ * point-type and range-type iterator types.
+ **/
+
+#include <utility>
+#include <ext/pb_ds/assoc_container.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+int main()
+{
+ // A collision-chaining hash table mapping ints to chars.
+ typedef cc_hash_table<int, char> map_t;
+
+ // A map_t object.
+ map_t h;
+
+ // Insert a value mapping the int 1 to the char 'a'.
+ h.insert(make_pair(1, 'a'));
+
+ // Find the entry of the key '1' the* wrong* way.
+ // The following line will not compile, since map_t::find returns a
+ // point-iterator, which, by design, is not convertible to a
+ // range-iterator.
+ map_t::iterator it = h.find(1); // { dg-error "conversion from" }
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/hash_illegal_resize.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_illegal_resize.cc
new file mode 100644
index 000000000..3b239d43c
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_illegal_resize.cc
@@ -0,0 +1,135 @@
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009, 2011 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_illegal_resize_example.cpp
+ * An example of illegally externally resizing a hash-based container object.
+ */
+
+/**
+ * This example shows the case where a hash-based container object is
+ * resized to a value which it cannot accomodate at runtime. Illegal
+ * runtime resizes cause an exception.
+ */
+
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/hash_policy.hpp>
+#include <ext/pb_ds/exception.hpp>
+#include <cassert>
+
+// size of test containers
+#ifdef _GLIBCXX_DEBUG
+# define SIZE 100
+# define RESIZE 20
+#else
+# define SIZE 1000
+# define RESIZE 200
+#endif
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A simple hash functor.
+// hash could serve instead of this functor, but it is not yet
+// standard everywhere.
+struct int_hash : public unary_function<int, size_t>
+{
+ inline size_t
+ operator()(const int& r_i) const
+ { return r_i; }
+};
+
+
+int main()
+{
+ // A probing hash table mapping ints to chars.
+ typedef
+ gp_hash_table<
+ int,
+ int,
+ int_hash,
+ equal_to<int>,
+ // Combining function.
+ direct_mod_range_hashing<>,
+ // Probe function.
+ quadratic_probe_fn<>,
+ // Resize policy.
+ hash_standard_resize_policy<
+ hash_prime_size_policy,
+ hash_load_check_resize_trigger<>,
+ /* Allow external access to size.
+ * Without setting this to true, external resizing
+ * is not possible.
+ */
+ true> >
+ map_t;
+
+ map_t g;
+
+ // Insert some elements.
+ int i;
+
+ for (i = 0; i < SIZE; ++i)
+ g[i] = 2* i;
+
+ // Check all ok.
+ assert(g.size() == SIZE);
+ for (i = 0; i < SIZE; ++i)
+ assert(g.find(i) != g.end() && g.find(i)->second == 2 * i);
+
+ // Now attempt to resize the table to 200 (impossible).
+ bool ex_thrown = false;
+
+ try
+ {
+ g.resize(RESIZE);
+ }
+ catch(__gnu_pbds::resize_error& )
+ {
+ ex_thrown = true;
+ }
+
+ // Assert an exception was thrown. A probing table cannot contain
+ // 1000 entries in less than 1000 places.
+ assert(ex_thrown);
+
+ // Irrespective of the fact that the resize was not successful, the
+ // container object should still be in a valid state; the following
+ // checks this.
+ // Check all ok.
+ assert(g.size() == SIZE);
+ for (i = 0; i < SIZE; ++i)
+ assert(g.find(i) != g.end() && g.find(i)->second == 2 * i);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/hash_initial_size.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_initial_size.cc
new file mode 100644
index 000000000..4efe8aae8
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_initial_size.cc
@@ -0,0 +1,110 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_initial_size_example.cpp
+ * An example of setting an initial size for a container object.
+ */
+
+/**
+ * This example shows how to set the initial size of a hash-based
+ * container object through its resize-policy object.
+ */
+
+#include <cassert>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/hash_policy.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A simple hash functor.
+// hash could serve instead of this functor, but it is not yet
+// standard everywhere.
+struct int_hash : public unary_function<int, size_t>
+{
+ inline size_t
+ operator()(const int& r_i) const
+ { return r_i; }
+};
+
+int main()
+{
+ // Resize policy type.
+ typedef
+ hash_standard_resize_policy<
+ // Size-policy type.
+ hash_exponential_size_policy<>,
+ // Trigger-policy type.
+ hash_load_check_resize_trigger<>,
+ /* Allow external access to size.
+ * This is just used in this example for using the
+ * get_actual_size method (which won't be accessible without
+ * this flag.
+ */
+ true>
+ resize_policy_t;
+
+ // A collision-probing hash table mapping ints to chars.
+ typedef
+ gp_hash_table<
+ int,
+ char,
+ int_hash,
+ equal_to<
+ int>,
+ // Combining function.
+ direct_mask_range_hashing<>,
+ // Probe function.
+ linear_probe_fn<>,
+ // Resize policy.
+ resize_policy_t>
+ map_t;
+
+ // A resize-policy object with suggested initial size 256.
+ resize_policy_t res(hash_exponential_size_policy<>(256));
+
+ map_t g(int_hash(),
+ equal_to<int>(),
+ direct_mask_range_hashing<>(),
+ linear_probe_fn<>(),
+ res);
+
+ // Check the actual size of the container object. In this case, this
+ // should be the initial size given by the size policy object.
+ assert(g.get_actual_size() == 256);
+
+ // The logical size of g, though is 0 (it does not contain any elements).
+ assert(g.size() == 0);
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/hash_load_set_change.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_load_set_change.cc
new file mode 100644
index 000000000..0251060e7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_load_set_change.cc
@@ -0,0 +1,131 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_load_set_change_example.cpp
+ * An example of setting and changing the load factor of a hash-based
+ * container object.
+ */
+
+/**
+ * This example shows how to set and change the load-factor of
+ * a hash-based container object through its resize-policy object.
+ */
+
+#include <functional>
+#include <cassert>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/hash_policy.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A simple hash functor.
+// hash could serve instead of this functor, but it is not yet
+// standard everywhere.
+struct int_hash : public unary_function<int, size_t>
+{
+ inline size_t
+ operator()(int i) const
+ { return i; }
+};
+
+int main()
+{
+ // A trigger policy type.
+ typedef hash_load_check_resize_trigger< true> trigger_t;
+
+ // A resize policy type.
+ typedef
+ hash_standard_resize_policy<
+ hash_exponential_size_policy<>,
+ // Trigger type.
+ trigger_t,
+ /* Allow external access to size.
+ * This is not necessary for setting the load factor,
+ * but it allows to call get_actual_size.
+ */
+ true>
+ resize_t;
+
+ // A collision-chaining hash table mapping ints to chars.
+ typedef
+ cc_hash_table<
+ int,
+ char,
+ int_hash,
+ equal_to<int>,
+ // Combining function.
+ direct_mask_range_hashing<>,
+ // Resize policy.
+ resize_t>
+ map_t;
+
+ // A trigger policy object with load between 0.3 and 0.8.
+ trigger_t trigger(static_cast<float>(0.3), static_cast<float>(0.8));
+
+ // A resize policy object with the above trigger.
+ resize_t resize(hash_exponential_size_policy<>(),
+ trigger);
+
+ map_t r_c(int_hash(),
+ equal_to<int>(),
+ direct_mask_range_hashing<>(),
+ resize);
+
+ r_c[1] = 'a';
+
+ // Check the loads and sizes.
+ assert(r_c.get_loads().first == static_cast<float>(0.3));
+ assert(r_c.get_loads().second == static_cast<float>(0.8));
+ assert(r_c.get_actual_size() == 8);
+ assert(r_c.size() == 1);
+
+ // Note that there is a discrepancy between the loads of the policy
+ // object and the actual size of the container object. This is
+ // because the container's construction performs an implicit
+ // external resize.
+ r_c[2] = 'b';
+ r_c[3] = 'c';
+ r_c[4] = 'd';
+
+ assert(r_c.get_actual_size() == 8);
+
+ // Change the loads. This causes (potentially) a resize.
+ r_c.set_loads(make_pair(static_cast<float>(0.01),
+ static_cast<float>(0.05)));
+
+ // The actual size should really change in this case.
+ assert(r_c.get_actual_size() > 8);
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/hash_mod.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_mod.cc
new file mode 100644
index 000000000..3d3f27b21
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_mod.cc
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_mod_example.cpp
+ * An example showing how to use a mod range-hasing function
+ */
+
+/**
+ * This example shows how to use a hash-based container employing
+ * a modulo-based range-hashing function.
+ */
+
+#include <functional>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/hash_policy.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A simple hash functor.
+// hash could serve instead of this functor, but it is not yet
+// standard everywhere.
+struct int_hash : public unary_function<int, size_t>
+{
+ inline size_t
+ operator()(int i) const
+ { return i; }
+};
+
+int main()
+{
+ // In this case, we are worried that the key distribution will be
+ // skewed. We wish to use a more robust combining function.
+
+ // A collision-chaining hash table mapping ints to chars.
+ typedef
+ cc_hash_table<
+ int,
+ char,
+ int_hash,
+ equal_to<int>,
+ // Combining function.
+ direct_mod_range_hashing<> >
+ map_t;
+
+ map_t r_c;
+
+ // Use regularly.
+ r_c[32] = 'b';
+ r_c[1024] = 'c';
+ r_c[4096] = 'd';
+
+ // The above keys are all powers of 2. A mask combining function
+ // would hamper performance in such a case.
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/hash_resize.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_resize.cc
new file mode 100644
index 000000000..8dcf878e6
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_resize.cc
@@ -0,0 +1,125 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_resize_example.cpp
+ * An example of externally resizing a map.
+ */
+
+/**
+ * This example shows how to externally manipulate the size of a hash-based
+ * container object throught its resize-policy object.
+ **/
+
+#include <functional>
+#include <cassert>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/hash_policy.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A simple hash functor.
+// hash could serve instead of this functor, but it is not yet
+// standard everywhere.
+struct int_hash : public unary_function<int, size_t>
+{
+ inline size_t
+ operator()(const int& r_i) const
+ { return r_i; }
+};
+
+int main()
+{
+ // A probing hash table mapping ints to chars.
+ typedef
+ gp_hash_table<
+ int,
+ char,
+ int_hash,
+ equal_to<
+ int>,
+ // Combining function.
+ direct_mask_range_hashing<>,
+ // Probe function.
+ linear_probe_fn<>,
+ // Resize policy.
+ hash_standard_resize_policy<
+ hash_exponential_size_policy<>,
+ hash_load_check_resize_trigger<>,
+ /* Allow external access to size.
+ * Without setting this to true, external resizing
+ * is not possible.
+ */
+ true> >
+ map_t;
+
+ map_t g;
+
+ // Check the actual size of the container object. In this case, this
+ // should be the initial size given by the size policy object.
+ assert(g.get_actual_size() == 8);
+
+ // Insert some elements.
+ g[1] = 'a';
+ g[2] = 'b';
+ g[3] = 'c';
+
+ // Now resize the table upward.
+ g.resize(200);
+
+ // Check the actual size of the container object.
+ // For the policy used in this example, the nearest larger size than
+ // 200 is 256.
+ assert(g.get_actual_size() == 256);
+
+ g[67] = 'g';
+ g[22] = 'f';
+
+ // Regardless of the internal size, the logical size should be 5.
+ assert(g.size() == 5);
+
+ // Now resize the table downward.
+ g.resize(106);
+
+ // Check the actual size of the container object.
+ // For the policy used in this example, the nearest larger size than
+ // 106 is 128.
+ assert(g.get_actual_size() == 128);
+
+ g[37] = 'f';
+
+ // Regardless of the internal size, the logical size should be 5.
+ assert(g.size() == 6);
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/hash_resize_neg.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_resize_neg.cc
new file mode 100644
index 000000000..9577dfbc0
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_resize_neg.cc
@@ -0,0 +1,63 @@
+// { dg-do compile }
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2007, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_bad_resize_example.cpp
+ * An example showing how *not* to resize a hash-based container.
+ */
+
+/**
+ * This non-compiling example shows wrong use of hash-based
+ * containers. By default, resize policies don't allow external size
+ * access.
+ **/
+
+#include <ext/pb_ds/assoc_container.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+int main()
+{
+ // A collision-chaining hash table mapping ints to chars.
+ typedef cc_hash_table< int, char> map_t;
+
+ // A map_t object.
+ map_t h;
+
+ // The following line won't compile. The resize policy needs to be
+ // configured to allow external resize (by default, this is not
+ // available).
+ h.resize(20); // { dg-error "instantiated from" }
+}
+
+// { dg-error "invalid" "" { target *-*-* } 187 }
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/hash_shift_mask.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_shift_mask.cc
new file mode 100644
index 000000000..1abe25f67
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/hash_shift_mask.cc
@@ -0,0 +1,108 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_shift_mask_example.cpp
+ * An example showing how to write a range-hasing functor.
+ */
+
+/**
+ * In some rare cases, advance knowledge of the distribution of keys allows
+ * writing more efficient hash-related policies.
+ * In the rather simplistic case of the example, it is known in advance that
+ * all keys have 0 two lowest bits. The example shows how to write
+ * a range-hashing function disregarding the two lowest bits of the hash value.
+ */
+
+#include <functional>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/hash_policy.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A simple hash functor. hash could serve instead of this functor,
+// but it is not yet standard everywhere.
+struct simple_int_hash : public unary_function<int, size_t>
+{
+ inline size_t
+ operator()(int i) const
+ { return i; }
+};
+
+// A range-hashing function which shifts 2 bits right and then masks.
+class shift_two_mask_range_hashing : private direct_mask_range_hashing<>
+{
+public:
+ typedef size_t size_type;
+
+ // Swaps with a different instant.
+ void
+ swap(shift_two_mask_range_hashing& other)
+ { direct_mask_range_hashing<>::swap(other); }
+
+ // Called by the container when internally resized.
+ void
+ notify_resized(size_type size)
+ { direct_mask_range_hashing<>::notify_resized(size); }
+
+ // Given a hash value, returns a number in the range of the internal
+ // size of the container.
+ inline size_type
+ operator()(size_type hash) const
+ { return direct_mask_range_hashing<>::operator()(hash >> 2); }
+};
+
+int
+main()
+{
+ // A collision-chaining hash table mapping ints to chars.
+ typedef
+ cc_hash_table<
+ int,
+ char,
+ // Hash function.
+ simple_int_hash,
+ equal_to<int>,
+ // Range hashing function.
+ shift_two_mask_range_hashing>
+ map_t;
+
+ map_t h;
+
+ // Use normally.
+ h[16] = 'a';
+ h[256] = 'e';
+ h[4] = 'z';
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_container_traits.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_container_traits.cc
new file mode 100644
index 000000000..007c19f43
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_container_traits.cc
@@ -0,0 +1,200 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_container_traits_example.cpp
+ * A basic example showing how to use container_traits for querying container types
+ * for their behavior.
+ */
+
+/**
+ * The following example shows how to use container_traits in order to print
+ * out information on an priority queue's behavior, e.g., its underlying
+ * data structure.
+ */
+
+#include <iostream>
+#include <ext/pb_ds/priority_queue.hpp>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+template<class DS_Category>
+void
+print_container_category(DS_Category);
+
+template<>
+void
+print_container_category(binary_heap_tag)
+{ cout << "Binary heap:" << endl; }
+
+template<>
+void
+print_container_category(binomial_heap_tag)
+{ cout << "Binomial heap:" << endl; }
+
+template<>
+void
+print_container_category(rc_binomial_heap_tag)
+{ cout << "Redundant-counter binomial heap:" << endl; }
+
+template<>
+void
+print_container_category(pairing_heap_tag)
+{ cout << "Pairing heap:" << endl; }
+
+template<>
+void
+print_container_category(thin_heap_tag)
+{ cout << "Thin heap:" << endl; }
+
+template<class Invalidation_Guarantee>
+void
+print_invalidation_guarantee(Invalidation_Guarantee);
+
+template<>
+void
+print_invalidation_guarantee(basic_invalidation_guarantee)
+{
+ cout << "Guarantees only that found references, pointers, and "
+ "iterators are valid as long as the container object is not "
+ "modified" << endl;
+}
+
+template<>
+void
+print_invalidation_guarantee(point_invalidation_guarantee)
+{
+ cout << "Guarantees that found references, pointers, and "
+ "point_iterators are valid even if the container object "
+ "is modified" << endl;
+}
+
+template<>
+void
+print_invalidation_guarantee(range_invalidation_guarantee)
+{
+ cout << "Guarantees that iterators remain valid even if the "
+ "container object is modified" << endl;
+}
+
+void
+print_split_join_can_throw(bool can)
+{
+ if (can)
+ {
+ cout << "Can throw exceptions if split or joined" << endl;
+ return;
+ }
+ cout << "Cannot throw exceptions if split or joined" << endl;
+}
+
+template<class DS_Traits>
+void
+print_container_attributes()
+{
+ // First print out the data structure category.
+ print_container_category(typename DS_Traits::container_category());
+
+ // Now print the attributes of the container.
+ print_invalidation_guarantee(typename DS_Traits::invalidation_guarantee());
+ print_split_join_can_throw(DS_Traits::split_join_can_throw);
+ cout << endl << endl;
+}
+
+int main()
+{
+ {
+ // Print the attributes of a binary heap.
+ typedef
+ __gnu_pbds::priority_queue<
+ int,
+ std::less<int>,
+ binary_heap_tag>
+ t;
+
+ print_container_attributes<container_traits<t> >();
+ }
+
+ {
+ // Print the attributes of a binomial heap.
+ typedef
+ __gnu_pbds::priority_queue<
+ int,
+ std::less<int>,
+ binomial_heap_tag>
+ t;
+
+ print_container_attributes<container_traits<t> >();
+ }
+
+ {
+ // Print the attributes of a redundant-counter binomial heap.
+ typedef
+ __gnu_pbds::priority_queue<
+ int,
+ std::less<int>,
+ rc_binomial_heap_tag>
+ t;
+
+ print_container_attributes<container_traits<t> >();
+ }
+
+ {
+ // Print the attributes of a pairing heap.
+ typedef
+ __gnu_pbds::priority_queue<
+ int,
+ std::less<int>,
+ pairing_heap_tag>
+ t;
+
+ print_container_attributes<container_traits<t> >();
+ }
+
+ {
+ /**
+ * Print the attributes of a thin heap.
+ */
+
+ typedef
+ __gnu_pbds::priority_queue<
+ int,
+ std::less<int>,
+ thin_heap_tag>
+ t;
+
+ print_container_attributes<container_traits<t> >();
+ }
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_dijkstra.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_dijkstra.cc
new file mode 100644
index 000000000..74fdc0e62
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_dijkstra.cc
@@ -0,0 +1,157 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_dijkstra_example.cpp
+ * A basic example showing how to cross reference a vector and a
+ * priority-queue for modify.
+ */
+
+/**
+ * This example shows how to cross-reference priority queues
+ * and a vector. I.e., using a vector to
+ * map keys to entries in a priority queue, and using the priority
+ * queue to map entries to the vector. The combination
+ * can be used for fast modification of keys.
+ *
+ * As an example, a very simple form of Diskstra's algorithm is used. The graph
+ * is represented by an adjacency matrix. Nodes and vertices are size_ts, and
+ * it is assumed that the minimal path between any two nodes is less than 1000.
+ */
+
+
+
+#include <vector>
+#include <iostream>
+#include <ext/pb_ds/priority_queue.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// The value type of the priority queue.
+// The first entry is the node's id, and the second is the distance.
+typedef std::pair<size_t, size_t> pq_value;
+
+// Comparison functor used to compare priority-queue value types.
+struct pq_value_cmp : public binary_function<pq_value, pq_value, bool>
+{
+ inline bool
+ operator()(const pq_value& r_lhs, const pq_value& r_rhs) const
+ {
+ // Note that a value is considered smaller than a different value
+ // if its distance is* larger*. This is because by STL
+ // conventions, "larger" entries are nearer the top of the
+ // priority queue.
+ return r_rhs.second < r_lhs.second;
+ }
+};
+
+int main()
+{
+ enum
+ {
+ // Number of vertices is hard-coded in this example.
+ num_vertices = 5,
+ // "Infinity".
+ graph_inf = 1000
+ };
+
+ // The edge-distance matrix.
+ // For example, the distance from node 0 to node 1 is 5, and the
+ // distance from node 1 to node 0 is 2.
+ const size_t a_a_edge_legnth[num_vertices][num_vertices] =
+ {
+ {0, 5, 3, 7, 6},
+ {2, 0, 2, 8, 9},
+ {2, 1, 0, 8, 0},
+ {1, 8, 3, 0, 2},
+ {2, 3, 4, 2, 0}
+ };
+
+ // The priority queue type.
+ typedef __gnu_pbds::priority_queue< pq_value, pq_value_cmp> pq_t;
+
+ // The priority queue object.
+ pq_t p;
+
+ // This vector contains for each node, a find-iterator into the
+ // priority queue.
+ vector<pq_t::point_iterator> a_it;
+
+ // First we initialize the data structures.
+
+ // For each node, we push into the priority queue a value
+ // identifying it with a distance of infinity.
+ for (size_t i = 0; i < num_vertices; ++i)
+ a_it.push_back(p.push(pq_value(i, graph_inf)));
+
+ // Now we take the initial node, in this case 0, and modify its
+ // distance to 0.
+ p.modify(a_it[0], pq_value(0, 0));
+
+ // The priority queue contains all vertices whose final distance has
+ // not been determined, so to finish the algorithm, we must loop
+ // until it is empty.
+ while (!p.empty())
+ {
+ // First we find the node whose distance is smallest.
+ const pq_value& r_v = p.top();
+ const size_t node_id = r_v.first;
+ const size_t dist = r_v.second;
+
+ // This is the node's final distance, so we can print it out.
+ cout << "The distance from 0 to " << node_id
+ << " is " << dist << endl;
+
+ // Now we go over the node's neighbors and "relax" the
+ // distances, if applicable.
+ for (size_t neighbor_i = 0; neighbor_i < num_vertices; ++neighbor_i)
+ {
+ // Potentially, the distance to the neighbor is the distance
+ // to the currently-considered node + the distance from this
+ // node to the neighbor.
+ const size_t pot_dist = dist + a_a_edge_legnth[node_id][neighbor_i];
+
+ if (a_it[neighbor_i] == a_it[0])
+ continue;
+
+ // "Relax" the distance (if appropriate) through modify.
+ if (pot_dist < a_it[neighbor_i]->second)
+ p.modify(a_it[neighbor_i], pq_value(neighbor_i, pot_dist));
+ }
+
+ // Done with the node, so we pop it.
+ a_it[node_id] = a_it[0];
+ p.pop();
+ }
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_erase_if.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_erase_if.cc
new file mode 100644
index 000000000..0f3ca1fb4
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_erase_if.cc
@@ -0,0 +1,67 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_erase_if.cpp
+ * Example showing how to conditionally erase values from a priority queue.
+ */
+
+/**
+ * This example shows how to erase from a priority queue using erase_if.
+ */
+
+#include <functional>
+#include <iostream>
+#include <cassert>
+#include <ext/pb_ds/priority_queue.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+int
+main()
+{
+ __gnu_pbds::priority_queue<int> p;
+
+ // First we insert some values into the container.
+ for (int i = 0; i < 1000; ++i)
+ p.push(i);
+
+ assert(p.top() == 999);
+
+ // Now we erase all values that satisfy some predicate, in this case
+ // one that returns true for all those larger than 500.
+ p.erase_if(bind1st(less<int>(), 500));
+
+ // The largest value should be now 500.
+ assert(p.top() == 500);
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_split_join.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_split_join.cc
new file mode 100644
index 000000000..c2d83c0b2
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_split_join.cc
@@ -0,0 +1,124 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_split_join_example.cpp
+ * A basic example showing how to split and join priority queues.
+ */
+
+/**
+ * This example shows how to split and join priority queues.
+ */
+
+#include <functional>
+#include <iostream>
+#include <cassert>
+#include <ext/pb_ds/priority_queue.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+int
+main()
+{
+ // Two priority queue objects.
+ __gnu_pbds::priority_queue<int> even_p, odd_p;
+
+ // First we insert some values: even ones into even_p, and odd ones
+ // into odd_p.
+ for (size_t i = 0; i < 10; ++i)
+ {
+ even_p.push(2* i);
+ odd_p.push(2* i + 1);
+ }
+
+ // Check that each one contains the appropriate 10 values.
+ assert(even_p.size() == 10);
+ assert(even_p.top() == 18);
+
+ // Print out the values.
+ cout << "Initial values in even priority queue:" << endl;
+ __gnu_pbds::priority_queue<int>::const_iterator it;
+ for (it = even_p.begin(); it != even_p.end(); ++it)
+ cout <<* it << endl;
+
+ assert(odd_p.size() == 10);
+ assert(odd_p.top() == 19);
+
+ // Print out the values.
+ cout << "Initial values in odd priority queue:" << endl;
+ for (it = odd_p.begin(); it != odd_p.end(); ++it)
+ cout <<* it << endl;
+
+ // Now join the queues.
+ even_p.join(odd_p);
+
+ // Check that each one contains the appropriate values.
+
+ assert(even_p.size() == 20);
+ assert(even_p.top() == 19);
+
+ // Print out the values.
+ cout << "After-join values in even priority queue:" << endl;
+ for (it = even_p.begin(); it != even_p.end(); ++it)
+ cout <<* it << endl;
+
+ assert(odd_p.size() == 0);
+
+ // Print out the values.
+ cout << "After-join values in odd priority queue:" << endl;
+ for (it = odd_p.begin(); it != odd_p.end(); ++it)
+ cout <<* it << endl;
+
+ // Now split the queues.
+ even_p.split(bind2nd(modulus<int>(), 2), odd_p);
+
+ // Check that each one contains the appropriate 10 values.
+
+ assert(even_p.size() == 10);
+ assert(even_p.top() == 18);
+
+ // Print out the values.
+ cout << "After-split values in even priority queue:" << endl;
+ for (it = even_p.begin(); it != even_p.end(); ++it)
+ cout <<* it << endl;
+
+ assert(odd_p.size() == 10);
+ assert(odd_p.top() == 19);
+
+ // Print out the values.
+ cout << "After-split values in odd priority queue:" << endl;
+ for (it = odd_p.begin(); it != odd_p.end(); ++it)
+ cout <<* it << endl;
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_xref.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_xref.cc
new file mode 100644
index 000000000..690814091
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/priority_queue_xref.cc
@@ -0,0 +1,210 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2007, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_xref_example.cpp
+ * A basic example showing how to cross-reference priority queues and other
+ * containers for erase.
+ */
+
+/**
+ * This example shows how to cross-reference priority queues
+ * and other containers. I.e., using an associative container to
+ * map keys to entries in a priority queue, and using the priority
+ * queue to map entries to the associative container. The combination
+ * can be used for fast operations involving both priorities and
+ * arbitrary keys.
+ *
+ * The most useful examples of this technique are usually from the
+ * field of graph algorithms (where erasing or modifying an arbitrary
+ * entry of a priority queue is sometimes necessary), but a full-blown
+ * example would be too long. Instead, this example shows a very simple
+ * version of Dijkstra's
+ */
+
+#include <iostream>
+#include <cassert>
+#include <ext/pb_ds/priority_queue.hpp>
+#include <ext/pb_ds/assoc_container.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A priority queue of integers, which supports fast pushes,
+// duplicated-int avoidance, and arbitrary-int erases.
+class mapped_priority_queue
+{
+public:
+
+ // Pushes an int into the container. If the key is already in, this
+ // is a no-op.
+ void
+ push(const int& r_str);
+
+ // Returns a const reference to the largest int in the container.
+ int
+ top() const
+ {
+ assert(!empty());
+ return m_pq.top();
+ }
+
+ // Erases the largest int in the container.
+ void
+ pop();
+
+ // Erases an arbitrary int. If the int is not in the container, this
+ // is a no-op, and the return value is false.
+ bool
+ erase(const int& r_str);
+
+ bool
+ empty() const
+ { return m_pq.empty(); }
+
+ size_t
+ size() const
+ { return m_pq.size(); }
+
+private:
+ // A priority queue of strings.
+ typedef __gnu_pbds::priority_queue< int> pq_t;
+
+ // A hash-table mapping strings to point_iterators inside the
+ // priority queue.
+ typedef cc_hash_table< int, pq_t::point_iterator> map_t;
+
+ pq_t m_pq;
+ map_t m_map;
+};
+
+void
+mapped_priority_queue::
+push(const int& r_str)
+{
+ // First check if the int is already in the container. If so, just return.
+ if (m_map.find(r_str) != m_map.end())
+ return;
+
+ // Push the int into the priority queue, and store a point_iterator to it.
+ pq_t::point_iterator pq_it = m_pq.push(r_str);
+
+ try
+ {
+ // Now make the map associate the int to the point_iterator.
+ m_map[r_str] = pq_it;
+ }
+ catch(...)
+ {
+ // If the above failed, we need to remove the int from the
+ // priority queue as well.
+ m_pq.erase(pq_it);
+ throw;
+ }
+}
+
+void
+mapped_priority_queue::
+pop()
+{
+ assert(!empty());
+
+ // Erase the int from the map.
+ m_map.erase(m_pq.top());
+
+ // ...then from the priority queue.
+ m_pq.pop();
+}
+
+bool
+mapped_priority_queue::
+erase(const int& r_str)
+{
+ map_t::point_iterator map_it = m_map.find(r_str);
+
+ // If the int is not in the map, this is a no-op.
+ if (map_it == m_map.end())
+ return false;
+
+ // Otherwise, we erase it from the priority queue.
+ m_pq.erase(map_it->second);
+
+ // ...then from the map.
+ m_map.erase(r_str);
+
+ return true;
+}
+
+int main()
+{
+ // Push some values into the container object.
+ mapped_priority_queue m;
+ m.push(1);
+ m.push(2);
+
+ // The following four operations are no-ops: 2 and 1 are already in
+ // the container.
+ m.push(2);
+ m.push(2);
+ m.push(2);
+ m.push(1);
+
+ m.push(10);
+ m.push(11);
+ m.push(12);
+
+ // The size should be 5, since m contains the set {1, 2, 10, 11, 12}.
+ assert(m.size() == 5);
+
+ // The largest value should be 12.
+ assert(m.top() == 12);
+
+ // Now erase some values.
+
+ // Erasing 1 actually erases a value.
+ assert(m.erase(1));
+
+ // ...but erasing 1 again is a no-op.
+ assert(!m.erase(1));
+
+ // The size should be 5, since m contains the set {2, 10, 11, 12}.
+ assert(m.size() == 4);
+
+ // Now print the values in the container.
+ while (!m.empty())
+ {
+ cout << m.top() << endl;
+ m.pop();
+ }
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/ranged_hash.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/ranged_hash.cc
new file mode 100644
index 000000000..e9f33b113
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/ranged_hash.cc
@@ -0,0 +1,151 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file ranged_hash_example.cpp
+ * A basic example showing how to write a ranged-hash functor.
+ */
+
+/**
+ * In some cases it is beneficial to write a hash function which determines
+ * hash values based on the size of the container object.
+ * The example shows an example of a string-hashing function which
+ * uses a fast method for hashing strings when the number of strings
+ * in the container object is small, and a slower but more careful method
+ * for hashing strings when the number of strings in the container object
+ * is large.
+ */
+
+#include <functional>
+#include <cassert>
+#include <string>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/hash_policy.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+/**
+ * A (somewhat simplistic) ranged-hash function for strings.
+ * It uses the size of the container object to determine
+ * the hashing method. For smaller sizes it uses a simple hash function;
+ * for larger sizes it uses a more complicated hash function.
+ */
+class simple_string_ranged_hash_fn
+ : public unary_function<string, size_t>
+{
+public:
+ typedef size_t size_type;
+
+ simple_string_ranged_hash_fn() : m_container_size(0) { }
+
+ // Called to notify that the size has changed.
+ void
+ notify_resized(size_t size)
+ { m_container_size = size; }
+
+ // Called for hashing a string into a size_t in a given range.
+ size_t
+ operator()(const string& r_string)
+ {
+ /*
+ * This (simplified) hash algorithm decides that if there are
+ * fewer than 100 strings in the container it will hash
+ * a string by summing its characters; otherwise, it will
+ * perform a more complicated operation in order to produce
+ * hash values with fewer collisions.
+ */
+ string::const_iterator it = r_string.begin();
+ size_t hash = 0;
+ if (m_container_size < 100)
+ {
+ // For this size, perform an accumulate type of operation.
+ while (it != r_string.end())
+ hash += static_cast<size_t>(*it++);
+ }
+ else
+ {
+ // For this size, perform a different operation.
+ while (it != r_string.end())
+ {
+ hash += static_cast<size_t>(*it++);
+ hash *= 5;
+ }
+ }
+
+ // The function must, by whatever means, return a size in the
+ // range 0 to m_container_size.
+ return hash % m_container_size;
+ }
+
+ // Swaps content.
+ void
+ swap(simple_string_ranged_hash_fn& other)
+ {
+ std::swap(m_container_size, other.m_container_size);
+ }
+
+private:
+ // Records the size of the container object.
+ size_t m_container_size;
+};
+
+int
+main()
+{
+ // A collision-chaining hash table storing strings.
+ typedef
+ cc_hash_table<
+ string,
+ null_mapped_type,
+ null_hash_fn,
+ equal_to<string>,
+ simple_string_ranged_hash_fn>
+ set_t;
+
+ // Note that in the above, the library determines a resize policy
+ // appropriate for modulo-based range hashing.
+ set_t h;
+
+ // Use the table normally.
+ h.insert("Hello, ");
+ h.insert("world");
+
+ assert(h.size() == 2);
+
+ assert(h.find("Hello, ") != h.end());
+ assert(h.find("world") != h.end());
+
+ assert(h.find("Goodbye, oh cruel world!") == h.end());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/store_hash.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/store_hash.cc
new file mode 100644
index 000000000..f762bfdb2
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/store_hash.cc
@@ -0,0 +1,97 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file store_hash_example.cpp
+ * An example showing how to store hash-values with
+ * each entry in a hash-based container.
+ */
+
+/**
+ * This example shows how to configure a hash-based container to store
+ * the hash value of each key along with each entry. This technique
+ * is useful for complex keys (e.g., strings in this example), since
+ * it lowers the cost of collisions. For simpler types (e.g., integers),
+ * where the cost of comparing keys is of the same order as the cost
+ * of comparing hash values, this technique adds unnecessary overhead.
+ */
+
+#include <functional>
+#include <string>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/hash_policy.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A string hash functor.
+struct string_hash : public unary_function<string, size_t>
+{
+ inline size_t
+ operator()(string str) const
+ {
+ string::const_iterator b = str.begin();
+ string::const_iterator e = str.end();
+
+ size_t hash = 0;
+ while (b != e)
+ {
+ hash *= 5;
+ hash += static_cast<size_t>(*b);
+ ++b;
+ }
+ return hash;
+ }
+};
+
+int main()
+{
+ // A collision-chaining hash table mapping strings to ints.
+ typedef
+ cc_hash_table<
+ string,
+ int,
+ string_hash,
+ equal_to<string>,
+ direct_mask_range_hashing<>,
+ hash_standard_resize_policy<>,
+ true>
+ map_t;
+
+ map_t h;
+
+ // Use regularly.
+ h["Hello, "] = 0;
+ h["world"] = 1;
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/tree_intervals.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/tree_intervals.cc
new file mode 100644
index 000000000..406ab8e0c
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/tree_intervals.cc
@@ -0,0 +1,212 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_intervals_example.cpp
+ * An example showing how to augment a trees to support operations involving
+ * line intervals.
+ */
+
+/**
+ * In some cases tree structure can be used for various purposes other
+ * than storing entries by key order. This example shows how a
+ * tree-based container can be used for geometric-line intersection
+ * determination. That is, the key of the container is a pair of
+ * numbers representing a line interval. The container object can be
+ * used to query whether a line interval intersects any line interval
+ * it currently stores.
+ *
+ * This type of problem arises not only in geometric applications, but
+ * also sometimes in distributed filesystems. Assume that "leases" are
+ * taken for parts of files or LUNs. When a new lease is requested, it
+ * is necessary to check that it does not conflict with a lease
+ * already taken. In this case a file or LUN can be envisioned as a
+ * line segment; leases requested and granted for contiguous parts of
+ * the file or LUN can be represented as line intervals as well.
+ */
+
+#include <cassert>
+#include <cstdlib>
+#include <ext/pb_ds/assoc_container.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// Following are definitions of line intervals and functors operating
+// on them. As the purpose of this example is node invariants, and not
+// computational-geometry algorithms per-se, some simplifications are
+// made (e.g., intervals are defined by unsigned integers, and not by
+// a parameterized type, data members are public, etc.).
+
+// An interval of unsigned integers.
+typedef pair< unsigned int, unsigned int> interval;
+
+// Functor updating maximal endpoints of entries. Algorithm taken from
+// "Introduction to Algorithms" by Cormen, Leiserson, and Rivest.
+template<class Const_Node_Iterator,
+ class Node_Iterator,
+ class Cmp_Fn,
+ class Allocator>
+struct intervals_node_update
+{
+public:
+ // The metadata that each node stores is the largest endpoint of an
+ // interval in its subtree. In this case, this is an unsigned int.
+ typedef unsigned int metadata_type;
+
+ // Checks whether a set of intervals contains at least one interval
+ // overlapping some interval. Algorithm taken from "Introduction to
+ // Algorithms" by Cormen, Leiserson, and Rivest.
+ bool
+ overlaps(const interval& r_interval)
+ {
+ Const_Node_Iterator nd_it = node_begin();
+ Const_Node_Iterator end_it = node_end();
+
+ while (nd_it != end_it)
+ {
+ // Check whether r_interval overlaps the current interval.
+ if (r_interval.second >= (*nd_it)->first&&
+ r_interval.first <= (*nd_it)->second)
+ return true;
+
+ // Get the const node iterator of the node's left child.
+ Const_Node_Iterator l_nd_it = nd_it.get_l_child();
+
+ // Calculate the maximal endpoint of the left child. If the
+ // node has no left child, then this is the node's maximal
+ // endpoint.
+ const unsigned int l_max_endpoint =(l_nd_it == end_it)?
+ 0 : l_nd_it.get_metadata();
+
+ // Now use the endpoint to determine which child to choose.
+ if (l_max_endpoint >= r_interval.first)
+ nd_it = l_nd_it;
+ else
+ nd_it = nd_it.get_r_child();
+ }
+
+ return false;
+ }
+
+protected:
+ // Update predicate: nd_it is a node iterator to the node currently
+ // updated; end_nd_it is a const node iterator to a just-after leaf
+ // node.
+ inline void
+ operator()(Node_Iterator nd_it, Const_Node_Iterator end_nd_it)
+ {
+ // The left maximal endpoint is 0 if there is no left child.
+ const unsigned int l_max_endpoint =(nd_it.get_l_child() == end_nd_it)?
+ 0 : nd_it.get_l_child().get_metadata();
+
+ // The right maximal endpoint is 0 if there is no right child.
+ const unsigned int r_max_endpoint =(nd_it.get_r_child() == end_nd_it)?
+ 0 : nd_it.get_r_child().get_metadata();
+
+ // The maximal endpoint is the endpoint of the node's interval,
+ // and the maximal endpoints of its children.
+ const_cast<unsigned int&>(nd_it.get_metadata()) =
+ max((*nd_it)->second, max<unsigned int>(l_max_endpoint, r_max_endpoint));
+ }
+
+ virtual Const_Node_Iterator
+ node_begin() const = 0;
+
+ virtual Const_Node_Iterator
+ node_end() const = 0;
+
+ virtual
+ ~intervals_node_update()
+ { }
+};
+
+// The following function performs some operation sequence on a
+// generic associative container supporting order statistics. It
+// inserts some intervals, and checks for overlap.
+template<class Cntnr>
+void
+some_op_sequence(Cntnr r_c)
+{
+ // Insert some entries.
+ r_c.insert(make_pair(0, 100));
+ r_c.insert(make_pair(150, 160));
+ r_c.insert(make_pair(300, 1000));
+ r_c.insert(make_pair(10000, 100000));
+ r_c.insert(make_pair(200, 100200));
+
+ // Test overlaps.
+
+ // Overlaps 150 - 160
+ assert(r_c.overlaps(make_pair(145, 165)) == true);
+ // Overlaps 150 - 160
+ assert(r_c.overlaps(make_pair(145, 155)) == true);
+ assert(r_c.overlaps(make_pair(165, 175)) == false);
+ assert(r_c.overlaps(make_pair(100201, 100203)) == false);
+
+ // Erase an interval
+ r_c.erase(make_pair(150, 160));
+
+ // Test overlaps again.
+ assert(r_c.overlaps(make_pair(145, 165)) == false);
+ assert(r_c.overlaps(make_pair(165, 175)) == false);
+ assert(r_c.overlaps(make_pair(0, 300000)) == true);
+}
+
+int main()
+{
+ // Test a red-black tree.
+ some_op_sequence(tree<
+ interval,
+ null_mapped_type,
+ less<interval>,
+ rb_tree_tag,
+ intervals_node_update>());
+
+ // Test an ordered-vector tree.
+ some_op_sequence(tree<
+ interval,
+ null_mapped_type,
+ less<interval>,
+ ov_tree_tag,
+ intervals_node_update>());
+
+ // Test a splay tree.
+ some_op_sequence(tree<
+ interval,
+ null_mapped_type,
+ less<interval>,
+ splay_tree_tag,
+ intervals_node_update>());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/tree_join.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/tree_join.cc
new file mode 100644
index 000000000..5953804f5
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/tree_join.cc
@@ -0,0 +1,112 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_join_example.cpp
+ * An example showing how to join splay_tree_map objects.
+ * The code in the example is relevant to red-black trees as well.
+ */
+
+/**
+ * This example shows how to join tree based containers, i.e., taking two
+ * objects with non-overlapping sets of keys and combining them into
+ * a single object.
+ */
+
+// For tree
+#include <ext/pb_ds/assoc_container.hpp>
+// For join_error exception.
+#include <ext/pb_ds/exception.hpp>
+// For assert
+#include <cassert>
+
+using namespace std;
+using namespace __gnu_pbds;
+using namespace __gnu_pbds;
+
+int main()
+{
+ /*
+ *
+ */
+ // A splay tree table mapping ints to chars.
+ typedef tree<int, char, less<int>, splay_tree_tag> map_t;
+
+ // Two map_t object.
+ map_t h0, h1;
+
+ // Insert some values into the first table.
+ for (int i0 = 0; i0 < 100; ++i0)
+ h0.insert(make_pair(i0, 'a'));
+
+ // Insert some values into the second table.
+ for (int i1 = 0; i1 < 100; ++i1)
+ h1.insert(make_pair(1000 + i1, 'b'));
+
+ // Since all the elements in h0 are smaller than those in h1, it is
+ // possible to join the two tables. This is exception free.
+ h0.join(h1);
+
+ // Check that h0 should now contain all entries, and h1 should be empty.
+ assert(h0.size() == 200);
+ assert(h1.empty());
+
+
+ // Two other map_t objects.
+ map_t h2, h3;
+
+ h2[1] = 'a';
+ h2[3] = 'c';
+
+ h3[2] = 'b';
+
+ // Now perform an illegal join.
+ // It is not true that all elements in h2 are smaller than those in
+ // h3, nor is it true that they are all larger. Hence, attempting to
+ // join h2, and h3 should result in an exception.
+ bool exception_thrown = false;
+ try
+ {
+ h2.join(h3);
+ }
+ catch (__gnu_pbds::join_error& )
+ {
+ exception_thrown = true;
+ }
+ assert(exception_thrown);
+
+ // Since the operation was not performed, the tables should be unaltered.
+ assert(h2.size() == 2);
+ assert(h3[2] == 'b');
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/tree_order_statistics.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/tree_order_statistics.cc
new file mode 100644
index 000000000..584574030
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/tree_order_statistics.cc
@@ -0,0 +1,124 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_order_statistics_example.cpp
+ * An example showing how to use functors for order-statistics
+ * in tree-based containers.
+ */
+
+/**
+ * In some cases tree structure can be used for various purposes asides
+ * from storing entries by key order.
+ * This example shows how a tree-based container can be used for
+ * order-statistics, i.e., for determining the order of each key
+ * in the (ordered) sequence of keys stored within the container object.
+ */
+
+#include <cassert>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/tree_policy.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A red-black tree table storing ints and their order
+// statistics. Note that since the tree uses
+// tree_order_statistics_node_update as its update policy, then it
+// includes its methods by_order and order_of_key.
+typedef
+tree<
+ int,
+ null_mapped_type,
+ less<int>,
+ rb_tree_tag,
+ // This policy updates nodes' metadata for order statistics.
+ tree_order_statistics_node_update>
+set_t;
+
+int main()
+{
+ // Insert some entries into s.
+ set_t s;
+ s.insert(12);
+ s.insert(505);
+ s.insert(30);
+ s.insert(1000);
+ s.insert(10000);
+ s.insert(100);
+
+ // The order of the keys should be: 12, 30, 100, 505, 1000, 10000.
+ assert(*s.find_by_order(0) == 12);
+ assert(*s.find_by_order(1) == 30);
+ assert(*s.find_by_order(2) == 100);
+ assert(*s.find_by_order(3) == 505);
+ assert(*s.find_by_order(4) == 1000);
+ assert(*s.find_by_order(5) == 10000);
+ assert(s.find_by_order(6) == s.end());
+
+ // The order of the keys should be: 12, 30, 100, 505, 1000, 10000.
+ assert(s.order_of_key(10) == 0);
+ assert(s.order_of_key(12) == 0);
+ assert(s.order_of_key(15) == 1);
+ assert(s.order_of_key(30) == 1);
+ assert(s.order_of_key(99) == 2);
+ assert(s.order_of_key(100) == 2);
+ assert(s.order_of_key(505) == 3);
+ assert(s.order_of_key(1000) == 4);
+ assert(s.order_of_key(10000) == 5);
+ assert(s.order_of_key(9999999) == 6);
+
+ // Erase an entry.
+ s.erase(30);
+
+ // The order of the keys should be: 12, 100, 505, 1000, 10000.
+ assert(*s.find_by_order(0) == 12);
+ assert(*s.find_by_order(1) == 100);
+ assert(*s.find_by_order(2) == 505);
+ assert(*s.find_by_order(3) == 1000);
+ assert(*s.find_by_order(4) == 10000);
+ assert(s.find_by_order(5) == s.end());
+
+ // The order of the keys should be: 12, 100, 505, 1000, 10000.
+ assert(s.order_of_key(10) == 0);
+ assert(s.order_of_key(12) == 0);
+ assert(s.order_of_key(100) == 1);
+ assert(s.order_of_key(505) == 2);
+ assert(s.order_of_key(707) == 3);
+ assert(s.order_of_key(1000) == 3);
+ assert(s.order_of_key(1001) == 4);
+ assert(s.order_of_key(10000) == 4);
+ assert(s.order_of_key(100000) == 5);
+ assert(s.order_of_key(9999999) == 5);
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/tree_order_statistics_join.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/tree_order_statistics_join.cc
new file mode 100644
index 000000000..18b47c134
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/tree_order_statistics_join.cc
@@ -0,0 +1,90 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_order_statistics_join_example.cpp
+ * An example showing how to augment a splay tree to support order statistics.
+ */
+
+// This example shows how join operations still maintain node
+// invariants. Specifically, it shows how the objects of containers
+// supporting order statistics can be joined into an object supporting
+// order statistics.
+// While the example does not show this, the same holds for split operations.
+
+#include <cassert>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/tree_policy.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A splay tree table mapping ints to chars and storing the ints order
+// statistics.
+typedef
+tree<int, char, less<int>,
+ splay_tree_tag,
+ tree_order_statistics_node_update>
+tree_map_t;
+
+int main()
+{
+ // Insert some entries into s0.
+ tree_map_t s0;
+ s0.insert(make_pair(12, 'a'));
+ s0.insert(make_pair(505, 'b'));
+ s0.insert(make_pair(30, 'c'));
+
+ // The order of the keys should be: 12, 30, 505.
+ assert(s0.find_by_order(0)->first == 12);
+ assert(s0.find_by_order(1)->first == 30);
+ assert(s0.find_by_order(2)->first == 505);
+
+ // Insert some entries into s1.
+ tree_map_t s1;
+ s1.insert(make_pair(506, 'a'));
+ s1.insert(make_pair(1222, 'b'));
+ s1.insert(make_pair(3004, 'a'));
+
+ // Now join s0 and s1.
+ s0.join(s1);
+
+ // The order of the keys should be: 12, 30, 505, 506, 1222, 3004.
+ assert(s0.find_by_order(0)->first == 12);
+ assert(s0.find_by_order(1)->first == 30);
+ assert(s0.find_by_order(2)->first == 505);
+ assert(s0.find_by_order(3)->first == 506);
+ assert(s0.find_by_order(4)->first == 1222);
+ assert(s0.find_by_order(5)->first == 3004);
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/trie_dna.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/trie_dna.cc
new file mode 100644
index 000000000..28c895680
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/trie_dna.cc
@@ -0,0 +1,118 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2007, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file trie_dna_example.cpp
+ * An example showing how to use a trie for storing DNA strings.
+ */
+
+/**
+ * This example shows how to use a PATRICIA trie for storing
+ DNA strings. The main point is writing element-access traits
+ for these strings.
+*/
+
+#include <cassert>
+#include <iostream>
+#include <cstdlib>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/trie_policy.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// DNA is represented by a string.
+typedef string dna_t;
+
+// Following is an element access traits for a DNA string.
+struct dna_string_e_access_traits
+{
+public:
+ typedef size_t size_type;
+ typedef dna_t key_type;
+ typedef const key_type& const_key_reference;
+ typedef char e_type;
+ typedef string::const_iterator const_iterator;
+
+ enum
+ {
+ // Number of distinct elements. This is 4 = |{'A', 'C', 'G', 'T'}|
+ max_size = 4
+ };
+
+ // Returns a const_iterator to the firstelement of r_key.
+ inline static const_iterator
+ begin(const_key_reference r_key)
+ { return r_key.begin(); }
+
+ // Returns a const_iterator to the after-lastelement of r_key.
+ inline static const_iterator
+ end(const_key_reference r_key)
+ { return r_key.end(); }
+
+ // Maps an element to a position.
+ inline static size_t
+ e_pos(e_type e)
+ {
+ switch(e)
+ {
+ case 'A':
+ return 0;
+ case 'C':
+ return 1;
+ case 'G':
+ return 2;
+ case 'T':
+ return 3;
+ default:
+ std::abort();
+ };
+ }
+};
+
+// A PATRICIA trie with DNA string element-access traits.
+typedef dna_string_e_access_traits traits_type;
+typedef trie<dna_t, string, traits_type> trie_type;
+
+int main()
+{
+ trie_type t;
+
+ // Now map some DNAs to diseases in namespace STD.
+ t["ACCGGTTACTGGTA"] = "gonorrhea";
+ t["CCGTTATCGGTA"] = "syphlis";
+
+ // Check gonorrhea already contracted.
+ assert(t.find("ACCGGTTACTGGTA") != t.end());
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/trie_prefix_search.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/trie_prefix_search.cc
new file mode 100644
index 000000000..98b99a76a
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/trie_prefix_search.cc
@@ -0,0 +1,110 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file trie_prefix_search_example.cpp
+ * An example showing how to use a trie for searching
+ * for words with a given prefix.
+ */
+
+/**
+ * This example shows how to use a PATRICIA trie for searching
+ * for words with a given prefix.
+ */
+
+#include <cassert>
+#include <iostream>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <ext/pb_ds/trie_policy.hpp>
+#include <ext/pb_ds/tag_and_trait.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+// A PATRICIA trie with a prefix-search node-updator type. Note that
+// since the node updator is trie_prefix_search_node_update, then the
+// container includes its method prefix_range.
+typedef null_mapped_type mapped_type;
+typedef string_trie_e_access_traits<> cmp_fn;
+typedef pat_trie_tag tag_type;
+
+typedef trie<string, mapped_type, cmp_fn, tag_type,
+ trie_prefix_search_node_update> trie_type;
+
+// The following helper function takes a trie object and r_key, a
+// const reference to a string, and prints all entries whose key
+// includes r_key as a prefix.
+void
+print_prefix_match(const trie_type& t, const string& key)
+{
+ typedef trie_type::const_iterator const_iterator;
+ typedef pair<const_iterator, const_iterator> pair_type;
+
+ cout << "All keys whose prefix matches \"" << key << "\":" << endl;
+
+ const pair_type match_range = t.prefix_range(key);
+ for (const_iterator it = match_range.first; it != match_range.second; ++it)
+ cout << *it << ' ';
+ cout << endl;
+}
+
+int main()
+{
+ trie_type t;
+
+ // Insert some entries.
+ assert(t.insert("I").second == true);
+ assert(t.insert("wish").second == true);
+ assert(t.insert("that").second == true);
+ assert(t.insert("I").second == false);
+ assert(t.insert("could").second == true);
+ assert(t.insert("ever").second == true);
+ assert(t.insert("see").second == true);
+ assert(t.insert("a").second == true);
+ assert(t.insert("poem").second == true);
+ assert(t.insert("lovely").second == true);
+ assert(t.insert("as").second == true);
+ assert(t.insert("a").second == false);
+ assert(t.insert("trie").second == true);
+
+ // Now search for prefixes.
+ print_prefix_match(t, "");
+ print_prefix_match(t, "a");
+ print_prefix_match(t, "as");
+ print_prefix_match(t, "ad");
+ print_prefix_match(t, "t");
+ print_prefix_match(t, "tr");
+ print_prefix_match(t, "trie");
+ print_prefix_match(t, "zzz");
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/example/trie_split.cc b/libstdc++-v3/testsuite/ext/pb_ds/example/trie_split.cc
new file mode 100644
index 000000000..c08eb9c98
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/example/trie_split.cc
@@ -0,0 +1,85 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file trie_split_example.cpp
+ * A basic example showing how to split trie-based container objects.
+ */
+
+/**
+ * This example shows how to split trie based containers, i.e., the opposite
+ * of a join operation.
+ */
+
+#include <string>
+#include <cassert>
+#include <ext/pb_ds/assoc_container.hpp>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+int main()
+{
+ // A PATRICIA trie table mapping strings to chars.
+ typedef trie<string, char> map_type;
+
+ // A map_type object.
+ map_type r;
+
+ // Inserts some entries into r.
+ for (int i = 0; i < 100; ++ i)
+ r.insert(make_pair(string(i, 'a'), 'b'));
+
+ // Now split r into a different map_type object.
+
+ // larger_r will hold the larger values following the split.
+ map_type larger_r;
+
+ // Split all elements with key larger than 'a'^1000 into larger_r.
+ // This is exception free.
+ r.split(string(1000, 'a'), larger_r);
+
+ // Since there were no elements with key larger than 'a'^1000, r
+ // should be unchanged.
+ assert(r.size() == 100);
+ assert(r.begin()->first == string(""));
+
+ // Now perform a split which actually changes the content of r.
+
+ // Split all elements with key larger than "aaa" into larger_r.
+ r.split(string("aaa"), larger_r);
+
+ assert(r.size() == 4);
+ assert(larger_r.begin()->first == string("aaaa"));
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/associative_containers.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/associative_containers.cc
new file mode 100644
index 000000000..26dec124d
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/associative_containers.cc
@@ -0,0 +1,165 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file assoc_link_regression_test_1.cpp
+ * A linkage regression test.
+ */
+
+
+#include <ext/pb_ds/assoc_container.hpp>
+#include <iostream>
+#include <cassert>
+
+using namespace std;
+using namespace __gnu_pbds;
+
+/**
+ * The following function performs a sequence of operations on an
+ * associative container object mapping integers to characters.
+ */
+template<typename Cntnr>
+void
+some_op_sequence(Cntnr& r_c)
+{
+ assert(r_c.empty());
+ assert(r_c.size() == 0);
+
+ r_c.insert(make_pair(1, 'a'));
+
+ r_c[2] = 'b';
+
+ assert(!r_c.empty());
+ assert(r_c.size() == 2);
+
+ cout << "Key 1 is mapped to " << r_c[1] << endl;
+ cout << "Key 2 is mapped to " << r_c[2] << endl;
+
+ cout << endl << "All value types in the container:" << endl;
+ for (typename Cntnr::const_iterator it = r_c.begin(); it != r_c.end(); ++it)
+ cout << it->first << " -> " << it->second << endl;
+
+ cout << endl;
+
+ r_c.clear();
+
+ assert(r_c.empty());
+ assert(r_c.size() == 0);
+}
+
+void
+assoc_link_regression_test_0()
+{
+ {
+ // Perform operations on a collision-chaining hash map.
+ cc_hash_table<int, char> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a general-probing hash map.
+ gp_hash_table<int, char> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a red-black tree map.
+ tree<int, char> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a splay tree map.
+ tree<int, char, less<int>, splay_tree_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a splay tree map.
+ tree<int, char, less<int>, ov_tree_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a list-update map.
+ list_update<int, char> c;
+ some_op_sequence(c);
+ }
+}
+
+
+void
+assoc_link_regression_test_1()
+{
+ {
+ // Perform operations on a collision-chaining hash map.
+ cc_hash_table<int, char> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a general-probing hash map.
+ gp_hash_table<int, char> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a red-black tree map.
+ tree<int, char> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a splay tree map.
+ tree<int, char, less<int>, splay_tree_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a splay tree map.
+ tree<int, char, less<int>, ov_tree_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ // Perform operations on a list-update map.
+ list_update<int, char> c;
+ some_op_sequence(c);
+ }
+}
+
+int
+main()
+{
+ assoc_link_regression_test_0();
+ assoc_link_regression_test_1();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_data_map_rand.cc
new file mode 100644
index 000000000..5656a5b29
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_data_map_rand.cc
@@ -0,0 +1,73 @@
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-DITERATIONS=5" { target simulator } }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_data_map_rand_regression_test.cpp
+ * Contains a random-operation test for maps and sets.
+ */
+
+#define PB_DS_REGRESSION
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+
+#ifndef ITERATIONS
+# ifdef _GLIBCXX_DEBUG
+# define ITERATIONS 100
+# else
+# define ITERATIONS 5000
+#endif
+#endif
+
+#ifndef KEYS
+# ifdef _GLIBCXX_DEBUG
+# define KEYS 200
+# else
+# define KEYS 10000
+# endif
+#endif
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ typedef hash_map_tl_t map_tl_t;
+
+ return rand_regression_test(ITERATIONS, KEYS,
+ "hash_data_map_rand_regression_test",
+ map_tl_t());
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_no_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_no_data_map_rand.cc
new file mode 100644
index 000000000..e0530f579
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/hash_no_data_map_rand.cc
@@ -0,0 +1,72 @@
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-DITERATIONS=5" { target simulator } }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009, 2011 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file hash_no_data_map_rand_regression_test.cpp
+ * Contains a random-operation test for maps and sets.
+ */
+
+#define PB_DS_REGRESSION
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+
+#ifndef ITERATIONS
+# ifdef _GLIBCXX_DEBUG
+# define ITERATIONS 100
+# else
+# define ITERATIONS 5000
+#endif
+#endif
+
+#ifndef KEYS
+# ifdef _GLIBCXX_DEBUG
+# define KEYS 200
+# else
+# define KEYS 10000
+# endif
+#endif
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ typedef hash_set_tl_t map_tl_t;
+
+ return rand_regression_test(ITERATIONS, KEYS,
+ "hash_no_data_map_rand_regression_test",
+ map_tl_t());
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_data_map_rand.cc
new file mode 100644
index 000000000..8bd77816c
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_data_map_rand.cc
@@ -0,0 +1,54 @@
+// { dg-require-time "" }
+
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file lu_data_map_rand_regression_test.cpp
+ * Contains a random-operation test for maps and sets.
+ */
+
+#define PB_DS_REGRESSION
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ typedef lu_map_tl_t map_tl_t;
+
+ return rand_regression_test(50, 10,
+ "lu_data_map_rand_regression_test",
+ map_tl_t());
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_no_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_no_data_map_rand.cc
new file mode 100644
index 000000000..72273a8bc
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_no_data_map_rand.cc
@@ -0,0 +1,54 @@
+// { dg-require-time "" }
+
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file lu_no_data_map_rand_regression_test.cpp
+ * Contains a random-operation test for maps and sets.
+ */
+
+#define PB_DS_REGRESSION
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ typedef lu_set_tl_t map_tl_t;
+
+ return rand_regression_test(50, 10,
+ "lu_no_data_map_rand_regression_test",
+ map_tl_t());
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queue_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queue_rand.cc
new file mode 100644
index 000000000..b21f486d6
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queue_rand.cc
@@ -0,0 +1,61 @@
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-DITERATIONS=5" { target simulator } }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file priority_queue_rand_regression_test.cpp
+ * Contains a random-operation test for priority queues.
+ */
+
+#define PB_DS_REGRESSION
+
+#include <regression/rand/priority_queue/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+
+#ifndef ITERATIONS
+#define ITERATIONS 5000
+#endif
+#ifndef KEYS
+#define KEYS 10000
+#endif
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ return rand_regression_test(ITERATIONS, KEYS,
+ "pq_no_data_map_rand_regression_test",
+ pq_tl_t());
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queues.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queues.cc
new file mode 100644
index 000000000..713c887a1
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queues.cc
@@ -0,0 +1,184 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * This example shows how to use priority queues. It defines a
+ * function performing a sequence of operations on
+ * a generic container. It then calls this function with some containers.
+ */
+
+#include <ext/pb_ds/priority_queue.hpp>
+#include <iostream>
+#include <cassert>
+
+using namespace std;
+using namespace __gnu_pbds;
+using namespace __gnu_pbds;
+
+template<typename Cntnr>
+void
+some_op_sequence(Cntnr& r_c)
+{
+ assert(r_c.empty());
+ assert(r_c.size() == 0);
+
+ for (size_t i = 0; i < 10; ++i)
+ r_c.push(i);
+
+ cout << endl << "All values in the container:" << endl;
+ for (typename Cntnr::const_iterator it = r_c.begin(); it != r_c.end();
+ ++it)
+ cout <<* it << endl;
+
+ assert(!r_c.empty());
+ assert(r_c.size() == 10);
+
+ cout << "Popping all values: " << endl;
+
+ while (!r_c.empty())
+ {
+ cout << r_c.top() << endl;
+
+ r_c.pop();
+ }
+
+ assert(r_c.empty());
+ assert(r_c.size() == 0);
+
+ cout << endl;
+}
+
+void
+priority_queue_link_regression_test_0()
+{
+ {
+ /*
+ * Perform operations on a pairing-heap queue.
+ */
+ cout << "Pairing heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, pairing_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ /*
+ * Perform operations on a binomial-heap queue.
+ */
+ cout << "Binomial heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, binomial_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ /*
+ * Perform operations on a binomial-heap queue.
+ */
+ cout << "Redundant-counter binomial heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, rc_binomial_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ /*
+ * Perform operations on a binomial-heap queue.
+ */
+ cout << "Binary heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, binary_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ /*
+ * Perform operations on a thin-heap queue.
+ */
+ cout << "Thin heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, thin_heap_tag> c;
+ some_op_sequence(c);
+ }
+}
+
+
+void
+priority_queue_link_regression_test_1()
+{
+ {
+ /*
+ * Perform operations on a pairing-heap queue.
+ */
+ cout << "Pairing heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, pairing_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ /*
+ * Perform operations on a binomial-heap queue.
+ */
+ cout << "Binomial heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, binomial_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ /*
+ * Perform operations on a binomial-heap queue.
+ */
+ cout << "Redundant-counter binomial heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, rc_binomial_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ /*
+ * Perform operations on a binomial-heap queue.
+ */
+ cout << "Binary heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, binary_heap_tag> c;
+ some_op_sequence(c);
+ }
+
+ {
+ /*
+ * Perform operations on a thin-heap queue.
+ */
+ cout << "Thin heap" << endl;
+ __gnu_pbds::priority_queue<int, less<int>, thin_heap_tag> c;
+ some_op_sequence(c);
+ }
+}
+
+int
+main()
+{
+ priority_queue_link_regression_test_0();
+ priority_queue_link_regression_test_1();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_data_map_rand.cc
new file mode 100644
index 000000000..01751e39f
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_data_map_rand.cc
@@ -0,0 +1,72 @@
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-DITERATIONS=5" { target simulator } }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009, 2011 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_data_map_rand_regression_test.cpp
+ * Contains a random-operation test for maps and sets.
+ */
+
+#define PB_DS_REGRESSION
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+
+#ifndef ITERATIONS
+# ifdef _GLIBCXX_DEBUG
+# define ITERATIONS 100
+# else
+# define ITERATIONS 5000
+#endif
+#endif
+
+#ifndef KEYS
+# ifdef _GLIBCXX_DEBUG
+# define KEYS 200
+# else
+# define KEYS 10000
+# endif
+#endif
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ typedef tree_map_tl_t map_tl_t;
+
+ return rand_regression_test(ITERATIONS, KEYS,
+ "tree_data_map_rand_regression_test",
+ map_tl_t());
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_no_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_no_data_map_rand.cc
new file mode 100644
index 000000000..c7dadb0d8
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_no_data_map_rand.cc
@@ -0,0 +1,73 @@
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-DITERATIONS=5" { target simulator } }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009, 2011 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_no_data_map_rand_regression_test.cpp
+ * Contains a random-operation test for maps and sets.
+ */
+
+#define PB_DS_REGRESSION
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+
+
+#ifndef ITERATIONS
+# ifdef _GLIBCXX_DEBUG
+# define ITERATIONS 100
+# else
+# define ITERATIONS 5000
+#endif
+#endif
+
+#ifndef KEYS
+# ifdef _GLIBCXX_DEBUG
+# define KEYS 200
+# else
+# define KEYS 10000
+# endif
+#endif
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ typedef tree_set_tl_t map_tl_t;
+
+ return rand_regression_test(ITERATIONS, KEYS,
+ "tree_no_data_map_rand_regression_test",
+ map_tl_t());
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_data_map_rand.cc
new file mode 100644
index 000000000..8a3902812
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_data_map_rand.cc
@@ -0,0 +1,72 @@
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-DITERATIONS=5" { target simulator } }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009, 2011 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file trie_data_map_rand_regression_test.cpp
+ * Contains a random-operation test for maps and sets.
+ */
+
+#define PB_DS_REGRESSION
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+
+#ifndef ITERATIONS
+# ifdef _GLIBCXX_DEBUG
+# define ITERATIONS 100
+# else
+# define ITERATIONS 5000
+#endif
+#endif
+
+#ifndef KEYS
+# ifdef _GLIBCXX_DEBUG
+# define KEYS 200
+# else
+# define KEYS 10000
+# endif
+#endif
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ typedef trie_map_tl_t map_tl_t;
+
+ return rand_regression_test(ITERATIONS, KEYS,
+ "trie_data_map_rand_regression_test",
+ map_tl_t());
+}
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_no_data_map_rand.cc b/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_no_data_map_rand.cc
new file mode 100644
index 000000000..2414118da
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/trie_no_data_map_rand.cc
@@ -0,0 +1,72 @@
+// { dg-require-time "" }
+// This can take long on simulators, timing out the test.
+// { dg-options "-DITERATIONS=5" { target simulator } }
+// { dg-timeout-factor 2.0 }
+
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009, 2010, 2011 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/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file trie_no_data_map_rand_regression_test.cpp
+ * Contains a random-operation test for maps and sets.
+ */
+
+#define PB_DS_REGRESSION
+
+#include <regression/rand/assoc/rand_regression_test.hpp>
+#include <regression/common_type.hpp>
+
+#ifndef ITERATIONS
+# ifdef _GLIBCXX_DEBUG
+# define ITERATIONS 100
+# else
+# define ITERATIONS 5000
+#endif
+#endif
+
+#ifndef KEYS
+# ifdef _GLIBCXX_DEBUG
+# define KEYS 200
+# else
+# define KEYS 10000
+# endif
+#endif
+
+int
+main(int argc, char* a_p_argv[])
+{
+ using namespace __gnu_pbds::test;
+ typedef trie_set_tl_t map_tl_t;
+
+ return rand_regression_test(ITERATIONS, KEYS,
+ "trie_no_data_map_rand_regression_test",
+ map_tl_t());
+}
diff --git a/libstdc++-v3/testsuite/ext/pod_char_traits.cc b/libstdc++-v3/testsuite/ext/pod_char_traits.cc
new file mode 100644
index 000000000..e8b221507
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pod_char_traits.cc
@@ -0,0 +1,68 @@
+// POD character, std::char_traits specialization -*- C++ -*-
+
+// Copyright (C) 2002, 2003, 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/>.
+
+
+// Gabriel Dos Reis <gdr@integrable-solutions.net>
+// Benjamin Kosnik <bkoz@redhat.com>
+
+#include <ext/pod_char_traits.h>
+
+int main()
+{
+ using namespace __gnu_cxx;
+
+ typedef unsigned short value_type;
+ typedef unsigned int int_type;
+ typedef character<value_type, int_type> char_type;
+ typedef std::char_traits<char_type> traits_type;
+
+ bool test __attribute__((unused)) = true;
+
+ // 1 char_type <-> value_type conversions
+ value_type uc1 = 'c';
+ value_type uc2 = 'd';
+ char_type c1 = { uc1 };
+ char_type c2 = { uc2 };
+ test = !(c1 == c2);
+
+ // 2 char_traits
+ test = traits_type::eq(c1, c2);
+
+ // 3 basic_string<char_type>
+ typedef std::basic_string<char_type> string_type;
+ string_type str;
+ char_type c3 = { value_type('b') };
+ char_type c4 = { value_type('o') };
+ char_type c5 = { value_type('r') };
+ char_type c6 = { value_type('a') };
+ char_type c7 = { value_type('c') };
+ char_type c8 = { value_type('a') };
+ char_type c9 = { value_type('y') };
+ str += c3;
+ str += c4;
+ str += c5;
+ str += c6;
+ str += c7;
+ str += c8;
+ str += c9;
+ string_type::size_type len __attribute__((unused)) = str.size();
+ const char_type* arr __attribute__((unused)) = str.c_str();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pool_allocator/allocate_chunk.cc b/libstdc++-v3/testsuite/ext/pool_allocator/allocate_chunk.cc
new file mode 100644
index 000000000..983645806
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pool_allocator/allocate_chunk.cc
@@ -0,0 +1,62 @@
+// 2004-10-10 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/pool_allocator.h>
+
+struct small
+{
+ char c[16];
+};
+
+struct big
+{
+ char c[64];
+};
+
+void*
+operator new(size_t n) throw(std::bad_alloc)
+{
+ static bool first = true;
+ if (!first)
+ throw std::bad_alloc();
+ first = false;
+ return std::malloc(n);
+}
+
+// http://gcc.gnu.org/ml/libstdc++/2004-10/msg00098.html
+void test01()
+{
+ using __gnu_cxx::__pool_alloc;
+
+ __pool_alloc<big> alloc_big;
+ alloc_big.allocate(1);
+
+ // The constant 20 comes from __pool_alloc_base::_M_refill. See
+ // also __pool_alloc_base::_M_allocate_chunk.
+ __pool_alloc<small> alloc_small;
+ for (unsigned int i = 0; i < 20 * sizeof(big) / sizeof(small) + 1; ++i)
+ alloc_small.allocate(1);
+}
+
+int main()
+{
+ test01();
+}
diff --git a/libstdc++-v3/testsuite/ext/pool_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/pool_allocator/check_allocate_max_size.cc
new file mode 100644
index 000000000..ce6f8d6f3
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pool_allocator/check_allocate_max_size.cc
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/pool_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::__pool_alloc<value_type> allocator_type;
+ __gnu_test::check_allocate_max_size<allocator_type>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pool_allocator/check_deallocate_null.cc b/libstdc++-v3/testsuite/ext/pool_allocator/check_deallocate_null.cc
new file mode 100644
index 000000000..528d40b8a
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pool_allocator/check_deallocate_null.cc
@@ -0,0 +1,31 @@
+//
+// Copyright (C) 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <ext/pool_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::__pool_alloc<value_type> allocator_type;
+ __gnu_test::check_deallocate_null<allocator_type>();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/pool_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/pool_allocator/check_delete.cc
new file mode 100644
index 000000000..ecc399df6
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pool_allocator/check_delete.cc
@@ -0,0 +1,32 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/pool_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ // Uses new, but delete only sometimes.
+ typedef __gnu_cxx::__pool_alloc<unsigned int> allocator_type;
+ __gnu_test::check_delete<allocator_type, false>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pool_allocator/check_new.cc b/libstdc++-v3/testsuite/ext/pool_allocator/check_new.cc
new file mode 100644
index 000000000..f1bdb77bb
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pool_allocator/check_new.cc
@@ -0,0 +1,31 @@
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/pool_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef __gnu_cxx::__pool_alloc<unsigned int> allocator_type;
+ __gnu_test::check_new<allocator_type, true>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/pool_allocator/explicit_instantiation.cc b/libstdc++-v3/testsuite/ext/pool_allocator/explicit_instantiation.cc
new file mode 100644
index 000000000..f58932e8b
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pool_allocator/explicit_instantiation.cc
@@ -0,0 +1,27 @@
+// { dg-do compile }
+
+// 2001-11-25 Phil Edwards <pme@gcc.gnu.org>
+//
+// Copyright (C) 2001, 2003, 2004, 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/>.
+
+// 20.4.1.1 allocator members
+
+#include <cstdlib>
+#include <ext/pool_allocator.h>
+
+template class __gnu_cxx::__pool_alloc<int>;
diff --git a/libstdc++-v3/testsuite/ext/pool_allocator/variadic_construct.cc b/libstdc++-v3/testsuite/ext/pool_allocator/variadic_construct.cc
new file mode 100644
index 000000000..ec37058aa
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/pool_allocator/variadic_construct.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 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 <ext/pool_allocator.h>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::pair<int, char> pair_type;
+ __gnu_cxx::__pool_alloc<pair_type> alloc1;
+
+ pair_type* ptp1 = alloc1.allocate(1);
+ alloc1.construct(ptp1, 3, 'a');
+
+ VERIFY( ptp1->first == 3 );
+ VERIFY( ptp1->second == 'a' );
+
+ alloc1.deallocate(ptp1, 1);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/profile/all.cc b/libstdc++-v3/testsuite/ext/profile/all.cc
new file mode 100644
index 000000000..037eee497
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/profile/all.cc
@@ -0,0 +1,52 @@
+// { dg-options "-std=gnu++0x -O0" }
+// { dg-options "-std=gnu++0x -O0 -D_GLIBCXX_PROFILE_NO_THREADS" { target { ! tls_native } } }
+// { dg-do compile }
+// { dg-require-profile-mode "" }
+
+// -*- C++ -*-
+
+// Copyright (C) 2006, 2007, 2009, 2010 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 <map>
+#include <vector>
+#include <unordered_map>
+
+using std::map;
+using std::vector;
+using std::unordered_map;
+
+struct dumb_hash {
+ size_t operator()(int x) const {return 0;}
+ size_t operator()(int x, int y) const {return x == y;}
+};
+
+int main() {
+ map<int, int> m_to_umap;
+ vector<int> v_to_list;
+ unordered_map<int, int> um_too_small;
+ unordered_map<int, int> um_too_large(1000000);
+ unordered_map<int, int, dumb_hash, dumb_hash> um_dumb_hash;
+
+ for (int i = 0; i < 10000; ++i) {
+ m_to_umap[i] = i;
+ v_to_list.insert(v_to_list.begin(), i);
+ um_too_small[i] = i;
+ um_too_small[i] = i;
+ um_dumb_hash[i] = i;
+ }
+}
diff --git a/libstdc++-v3/testsuite/ext/profile/mh.cc b/libstdc++-v3/testsuite/ext/profile/mh.cc
new file mode 100644
index 000000000..dc2e94198
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/profile/mh.cc
@@ -0,0 +1,67 @@
+// { dg-do compile { target *-*-linux* } }
+// { dg-xfail-if "" { uclibc } { "*" } { "" } }
+// { dg-require-profile-mode "" }
+
+// -*- C++ -*-
+
+// Copyright (C) 2006, 2007, 2009, 2010 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 <stdio.h>
+#include <malloc.h>
+#include <vector>
+
+using std::vector;
+
+static void my_init_hook (void);
+static void *my_malloc_hook (size_t, const void *);
+typedef void* (*malloc_hook) (size_t, const void *);
+
+malloc_hook old_malloc_hook;
+
+void (*__malloc_initialize_hook) (void) = my_init_hook;
+
+static void
+my_init_hook (void)
+{
+ old_malloc_hook = __malloc_hook;
+ __malloc_hook = my_malloc_hook;
+}
+
+static void *
+my_malloc_hook (size_t size, const void *caller)
+{
+ void *result;
+ __malloc_hook = old_malloc_hook;
+ result = malloc (size);
+ old_malloc_hook = __malloc_hook;
+
+ // With _GLIBCXX_PROFILE, the instrumentation of the vector constructor
+ // will call back into malloc.
+ vector<int> v;
+
+ __malloc_hook = my_malloc_hook;
+ return result;
+}
+
+
+int main()
+{
+ int* test = (int*) malloc(sizeof(int));
+ *test = 1;
+ return *test;
+}
diff --git a/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc b/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc
new file mode 100644
index 000000000..58cab3a66
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc
@@ -0,0 +1,28 @@
+// { dg-options "-D_GLIBCXX_DEBUG -D_GLIBCXX_PROFILE" }
+// { dg-do compile }
+
+// -*- C++ -*-
+
+// Otherwise we may get *multiple* errors.
+#undef _GLIBCXX_PARALLEL
+
+// Copyright (C) 2006, 2007, 2009, 2010, 2011 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>
+
+// { dg-error "multiple inlined namespaces" "" { target *-*-* } 242 }
diff --git a/libstdc++-v3/testsuite/ext/profile/profiler_algos.cc b/libstdc++-v3/testsuite/ext/profile/profiler_algos.cc
new file mode 100644
index 000000000..fb9c8080d
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/profile/profiler_algos.cc
@@ -0,0 +1,147 @@
+// { dg-require-profile-mode "" }
+
+// -*- C++ -*-
+
+// Unit tests for profile/impl/profile_algos.h.
+
+// Copyright (C) 2010, 2011 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 <profile/impl/profiler.h>
+
+using std::_GLIBCXX_STD_C::vector;
+
+enum Failure
+{
+ NO_FAILURES = 0x0,
+ INSERT_AFTER_N = 0x1,
+ INSERT_AT_HEAD = 0x2,
+ INSERT_AT_TAIL = 0x4,
+ INSERT_IN_THE_MIDDLE = 0x8,
+ TOP_N = 0x10,
+ FOR_EACH = 0x20,
+ REMOVE = 0x40
+};
+
+
+static int
+test_insert_top_n()
+{
+ vector<int> v;
+
+ for (int i = 0; i < 10; i++)
+ v.push_back(10 - i);
+
+ // Inserting -5 should have no effect if size is limited to 10.
+ __gnu_profile::__insert_top_n(v, -5, 10);
+ for (int i = 0; i < 10; i++)
+ if (v[i] != 10 - i)
+ return INSERT_AFTER_N;
+
+ // Insert at head.
+ __gnu_profile::__insert_top_n(v, 11, 10);
+ for (int i = 0; i < 11; i++)
+ if (v[i] != 11 - i)
+ return INSERT_AT_HEAD;
+
+ // Insert at end.
+ __gnu_profile::__insert_top_n(v, 0, 100);
+ for (int i = 0; i < 12; i++)
+ if (v[i] != 11 - i)
+ return INSERT_AT_TAIL;
+
+ // Insert in the middle.
+ __gnu_profile::__insert_top_n(v, 6, 11);
+ for (int i = 0; i < 6; i++)
+ if (v[i] != 11 - i)
+ return INSERT_IN_THE_MIDDLE;
+ for (int i = 6; i < 13; i++)
+ if (v[i] != 12 - i)
+ return INSERT_IN_THE_MIDDLE;
+
+ return NO_FAILURES;
+}
+
+static int
+test_top_n()
+{
+ vector<int> v, out;
+
+ for (int i = 0; i < 100; i++)
+ {
+ v.push_back(100 + i);
+ v.push_back(100 - i);
+ }
+
+ __gnu_profile::__top_n(v, out, 10);
+
+ for (int i = 0; i < 10; i++)
+ if (out[i] != 199 - i)
+ return TOP_N;
+
+ return NO_FAILURES;
+}
+
+struct test_for_each_helper
+{
+ static int sum;
+ void operator ()(int i) {
+ sum += i;
+ }
+};
+
+int test_for_each_helper::sum = 0;
+
+static int
+test_for_each()
+{
+ vector<int> v;
+ test_for_each_helper helper;
+ int checksum = 0;
+
+ for (int i = 0; i < 10; i++)
+ {
+ v.push_back(i);
+ checksum += i;
+ }
+
+ __gnu_profile::__for_each(v.begin(), v.end(), helper);
+
+ return helper.sum == checksum ? NO_FAILURES : FOR_EACH;
+}
+
+static int
+test_remove()
+{
+ vector<char> v;
+
+ for (int i = 0; i < 10; i++)
+ v.push_back(' ');
+ v.push_back('x');
+ for (int i = 0; i < 10; i++)
+ v.push_back(' ');
+ v.push_back('x');
+
+ return __gnu_profile::__remove(v.begin(), v.end(), ' ') == v.begin() + 2
+ ? NO_FAILURES : REMOVE;
+}
+
+int main()
+{
+ return test_insert_top_n() | test_top_n() | test_for_each() | test_remove();
+}
diff --git a/libstdc++-v3/testsuite/ext/rope/1.cc b/libstdc++-v3/testsuite/ext/rope/1.cc
new file mode 100644
index 000000000..3fd84e541
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/rope/1.cc
@@ -0,0 +1,37 @@
+// 2001-10-03 From: Dimitris Vyzovitis <vyzo@media.mit.edu>
+
+// Copyright (C) 2001, 2004, 2005, 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/>.
+
+// rope (SGI extension)
+
+#include <ext/rope>
+#include <iostream>
+
+void test01()
+{
+ __gnu_cxx::crope foo;
+ foo += "bar";
+ const char* data = foo.c_str();
+ std::cout << data << std::endl;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/rope/2.cc b/libstdc++-v3/testsuite/ext/rope/2.cc
new file mode 100644
index 000000000..212ba0a08
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/rope/2.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2004, 2005, 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/>.
+
+// rope (SGI extension)
+
+#include <ext/rope>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ using namespace std;
+ using namespace __gnu_cxx;
+ bool test __attribute__((unused)) = true;
+
+ crope r(10000, 'x');
+ crope r2 = r + "abc" + r;
+ crope r3 = r2.substr(10000, 3);
+ crope r4 = r2.substr(10000, 10000);
+
+ reverse(r2.mutable_begin(), r2.mutable_end());
+ VERIFY( r2[10000] == 'c' );
+
+ crope r5('a');
+ r5.push_front('b');
+ VERIFY( r5[0] == 'b' );
+ VERIFY( r5[1] == 'a' );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/rope/3.cc b/libstdc++-v3/testsuite/ext/rope/3.cc
new file mode 100644
index 000000000..1b319f7eb
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/rope/3.cc
@@ -0,0 +1,99 @@
+// Copyright (C) 2004, 2005, 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/>.
+
+// rope (SGI extension)
+
+#include <ext/rope>
+#include <testsuite_hooks.h>
+
+const char base[] =
+"Happy families are all alike; every unhappy family is unhappy in \
+its own way. \
+ \
+Everything was in confusion in the Oblonskys' house. The wife \
+had discovered that the husband was carrying on an intrigue with \
+a French girl, who had been a governess in their family, and she \
+had announced to her husband that she could not go on living in \
+the same house with him. This position of affairs had now lasted \
+three days, and not only the husband and wife themselves, but all \
+the members of their family and household, were painfully \
+conscious of it. Every person in the house felt that there was \
+so sense in their living together, and that the stray people \
+brought together by chance in any inn had more in common with one \
+another than they, the members of the family and household of the \
+Oblonskys. The wife did not leave her own room, the husband had \
+not been at home for three days. The children ran wild all over \
+the house; the English governess quarreled with the housekeeper, \
+and wrote to a friend asking her to look out for a new situation \
+for her; the man-cook had walked off the day before just at \
+dinner time; the kitchen-maid, and the coachman had given \
+warning."
+ ;
+
+int baselen = sizeof(base) - 1;
+
+template<class StringType>
+StringType
+multiply(const StringType& s, int n)
+{
+ StringType result;
+ while (n > 0)
+ {
+ result += s;
+ --n;
+ }
+ return result;
+}
+
+template <class StringType>
+StringType
+mung_substrings(const StringType& s, int len, int n, int skip)
+{
+ StringType result;
+ int start = 0;
+ while (n > 0)
+ {
+ StringType tmp = s.substr (start, len);
+ result += tmp;
+ --n;
+ start += skip;
+ }
+ return result;
+}
+
+void
+test01()
+{
+ using namespace __gnu_cxx;
+ bool test __attribute__((unused)) = true;
+
+ crope r;
+ r = multiply(crope(base), 100000);
+
+ crope r1;
+ r1 = mung_substrings(r, 100000, 500, 73);
+
+ VERIFY( r1.size() == 50000000 );
+ VERIFY( r1.substr(88888, 6)[0] == 's' );
+ VERIFY( r1.substr(88888, 6)[2] == 'h' );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/rope/36832.cc b/libstdc++-v3/testsuite/ext/rope/36832.cc
new file mode 100644
index 000000000..063df3cc9
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/rope/36832.cc
@@ -0,0 +1,35 @@
+// 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/>.
+
+// rope (SGI extension)
+
+#include <ext/rope>
+
+// libstdc++/36832
+void test01()
+{
+ __gnu_cxx::crope myRope;
+ myRope = "1234567890";
+ char buffer[100];
+ myRope.copy(1, 1, buffer);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/rope/4.cc b/libstdc++-v3/testsuite/ext/rope/4.cc
new file mode 100644
index 000000000..a7421f345
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/rope/4.cc
@@ -0,0 +1,39 @@
+// Copyright (C) 2005, 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/>.
+
+// sequence_buffer (SGI extension)
+
+#include <ext/rope>
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::crope r1("wibble");
+ __gnu_cxx::crope r2;
+ std::copy( r1.begin(), r1.end(),
+ __gnu_cxx::sequence_buffer<__gnu_cxx::crope>(r2) );
+ VERIFY( r1 == r2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/rope/40299.cc b/libstdc++-v3/testsuite/ext/rope/40299.cc
new file mode 100644
index 000000000..4d83fc98c
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/rope/40299.cc
@@ -0,0 +1,27 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 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 <ext/rope>
+
+// libstdc++/40299
+void test01()
+{
+ __gnu_cxx::crope asdf;
+}
diff --git a/libstdc++-v3/testsuite/ext/rope/44708.cc b/libstdc++-v3/testsuite/ext/rope/44708.cc
new file mode 100644
index 000000000..ac2fa95c7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/rope/44708.cc
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2010 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 <iostream>
+#include <ext/rope>
+
+using namespace std;
+
+// libstdc++/44708
+void test01()
+{
+ __gnu_cxx::crope line("test-test-test");
+ cout << line.c_str() << endl;
+}
diff --git a/libstdc++-v3/testsuite/ext/rope/44963.cc b/libstdc++-v3/testsuite/ext/rope/44963.cc
new file mode 100644
index 000000000..32bd9ded6
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/rope/44963.cc
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2010 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 <ext/rope>
+
+// libstdc++/44963
+void test01()
+{
+ __gnu_cxx::crope line("test");
+ auto ii(std::back_inserter(line));
+
+ *ii++ = 'm';
+ *ii++ = 'e';
+}
diff --git a/libstdc++-v3/testsuite/ext/rope/pthread7-rope.cc b/libstdc++-v3/testsuite/ext/rope/pthread7-rope.cc
new file mode 100644
index 000000000..fd1ed09c6
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/rope/pthread7-rope.cc
@@ -0,0 +1,103 @@
+// 2003-05-03 Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
+//
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010
+// 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/>.
+
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthreads" { target *-*-solaris* } }
+
+#include <ext/rope>
+#include <cstring>
+#include <pthread.h>
+#include <testsuite_hooks.h>
+
+const int max_thread_count = 4;
+const int max_loop_count = 10000;
+
+typedef __gnu_cxx::rope<char, std::allocator<char> > rope_type;
+rope_type foo2;
+rope_type foo4;
+
+void* thread_main(void *)
+{
+ // To see a problem with gcc 3.3 and before, set a break point here.
+ // Single step through c_str implementation, call sched_yield after
+ // capture of NULL __old_c_string in any thread. Single step
+ // through another thread past that same point. Now, one thread
+ // will receive a bad pointer return. Adding dummy sched_yield
+ // should never change program semantics under POSIX threads.
+ const char* data4 = foo4.c_str();
+
+ // Please note that the memory leak in the rope implementation with
+ // this test case, existed before and after fixing this bug...
+ bool test __attribute__((unused)) = true;
+ VERIFY( !std::strcmp (data4, "barbazbonglehellohellohello") );
+ return 0;
+}
+
+int
+main()
+{
+ bool test __attribute__((unused)) = true;
+
+ pthread_t tid[max_thread_count];
+
+#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
+ pthread_setconcurrency (max_thread_count);
+#endif
+
+ rope_type foo;
+ foo += "bar";
+ foo += "baz";
+ foo += "bongle";
+ const char* data = foo.c_str();
+ VERIFY( !std::strcmp (data, "barbazbongle") );
+
+ const char* data2;
+ {
+ foo2 += "bar2";
+ foo2 += "baz2";
+ foo2 += "bongle2";
+ data2 = foo2.c_str();
+ VERIFY( !std::strcmp (data2, "bar2baz2bongle2") );
+ }
+
+ rope_type foo3 ("hello");
+ const char* data3 = foo3.c_str();
+ VERIFY( !std::strcmp (data3, "hello") );
+
+ for (int j = 0; j < max_loop_count; j++)
+ {
+ foo4 = foo;
+ foo4 += foo3;
+ foo4 += foo3;
+ foo4 += foo3;
+
+ for (int i = 0; i < max_thread_count; i++)
+ pthread_create (&tid[i], 0, thread_main, 0);
+
+ for (int i = 0; i < max_thread_count; i++)
+ pthread_join (tid[i], 0);
+ }
+
+ VERIFY( !std::strcmp (data, "barbazbongle") );
+ VERIFY( !std::strcmp (data2, "bar2baz2bongle2") );
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/slist/23781_neg.cc b/libstdc++-v3/testsuite/ext/slist/23781_neg.cc
new file mode 100644
index 000000000..e1493c675
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/slist/23781_neg.cc
@@ -0,0 +1,28 @@
+// 2005-09-10 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005, 2009, 2010 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/>.
+//
+
+// { dg-do compile }
+
+// libstdc++/23781
+#include <ext/slist>
+#include <cstddef>
+
+__gnu_cxx::slist<int>::iterator it = NULL; // { dg-error "conversion" }
+__gnu_cxx::slist<int>::const_iterator cit = NULL; // { dg-error "conversion" }
diff --git a/libstdc++-v3/testsuite/ext/slist/check_construct_destroy.cc b/libstdc++-v3/testsuite/ext/slist/check_construct_destroy.cc
new file mode 100644
index 000000000..c310515ad
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/slist/check_construct_destroy.cc
@@ -0,0 +1,78 @@
+// 2004-07-26 Matt Austern <austern@apple.com>
+//
+// Copyright (C) 2003, 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 <ext/slist>
+#include <iterator>
+#include <testsuite_allocator.h>
+
+using namespace __gnu_test;
+
+int main()
+{
+ typedef __gnu_cxx::slist<int, tracker_allocator<int> > Container;
+ const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 };
+ bool ok = true;
+
+ tracker_allocator_counter::reset();
+ {
+ Container c;
+ ok = check_construct_destroy("empty container", 0, 0) && ok;
+ }
+ ok = check_construct_destroy("empty container", 0, 0) && ok;
+
+
+ tracker_allocator_counter::reset();
+ {
+ Container c(arr10, arr10 + 10);
+ ok = check_construct_destroy("Construct from range", 10, 0) && ok;
+ }
+ ok = check_construct_destroy("Construct from range", 10, 10) && ok;
+
+ {
+ Container c(arr10, arr10 + 10);
+ tracker_allocator_counter::reset();
+ c.insert(c.begin(), arr10[0]);
+ ok = check_construct_destroy("Insert element", 1, 0) && ok;
+ }
+ ok = check_construct_destroy("Insert element", 1, 11) && ok;
+
+ {
+ Container c(arr10, arr10 + 10);
+ tracker_allocator_counter::reset();
+ Container::iterator i5 = c.begin();
+ std::advance(i5, 5);
+ c.insert(i5, arr10, arr10+3);
+ ok = check_construct_destroy("Insert short range", 3, 0) && ok;
+ }
+ ok = check_construct_destroy("Insert short range", 3, 13) && ok;
+
+ {
+ Container c(arr10, arr10 + 10);
+ tracker_allocator_counter::reset();
+ Container::iterator i7 = c.begin();
+ std::advance(i7, 5);
+ c.insert(i7, arr10, arr10+10);
+ ok = check_construct_destroy("Insert long range", 10, 0) && ok;
+ }
+ ok = check_construct_destroy("Insert long range", 10, 20) && ok;
+
+ return ok ? 0 : 1;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/slist/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/ext/slist/requirements/explicit_instantiation.cc
new file mode 100644
index 000000000..71bf20bd3
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/slist/requirements/explicit_instantiation.cc
@@ -0,0 +1,25 @@
+// Copyright (C) 2004, 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 file tests explicit instantiation of library containers
+
+#include <ext/slist>
+
+// { dg-do compile }
+
+template class __gnu_cxx::slist<int>;
diff --git a/libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-1.cc b/libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-1.cc
new file mode 100644
index 000000000..d920683f0
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-1.cc
@@ -0,0 +1,57 @@
+// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+// Free Software Foundation
+//
+// 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/>.
+
+// { dg-require-fileio "" }
+
+#include <cstdio>
+#include <fstream>
+#include <cstring>
+#include <ext/stdio_filebuf.h>
+#include <testsuite_hooks.h>
+
+void test1()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ FILE* file = fopen("tmp_10063-1", "w");
+ putc('0', file);
+ putc('1', file);
+ {
+ __gnu_cxx::stdio_filebuf<char> sbuf(file, ios_base::out);
+ sbuf.sputc('2');
+ sbuf.sputc('3');
+ }
+ putc('4', file);
+ fclose(file);
+
+ filebuf fbuf;
+ fbuf.open("tmp_10063-1", ios_base::in);
+ char buf[10];
+ streamsize n = fbuf.sgetn(buf, sizeof(buf));
+ fbuf.close();
+
+ VERIFY(n == 5);
+ VERIFY(!memcmp(buf, "01234", 5));
+}
+
+int main()
+{
+ test1();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-2.cc b/libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-2.cc
new file mode 100644
index 000000000..d0a1fcfc4
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-2.cc
@@ -0,0 +1,63 @@
+// Copyright (C) 2000, 2001, 2002, 2003, 2009, 2010 Free Software Foundation
+//
+// 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/>.
+
+// The ARM simulator does not provide support for "fstat", which
+// causes "sbumpc" to return an incorrect value.
+// { dg-do run { xfail arm*-*-elf arm*-*-eabi } }
+
+// { dg-require-fileio "" }
+
+#include <cstdio>
+#include <fstream>
+#include <ext/stdio_filebuf.h>
+#include <testsuite_hooks.h>
+
+void test2()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ filebuf fbuf;
+ fbuf.open("tmp_10063-2", ios_base::out | ios_base::trunc);
+ fbuf.sputn("01234", 5);
+ fbuf.close();
+
+ FILE* file = fopen("tmp_10063-2", "r");
+ setbuf(file, 0);
+ int c = getc(file);
+ VERIFY(c == '0');
+ c = getc(file);
+ VERIFY(c == '1');
+ {
+ __gnu_cxx::stdio_filebuf<char> sbuf(file, ios_base::in);
+ c = sbuf.sbumpc();
+ VERIFY(c == '2');
+ c = sbuf.sbumpc();
+ VERIFY(c == '3');
+ c = sbuf.sbumpc();
+ VERIFY(c == '4');
+ c = sbuf.sgetc();
+ VERIFY(c == EOF);
+ }
+ fclose(file);
+}
+
+int main()
+{
+ test2();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-3.cc b/libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-3.cc
new file mode 100644
index 000000000..edffd047e
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_filebuf/char/10063-3.cc
@@ -0,0 +1,62 @@
+// Copyright (C) 2004, 2009 Free Software Foundation
+//
+// 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/>.
+
+// The ARM simulator does not provide support for "fstat", which
+// causes "sbumpc" to return an incorrect value.
+// { dg-do run { xfail arm*-*-elf arm*-*-eabi } }
+
+// { dg-require-fileio "" }
+
+#include <cstdio>
+#include <fstream>
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+void test3()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ filebuf fbuf;
+ fbuf.open("tmp_10063-3", ios_base::out | ios_base::trunc);
+ fbuf.sputn("01234", 5);
+ fbuf.close();
+
+ FILE* file = fopen("tmp_10063-3", "r");
+ int c = getc(file);
+ VERIFY(c == '0');
+ c = getc(file);
+ VERIFY(c == '1');
+ {
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ c = sbuf.sbumpc();
+ VERIFY(c == '2');
+ c = sbuf.sbumpc();
+ VERIFY(c == '3');
+ c = sbuf.sbumpc();
+ VERIFY(c == '4');
+ c = sbuf.sgetc();
+ VERIFY(c == EOF);
+ }
+ fclose(file);
+}
+
+int main()
+{
+ test3();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_filebuf/char/2.cc b/libstdc++-v3/testsuite/ext/stdio_filebuf/char/2.cc
new file mode 100644
index 000000000..aada638bb
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_filebuf/char/2.cc
@@ -0,0 +1,62 @@
+// 2003-04-12 Paolo Carlini <pcarlini at unitus dot it>
+
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 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/>.
+
+// stdio_filebuf.h
+
+// { dg-require-fileio "" }
+
+#include <ext/stdio_filebuf.h>
+#include <cstdio>
+#include <fstream>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// Small stack-based buffers (i.e., using _M_unbuf) were not flushed
+// out by _M_really_overflow upon overflow.
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ const char* name = "tmp_file1";
+ FILE* file = fopen(name, "w");
+ {
+ using namespace __gnu_cxx;
+ stdio_filebuf<char> sbuf(file, ios_base::out, 2);
+ sbuf.sputc('T');
+ sbuf.sputc('S');
+ sbuf.sputc('P');
+ }
+ fclose(file);
+
+ filebuf fbuf;
+ fbuf.open(name, ios_base::in);
+ char buf[10];
+ streamsize n = fbuf.sgetn(buf, sizeof(buf));
+ fbuf.close();
+
+ VERIFY( n == 3 );
+ VERIFY( !memcmp(buf, "TSP", 3) );
+}
+
+int main()
+{
+ test01();
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_filebuf/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/ext/stdio_filebuf/requirements/explicit_instantiation.cc
new file mode 100644
index 000000000..6c4afc022
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_filebuf/requirements/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// 2003-02-11 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2003, 2004, 2005, 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/>.
+
+// stdio_filebuf.h
+
+#include <ext/stdio_filebuf.h>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+// { dg-do compile }
+
+// libstdc++/9320
+namespace __gnu_cxx
+{
+ typedef short type_t;
+ template class stdio_filebuf<type_t, std::char_traits<type_t> >;
+ template class stdio_filebuf<__gnu_test::pod_char, std::char_traits<__gnu_test::pod_char> >;
+} // __gnu_cxx
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/1.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/1.cc
new file mode 100644
index 000000000..47b337213
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/1.cc
@@ -0,0 +1,66 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Free Software Foundation
+//
+// 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/>.
+
+// { dg-require-fileio "" }
+
+#include <ext/stdio_sync_filebuf.h>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+
+ bool test __attribute__((unused)) = true;
+ const char* c_lit = "black pearl jasmine tea";
+ unsigned size = strlen(c_lit);
+ const char* name = "stdiobuf-1.txt";
+
+ FILE* fout = fopen(name, "w");
+ VERIFY( fwrite(c_lit, 1, size, fout) == size );
+ fclose(fout);
+
+ FILE* fin = fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(fin);
+
+ VERIFY( sbuf.sgetc() == c_lit[0] );
+ VERIFY( getc(fin) == c_lit[0] );
+ VERIFY( sbuf.sgetc() == c_lit[1] );
+ VERIFY( sbuf.sbumpc() == c_lit[1] );
+ VERIFY( ungetc('Z', fin) == 'Z' );
+ VERIFY( sbuf.sbumpc() == 'Z' );
+ VERIFY( getc(fin) == c_lit[2] );
+ VERIFY( sbuf.sputbackc('X') == 'X' );
+ VERIFY( getc(fin) == 'X' );
+
+ char buf[5];
+ memset(buf, 'x', 5);
+ VERIFY( sbuf.sgetn(buf, 5) == 5 );
+ VERIFY( !memcmp(buf, c_lit + 3, 5) );
+ VERIFY( getc(fin) == c_lit[8] );
+
+ fclose(fin);
+}
+
+int main ()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-1.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-1.cc
new file mode 100644
index 000000000..521575fca
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-1.cc
@@ -0,0 +1,47 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-require-fileio "" }
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ int c1 = sbuf.sbumpc();
+ VERIFY( c1 != EOF );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = sbuf.sbumpc();
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-2.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-2.cc
new file mode 100644
index 000000000..f7c4eeef3
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-2.cc
@@ -0,0 +1,47 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-require-fileio "" }
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ int c1 = sbuf.sbumpc();
+ VERIFY( c1 != EOF );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = std::fgetc(file);
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-3.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-3.cc
new file mode 100644
index 000000000..9070e80f6
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-3.cc
@@ -0,0 +1,47 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-require-fileio "" }
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ char buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = sbuf.sbumpc();
+ VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-4.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-4.cc
new file mode 100644
index 000000000..ab41acab3
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-4.cc
@@ -0,0 +1,47 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-require-fileio "" }
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test05()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+ char buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ int c2 = sbuf.sungetc();
+ VERIFY( c2 != EOF );
+ int c3 = std::fgetc(file);
+ VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/35209.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/35209.cc
new file mode 100644
index 000000000..b199b58f7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/35209.cc
@@ -0,0 +1,39 @@
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-do link }
+
+#include <ext/stdio_sync_filebuf.h>
+
+struct my_ssf
+: __gnu_cxx::stdio_sync_filebuf<char>
+{
+ my_ssf(std::__c_file* __f)
+ : __gnu_cxx::stdio_sync_filebuf<char>(__f) { }
+};
+
+// libstdc++/35209
+void test01()
+{
+ my_ssf ss1(0);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc
new file mode 100644
index 000000000..2629ecb43
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc
@@ -0,0 +1,66 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Free Software Foundation
+//
+// 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 <ext/stdio_sync_filebuf.h>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef char_traits<wchar_t> traits_type;
+
+ bool test __attribute__((unused)) = true;
+ const char* c_lit = "black pearl jasmine tea";
+ const wchar_t* w_lit = L"black pearl jasmine tea";
+ unsigned size = strlen(c_lit);
+ const char* name = "stdiobuf-1.txt";
+
+ FILE* fout = fopen(name, "w");
+ VERIFY( fwrite(c_lit, 1, size, fout) == size );
+ fclose(fout);
+
+ FILE* fin = fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> wsbuf(fin);
+
+ VERIFY( traits_type::to_char_type(wsbuf.sgetc()) == w_lit[0] );
+ VERIFY( traits_type::to_char_type(getwc(fin)) == w_lit[0] );
+ VERIFY( traits_type::to_char_type(wsbuf.sgetc()) == w_lit[1] );
+ VERIFY( traits_type::to_char_type(wsbuf.sbumpc()) == w_lit[1] );
+ VERIFY( ungetwc(L'Z', fin) == L'Z' );
+ VERIFY( wsbuf.sbumpc() == L'Z' );
+ VERIFY( traits_type::to_char_type(getwc(fin)) == w_lit[2] );
+ VERIFY( wsbuf.sputbackc(L'X') == L'X' );
+ VERIFY( getwc(fin) == L'X' );
+
+ wchar_t buf[5];
+ wmemset(buf, static_cast<wchar_t>(0xdeadbeef), 5);
+ VERIFY( wsbuf.sgetn(buf, 5) == 5 );
+ VERIFY( !wmemcmp(buf, w_lit + 3, 5) );
+ VERIFY( traits_type::to_char_type(getwc(fin)) == w_lit[8] );
+
+ fclose(fin);
+}
+
+int main ()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12077.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12077.cc
new file mode 100644
index 000000000..7e4795f68
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12077.cc
@@ -0,0 +1,81 @@
+// { dg-require-namedlocale "is_IS.UTF-8" }
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation
+//
+// 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 <iostream>
+#include <locale>
+#include <cstdio>
+#include <testsuite_hooks.h>
+
+// libstdc++/12077
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ const char* name = "tmp_12077";
+
+ locale loc = locale("is_IS.UTF-8");
+ locale::global(loc);
+ wcin.imbue(loc);
+
+ const char* str =
+ "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10\x11\x12\x13"
+ "\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20!\"#$%&"
+ "'()*+,-./0123456789:;<=>?@}~\x7f\xc2\x80\xc2\x81\xc2\x82\xc2"
+ "\x83\xc2\x84\xc2\x85\xc2\x86\xc2\x87\xc2\x88\xc2\x89\xc2\x8a"
+ "\xc2\x8b\xc2\x8c\xc2\x8d\xc2\x8e\xc2\x8f\xc2\x90\xc2\x91\xc2"
+ "\x92\xc2\x93\xc2\x94\xc2\x95\xc2\x96\xc2\x97\xc2\x98\xc2\x99"
+ "\xc2\x9a\xc2\x9b\xc2\x9c\xc3\xba\xc3\xbb\xc3\xbc\xc3\xbd\xc3"
+ "\xbe\xc3\xbf\xc4\x80\xc4\x81\xc4\x82\xc4\x83\xc4\x84\xc4\x85"
+ "\xc4\x86\xc4\x87\xc4\x88\xc4\x89\xc4\x8a\xc4\x8b\xc4\x8c\xc4"
+ "\x8d\xc4\x8e\xc4\x8f\xc4\x90\xc4\x91\xc4\x92\xc4\x93\xc4\x94"
+ "\xc4\x95\xc4\x96\xc4\x97\xc4\x98\xc4\x99\xdf\xb8\xdf\xb9\xdf"
+ "\xba\xdf\xbb\xdf\xbc\xdf\xbd\xdf\xbe\xdf\xbf\xe0\xa0\x80\xe0"
+ "\xa0\x81\xe0\xa0\x82\xe0\xa0\x83\xe0\xa0\x84\xe0\xa0\x85\xe0"
+ "\xa0\x86\xe0\xa0\x87\xe0\xa0\x88\xe0\xa0\x89\xe0\xa0\x8a\xe0"
+ "\xa0\x8b\xe0\xa0\x8c\xe0\xa0\x8d\xe0\xa0\x8e\xe0\xa0\x8f\xe0"
+ "\xa0\x90\xe0\xa0\x91\xe0\xa0\x92\xe0\xa0\x93\xe0\xa0\x94\xe0"
+ "\xa0\x95\xe0\xa0\x96\xe0\xa0\x97\x1\x2\x4\x8\x10\x20@\xc2\x80"
+ "\xc4\x80\xc8\x80\xd0\x80\xe0\xa0\x80\xe1\x80\x80\xe2\x80\x80"
+ "\xe4\x80\x80\xe8\x80\x80\xf0\x90\x80\x80\xf0\xa0\x80\x80\xf1"
+ "\x80\x80\x80\xf2\x80\x80\x80\xf4\x80\x80\x80\xf8\x88\x80\x80"
+ "\x80\xf8\x90\x80\x80\x80\xf8\xa0\x80\x80\x80\xf9\x80\x80\x80"
+ "\x80\xfa\x80\x80\x80\x80\xfc\x84\x80\x80\x80\x80\xfc\x88\x80"
+ "\x80\x80\x80\xfc\x90\x80\x80\x80\x80\xfc\xa0\x80\x80\x80\x80"
+ "\xfd\x80\x80\x80\x80\x80";
+
+ FILE* file = fopen(name, "w");
+ fputs(str, file);
+ fclose(file);
+
+ VERIFY( freopen(name, "r", stdin) );
+
+ streamsize n = wcin.rdbuf()->in_avail();
+ while (n--)
+ {
+ wint_t c = wcin.rdbuf()->sbumpc();
+ VERIFY( c != WEOF );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc
new file mode 100644
index 000000000..c3d35046c
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc
@@ -0,0 +1,45 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003, 2009 Free Software Foundation
+//
+// 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 <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ std::wint_t c1 = sbuf.sbumpc();
+ VERIFY( c1 != WEOF );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = sbuf.sbumpc();
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc
new file mode 100644
index 000000000..1756e3070
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc
@@ -0,0 +1,45 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003, 2009 Free Software Foundation
+//
+// 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 <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ std::wint_t c1 = sbuf.sbumpc();
+ VERIFY( c1 != WEOF );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = std::fgetwc(file);
+ VERIFY( c3 == c1 );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc
new file mode 100644
index 000000000..29cdea7bb
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc
@@ -0,0 +1,45 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003, 2009 Free Software Foundation
+//
+// 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 <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ wchar_t buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = sbuf.sbumpc();
+ VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc
new file mode 100644
index 000000000..a0e83551c
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc
@@ -0,0 +1,45 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003, 2009 Free Software Foundation
+//
+// 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 <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test05()
+{
+ bool test __attribute__((unused)) = true;
+ const char* name = "cin_unget-1.txt";
+
+ std::FILE* file = std::fopen(name, "r");
+ __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+ wchar_t buf[2];
+ VERIFY( sbuf.sgetn(buf, 2) == 2 );
+ std::wint_t c2 = sbuf.sungetc();
+ VERIFY( c2 != WEOF );
+ std::wint_t c3 = std::fgetwc(file);
+ VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
+
+ std::fclose(file);
+}
+
+int main ()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/35209.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/35209.cc
new file mode 100644
index 000000000..0f25a392e
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/35209.cc
@@ -0,0 +1,39 @@
+// Copyright (C) 2008, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-do link }
+
+#include <ext/stdio_sync_filebuf.h>
+
+struct my_ssf
+: __gnu_cxx::stdio_sync_filebuf<wchar_t>
+{
+ my_ssf(std::__c_file* __f)
+ : __gnu_cxx::stdio_sync_filebuf<wchar_t>(__f) { }
+};
+
+// libstdc++/35209
+void test01()
+{
+ my_ssf ss1(0);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/check_allocate_max_size.cc b/libstdc++-v3/testsuite/ext/throw_allocator/check_allocate_max_size.cc
new file mode 100644
index 000000000..b4d099671
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/throw_allocator/check_allocate_max_size.cc
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2007, 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/>.
+
+// { dg-require-time "" }
+
+#include <ext/throw_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type;
+ __gnu_test::check_allocate_max_size<allocator_type>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/check_deallocate_null.cc b/libstdc++-v3/testsuite/ext/throw_allocator/check_deallocate_null.cc
new file mode 100644
index 000000000..3f9d37ab1
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/throw_allocator/check_deallocate_null.cc
@@ -0,0 +1,37 @@
+//
+// Copyright (C) 2007, 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/>.
+
+// { dg-require-time "" }
+
+#include <ext/throw_allocator.h>
+#include <testsuite_allocator.h>
+
+int main()
+{
+ typedef int value_type;
+ typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type;
+
+ try { __gnu_test::check_deallocate_null<allocator_type>(); }
+ catch (std::logic_error&)
+ {
+ // Should throw logic_error to catch null erase.
+ }
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc
new file mode 100644
index 000000000..181a1ebc7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2007, 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/>.
+
+// { dg-require-time "" }
+
+#include <cstdlib>
+#include <ext/throw_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef __gnu_cxx::throw_allocator_random<unsigned int> allocator_type;
+ __gnu_test::check_delete<allocator_type, true>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc b/libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc
new file mode 100644
index 000000000..4338471a0
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2007, 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/>.
+
+// { dg-require-time "" }
+
+#include <cstdlib>
+#include <ext/throw_allocator.h>
+#include <replacement_memory_operators.h>
+
+int main()
+{
+ typedef __gnu_cxx::throw_allocator_random<unsigned int> allocator_type;
+ __gnu_test::check_new<allocator_type, true>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/deallocate_global.cc b/libstdc++-v3/testsuite/ext/throw_allocator/deallocate_global.cc
new file mode 100644
index 000000000..b9d3ae760
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/throw_allocator/deallocate_global.cc
@@ -0,0 +1,40 @@
+// { dg-require-cxa-atexit "" }
+
+//
+// Copyright (C) 2007, 2009, 2010 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/>.
+
+// { dg-require-time "" }
+
+#include <string>
+#include <stdexcept>
+#include <ext/throw_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char char_t;
+typedef std::char_traits<char_t> traits_t;
+typedef __gnu_cxx::throw_allocator_random<char_t> allocator_t;
+typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
+
+#ifndef _GLIBCXX_PROFILE
+string_t s("bayou bend");
+#endif
+
+int main()
+{
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/deallocate_local.cc b/libstdc++-v3/testsuite/ext/throw_allocator/deallocate_local.cc
new file mode 100644
index 000000000..0b22a76aa
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/throw_allocator/deallocate_local.cc
@@ -0,0 +1,43 @@
+//
+// Copyright (C) 2007, 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/>.
+
+// { dg-require-time "" }
+
+#include <string>
+#include <ext/throw_allocator.h>
+#include <replacement_memory_operators.h>
+
+typedef char char_t;
+typedef std::char_traits<char_t> traits_t;
+typedef __gnu_cxx::throw_allocator_random<char_t> allocator_t;
+typedef std::basic_string<char_t, traits_t, allocator_t> string_t;
+
+int main()
+{
+#ifndef _GLIBCXX_PROFILE
+ {
+ string_t s;
+ s += "bayou bend";
+ }
+#endif
+
+ if (__gnu_test::counter::count() != 0)
+ throw std::runtime_error("count not zero");
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/explicit_instantiation.cc b/libstdc++-v3/testsuite/ext/throw_allocator/explicit_instantiation.cc
new file mode 100644
index 000000000..c2600446f
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/throw_allocator/explicit_instantiation.cc
@@ -0,0 +1,25 @@
+// { dg-do compile }
+
+//
+// Copyright (C) 2007, 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 <cstdlib>
+#include <ext/throw_allocator.h>
+
+template class __gnu_cxx::throw_allocator_random<int>;
+template class __gnu_cxx::throw_allocator_limit<int>;
diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/variadic_construct.cc b/libstdc++-v3/testsuite/ext/throw_allocator/variadic_construct.cc
new file mode 100644
index 000000000..fd1ee8df4
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/throw_allocator/variadic_construct.cc
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2007-10-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 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/>.
+
+// { dg-require-time "" }
+
+#include <ext/throw_allocator.h>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::pair<int, char> pair_type;
+ __gnu_cxx::throw_allocator_random<pair_type> alloc1;
+
+ pair_type* ptp1 = alloc1.allocate(1);
+ alloc1.construct(ptp1, 3, 'a');
+
+ VERIFY( ptp1->first == 3 );
+ VERIFY( ptp1->second == 'a' );
+
+ alloc1.deallocate(ptp1, 1);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/throw_value/cons.cc b/libstdc++-v3/testsuite/ext/throw_value/cons.cc
new file mode 100644
index 000000000..fa3f3f71c
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/throw_value/cons.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 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 <type_traits>
+#include <ext/throw_allocator.h>
+
+void foo1()
+{
+ typedef __gnu_cxx::throw_value_limit value_type;
+ value_type v1;
+ value_type v2(v2);
+ value_type v3(value_type());
+}
+
+bool foo2()
+{
+ typedef __gnu_cxx::throw_value_limit value_type;
+ bool b = std::is_convertible<value_type, value_type>::value;
+ return b;
+}
+
+int main()
+{
+ foo1();
+ foo2();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/type_traits/add_unsigned.cc b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned.cc
new file mode 100644
index 000000000..a6b0aee24
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned.cc
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+
+// Copyright (C) 2006, 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 <ext/type_traits.h>
+#include <tr1/type_traits>
+#include <testsuite_hooks.h>
+
+template<typename T>
+ void
+ check_add_unsigned()
+ {
+ bool test __attribute__((unused)) = true;
+ typedef typename __gnu_cxx::__add_unsigned<T>::__type unsigned_type;
+ VERIFY( std::tr1::is_unsigned<unsigned_type>::value );
+ }
+
+int main()
+{
+ check_add_unsigned<char>();
+ check_add_unsigned<unsigned char>();
+ check_add_unsigned<signed char>();
+ check_add_unsigned<int>();
+ check_add_unsigned<unsigned int>();
+ check_add_unsigned<signed int>();
+ check_add_unsigned<long>();
+ check_add_unsigned<unsigned long>();
+ check_add_unsigned<signed long>();
+ check_add_unsigned<long long>();
+ check_add_unsigned<unsigned long long>();
+ check_add_unsigned<signed long long>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc
new file mode 100644
index 000000000..3e46b8538
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_floating_neg.cc
@@ -0,0 +1,38 @@
+// { dg-do compile }
+// -*- C++ -*-
+
+// Copyright (C) 2006, 2007, 2009, 2011 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 <ext/type_traits.h>
+#include <tr1/type_traits>
+
+template<typename T>
+ void
+ check_add_unsigned()
+ {
+ typedef typename __gnu_cxx::__add_unsigned<T>::__type unsigned_type;
+ }
+
+int main()
+{
+ check_add_unsigned<float>(); // { dg-error "instantiated from" }
+ return 0;
+}
+
+// { dg-error "instantiated from" "" { target *-*-* } 28 }
+// { dg-error "no type" "" { target *-*-* } 70 }
diff --git a/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc
new file mode 100644
index 000000000..59bc10153
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/type_traits/add_unsigned_integer_neg.cc
@@ -0,0 +1,39 @@
+// { dg-do compile }
+// -*- C++ -*-
+
+// Copyright (C) 2006, 2007, 2009, 2011 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 <ext/type_traits.h>
+#include <tr1/type_traits>
+
+template<typename T>
+ void
+ check_add_unsigned()
+ {
+ typedef typename __gnu_cxx::__add_unsigned<T>::__type unsigned_type;
+ }
+
+int main()
+{
+ check_add_unsigned<bool>(); // { dg-error "instantiated from" }
+ check_add_unsigned<wchar_t>(); // { dg-error "instantiated from" }
+ return 0;
+}
+
+// { dg-error "invalid use of incomplete" "" { target *-*-* } 28 }
+// { dg-error "declaration of" "" { target *-*-* } 64 }
diff --git a/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned.cc b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned.cc
new file mode 100644
index 000000000..b72d42aca
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned.cc
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+
+// Copyright (C) 2006, 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 <ext/type_traits.h>
+#include <tr1/type_traits>
+#include <testsuite_hooks.h>
+
+template<typename T>
+ void
+ check_remove_unsigned()
+ {
+ bool test __attribute__((unused)) = true;
+ typedef typename __gnu_cxx::__remove_unsigned<T>::__type signed_type;
+ VERIFY( std::tr1::is_signed<signed_type>::value );
+ }
+
+int main()
+{
+ check_remove_unsigned<char>();
+ check_remove_unsigned<unsigned char>();
+ check_remove_unsigned<signed char>();
+ check_remove_unsigned<int>();
+ check_remove_unsigned<unsigned int>();
+ check_remove_unsigned<signed int>();
+ check_remove_unsigned<long>();
+ check_remove_unsigned<unsigned long>();
+ check_remove_unsigned<signed long>();
+ check_remove_unsigned<long long>();
+ check_remove_unsigned<unsigned long long>();
+ check_remove_unsigned<signed long long>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc
new file mode 100644
index 000000000..291ef7554
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_floating_neg.cc
@@ -0,0 +1,38 @@
+// { dg-do compile }
+// -*- C++ -*-
+
+// Copyright (C) 2006, 2007, 2009, 2011 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 <ext/type_traits.h>
+#include <tr1/type_traits>
+
+template<typename T>
+ void
+ check_remove_unsigned()
+ {
+ typedef typename __gnu_cxx::__remove_unsigned<T>::__type signed_type;
+ }
+
+int main()
+{
+ check_remove_unsigned<float>(); // { dg-error "instantiated from" }
+ return 0;
+}
+
+// { dg-error "instantiated from" "" { target *-*-* } 28 }
+// { dg-error "no type" "" { target *-*-* } 113 }
diff --git a/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc
new file mode 100644
index 000000000..0f79877f7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/type_traits/remove_unsigned_integer_neg.cc
@@ -0,0 +1,39 @@
+// { dg-do compile }
+// -*- C++ -*-
+
+// Copyright (C) 2006, 2007, 2009, 2011 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 <ext/type_traits.h>
+#include <tr1/type_traits>
+
+template<typename T>
+ void
+ check_remove_unsigned()
+ {
+ typedef typename __gnu_cxx::__remove_unsigned<T>::__type signed_type;
+ }
+
+int main()
+{
+ check_remove_unsigned<bool>(); // { dg-error "instantiated from" }
+ check_remove_unsigned<wchar_t>(); // { dg-error "instantiated from" }
+ return 0;
+}
+
+// { dg-error "invalid use of incomplete" "" { target *-*-* } 28 }
+// { dg-error "declaration of" "" { target *-*-* } 107 }
diff --git a/libstdc++-v3/testsuite/ext/vstring/assign/move_assign.cc b/libstdc++-v3/testsuite/ext/vstring/assign/move_assign.cc
new file mode 100644
index 000000000..3f9e055b8
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/assign/move_assign.cc
@@ -0,0 +1,54 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2010 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/>.
+
+// NOTE: This makes use of the fact that we know how moveable
+// is implemented on vstring (via swap). If the implementation changes
+// this test may begin to fail.
+
+#include <ext/vstring.h>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::__sso_string a, b;
+ a.push_back('1');
+ b.assign(std::move(a));
+ VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::__rc_string a, b;
+ a.push_back('1');
+ b.assign(std::move(a));
+ VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/capacity/29134.cc b/libstdc++-v3/testsuite/ext/vstring/capacity/29134.cc
new file mode 100644
index 000000000..b572f1eb7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/capacity/29134.cc
@@ -0,0 +1,37 @@
+// Copyright (C) 2006, 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/>.
+
+// 21.3.3 basic_string capacity [lib.string.capacity]
+
+#include <ext/vstring.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/29134
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::__vstring vs;
+
+ VERIFY( vs.max_size() <= vs.get_allocator().max_size() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/capacity/shrink_to_fit.cc b/libstdc++-v3/testsuite/ext/vstring/capacity/shrink_to_fit.cc
new file mode 100644
index 000000000..bed965a5e
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/capacity/shrink_to_fit.cc
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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 <ext/vstring.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/42573
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::__vstring vs(100, 'a');
+ vs.push_back('b');
+ vs.push_back('b');
+ VERIFY( vs.size() < vs.capacity() );
+ vs.shrink_to_fit();
+ VERIFY( vs.size() == vs.capacity() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/cons/moveable.cc b/libstdc++-v3/testsuite/ext/vstring/cons/moveable.cc
new file mode 100644
index 000000000..b2572b2dd
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/cons/moveable.cc
@@ -0,0 +1,63 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2007, 2008, 2009, 2010 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/>.
+
+
+// NOTE: This makes use of the fact that we know how moveable
+// is implemented on vstring (via swap). If the implementation changes
+// this test may begin to fail.
+
+#include <ext/vstring.h>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::__sso_string a,b;
+ a.push_back('1');
+ b = std::move(a);
+ VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
+
+ __gnu_cxx::__sso_string c(std::move(b));
+ VERIFY( c.size() == 1 && c[0] == '1' );
+ VERIFY( b.size() == 0 );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::__rc_string a,b;
+ a.push_back('1');
+ b = std::move(a);
+ VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
+
+ __gnu_cxx::__rc_string c(std::move(b));
+ VERIFY( c.size() == 1 && c[0] == '1' );
+ VERIFY( b.size() == 0 );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/element_access/char/front_back.cc b/libstdc++-v3/testsuite/ext/vstring/element_access/char/front_back.cc
new file mode 100644
index 000000000..a1d4c5f02
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/element_access/char/front_back.cc
@@ -0,0 +1,44 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2007-10-16 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 2009 Free Software Foundation
+//
+// 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 <ext/vstring.h>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::__vstring str("ramifications");
+ const __gnu_cxx::__vstring cstr("melodien");
+
+ VERIFY( str.front() == 'r' );
+ VERIFY( str.back() == 's' );
+ VERIFY( cstr.front() == 'm' );
+ VERIFY( cstr.back() == 'n' );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/element_access/wchar_t/front_back.cc b/libstdc++-v3/testsuite/ext/vstring/element_access/wchar_t/front_back.cc
new file mode 100644
index 000000000..6e45bc55e
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/element_access/wchar_t/front_back.cc
@@ -0,0 +1,44 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2007-10-16 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 2009 Free Software Foundation
+//
+// 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 <ext/vstring.h>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::__wvstring str(L"ramifications");
+ const __gnu_cxx::__wvstring cstr(L"melodien");
+
+ VERIFY( str.front() == L'r' );
+ VERIFY( str.back() == L's' );
+ VERIFY( cstr.front() == L'm' );
+ VERIFY( cstr.back() == L'n' );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/hash/char/1.cc b/libstdc++-v3/testsuite/ext/vstring/hash/char/1.cc
new file mode 100644
index 000000000..94dce3787
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/hash/char/1.cc
@@ -0,0 +1,54 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2011 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 <ext/vstring.h>
+#include <unordered_map>
+#include <testsuite_hooks.h>
+
+// libstdc++/47773
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef __gnu_cxx::__vstring vstring_t;
+ typedef std::unordered_map<vstring_t, int> map_t;
+
+ map_t mymap;
+
+ mymap.insert(std::make_pair("hello", 10));
+ mymap.insert(std::make_pair("hi", 20));
+
+ VERIFY( mymap.size() == 2 );
+
+ map_t::const_iterator imap1 = mymap.begin();
+ map_t::const_iterator imap2 = mymap.begin();
+ ++imap2;
+
+ VERIFY( ((imap1->first == "hello" && imap1->second == 10
+ && imap2->first == "hi" && imap2->second == 20)
+ || (imap1->first == "hi" && imap1->second == 20
+ && imap2->first == "hello" && imap2->second == 10)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/hash/wchar_t/1.cc b/libstdc++-v3/testsuite/ext/vstring/hash/wchar_t/1.cc
new file mode 100644
index 000000000..d23a882de
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/hash/wchar_t/1.cc
@@ -0,0 +1,54 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2011 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 <ext/vstring.h>
+#include <unordered_map>
+#include <testsuite_hooks.h>
+
+// libstdc++/47773
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef __gnu_cxx::__wvstring vstring_t;
+ typedef std::unordered_map<vstring_t, int> map_t;
+
+ map_t mymap;
+
+ mymap.insert(std::make_pair(L"hello", 10));
+ mymap.insert(std::make_pair(L"hi", 20));
+
+ VERIFY( mymap.size() == 2 );
+
+ map_t::const_iterator imap1 = mymap.begin();
+ map_t::const_iterator imap2 = mymap.begin();
+ ++imap2;
+
+ VERIFY( ((imap1->first == L"hello" && imap1->second == 10
+ && imap2->first == L"hi" && imap2->second == 20)
+ || (imap1->first == L"hi" && imap1->second == 20
+ && imap2->first == L"hello" && imap2->second == 10)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/init-list.cc b/libstdc++-v3/testsuite/ext/vstring/init-list.cc
new file mode 100644
index 000000000..1d9279f0f
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/init-list.cc
@@ -0,0 +1,71 @@
+// 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/>.
+//
+
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+#include <ext/vstring.h>
+#include <testsuite_hooks.h>
+
+int test01(void)
+{
+ bool test = true;
+
+ __gnu_cxx::__vstring s1 = { 'a', 'b', 'c' };
+ VERIFY(s1 == "abc");
+
+ s1 = { 'd', 'e', 'f' };
+ VERIFY(s1 == "def");
+
+ s1 += { 'g', 'h', 'i' };
+ VERIFY(s1 == "defghi");
+
+ s1.append({ 'j', 'k', 'l' });
+ VERIFY(s1 == "defghijkl");
+
+ s1.assign({ 'm', 'n', 'o' });
+ VERIFY(s1 == "mno");
+
+ // There aren't actually overloads of insert and replace taking size_type
+ // and initializer_list, but test the usage anyway.
+ s1.insert(2, { 'p', 'q', 'r' });
+ VERIFY(s1 == "mnpqro");
+
+ s1.replace(2, 3, { 's', 't', 'u' });
+ VERIFY(s1 == "mnstuo");
+
+ __gnu_cxx::__vstring::iterator i1, i2;
+
+ i1 = s1.begin()+2;
+ s1.insert(i1, { 'v', 'w', 'x' });
+ VERIFY(s1 == "mnvwxstuo");
+
+ i1 = s1.begin()+2;
+ i2 = i1+6;
+ s1.replace(i1, i2, { 'y', 'z' });
+ VERIFY(s1 == "mnyzo");
+
+ return test;
+}
+
+int main()
+{
+ __gnu_test::set_memory_limits();
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/char/28277.cc b/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/char/28277.cc
new file mode 100644
index 000000000..b16980ec6
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/char/28277.cc
@@ -0,0 +1,53 @@
+// 2007-04-09 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 2008, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-options "-DWIDTH=200000" { target simulator } }
+
+#include <ostream>
+#include <sstream>
+#include <ext/vstring.h>
+#include <testsuite_hooks.h>
+
+#ifndef WIDTH
+#define WIDTH 20000000
+#endif
+
+// libstdc++/28277
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ ostringstream oss_01;
+ const __gnu_cxx::__vstring str_01(50, 'a');
+
+ oss_01.width(WIDTH);
+ const streamsize width = oss_01.width();
+
+ oss_01 << str_01;
+
+ VERIFY( oss_01.good() );
+ VERIFY( oss_01.str().size() == __gnu_cxx::__vstring::size_type(width) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc b/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc
new file mode 100644
index 000000000..ad122bd54
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/inserters_extractors/wchar_t/28277.cc
@@ -0,0 +1,53 @@
+// 2007-04-09 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 2008, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-options "-DWIDTH=500000" { target simulator } }
+
+#include <ostream>
+#include <sstream>
+#include <ext/vstring.h>
+#include <testsuite_hooks.h>
+
+#ifndef WIDTH
+#define WIDTH 50000000
+#endif
+
+// libstdc++/28277
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wostringstream oss_01;
+ const __gnu_cxx::__wvstring str_01(50, L'a');
+
+ oss_01.width(WIDTH);
+ const streamsize width = oss_01.width();
+
+ oss_01 << str_01;
+
+ VERIFY( oss_01.good() );
+ VERIFY( oss_01.str().size() == __gnu_cxx::__wvstring::size_type(width) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/operators/1.cc b/libstdc++-v3/testsuite/ext/vstring/operators/1.cc
new file mode 100644
index 000000000..f7cb7992d
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/operators/1.cc
@@ -0,0 +1,93 @@
+// 2010-12-15 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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/>.
+//
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+#include <ext/vstring.h>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_cxx::__vstring;
+
+ VERIFY( (__vstring("abc") + __vstring("def")
+ == __vstring("abcdef")) );
+ __vstring s1("abc");
+ VERIFY( s1 + __vstring("def") == __vstring("abcdef") );
+ __vstring s2("def");
+ VERIFY( __vstring("abc") + s2 == __vstring("abcdef") );
+ VERIFY( __vstring("abc") + 'd' == __vstring("abcd") );
+ VERIFY( __vstring("abc") + "def" == __vstring("abcdef") );
+ VERIFY( 'a' + __vstring("bcd") == __vstring("abcd") );
+ VERIFY( "abc" + __vstring("def") == __vstring("abcdef") );
+
+ VERIFY( (__vstring("abcdefghij") + __vstring("klmnopqrst")
+ == __vstring("abcdefghijklmnopqrst")) );
+ __vstring s1l("abcdefghij");
+ VERIFY( (s1l + __vstring("klmnopqrst")
+ == __vstring("abcdefghijklmnopqrst")) );
+ __vstring s2l("klmnopqrst");
+ VERIFY( (__vstring("abcdefghij") + s2l
+ == __vstring("abcdefghijklmnopqrst")) );
+ VERIFY( (__vstring("abcdefghijklmno") + 'p'
+ == __vstring("abcdefghijklmnop")) );
+ VERIFY( (__vstring("abcdefghijklmno") + "pqrst"
+ == __vstring("abcdefghijklmnopqrst")) );
+ VERIFY( ('a' + __vstring("bcdefghijklmnop")
+ == __vstring("abcdefghijklmnop")) );
+ VERIFY( ("abcde" + __vstring("fghijklmnopqrst")
+ == __vstring("abcdefghijklmnopqrst")) );
+
+ VERIFY( (__vstring("abcdefghijklmnopqrst") + __vstring("uvwxy")
+ == __vstring("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (__vstring("abcde") + __vstring("fghijklmnopqrstuvwxy")
+ == __vstring("abcdefghijklmnopqrstuvwxy")) );
+ __vstring s1ll1("abcdefghijklmnopqrst");
+ VERIFY( (s1ll1 + __vstring("uvwxy")
+ == __vstring("abcdefghijklmnopqrstuvwxy")) );
+ __vstring s1ll2("abcde");
+ VERIFY( (s1ll2 + __vstring("fghijklmnopqrstuvwxy")
+ == __vstring("abcdefghijklmnopqrstuvwxy")) );
+ __vstring s2ll1("fghijklmnopqrstuvwxy");
+ VERIFY( (__vstring("abcde") + s2ll1
+ == __vstring("abcdefghijklmnopqrstuvwxy")) );
+ __vstring s2ll2("uvwxy");
+ VERIFY( (__vstring("abcdefghijklmnopqrst") + s2ll2
+ == __vstring("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (__vstring("abcdefghijklmnopqrst") + 'u'
+ == __vstring("abcdefghijklmnopqrstu")) );
+ VERIFY( (__vstring("abcdefghijklmnopqrst") + "uvwxy"
+ == __vstring("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (__vstring("abcde") + "fghijklmnopqrstuvwxy"
+ == __vstring("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( ('a' + __vstring("bcdefghijklmnopqrstuvwxy")
+ == __vstring("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( ("abcde" + __vstring("fghijklmnopqrstuvwxy")
+ == __vstring("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( ("abcdefghijklmnopqrst" + __vstring("uvwxy")
+ == __vstring("abcdefghijklmnopqrstuvwxy")) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/operators/2.cc b/libstdc++-v3/testsuite/ext/vstring/operators/2.cc
new file mode 100644
index 000000000..7561fbda3
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/operators/2.cc
@@ -0,0 +1,79 @@
+// 2010-12-19 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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/>.
+//
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+#include <ext/vstring.h>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_cxx::__vstring;
+ using std::move;
+
+ __vstring s01("abc");
+ s01.reserve(30);
+ __vstring s02("def");
+ s02.reserve(30);
+ VERIFY( move(s01) + move(s02) == __vstring("abcdef") );
+
+ __vstring s03("abcdefghijklmnopqrstuvw");
+ __vstring s04("xyz");
+ s04.reserve(30);
+ VERIFY( move(s03) + move(s04) == __vstring("abcdefghijklmnopqrstuvwxyz") );
+
+ __vstring s05("abc");
+ s05.reserve(30);
+ __vstring s06("defghijklmnopqrstuvwxyz");
+ VERIFY( move(s05) + move(s06) == __vstring("abcdefghijklmnopqrstuvwxyz") );
+
+ const __vstring sc1("abc");
+ __vstring s07("def");
+ s07.reserve(30);
+ VERIFY( sc1 + move(s07) == __vstring("abcdef") );
+
+ const __vstring sc2("def");
+ __vstring s08("abc");
+ s08.reserve(30);
+ VERIFY( move(s08) + sc2 == __vstring("abcdef") );
+
+ __vstring s09("abc");
+ s09.reserve(30);
+ VERIFY( move(s09) + 'd' == __vstring("abcd") );
+
+ __vstring s10("abc");
+ s10.reserve(30);
+ VERIFY( move(s10) + "def" == __vstring("abcdef") );
+
+ __vstring s11("bcd");
+ s11.reserve(30);
+ VERIFY( 'a' + move(s11) == __vstring("abcd") );
+
+ __vstring s12("def");
+ s12.reserve(30);
+ VERIFY( "abc" + move(s12) == __vstring("abcdef") );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/range_access.cc b/libstdc++-v3/testsuite/ext/vstring/range_access.cc
new file mode 100644
index 000000000..f734e92c7
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/range_access.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 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/>.
+
+// 24.6.5, range access [iterator.range]
+
+#include <ext/vstring.h>
+
+void
+test01()
+{
+ __gnu_cxx::__vstring s("Hello, World!");
+ std::begin(s);
+ std::end(s);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ __gnu_cxx::__wvstring ws(L"Hello, World!");
+ std::begin(ws);
+ std::end(ws);
+#endif
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/citerators.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/citerators.cc
new file mode 100644
index 000000000..582cadac3
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/citerators.cc
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2007-10-15 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 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 <ext/vstring.h>
+#include <testsuite_containers.h>
+
+int main()
+{
+ typedef __gnu_cxx::__vstring test_type;
+ __gnu_test::citerator<test_type> test;
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/dr438/constructor.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/dr438/constructor.cc
new file mode 100644
index 000000000..df493ca0d
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/dr438/constructor.cc
@@ -0,0 +1,31 @@
+// 2007-04-27 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-do compile }
+
+#include <ext/vstring.h>
+
+void f()
+{
+ __gnu_cxx::__versa_string<char, std::char_traits<char>,
+ std::allocator<char>, __gnu_cxx::__sso_string_base> vs(10, 1);
+
+ __gnu_cxx::__versa_string<char, std::char_traits<char>,
+ std::allocator<char>, __gnu_cxx::__rc_string_base> vr(10, 1);
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/exception/basic.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/exception/basic.cc
new file mode 100644
index 000000000..a0042d488
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/exception/basic.cc
@@ -0,0 +1,55 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+
+// 2009-11-10 Benjamin Kosnik <benjamin@redhat.com>
+
+// Copyright (C) 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 <ext/vstring.h>
+#include <exception/safety.h>
+
+void
+value()
+{
+#if 1
+ typedef char value_type;
+#else
+ // XXX
+ // __gnu_cxx::__rc_string_base<>::_Rep::_M_align’ with constructor
+ // not allowed in union
+ // typedef __gnu_cxx::throw_value_limit value_type;
+#endif
+ typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type;
+ typedef std::char_traits<value_type> traits_type;
+
+ typedef __gnu_cxx::__versa_string<value_type, traits_type,
+ allocator_type, __gnu_cxx::__rc_string_base> test_type_rc;
+
+ typedef __gnu_cxx::__versa_string<value_type, traits_type,
+ allocator_type, __gnu_cxx::__sso_string_base> test_type_sso;
+
+ __gnu_test::basic_safety<test_type_rc> test_rc;
+ __gnu_test::basic_safety<test_type_sso> test_sso;
+}
+
+// Container requirement testing, exceptional behavior
+int main()
+{
+ value();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/exception/generation_prohibited.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/exception/generation_prohibited.cc
new file mode 100644
index 000000000..4ffe0df3b
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/exception/generation_prohibited.cc
@@ -0,0 +1,52 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+
+// 2009-09-14 Benjamin Kosnik <benjamin@redhat.com>
+
+// Copyright (C) 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 <ext/vstring.h>
+#include <exception/safety.h>
+
+void
+char_instance()
+{
+ typedef char value_type;
+ typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type;
+ typedef std::char_traits<value_type> traits_type;
+ typedef __gnu_cxx::__versa_string<value_type, traits_type, allocator_type> test_type;
+ __gnu_test::generation_prohibited<test_type> test;
+}
+
+void
+wchar_instance()
+{
+ typedef wchar_t value_type;
+ typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type;
+ typedef std::char_traits<value_type> traits_type;
+ typedef __gnu_cxx::__versa_string<value_type, traits_type, allocator_type> test_type;
+ __gnu_test::generation_prohibited<test_type> test;
+}
+
+// Container requirement testing, exceptional behavior
+int main()
+{
+ char_instance();
+ wchar_instance();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/exception/propagation_consistent.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/exception/propagation_consistent.cc
new file mode 100644
index 000000000..09d8618ab
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/exception/propagation_consistent.cc
@@ -0,0 +1,55 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+
+// 2009-09-14 Benjamin Kosnik <benjamin@redhat.com>
+
+// Copyright (C) 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 <ext/vstring.h>
+#include <exception/safety.h>
+
+void
+value()
+{
+#if 1
+ typedef char value_type;
+#else
+ // XXX
+ // __gnu_cxx::__rc_string_base<>::_Rep::_M_align’ with constructor
+ // not allowed in union
+ // typedef __gnu_cxx::throw_value_limit value_type;
+#endif
+ typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type;
+ typedef std::char_traits<value_type> traits_type;
+
+ typedef __gnu_cxx::__versa_string<value_type, traits_type,
+ allocator_type, __gnu_cxx::__rc_string_base> test_type_rc;
+
+ typedef __gnu_cxx::__versa_string<value_type, traits_type,
+ allocator_type, __gnu_cxx::__sso_string_base> test_type_sso;
+
+ __gnu_test::propagation_consistent<test_type_rc> test_rc;
+ __gnu_test::propagation_consistent<test_type_sso> test_sso;
+}
+
+// Container requirement testing, exceptional behavior
+int main()
+{
+ value();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/1.cc
new file mode 100644
index 000000000..81d6ce732
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/1.cc
@@ -0,0 +1,27 @@
+// Copyright (C) 2005, 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 file tests explicit instantiation of __versa_string
+
+#include <ext/vstring.h>
+
+// { dg-do compile }
+
+// libstdc++/21770
+template class __gnu_cxx::__versa_string<int, std::char_traits<int>,
+ std::allocator<char> >;
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/2.cc
new file mode 100644
index 000000000..3423b76be
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/2.cc
@@ -0,0 +1,32 @@
+// Copyright (C) 2005, 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 file tests explicit instantiation of __versa_string
+
+#include <ext/vstring.h>
+
+// { dg-do compile }
+
+// libstdc++/21770
+template class __gnu_cxx::__versa_string<int, std::char_traits<int>,
+ std::allocator<char>,
+ __gnu_cxx::__sso_string_base>;
+
+template class __gnu_cxx::__versa_string<int, std::char_traits<int>,
+ std::allocator<char>,
+ __gnu_cxx::__rc_string_base>;
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char/1.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char/1.cc
new file mode 100644
index 000000000..6e0972a39
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char/1.cc
@@ -0,0 +1,31 @@
+// Copyright (C) 2005, 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 file tests explicit instantiation of __versa_string
+
+#include <ext/vstring.h>
+
+// { dg-do compile }
+
+template class __gnu_cxx::__versa_string<char, std::char_traits<char>,
+ std::allocator<char>,
+ __gnu_cxx::__sso_string_base>;
+
+template class __gnu_cxx::__versa_string<char, std::char_traits<char>,
+ std::allocator<char>,
+ __gnu_cxx::__rc_string_base>;
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char16_t/1.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char16_t/1.cc
new file mode 100644
index 000000000..f6f7d4141
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char16_t/1.cc
@@ -0,0 +1,34 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-string-conversions "" }
+
+// 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 file tests explicit instantiation of __versa_string
+
+#include <ext/vstring.h>
+
+template class __gnu_cxx::__versa_string<char16_t, std::char_traits<char16_t>,
+ std::allocator<char16_t>,
+ __gnu_cxx::__sso_string_base>;
+
+template class __gnu_cxx::__versa_string<char16_t, std::char_traits<char16_t>,
+ std::allocator<char16_t>,
+ __gnu_cxx::__rc_string_base>;
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char32_t/1.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char32_t/1.cc
new file mode 100644
index 000000000..0020792cc
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/char32_t/1.cc
@@ -0,0 +1,34 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-string-conversions "" }
+
+// 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 file tests explicit instantiation of __versa_string
+
+#include <ext/vstring.h>
+
+template class __gnu_cxx::__versa_string<char32_t, std::char_traits<char32_t>,
+ std::allocator<char32_t>,
+ __gnu_cxx::__sso_string_base>;
+
+template class __gnu_cxx::__versa_string<char32_t, std::char_traits<char32_t>,
+ std::allocator<char32_t>,
+ __gnu_cxx::__rc_string_base>;
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/wchar_t/1.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/wchar_t/1.cc
new file mode 100644
index 000000000..964832803
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/explicit_instantiation/wchar_t/1.cc
@@ -0,0 +1,31 @@
+// Copyright (C) 2005, 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 file tests explicit instantiation of __versa_string
+
+#include <ext/vstring.h>
+
+// { dg-do compile }
+
+template class __gnu_cxx::__versa_string<wchar_t, std::char_traits<wchar_t>,
+ std::allocator<wchar_t>,
+ __gnu_cxx::__sso_string_base>;
+
+template class __gnu_cxx::__versa_string<wchar_t, std::char_traits<wchar_t>,
+ std::allocator<wchar_t>,
+ __gnu_cxx::__rc_string_base>;
diff --git a/libstdc++-v3/testsuite/ext/vstring/requirements/typedefs.cc b/libstdc++-v3/testsuite/ext/vstring/requirements/typedefs.cc
new file mode 100644
index 000000000..06db6afc3
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/requirements/typedefs.cc
@@ -0,0 +1,25 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 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 <testsuite_containers.h>
+#include <ext/vstring.h>
+
+// Check container for required typedefs.
+__gnu_test::types<__gnu_cxx::__vstring> t;
diff --git a/libstdc++-v3/testsuite/ext/vstring/types/23767.cc b/libstdc++-v3/testsuite/ext/vstring/types/23767.cc
new file mode 100644
index 000000000..a963f2712
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/vstring/types/23767.cc
@@ -0,0 +1,43 @@
+// 2005-09-12 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005, 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/>.
+//
+
+// { dg-do compile }
+
+#include <ext/vstring.h>
+
+struct T
+{
+ typedef __gnu_cxx::__vstring Vstring;
+ typedef Vstring::iterator iterator;
+ typedef Vstring::const_iterator const_iterator;
+
+ char t(iterator f) { return *f; }
+ char t(const_iterator f) const { return *f; }
+};
+
+// libstdc++/23767
+void f()
+{
+ __gnu_cxx::__vstring vs;
+ T t;
+ T::const_iterator i = vs.begin();
+
+ t.t(i);
+}