From 7865836f4b0f698454c31b4593effcb032c22c1e Mon Sep 17 00:00:00 2001 From: kan Date: Sat, 19 May 2007 01:25:07 +0000 Subject: GCC 4.2.0 release C++ standard library and runtime support code. --- contrib/libstdc++/include/Makefile.am | 677 ++- contrib/libstdc++/include/Makefile.in | 790 +++- contrib/libstdc++/include/backward/algo.h | 6 +- contrib/libstdc++/include/backward/algobase.h | 6 +- contrib/libstdc++/include/backward/alloc.h | 2 +- .../libstdc++/include/backward/backward_warning.h | 2 +- contrib/libstdc++/include/backward/bvector.h | 6 +- contrib/libstdc++/include/backward/complex.h | 6 +- contrib/libstdc++/include/backward/defalloc.h | 2 +- contrib/libstdc++/include/backward/deque.h | 6 +- contrib/libstdc++/include/backward/fstream.h | 6 +- contrib/libstdc++/include/backward/function.h | 6 +- contrib/libstdc++/include/backward/hash_map.h | 6 +- contrib/libstdc++/include/backward/hash_set.h | 2 +- contrib/libstdc++/include/backward/hashtable.h | 6 +- contrib/libstdc++/include/backward/heap.h | 6 +- contrib/libstdc++/include/backward/iomanip.h | 6 +- contrib/libstdc++/include/backward/iostream.h | 6 +- contrib/libstdc++/include/backward/istream.h | 11 +- contrib/libstdc++/include/backward/iterator.h | 6 +- contrib/libstdc++/include/backward/list.h | 6 +- contrib/libstdc++/include/backward/map.h | 6 +- contrib/libstdc++/include/backward/multimap.h | 6 +- contrib/libstdc++/include/backward/multiset.h | 6 +- contrib/libstdc++/include/backward/new.h | 4 +- contrib/libstdc++/include/backward/ostream.h | 6 +- contrib/libstdc++/include/backward/pair.h | 6 +- contrib/libstdc++/include/backward/queue.h | 6 +- contrib/libstdc++/include/backward/rope.h | 6 +- contrib/libstdc++/include/backward/set.h | 6 +- contrib/libstdc++/include/backward/slist.h | 6 +- contrib/libstdc++/include/backward/stack.h | 6 +- contrib/libstdc++/include/backward/stream.h | 6 +- contrib/libstdc++/include/backward/streambuf.h | 6 +- contrib/libstdc++/include/backward/strstream | 12 +- contrib/libstdc++/include/backward/tempbuf.h | 10 +- contrib/libstdc++/include/backward/tree.h | 5 +- contrib/libstdc++/include/backward/vector.h | 6 +- contrib/libstdc++/include/bits/allocator.h | 45 +- contrib/libstdc++/include/bits/basic_ios.h | 11 +- contrib/libstdc++/include/bits/basic_ios.tcc | 22 +- contrib/libstdc++/include/bits/basic_string.h | 364 +- contrib/libstdc++/include/bits/basic_string.tcc | 345 +- .../libstdc++/include/bits/boost_concept_check.h | 15 +- contrib/libstdc++/include/bits/c++config | 161 +- contrib/libstdc++/include/bits/char_traits.h | 47 +- contrib/libstdc++/include/bits/codecvt.h | 66 +- contrib/libstdc++/include/bits/concept_check.h | 2 +- contrib/libstdc++/include/bits/cpp_type_traits.h | 316 +- contrib/libstdc++/include/bits/deque.tcc | 367 +- contrib/libstdc++/include/bits/fstream.tcc | 90 +- contrib/libstdc++/include/bits/functexcept.h | 48 +- contrib/libstdc++/include/bits/gslice.h | 191 +- contrib/libstdc++/include/bits/gslice_array.h | 42 +- contrib/libstdc++/include/bits/indirect_array.h | 68 +- contrib/libstdc++/include/bits/ios_base.h | 93 +- contrib/libstdc++/include/bits/istream.tcc | 657 ++- contrib/libstdc++/include/bits/list.tcc | 204 +- contrib/libstdc++/include/bits/locale_classes.h | 67 +- contrib/libstdc++/include/bits/locale_facets.h | 182 +- contrib/libstdc++/include/bits/locale_facets.tcc | 1265 +++--- contrib/libstdc++/include/bits/localefwd.h | 23 +- contrib/libstdc++/include/bits/mask_array.h | 19 +- contrib/libstdc++/include/bits/ostream.tcc | 508 +-- contrib/libstdc++/include/bits/ostream_insert.h | 114 + contrib/libstdc++/include/bits/postypes.h | 50 +- contrib/libstdc++/include/bits/slice_array.h | 46 +- contrib/libstdc++/include/bits/sstream.tcc | 128 +- contrib/libstdc++/include/bits/stl_algo.h | 914 ++-- contrib/libstdc++/include/bits/stl_algobase.h | 591 ++- contrib/libstdc++/include/bits/stl_bvector.h | 829 ++-- contrib/libstdc++/include/bits/stl_construct.h | 49 +- contrib/libstdc++/include/bits/stl_deque.h | 531 ++- contrib/libstdc++/include/bits/stl_function.h | 161 +- contrib/libstdc++/include/bits/stl_heap.h | 18 +- contrib/libstdc++/include/bits/stl_iterator.h | 89 +- .../include/bits/stl_iterator_base_funcs.h | 17 +- .../include/bits/stl_iterator_base_types.h | 10 +- contrib/libstdc++/include/bits/stl_list.h | 355 +- contrib/libstdc++/include/bits/stl_map.h | 214 +- contrib/libstdc++/include/bits/stl_multimap.h | 115 +- contrib/libstdc++/include/bits/stl_multiset.h | 130 +- contrib/libstdc++/include/bits/stl_numeric.h | 95 +- contrib/libstdc++/include/bits/stl_pair.h | 14 +- contrib/libstdc++/include/bits/stl_queue.h | 95 +- .../libstdc++/include/bits/stl_raw_storage_iter.h | 15 +- contrib/libstdc++/include/bits/stl_relops.h | 11 +- contrib/libstdc++/include/bits/stl_set.h | 131 +- contrib/libstdc++/include/bits/stl_stack.h | 27 +- contrib/libstdc++/include/bits/stl_tempbuf.h | 21 +- contrib/libstdc++/include/bits/stl_tree.h | 654 ++- contrib/libstdc++/include/bits/stl_uninitialized.h | 167 +- contrib/libstdc++/include/bits/stl_vector.h | 314 +- contrib/libstdc++/include/bits/stream_iterator.h | 14 +- contrib/libstdc++/include/bits/streambuf.tcc | 82 +- .../libstdc++/include/bits/streambuf_iterator.h | 186 +- contrib/libstdc++/include/bits/stringfwd.h | 19 +- contrib/libstdc++/include/bits/valarray_after.h | 455 +- contrib/libstdc++/include/bits/valarray_array.h | 887 ++-- contrib/libstdc++/include/bits/valarray_array.tcc | 16 +- contrib/libstdc++/include/bits/valarray_before.h | 248 +- contrib/libstdc++/include/bits/vector.tcc | 622 +-- contrib/libstdc++/include/c/std_cassert.h | 2 +- contrib/libstdc++/include/c/std_cctype.h | 2 +- contrib/libstdc++/include/c/std_cerrno.h | 10 +- contrib/libstdc++/include/c/std_cfloat.h | 2 +- contrib/libstdc++/include/c/std_ciso646.h | 2 +- contrib/libstdc++/include/c/std_climits.h | 2 +- contrib/libstdc++/include/c/std_clocale.h | 2 +- contrib/libstdc++/include/c/std_cmath.h | 2 +- contrib/libstdc++/include/c/std_csetjmp.h | 2 +- contrib/libstdc++/include/c/std_csignal.h | 2 +- contrib/libstdc++/include/c/std_cstdarg.h | 2 +- contrib/libstdc++/include/c/std_cstddef.h | 2 +- contrib/libstdc++/include/c/std_cstdio.h | 2 +- contrib/libstdc++/include/c/std_cstdlib.h | 2 +- contrib/libstdc++/include/c/std_cstring.h | 2 +- contrib/libstdc++/include/c/std_ctime.h | 2 +- contrib/libstdc++/include/c/std_cwchar.h | 2 +- contrib/libstdc++/include/c/std_cwctype.h | 2 +- contrib/libstdc++/include/c_compatibility/assert.h | 2 +- contrib/libstdc++/include/c_compatibility/ctype.h | 2 +- contrib/libstdc++/include/c_compatibility/errno.h | 2 +- contrib/libstdc++/include/c_compatibility/float.h | 2 +- contrib/libstdc++/include/c_compatibility/iso646.h | 2 +- contrib/libstdc++/include/c_compatibility/limits.h | 2 +- contrib/libstdc++/include/c_compatibility/locale.h | 2 +- contrib/libstdc++/include/c_compatibility/math.h | 2 +- contrib/libstdc++/include/c_compatibility/setjmp.h | 2 +- contrib/libstdc++/include/c_compatibility/signal.h | 2 +- contrib/libstdc++/include/c_compatibility/stdarg.h | 2 +- contrib/libstdc++/include/c_compatibility/stddef.h | 2 +- contrib/libstdc++/include/c_compatibility/stdio.h | 2 +- contrib/libstdc++/include/c_compatibility/stdlib.h | 2 +- contrib/libstdc++/include/c_compatibility/string.h | 2 +- contrib/libstdc++/include/c_compatibility/time.h | 2 +- contrib/libstdc++/include/c_compatibility/wchar.h | 2 +- contrib/libstdc++/include/c_compatibility/wctype.h | 2 +- contrib/libstdc++/include/c_std/cmath.tcc | 15 +- contrib/libstdc++/include/c_std/std_cassert.h | 15 +- contrib/libstdc++/include/c_std/std_cctype.h | 25 +- contrib/libstdc++/include/c_std/std_cerrno.h | 16 +- contrib/libstdc++/include/c_std/std_cfloat.h | 18 +- contrib/libstdc++/include/c_std/std_ciso646.h | 7 +- contrib/libstdc++/include/c_std/std_climits.h | 17 +- contrib/libstdc++/include/c_std/std_clocale.h | 23 +- contrib/libstdc++/include/c_std/std_cmath.h | 155 +- contrib/libstdc++/include/c_std/std_csetjmp.h | 23 +- contrib/libstdc++/include/c_std/std_csignal.h | 23 +- contrib/libstdc++/include/c_std/std_cstdarg.h | 26 +- contrib/libstdc++/include/c_std/std_cstddef.h | 24 +- contrib/libstdc++/include/c_std/std_cstdio.h | 60 +- contrib/libstdc++/include/c_std/std_cstdlib.h | 93 +- contrib/libstdc++/include/c_std/std_cstring.h | 24 +- contrib/libstdc++/include/c_std/std_ctime.h | 25 +- contrib/libstdc++/include/c_std/std_cwchar.h | 55 +- contrib/libstdc++/include/c_std/std_cwctype.h | 36 +- contrib/libstdc++/include/debug/bitset | 49 +- contrib/libstdc++/include/debug/debug.h | 566 +-- contrib/libstdc++/include/debug/deque | 23 +- contrib/libstdc++/include/debug/formatter.h | 17 +- contrib/libstdc++/include/debug/functions.h | 293 ++ contrib/libstdc++/include/debug/hash_map | 14 +- contrib/libstdc++/include/debug/hash_map.h | 28 +- contrib/libstdc++/include/debug/hash_multimap.h | 21 +- contrib/libstdc++/include/debug/hash_multiset.h | 19 +- contrib/libstdc++/include/debug/hash_set | 14 +- contrib/libstdc++/include/debug/hash_set.h | 28 +- contrib/libstdc++/include/debug/list | 73 +- contrib/libstdc++/include/debug/macros.h | 224 + contrib/libstdc++/include/debug/map | 8 +- contrib/libstdc++/include/debug/map.h | 27 +- contrib/libstdc++/include/debug/multimap.h | 23 +- contrib/libstdc++/include/debug/multiset.h | 23 +- contrib/libstdc++/include/debug/safe_base.h | 22 +- contrib/libstdc++/include/debug/safe_iterator.h | 66 +- contrib/libstdc++/include/debug/safe_iterator.tcc | 40 +- contrib/libstdc++/include/debug/safe_sequence.h | 80 +- contrib/libstdc++/include/debug/set | 6 +- contrib/libstdc++/include/debug/set.h | 23 +- contrib/libstdc++/include/debug/string | 44 +- contrib/libstdc++/include/debug/vector | 25 +- contrib/libstdc++/include/ext/algorithm | 169 +- contrib/libstdc++/include/ext/array_allocator.h | 149 + contrib/libstdc++/include/ext/atomicity.h | 118 + contrib/libstdc++/include/ext/bitmap_allocator.h | 1645 ++++--- .../include/ext/codecvt_specializations.h | 521 +++ contrib/libstdc++/include/ext/concurrence.h | 225 + contrib/libstdc++/include/ext/debug_allocator.h | 35 +- contrib/libstdc++/include/ext/functional | 681 +-- contrib/libstdc++/include/ext/hash_fun.h | 144 +- contrib/libstdc++/include/ext/hash_map | 910 ++-- contrib/libstdc++/include/ext/hash_set | 867 ++-- contrib/libstdc++/include/ext/hashtable.h | 1844 ++++---- contrib/libstdc++/include/ext/iterator | 23 +- contrib/libstdc++/include/ext/malloc_allocator.h | 29 +- contrib/libstdc++/include/ext/memory | 82 +- contrib/libstdc++/include/ext/mt_allocator.h | 1196 ++--- contrib/libstdc++/include/ext/new_allocator.h | 28 +- contrib/libstdc++/include/ext/numeric | 45 +- contrib/libstdc++/include/ext/numeric_traits.h | 98 + .../include/ext/pb_ds/assoc_container.hpp | 689 +++ .../basic_tree_policy/basic_tree_policy_base.hpp | 179 + .../basic_tree_policy/null_node_metadata.hpp | 73 + .../ext/pb_ds/detail/basic_tree_policy/traits.hpp | 91 + .../include/ext/pb_ds/detail/basic_types.hpp | 217 + .../detail/bin_search_tree_/bin_search_tree_.hpp | 503 +++ .../bin_search_tree_/cond_dtor_entry_dealtor.hpp | 76 + .../cond_key_dtor_entry_dealtor.hpp | 87 + .../constructors_destructor_fn_imps.hpp | 224 + .../detail/bin_search_tree_/debug_fn_imps.hpp | 278 ++ .../detail/bin_search_tree_/erase_fn_imps.hpp | 126 + .../pb_ds/detail/bin_search_tree_/find_fn_imps.hpp | 188 + .../pb_ds/detail/bin_search_tree_/info_fn_imps.hpp | 70 + .../detail/bin_search_tree_/insert_fn_imps.hpp | 217 + .../detail/bin_search_tree_/iterators_fn_imps.hpp | 142 + .../detail/bin_search_tree_/node_iterators.hpp | 243 + .../detail/bin_search_tree_/point_iterators.hpp | 387 ++ .../bin_search_tree_/policy_access_fn_imps.hpp | 62 + .../detail/bin_search_tree_/r_erase_fn_imps.hpp | 126 + .../detail/bin_search_tree_/rotate_fn_imps.hpp | 162 + .../detail/bin_search_tree_/split_join_fn_imps.hpp | 152 + .../ext/pb_ds/detail/bin_search_tree_/traits.hpp | 256 ++ .../ext/pb_ds/detail/binary_heap_/binary_heap_.hpp | 363 ++ .../pb_ds/detail/binary_heap_/const_iterator.hpp | 158 + .../detail/binary_heap_/const_point_iterator.hpp | 150 + .../constructors_destructor_fn_imps.hpp | 165 + .../pb_ds/detail/binary_heap_/debug_fn_imps.hpp | 78 + .../ext/pb_ds/detail/binary_heap_/entry_cmp.hpp | 99 + .../ext/pb_ds/detail/binary_heap_/entry_pred.hpp | 99 + .../pb_ds/detail/binary_heap_/erase_fn_imps.hpp | 252 ++ .../ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp | 97 + .../ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp | 70 + .../pb_ds/detail/binary_heap_/insert_fn_imps.hpp | 220 + .../detail/binary_heap_/iterators_fn_imps.hpp | 78 + .../detail/binary_heap_/policy_access_fn_imps.hpp | 62 + .../pb_ds/detail/binary_heap_/resize_policy.hpp | 259 ++ .../detail/binary_heap_/split_join_fn_imps.hpp | 178 + .../pb_ds/detail/binary_heap_/trace_fn_imps.hpp | 84 + .../pb_ds/detail/binomial_heap_/binomial_heap_.hpp | 122 + .../constructors_destructor_fn_imps.hpp | 67 + .../pb_ds/detail/binomial_heap_/debug_fn_imps.hpp | 55 + .../binomial_heap_base_/binomial_heap_base_.hpp | 240 + .../constructors_destructor_fn_imps.hpp | 103 + .../detail/binomial_heap_base_/debug_fn_imps.hpp | 97 + .../detail/binomial_heap_base_/erase_fn_imps.hpp | 198 + .../detail/binomial_heap_base_/find_fn_imps.hpp | 79 + .../detail/binomial_heap_base_/insert_fn_imps.hpp | 222 + .../binomial_heap_base_/split_join_fn_imps.hpp | 238 + .../pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp | 647 +++ .../detail/cc_hash_table_map_/cmp_fn_imps.hpp | 89 + .../cond_key_dtor_entry_dealtor.hpp | 123 + .../constructor_destructor_fn_imps.hpp | 197 + ...onstructor_destructor_no_store_hash_fn_imps.hpp | 61 + .../constructor_destructor_store_hash_fn_imps.hpp | 62 + .../detail/cc_hash_table_map_/debug_fn_imps.hpp | 80 + .../debug_no_store_hash_fn_imps.hpp | 55 + .../debug_store_hash_fn_imps.hpp | 59 + .../cc_hash_table_map_/entry_list_fn_imps.hpp | 97 + .../detail/cc_hash_table_map_/erase_fn_imps.hpp | 109 + .../erase_no_store_hash_fn_imps.hpp | 107 + .../erase_store_hash_fn_imps.hpp | 101 + .../detail/cc_hash_table_map_/find_fn_imps.hpp | 77 + .../cc_hash_table_map_/find_store_hash_fn_imps.hpp | 47 + .../detail/cc_hash_table_map_/info_fn_imps.hpp | 106 + .../detail/cc_hash_table_map_/insert_fn_imps.hpp | 49 + .../insert_no_store_hash_fn_imps.hpp | 76 + .../insert_store_hash_fn_imps.hpp | 77 + .../cc_hash_table_map_/iterators_fn_imps.hpp | 89 + .../cc_hash_table_map_/policy_access_fn_imps.hpp | 94 + .../detail/cc_hash_table_map_/resize_fn_imps.hpp | 139 + .../resize_no_store_hash_fn_imps.hpp | 60 + .../resize_store_hash_fn_imps.hpp | 60 + .../detail/cc_hash_table_map_/size_fn_imps.hpp | 65 + .../cc_hash_table_map_/standard_policies.hpp | 52 + .../detail/cc_hash_table_map_/trace_fn_imps.hpp | 78 + .../include/ext/pb_ds/detail/cond_dealtor.hpp | 131 + .../detail/constructors_destructor_fn_imps.hpp | 109 + .../ext/pb_ds/detail/container_base_dispatch.hpp | 338 ++ .../include/ext/pb_ds/detail/eq_fn/eq_by_less.hpp | 74 + .../include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp | 185 + .../constructor_destructor_fn_imps.hpp | 229 + ...onstructor_destructor_no_store_hash_fn_imps.hpp | 59 + .../constructor_destructor_store_hash_fn_imps.hpp | 60 + .../detail/gp_hash_table_map_/debug_fn_imps.hpp | 61 + .../debug_no_store_hash_fn_imps.hpp | 77 + .../debug_store_hash_fn_imps.hpp | 83 + .../detail/gp_hash_table_map_/erase_fn_imps.hpp | 106 + .../erase_no_store_hash_fn_imps.hpp | 91 + .../erase_store_hash_fn_imps.hpp | 92 + .../detail/gp_hash_table_map_/find_fn_imps.hpp | 76 + .../find_no_store_hash_fn_imps.hpp | 52 + .../gp_hash_table_map_/find_store_hash_fn_imps.hpp | 46 + .../pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp | 688 +++ .../detail/gp_hash_table_map_/info_fn_imps.hpp | 64 + .../detail/gp_hash_table_map_/insert_fn_imps.hpp | 49 + .../insert_no_store_hash_fn_imps.hpp | 117 + .../insert_store_hash_fn_imps.hpp | 124 + .../detail/gp_hash_table_map_/iterator_fn_imps.hpp | 89 + .../gp_hash_table_map_/policy_access_fn_imps.hpp | 106 + .../detail/gp_hash_table_map_/resize_fn_imps.hpp | 143 + .../resize_no_store_hash_fn_imps.hpp | 78 + .../resize_store_hash_fn_imps.hpp | 80 + .../gp_hash_table_map_/standard_policies.hpp | 80 + .../detail/gp_hash_table_map_/trace_fn_imps.hpp | 80 + .../hash_fn/direct_mask_range_hashing_imp.hpp | 64 + .../hash_fn/direct_mod_range_hashing_imp.hpp | 64 + .../pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp | 59 + .../detail/hash_fn/mask_based_range_hashing.hpp | 113 + .../detail/hash_fn/mod_based_range_hashing.hpp | 114 + .../ext/pb_ds/detail/hash_fn/probe_fn_base.hpp | 65 + .../detail/hash_fn/quadratic_probe_fn_imp.hpp | 59 + .../ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp | 365 ++ .../ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp | 333 ++ .../ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp | 79 + .../pb_ds/detail/hash_fn/sample_range_hashing.hpp | 83 + .../pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp | 83 + .../detail/hash_fn/sample_ranged_probe_fn.hpp | 83 + .../const_iterator.hpp | 168 + .../const_point_iterator.hpp | 160 + .../constructors_destructor_fn_imps.hpp | 158 + .../debug_fn_imps.hpp | 147 + .../erase_fn_imps.hpp | 156 + .../left_child_next_sibling_heap_/info_fn_imps.hpp | 70 + .../insert_fn_imps.hpp | 181 + .../iterators_fn_imps.hpp | 94 + .../left_child_next_sibling_heap_.hpp | 355 ++ .../detail/left_child_next_sibling_heap_/node.hpp | 129 + .../null_metadata.hpp | 63 + .../policy_access_fn_imps.hpp | 62 + .../trace_fn_imps.hpp | 101 + .../constructor_destructor_fn_imps.hpp | 147 + .../detail/list_update_map_/debug_fn_imps.hpp | 63 + .../list_update_map_/entry_metadata_base.hpp | 66 + .../detail/list_update_map_/erase_fn_imps.hpp | 141 + .../pb_ds/detail/list_update_map_/find_fn_imps.hpp | 96 + .../pb_ds/detail/list_update_map_/info_fn_imps.hpp | 63 + .../detail/list_update_map_/insert_fn_imps.hpp | 112 + .../detail/list_update_map_/iterators_fn_imps.hpp | 86 + .../ext/pb_ds/detail/list_update_map_/lu_map_.hpp | 365 ++ .../detail/list_update_map_/trace_fn_imps.hpp | 65 + .../list_update_policy/counter_lu_metadata.hpp | 92 + .../list_update_policy/counter_lu_policy_imp.hpp | 57 + .../list_update_policy/mtf_lu_policy_imp.hpp | 61 + .../list_update_policy/sample_update_policy.hpp | 80 + .../include/ext/pb_ds/detail/map_debug_base.hpp | 356 ++ .../ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp | 80 + .../constructors_destructor_fn_imps.hpp | 279 ++ .../pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp | 90 + .../pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp | 199 + .../ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp | 66 + .../pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp | 69 + .../detail/ov_tree_map_/iterators_fn_imps.hpp | 109 + .../pb_ds/detail/ov_tree_map_/node_iterators.hpp | 303 ++ .../ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp | 528 +++ .../detail/ov_tree_map_/policy_access_fn_imps.hpp | 57 + .../detail/ov_tree_map_/split_join_fn_imps.hpp | 143 + .../ext/pb_ds/detail/ov_tree_map_/traits.hpp | 189 + .../constructors_destructor_fn_imps.hpp | 97 + .../pb_ds/detail/pairing_heap_/debug_fn_imps.hpp | 59 + .../pb_ds/detail/pairing_heap_/erase_fn_imps.hpp | 242 + .../pb_ds/detail/pairing_heap_/find_fn_imps.hpp | 56 + .../pb_ds/detail/pairing_heap_/insert_fn_imps.hpp | 107 + .../pb_ds/detail/pairing_heap_/pairing_heap_.hpp | 222 + .../detail/pairing_heap_/split_join_fn_imps.hpp | 146 + .../ext/pb_ds/detail/pat_trie_/child_iterator.hpp | 99 + .../detail/pat_trie_/cond_dtor_entry_dealtor.hpp | 85 + .../detail/pat_trie_/const_child_iterator.hpp | 117 + .../pat_trie_/constructors_destructor_fn_imps.hpp | 220 + .../ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp | 123 + .../ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp | 325 ++ .../ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp | 275 ++ .../include/ext/pb_ds/detail/pat_trie_/head.hpp | 130 + .../ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp | 64 + .../pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp | 471 ++ .../ext/pb_ds/detail/pat_trie_/internal_node.hpp | 609 +++ .../pb_ds/detail/pat_trie_/iterators_fn_imps.hpp | 126 + .../include/ext/pb_ds/detail/pat_trie_/leaf.hpp | 177 + .../ext/pb_ds/detail/pat_trie_/node_base.hpp | 134 + .../ext/pb_ds/detail/pat_trie_/node_iterators.hpp | 344 ++ .../pb_ds/detail/pat_trie_/node_metadata_base.hpp | 92 + .../ext/pb_ds/detail/pat_trie_/pat_trie_.hpp | 526 +++ .../ext/pb_ds/detail/pat_trie_/point_iterators.hpp | 490 ++ .../detail/pat_trie_/policy_access_fn_imps.hpp | 69 + .../ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp | 109 + .../ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp | 156 + .../ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp | 260 ++ .../detail/pat_trie_/split_join_branch_bag.hpp | 99 + .../detail/pat_trie_/synth_e_access_traits.hpp | 235 + .../ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp | 119 + .../include/ext/pb_ds/detail/pat_trie_/traits.hpp | 356 ++ .../ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp | 61 + .../pb_ds/detail/priority_queue_base_dispatch.hpp | 97 + .../constructors_destructor_fn_imps.hpp | 106 + .../pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp | 84 + .../pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp | 295 ++ .../ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp | 45 + .../ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp | 52 + .../pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp | 121 + .../include/ext/pb_ds/detail/rb_tree_map_/node.hpp | 144 + .../ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp | 286 ++ .../detail/rb_tree_map_/split_join_fn_imps.hpp | 319 ++ .../ext/pb_ds/detail/rb_tree_map_/traits.hpp | 130 + .../constructors_destructor_fn_imps.hpp | 94 + .../detail/rc_binomial_heap_/debug_fn_imps.hpp | 127 + .../detail/rc_binomial_heap_/erase_fn_imps.hpp | 113 + .../detail/rc_binomial_heap_/insert_fn_imps.hpp | 160 + .../ext/pb_ds/detail/rc_binomial_heap_/rc.hpp | 268 ++ .../detail/rc_binomial_heap_/rc_binomial_heap_.hpp | 204 + .../rc_binomial_heap_/split_join_fn_imps.hpp | 87 + .../detail/rc_binomial_heap_/trace_fn_imps.hpp | 59 + ...hash_max_collision_check_resize_trigger_imp.hpp | 221 + .../hash_exponential_size_policy_imp.hpp | 96 + .../hash_load_check_resize_trigger_imp.hpp | 300 ++ .../hash_load_check_resize_trigger_size_base.hpp | 100 + .../resize_policy/hash_prime_size_policy_imp.hpp | 165 + .../hash_standard_resize_policy_imp.hpp | 260 ++ .../detail/resize_policy/sample_resize_policy.hpp | 131 + .../detail/resize_policy/sample_resize_trigger.hpp | 145 + .../detail/resize_policy/sample_size_policy.hpp | 79 + .../constructors_destructor_fn_imps.hpp | 108 + .../ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp | 80 + .../ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp | 163 + .../ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp | 105 + .../ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp | 45 + .../pb_ds/detail/splay_tree_/insert_fn_imps.hpp | 99 + .../include/ext/pb_ds/detail/splay_tree_/node.hpp | 131 + .../ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp | 289 ++ .../ext/pb_ds/detail/splay_tree_/splay_tree_.hpp | 304 ++ .../detail/splay_tree_/split_join_fn_imps.hpp | 118 + .../ext/pb_ds/detail/splay_tree_/traits.hpp | 119 + .../include/ext/pb_ds/detail/standard_policies.hpp | 163 + .../thin_heap_/constructors_destructor_fn_imps.hpp | 112 + .../ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp | 118 + .../ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp | 302 ++ .../ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp | 57 + .../ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp | 332 ++ .../pb_ds/detail/thin_heap_/split_join_fn_imps.hpp | 132 + .../ext/pb_ds/detail/thin_heap_/thin_heap_.hpp | 357 ++ .../ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp | 61 + .../detail/tree_policy/node_metadata_selector.hpp | 122 + .../detail/tree_policy/null_node_update_imp.hpp | 56 + .../detail/tree_policy/order_statistics_imp.hpp | 147 + .../detail/tree_policy/sample_tree_node_update.hpp | 78 + .../include/ext/pb_ds/detail/tree_trace_base.hpp | 215 + .../detail/trie_policy/node_metadata_selector.hpp | 122 + .../detail/trie_policy/null_node_update_imp.hpp | 56 + .../detail/trie_policy/order_statistics_imp.hpp | 189 + .../trie_policy/prefix_search_node_update_imp.hpp | 157 + .../trie_policy/sample_trie_e_access_traits.hpp | 95 + .../detail/trie_policy/sample_trie_node_update.hpp | 78 + .../string_trie_e_access_traits_imp.hpp | 105 + .../pb_ds/detail/trie_policy/trie_policy_base.hpp | 255 ++ .../include/ext/pb_ds/detail/type_utils.hpp | 165 + .../include/ext/pb_ds/detail/types_traits.hpp | 85 + .../detail/unordered_iterator/const_iterator.hpp | 135 + .../unordered_iterator/const_point_iterator.hpp | 157 + .../pb_ds/detail/unordered_iterator/iterator.hpp | 156 + .../detail/unordered_iterator/point_iterator.hpp | 149 + contrib/libstdc++/include/ext/pb_ds/exception.hpp | 108 + .../libstdc++/include/ext/pb_ds/hash_policy.hpp | 610 +++ .../include/ext/pb_ds/list_update_policy.hpp | 141 + .../libstdc++/include/ext/pb_ds/priority_queue.hpp | 131 + .../libstdc++/include/ext/pb_ds/tag_and_trait.hpp | 357 ++ .../libstdc++/include/ext/pb_ds/tree_policy.hpp | 168 + .../libstdc++/include/ext/pb_ds/trie_policy.hpp | 365 ++ contrib/libstdc++/include/ext/pod_char_traits.h | 99 +- contrib/libstdc++/include/ext/pool_allocator.h | 91 +- contrib/libstdc++/include/ext/rb_tree | 31 +- contrib/libstdc++/include/ext/rc_string_base.h | 717 +++ contrib/libstdc++/include/ext/rope | 4759 +++++++++++--------- contrib/libstdc++/include/ext/ropeimpl.h | 2743 +++++------ contrib/libstdc++/include/ext/slist | 1765 ++++---- contrib/libstdc++/include/ext/sso_string_base.h | 569 +++ contrib/libstdc++/include/ext/stdio_filebuf.h | 12 +- contrib/libstdc++/include/ext/stdio_sync_filebuf.h | 14 +- contrib/libstdc++/include/ext/throw_allocator.h | 426 ++ contrib/libstdc++/include/ext/type_traits.h | 153 + contrib/libstdc++/include/ext/typelist.h | 473 ++ contrib/libstdc++/include/ext/vstring.h | 2198 +++++++++ contrib/libstdc++/include/ext/vstring.tcc | 690 +++ contrib/libstdc++/include/ext/vstring_fwd.h | 75 + contrib/libstdc++/include/ext/vstring_util.h | 177 + contrib/libstdc++/include/precompiled/extc++.h | 65 + contrib/libstdc++/include/precompiled/stdc++.h | 86 + contrib/libstdc++/include/precompiled/stdtr1c++.h | 58 + contrib/libstdc++/include/std/std_algorithm.h | 7 +- contrib/libstdc++/include/std/std_bitset.h | 1171 ++--- contrib/libstdc++/include/std/std_complex.h | 605 ++- contrib/libstdc++/include/std/std_deque.h | 7 +- contrib/libstdc++/include/std/std_fstream.h | 167 +- contrib/libstdc++/include/std/std_functional.h | 7 +- contrib/libstdc++/include/std/std_iomanip.h | 20 +- contrib/libstdc++/include/std/std_ios.h | 11 +- contrib/libstdc++/include/std/std_iosfwd.h | 20 +- contrib/libstdc++/include/std/std_iostream.h | 21 +- contrib/libstdc++/include/std/std_istream.h | 150 +- contrib/libstdc++/include/std/std_iterator.h | 7 +- contrib/libstdc++/include/std/std_limits.h | 45 +- contrib/libstdc++/include/std/std_list.h | 7 +- contrib/libstdc++/include/std/std_locale.h | 5 +- contrib/libstdc++/include/std/std_map.h | 7 +- contrib/libstdc++/include/std/std_memory.h | 21 +- contrib/libstdc++/include/std/std_numeric.h | 7 +- contrib/libstdc++/include/std/std_ostream.h | 201 +- contrib/libstdc++/include/std/std_queue.h | 7 +- contrib/libstdc++/include/std/std_set.h | 7 +- contrib/libstdc++/include/std/std_sstream.h | 124 +- contrib/libstdc++/include/std/std_stack.h | 7 +- contrib/libstdc++/include/std/std_stdexcept.h | 20 +- contrib/libstdc++/include/std/std_streambuf.h | 75 +- contrib/libstdc++/include/std/std_string.h | 17 +- contrib/libstdc++/include/std/std_utility.h | 7 +- contrib/libstdc++/include/std/std_valarray.h | 338 +- contrib/libstdc++/include/std/std_vector.h | 7 +- contrib/libstdc++/include/tr1/array | 251 ++ contrib/libstdc++/include/tr1/bind_iterate.h | 78 + contrib/libstdc++/include/tr1/bind_repeat.h | 192 + contrib/libstdc++/include/tr1/boost_shared_ptr.h | 1149 +++++ contrib/libstdc++/include/tr1/cctype | 56 + contrib/libstdc++/include/tr1/cfenv | 84 + contrib/libstdc++/include/tr1/cfloat | 47 + contrib/libstdc++/include/tr1/cinttypes | 81 + contrib/libstdc++/include/tr1/climits | 51 + contrib/libstdc++/include/tr1/cmath | 943 ++++ contrib/libstdc++/include/tr1/common.h | 78 + contrib/libstdc++/include/tr1/complex | 409 ++ contrib/libstdc++/include/tr1/cstdarg | 39 + contrib/libstdc++/include/tr1/cstdbool | 43 + contrib/libstdc++/include/tr1/cstdint | 92 + contrib/libstdc++/include/tr1/cstdio | 57 + contrib/libstdc++/include/tr1/cstdlib | 79 + contrib/libstdc++/include/tr1/ctgmath | 39 + contrib/libstdc++/include/tr1/ctime | 39 + contrib/libstdc++/include/tr1/ctype.h | 39 + contrib/libstdc++/include/tr1/cwchar | 72 + contrib/libstdc++/include/tr1/cwctype | 57 + contrib/libstdc++/include/tr1/fenv.h | 39 + contrib/libstdc++/include/tr1/float.h | 39 + contrib/libstdc++/include/tr1/functional | 1106 +++++ contrib/libstdc++/include/tr1/functional_hash.h | 232 + contrib/libstdc++/include/tr1/functional_iterate.h | 922 ++++ contrib/libstdc++/include/tr1/hashtable | 1182 +++++ contrib/libstdc++/include/tr1/hashtable_policy.h | 903 ++++ contrib/libstdc++/include/tr1/inttypes.h | 39 + contrib/libstdc++/include/tr1/limits.h | 39 + contrib/libstdc++/include/tr1/math.h | 99 + contrib/libstdc++/include/tr1/memory | 56 + contrib/libstdc++/include/tr1/mu_iterate.h | 52 + contrib/libstdc++/include/tr1/random | 2365 ++++++++++ contrib/libstdc++/include/tr1/random.tcc | 1547 +++++++ contrib/libstdc++/include/tr1/ref_fwd.h | 59 + contrib/libstdc++/include/tr1/ref_wrap_iterate.h | 44 + contrib/libstdc++/include/tr1/repeat.h | 677 +++ contrib/libstdc++/include/tr1/stdarg.h | 39 + contrib/libstdc++/include/tr1/stdbool.h | 39 + contrib/libstdc++/include/tr1/stdint.h | 39 + contrib/libstdc++/include/tr1/stdio.h | 39 + contrib/libstdc++/include/tr1/stdlib.h | 56 + contrib/libstdc++/include/tr1/tgmath.h | 39 + contrib/libstdc++/include/tr1/tuple | 161 + contrib/libstdc++/include/tr1/tuple_defs.h | 114 + contrib/libstdc++/include/tr1/tuple_iterate.h | 172 + contrib/libstdc++/include/tr1/type_traits | 703 +++ contrib/libstdc++/include/tr1/type_traits_fwd.h | 226 + contrib/libstdc++/include/tr1/unordered_map | 168 + contrib/libstdc++/include/tr1/unordered_set | 166 + contrib/libstdc++/include/tr1/utility | 102 + contrib/libstdc++/include/tr1/wchar.h | 39 + contrib/libstdc++/include/tr1/wctype.h | 39 + 570 files changed, 84983 insertions(+), 16344 deletions(-) create mode 100644 contrib/libstdc++/include/bits/ostream_insert.h create mode 100644 contrib/libstdc++/include/debug/functions.h create mode 100644 contrib/libstdc++/include/debug/macros.h create mode 100644 contrib/libstdc++/include/ext/array_allocator.h create mode 100644 contrib/libstdc++/include/ext/atomicity.h create mode 100644 contrib/libstdc++/include/ext/codecvt_specializations.h create mode 100644 contrib/libstdc++/include/ext/concurrence.h create mode 100644 contrib/libstdc++/include/ext/numeric_traits.h create mode 100644 contrib/libstdc++/include/ext/pb_ds/assoc_container.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/basic_tree_policy/basic_tree_policy_base.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/basic_tree_policy/traits.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/basic_types.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/bin_search_tree_/traits.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/const_iterator.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/entry_pred.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/standard_policies.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/cond_dealtor.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/container_base_dispatch.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/eq_fn/eq_by_less.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/standard_policies.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/null_metadata.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/map_debug_base.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/ov_tree_map_/traits.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/child_iterator.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/cond_dtor_entry_dealtor.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/head.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/internal_node.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/leaf.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/node_base.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/node_iterators.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/node_metadata_base.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/point_iterators.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/traits.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/priority_queue_base_dispatch.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rb_tree_map_/node.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rb_tree_map_/traits.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/splay_tree_/node.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/splay_tree_/traits.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/standard_policies.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/tree_policy/null_node_update_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/tree_trace_base.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/trie_policy/null_node_update_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/trie_policy/sample_trie_e_access_traits.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/trie_policy/string_trie_e_access_traits_imp.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/type_utils.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/types_traits.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/unordered_iterator/iterator.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/exception.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/hash_policy.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/list_update_policy.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/priority_queue.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/tag_and_trait.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/tree_policy.hpp create mode 100644 contrib/libstdc++/include/ext/pb_ds/trie_policy.hpp create mode 100644 contrib/libstdc++/include/ext/rc_string_base.h create mode 100644 contrib/libstdc++/include/ext/sso_string_base.h create mode 100644 contrib/libstdc++/include/ext/throw_allocator.h create mode 100644 contrib/libstdc++/include/ext/type_traits.h create mode 100644 contrib/libstdc++/include/ext/typelist.h create mode 100644 contrib/libstdc++/include/ext/vstring.h create mode 100644 contrib/libstdc++/include/ext/vstring.tcc create mode 100644 contrib/libstdc++/include/ext/vstring_fwd.h create mode 100644 contrib/libstdc++/include/ext/vstring_util.h create mode 100644 contrib/libstdc++/include/precompiled/extc++.h create mode 100644 contrib/libstdc++/include/precompiled/stdc++.h create mode 100644 contrib/libstdc++/include/precompiled/stdtr1c++.h create mode 100644 contrib/libstdc++/include/tr1/array create mode 100644 contrib/libstdc++/include/tr1/bind_iterate.h create mode 100644 contrib/libstdc++/include/tr1/bind_repeat.h create mode 100644 contrib/libstdc++/include/tr1/boost_shared_ptr.h create mode 100644 contrib/libstdc++/include/tr1/cctype create mode 100644 contrib/libstdc++/include/tr1/cfenv create mode 100644 contrib/libstdc++/include/tr1/cfloat create mode 100644 contrib/libstdc++/include/tr1/cinttypes create mode 100644 contrib/libstdc++/include/tr1/climits create mode 100644 contrib/libstdc++/include/tr1/cmath create mode 100644 contrib/libstdc++/include/tr1/common.h create mode 100644 contrib/libstdc++/include/tr1/complex create mode 100644 contrib/libstdc++/include/tr1/cstdarg create mode 100644 contrib/libstdc++/include/tr1/cstdbool create mode 100644 contrib/libstdc++/include/tr1/cstdint create mode 100644 contrib/libstdc++/include/tr1/cstdio create mode 100644 contrib/libstdc++/include/tr1/cstdlib create mode 100644 contrib/libstdc++/include/tr1/ctgmath create mode 100644 contrib/libstdc++/include/tr1/ctime create mode 100644 contrib/libstdc++/include/tr1/ctype.h create mode 100644 contrib/libstdc++/include/tr1/cwchar create mode 100644 contrib/libstdc++/include/tr1/cwctype create mode 100644 contrib/libstdc++/include/tr1/fenv.h create mode 100644 contrib/libstdc++/include/tr1/float.h create mode 100644 contrib/libstdc++/include/tr1/functional create mode 100644 contrib/libstdc++/include/tr1/functional_hash.h create mode 100644 contrib/libstdc++/include/tr1/functional_iterate.h create mode 100644 contrib/libstdc++/include/tr1/hashtable create mode 100644 contrib/libstdc++/include/tr1/hashtable_policy.h create mode 100644 contrib/libstdc++/include/tr1/inttypes.h create mode 100644 contrib/libstdc++/include/tr1/limits.h create mode 100644 contrib/libstdc++/include/tr1/math.h create mode 100644 contrib/libstdc++/include/tr1/memory create mode 100644 contrib/libstdc++/include/tr1/mu_iterate.h create mode 100644 contrib/libstdc++/include/tr1/random create mode 100644 contrib/libstdc++/include/tr1/random.tcc create mode 100644 contrib/libstdc++/include/tr1/ref_fwd.h create mode 100644 contrib/libstdc++/include/tr1/ref_wrap_iterate.h create mode 100644 contrib/libstdc++/include/tr1/repeat.h create mode 100644 contrib/libstdc++/include/tr1/stdarg.h create mode 100644 contrib/libstdc++/include/tr1/stdbool.h create mode 100644 contrib/libstdc++/include/tr1/stdint.h create mode 100644 contrib/libstdc++/include/tr1/stdio.h create mode 100644 contrib/libstdc++/include/tr1/stdlib.h create mode 100644 contrib/libstdc++/include/tr1/tgmath.h create mode 100644 contrib/libstdc++/include/tr1/tuple create mode 100644 contrib/libstdc++/include/tr1/tuple_defs.h create mode 100644 contrib/libstdc++/include/tr1/tuple_iterate.h create mode 100644 contrib/libstdc++/include/tr1/type_traits create mode 100644 contrib/libstdc++/include/tr1/type_traits_fwd.h create mode 100644 contrib/libstdc++/include/tr1/unordered_map create mode 100644 contrib/libstdc++/include/tr1/unordered_set create mode 100644 contrib/libstdc++/include/tr1/utility create mode 100644 contrib/libstdc++/include/tr1/wchar.h create mode 100644 contrib/libstdc++/include/tr1/wctype.h (limited to 'contrib/libstdc++/include') diff --git a/contrib/libstdc++/include/Makefile.am b/contrib/libstdc++/include/Makefile.am index ae9495a..19d170b 100644 --- a/contrib/libstdc++/include/Makefile.am +++ b/contrib/libstdc++/include/Makefile.am @@ -1,6 +1,7 @@ ## Makefile for the include subdirectory of the GNU C++ Standard library. ## -## Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +## Free Software Foundation, Inc. ## ## This file is part of the libstdc++ version 3 distribution. ## Process this file with automake to produce Makefile.in. @@ -18,7 +19,7 @@ ## You should have received a copy of the GNU General Public License along ## with this library; see the file COPYING. If not, write to the Free -## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +## Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, ## USA. include $(top_srcdir)/fragment.am @@ -92,7 +93,6 @@ bits_srcdir = ${glibcxx_srcdir}/include/bits bits_builddir = ./bits bits_headers = \ ${bits_srcdir}/allocator.h \ - ${bits_srcdir}/atomicity.h \ ${bits_srcdir}/basic_ios.h \ ${bits_srcdir}/basic_ios.tcc \ ${bits_srcdir}/basic_string.h \ @@ -101,7 +101,6 @@ bits_headers = \ ${bits_srcdir}/char_traits.h \ ${bits_srcdir}/codecvt.h \ ${bits_srcdir}/concept_check.h \ - ${bits_srcdir}/concurrence.h \ ${bits_srcdir}/cpp_type_traits.h \ ${bits_srcdir}/deque.tcc \ ${bits_srcdir}/fstream.tcc \ @@ -118,6 +117,7 @@ bits_headers = \ ${bits_srcdir}/localefwd.h \ ${bits_srcdir}/mask_array.h \ ${bits_srcdir}/ostream.tcc \ + ${bits_srcdir}/ostream_insert.h \ ${bits_srcdir}/postypes.h \ ${bits_srcdir}/stream_iterator.h \ ${bits_srcdir}/streambuf_iterator.h \ @@ -145,13 +145,11 @@ bits_headers = \ ${bits_srcdir}/stl_set.h \ ${bits_srcdir}/stl_stack.h \ ${bits_srcdir}/stl_tempbuf.h \ - ${bits_srcdir}/stl_threads.h \ ${bits_srcdir}/stl_tree.h \ ${bits_srcdir}/stl_uninitialized.h \ ${bits_srcdir}/stl_vector.h \ ${bits_srcdir}/streambuf.tcc \ ${bits_srcdir}/stringfwd.h \ - ${bits_srcdir}/type_traits.h \ ${bits_srcdir}/valarray_array.h \ ${bits_srcdir}/valarray_array.tcc \ ${bits_srcdir}/valarray_before.h \ @@ -198,32 +196,422 @@ backward_headers = \ ${backward_srcdir}/strstream \ ${backward_srcdir}/backward_warning.h + +pb_srcdir = ${glibcxx_srcdir}/include/ext/pb_ds +pb_builddir = ./ext/pb_ds + +pb_subdirs = \ + ${pb_builddir}/detail \ + ${pb_builddir}/detail/pairing_heap_ \ + ${pb_builddir}/detail/splay_tree_ \ + ${pb_builddir}/detail/list_update_map_ \ + ${pb_builddir}/detail/basic_tree_policy \ + ${pb_builddir}/detail/trie_policy \ + ${pb_builddir}/detail/gp_hash_table_map_ \ + ${pb_builddir}/detail/tree_policy \ + ${pb_builddir}/detail/binomial_heap_base_ \ + ${pb_builddir}/detail/resize_policy \ + ${pb_builddir}/detail/bin_search_tree_ \ + ${pb_builddir}/detail/binomial_heap_ \ + ${pb_builddir}/detail/thin_heap_ \ + ${pb_builddir}/detail/pat_trie_ \ + ${pb_builddir}/detail/cc_hash_table_map_ \ + ${pb_builddir}/detail/rc_binomial_heap_ \ + ${pb_builddir}/detail/left_child_next_sibling_heap_ \ + ${pb_builddir}/detail/unordered_iterator \ + ${pb_builddir}/detail/binary_heap_ \ + ${pb_builddir}/detail/ov_tree_map_ \ + ${pb_builddir}/detail/hash_fn \ + ${pb_builddir}/detail/eq_fn \ + ${pb_builddir}/detail/rb_tree_map_ \ + ${pb_builddir}/detail/list_update_policy + +# The ability for make and the underlying host to deal with this +# unweildy list as one entire entity is not a sure thing, and may +# cause build errors. Thus, split one list into many smaller +# mini-lists, with the maximum size per mini-list of no more than 42. + +pb_headers1 = \ + ${pb_srcdir}/assoc_container.hpp \ + ${pb_srcdir}/exception.hpp \ + ${pb_srcdir}/hash_policy.hpp \ + ${pb_srcdir}/list_update_policy.hpp \ + ${pb_srcdir}/priority_queue.hpp \ + ${pb_srcdir}/tag_and_trait.hpp \ + ${pb_srcdir}/tree_policy.hpp \ + ${pb_srcdir}/trie_policy.hpp \ + ${pb_srcdir}/detail/basic_tree_policy/basic_tree_policy_base.hpp \ + ${pb_srcdir}/detail/basic_tree_policy/null_node_metadata.hpp \ + ${pb_srcdir}/detail/basic_tree_policy/traits.hpp \ + ${pb_srcdir}/detail/basic_types.hpp \ + ${pb_srcdir}/detail/binary_heap_/binary_heap_.hpp \ + ${pb_srcdir}/detail/binary_heap_/const_iterator.hpp \ + ${pb_srcdir}/detail/binary_heap_/const_point_iterator.hpp \ + ${pb_srcdir}/detail/binary_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/entry_cmp.hpp \ + ${pb_srcdir}/detail/binary_heap_/entry_pred.hpp \ + ${pb_srcdir}/detail/binary_heap_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/resize_policy.hpp \ + ${pb_srcdir}/detail/binary_heap_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/binomial_heap_base_.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_/binomial_heap_.hpp \ + ${pb_srcdir}/detail/binomial_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/bin_search_tree_.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp + +pb_headers2 = \ + ${pb_srcdir}/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/node_iterators.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/point_iterators.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/r_erase_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/rotate_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/traits.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/cc_ht_map_.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/cmp_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/entry_list_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/resize_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/size_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/standard_policies.hpp + +pb_headers3 = \ + ${pb_srcdir}/detail/cc_hash_table_map_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/cond_dealtor.hpp \ + ${pb_srcdir}/detail/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/container_base_dispatch.hpp \ + ${pb_srcdir}/detail/eq_fn/eq_by_less.hpp \ + ${pb_srcdir}/detail/eq_fn/hash_eq_fn.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/gp_ht_map_.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/iterator_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/resize_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/standard_policies.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/hash_fn/direct_mask_range_hashing_imp.hpp \ + ${pb_srcdir}/detail/hash_fn/direct_mod_range_hashing_imp.hpp \ + ${pb_srcdir}/detail/hash_fn/linear_probe_fn_imp.hpp \ + ${pb_srcdir}/detail/hash_fn/mask_based_range_hashing.hpp \ + ${pb_srcdir}/detail/hash_fn/mod_based_range_hashing.hpp \ + ${pb_srcdir}/detail/hash_fn/probe_fn_base.hpp \ + ${pb_srcdir}/detail/hash_fn/quadratic_probe_fn_imp.hpp \ + ${pb_srcdir}/detail/hash_fn/ranged_hash_fn.hpp \ + ${pb_srcdir}/detail/hash_fn/ranged_probe_fn.hpp + +pb_headers4 = \ + ${pb_srcdir}/detail/hash_fn/sample_probe_fn.hpp \ + ${pb_srcdir}/detail/hash_fn/sample_ranged_hash_fn.hpp \ + ${pb_srcdir}/detail/hash_fn/sample_ranged_probe_fn.hpp \ + ${pb_srcdir}/detail/hash_fn/sample_range_hashing.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/const_iterator.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/const_point_iterator.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/node.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/null_metadata.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/constructor_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/entry_metadata_base.hpp \ + ${pb_srcdir}/detail/list_update_map_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/lu_map_.hpp \ + ${pb_srcdir}/detail/list_update_map_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_policy/counter_lu_metadata.hpp \ + ${pb_srcdir}/detail/list_update_policy/counter_lu_policy_imp.hpp \ + ${pb_srcdir}/detail/list_update_policy/mtf_lu_policy_imp.hpp \ + ${pb_srcdir}/detail/list_update_policy/sample_update_policy.hpp \ + ${pb_srcdir}/detail/map_debug_base.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/cond_dtor.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/node_iterators.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/ov_tree_map_.hpp + +pb_headers5 = \ + ${pb_srcdir}/detail/ov_tree_map_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/traits.hpp \ + ${pb_srcdir}/detail/pairing_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/pairing_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/pairing_heap_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/pairing_heap_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/pairing_heap_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/pairing_heap_/pairing_heap_.hpp \ + ${pb_srcdir}/detail/pairing_heap_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/child_iterator.hpp \ + ${pb_srcdir}/detail/pat_trie_/cond_dtor_entry_dealtor.hpp \ + ${pb_srcdir}/detail/pat_trie_/const_child_iterator.hpp \ + ${pb_srcdir}/detail/pat_trie_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/head.hpp \ + ${pb_srcdir}/detail/pat_trie_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/insert_join_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/internal_node.hpp \ + ${pb_srcdir}/detail/pat_trie_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/leaf.hpp \ + ${pb_srcdir}/detail/pat_trie_/node_base.hpp \ + ${pb_srcdir}/detail/pat_trie_/node_iterators.hpp \ + ${pb_srcdir}/detail/pat_trie_/node_metadata_base.hpp \ + ${pb_srcdir}/detail/pat_trie_/pat_trie_.hpp \ + ${pb_srcdir}/detail/pat_trie_/point_iterators.hpp \ + ${pb_srcdir}/detail/pat_trie_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/r_erase_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/rotate_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/split_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/split_join_branch_bag.hpp \ + ${pb_srcdir}/detail/pat_trie_/synth_e_access_traits.hpp \ + ${pb_srcdir}/detail/pat_trie_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/traits.hpp \ + ${pb_srcdir}/detail/pat_trie_/update_fn_imps.hpp \ + ${pb_srcdir}/detail/priority_queue_base_dispatch.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/debug_fn_imps.hpp + +pb_headers6 = \ + ${pb_srcdir}/detail/rb_tree_map_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/node.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/rb_tree_.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/traits.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/rc_binomial_heap_.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/rc.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp \ + ${pb_srcdir}/detail/resize_policy/hash_exponential_size_policy_imp.hpp \ + ${pb_srcdir}/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp \ + ${pb_srcdir}/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp \ + ${pb_srcdir}/detail/resize_policy/hash_prime_size_policy_imp.hpp \ + ${pb_srcdir}/detail/resize_policy/hash_standard_resize_policy_imp.hpp \ + ${pb_srcdir}/detail/resize_policy/sample_resize_policy.hpp \ + ${pb_srcdir}/detail/resize_policy/sample_resize_trigger.hpp \ + ${pb_srcdir}/detail/resize_policy/sample_size_policy.hpp \ + ${pb_srcdir}/detail/splay_tree_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/node.hpp \ + ${pb_srcdir}/detail/splay_tree_/splay_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/splay_tree_.hpp \ + ${pb_srcdir}/detail/splay_tree_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/traits.hpp \ + ${pb_srcdir}/detail/standard_policies.hpp \ + ${pb_srcdir}/detail/thin_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/thin_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/thin_heap_/erase_fn_imps.hpp + +pb_headers7 = \ + ${pb_srcdir}/detail/thin_heap_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/thin_heap_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/thin_heap_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/thin_heap_/thin_heap_.hpp \ + ${pb_srcdir}/detail/thin_heap_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/tree_policy/node_metadata_selector.hpp \ + ${pb_srcdir}/detail/tree_policy/null_node_update_imp.hpp \ + ${pb_srcdir}/detail/tree_policy/order_statistics_imp.hpp \ + ${pb_srcdir}/detail/tree_policy/sample_tree_node_update.hpp \ + ${pb_srcdir}/detail/tree_trace_base.hpp \ + ${pb_srcdir}/detail/trie_policy/node_metadata_selector.hpp \ + ${pb_srcdir}/detail/trie_policy/null_node_update_imp.hpp \ + ${pb_srcdir}/detail/trie_policy/order_statistics_imp.hpp \ + ${pb_srcdir}/detail/trie_policy/prefix_search_node_update_imp.hpp \ + ${pb_srcdir}/detail/trie_policy/sample_trie_e_access_traits.hpp \ + ${pb_srcdir}/detail/trie_policy/sample_trie_node_update.hpp \ + ${pb_srcdir}/detail/trie_policy/string_trie_e_access_traits_imp.hpp \ + ${pb_srcdir}/detail/trie_policy/trie_policy_base.hpp \ + ${pb_srcdir}/detail/types_traits.hpp \ + ${pb_srcdir}/detail/type_utils.hpp \ + ${pb_srcdir}/detail/unordered_iterator/const_iterator.hpp \ + ${pb_srcdir}/detail/unordered_iterator/const_point_iterator.hpp \ + ${pb_srcdir}/detail/unordered_iterator/iterator.hpp \ + ${pb_srcdir}/detail/unordered_iterator/point_iterator.hpp + + + ext_srcdir = ${glibcxx_srcdir}/include/ext -ext_builddir = ./ext +ext_builddir = ./ext ext_headers = \ ${ext_srcdir}/algorithm \ + ${ext_srcdir}/atomicity.h \ + ${ext_srcdir}/array_allocator.h \ ${ext_srcdir}/bitmap_allocator.h \ + ${ext_srcdir}/codecvt_specializations.h \ + ${ext_srcdir}/concurrence.h \ ${ext_srcdir}/debug_allocator.h \ - ${ext_srcdir}/enc_filebuf.h \ ${ext_srcdir}/stdio_filebuf.h \ ${ext_srcdir}/stdio_sync_filebuf.h \ ${ext_srcdir}/functional \ ${ext_srcdir}/hash_map \ ${ext_srcdir}/hash_set \ + ${ext_srcdir}/hash_fun.h \ + ${ext_srcdir}/hashtable.h \ ${ext_srcdir}/iterator \ ${ext_srcdir}/malloc_allocator.h \ ${ext_srcdir}/memory \ ${ext_srcdir}/mt_allocator.h \ ${ext_srcdir}/new_allocator.h \ ${ext_srcdir}/numeric \ + ${ext_srcdir}/numeric_traits.h \ ${ext_srcdir}/pod_char_traits.h \ ${ext_srcdir}/pool_allocator.h \ ${ext_srcdir}/rb_tree \ ${ext_srcdir}/rope \ ${ext_srcdir}/ropeimpl.h \ ${ext_srcdir}/slist \ - ${ext_srcdir}/hash_fun.h \ - ${ext_srcdir}/hashtable.h + ${ext_srcdir}/throw_allocator.h \ + ${ext_srcdir}/typelist.h \ + ${ext_srcdir}/type_traits.h \ + ${ext_srcdir}/rc_string_base.h \ + ${ext_srcdir}/sso_string_base.h \ + ${ext_srcdir}/vstring.h \ + ${ext_srcdir}/vstring.tcc \ + ${ext_srcdir}/vstring_fwd.h \ + ${ext_srcdir}/vstring_util.h + + +tr1_srcdir = ${glibcxx_srcdir}/include/tr1 +tr1_builddir = ./tr1 +tr1_headers = \ + ${tr1_srcdir}/array \ + ${tr1_srcdir}/bind_repeat.h \ + ${tr1_srcdir}/bind_iterate.h \ + ${tr1_srcdir}/boost_shared_ptr.h \ + ${tr1_srcdir}/cctype \ + ${tr1_srcdir}/cfenv \ + ${tr1_srcdir}/cfloat \ + ${tr1_srcdir}/cinttypes \ + ${tr1_srcdir}/climits \ + ${tr1_srcdir}/cmath \ + ${tr1_srcdir}/common.h \ + ${tr1_srcdir}/complex \ + ${tr1_srcdir}/cstdarg \ + ${tr1_srcdir}/cstdbool \ + ${tr1_srcdir}/cstdint \ + ${tr1_srcdir}/cstdio \ + ${tr1_srcdir}/cstdlib \ + ${tr1_srcdir}/ctgmath \ + ${tr1_srcdir}/ctime \ + ${tr1_srcdir}/ctype.h \ + ${tr1_srcdir}/cwchar \ + ${tr1_srcdir}/cwctype \ + ${tr1_srcdir}/fenv.h \ + ${tr1_srcdir}/float.h \ + ${tr1_srcdir}/functional \ + ${tr1_srcdir}/functional_hash.h \ + ${tr1_srcdir}/functional_iterate.h \ + ${tr1_srcdir}/hashtable \ + ${tr1_srcdir}/hashtable_policy.h \ + ${tr1_srcdir}/inttypes.h \ + ${tr1_srcdir}/limits.h \ + ${tr1_srcdir}/math.h \ + ${tr1_srcdir}/memory \ + ${tr1_srcdir}/mu_iterate.h \ + ${tr1_srcdir}/random \ + ${tr1_srcdir}/random.tcc \ + ${tr1_srcdir}/ref_fwd.h \ + ${tr1_srcdir}/ref_wrap_iterate.h \ + ${tr1_srcdir}/repeat.h \ + ${tr1_srcdir}/stdarg.h \ + ${tr1_srcdir}/stdbool.h \ + ${tr1_srcdir}/stdint.h \ + ${tr1_srcdir}/stdio.h \ + ${tr1_srcdir}/stdlib.h \ + ${tr1_srcdir}/tgmath.h \ + ${tr1_srcdir}/tuple \ + ${tr1_srcdir}/tuple_defs.h \ + ${tr1_srcdir}/tuple_iterate.h \ + ${tr1_srcdir}/type_traits \ + ${tr1_srcdir}/type_traits_fwd.h \ + ${tr1_srcdir}/unordered_set \ + ${tr1_srcdir}/unordered_map \ + ${tr1_srcdir}/utility \ + ${tr1_srcdir}/wchar.h \ + ${tr1_srcdir}/wctype.h + # This is the common subset of files that all three "C" header models use. c_base_srcdir = $(C_INCLUDE_DIR) @@ -298,6 +686,7 @@ debug_headers = \ ${debug_srcdir}/debug.h \ ${debug_srcdir}/deque \ ${debug_srcdir}/formatter.h \ + ${debug_srcdir}/functions.h \ ${debug_srcdir}/hash_map \ ${debug_srcdir}/hash_map.h \ ${debug_srcdir}/hash_multimap.h \ @@ -306,6 +695,7 @@ debug_headers = \ ${debug_srcdir}/hash_set.h \ ${debug_srcdir}/list \ ${debug_srcdir}/map \ + ${debug_srcdir}/macros.h \ ${debug_srcdir}/map.h \ ${debug_srcdir}/multimap.h \ ${debug_srcdir}/multiset.h \ @@ -335,16 +725,21 @@ endif host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR) host_builddir = ./${host_alias}/bits +host_installdir = ${gxx_include_dir}/${host_alias}$(MULTISUBDIR)/bits host_headers = \ ${host_srcdir}/ctype_base.h \ ${host_srcdir}/ctype_inline.h \ ${host_srcdir}/ctype_noninline.h \ ${host_srcdir}/os_defines.h \ - ${glibcxx_srcdir}/$(ATOMIC_WORD_SRCDIR)/atomic_word.h + ${glibcxx_srcdir}/$(ATOMIC_WORD_SRCDIR)/atomic_word.h \ + ${glibcxx_srcdir}/$(ABI_TWEAKS_SRCDIR)/cxxabi_tweaks.h \ + ${glibcxx_srcdir}/$(CPU_DEFINES_SRCDIR)/cpu_defines.h # Non-installed host_header files. +COMPATIBILITY_H = config/abi/compatibility.h host_headers_noinst = \ - ${glibcxx_srcdir}/$(CLOCALE_INTERNAL_H) + ${glibcxx_srcdir}/$(CLOCALE_INTERNAL_H) \ + ${glibcxx_srcdir}/$(COMPATIBILITY_H) # These host_headers_extra files are all built with ad hoc naming rules. host_headers_extra = \ @@ -354,21 +749,45 @@ host_headers_extra = \ ${host_builddir}/c++io.h \ ${host_builddir}/c++locale.h \ ${host_builddir}/messages_members.h \ - ${host_builddir}/time_members.h \ - ${host_builddir}/codecvt_specializations.h + ${host_builddir}/time_members.h thread_host_headers = \ ${host_builddir}/gthr.h \ ${host_builddir}/gthr-single.h \ ${host_builddir}/gthr-posix.h \ + ${host_builddir}/gthr-tpf.h \ ${host_builddir}/gthr-default.h -pch_input = ${host_builddir}/stdc++.h -pch_output_builddir = ${host_builddir}/stdc++.h.gch -pch_source = ${glibcxx_srcdir}/include/stdc++.h + +pch1_source = ${glibcxx_srcdir}/include/precompiled/stdc++.h +pch1_output_builddir = ${host_builddir}/stdc++.h.gch +pch1_output_anchor = ${host_builddir}/stdc++.h +pch1_output_installdir = ${host_installdir}/stdc++.h.gch +pch1a_output = ${pch1_output_builddir}/O0g.gch +pch1b_output = ${pch1_output_builddir}/O2g.gch +pch1_output = ${pch1a_output} ${pch1b_output} + +pch2_source = ${glibcxx_srcdir}/include/precompiled/stdtr1c++.h +pch2_output_builddir = ${host_builddir}/stdtr1c++.h.gch +pch2_output_anchor = ${host_builddir}/stdtr1c++.h +pch2_output_installdir = ${host_installdir}/stdtr1c++.h.gch +pch2_output = ${pch2_output_builddir}/O2g.gch + +pch3_source = ${glibcxx_srcdir}/include/precompiled/extc++.h +pch3_output_builddir = ${host_builddir}/extc++.h.gch +pch3_output_anchor = ${host_builddir}/extc++.h +pch3_output_installdir = ${host_installdir}/extc++.h.gch +pch3_output = ${pch3_output_builddir}/O2g.gch + + +pch_output = ${pch1_output} ${pch2_output} ${pch3_output} +pch_output_dirs = \ + ${pch1_output_builddir} ${pch2_output_builddir} ${pch3_output_builddir} +pch_output_anchors = \ + ${pch1_output_anchor} ${pch2_output_anchor} ${pch3_output_anchor} PCHFLAGS=-Winvalid-pch -Wno-deprecated -x c++-header $(CXXFLAGS) if GLIBCXX_BUILD_PCH -pch_build = ${pch_input} +pch_build = ${pch_output} pch_install = install-pch else pch_build = @@ -379,7 +798,7 @@ endif # CLEANFILES and all-local are kept up-to-date. allstamped = \ stamp-std stamp-bits stamp-c_base stamp-c_compatibility \ - stamp-backward stamp-ext stamp-debug stamp-host + stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-debug stamp-host # List of all files that are created by explicit building, editing, or # catenation. @@ -399,8 +818,8 @@ stamp-std: ${std_headers} fi ;\ if [ ! -f stamp-std ]; then \ (cd ${std_builddir} && for h in $?; do \ - official_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ - $(LN_S) $$h ./$${official_name} || true ;\ + build_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ + $(LN_S) $$h ./$${build_name} || true ;\ done) ;\ fi ;\ $(STAMP) stamp-std @@ -420,8 +839,8 @@ stamp-c_base: stamp-bits ${c_base_headers} ${c_base_headers_extra} fi ;\ if [ ! -f stamp-c_base ]; then \ (cd ${c_base_builddir} && for h in ${c_base_headers}; do \ - official_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ - $(LN_S) $$h ./$${official_name} || true ;\ + build_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ + $(LN_S) $$h ./$${build_name} || true ;\ done) ;\ if [ ! -z "${c_base_headers_extra}" ]; then \ (cd ${bits_builddir} && $(LN_S) ${c_base_headers_extra} . || true) ;\ @@ -458,6 +877,66 @@ stamp-ext: ${ext_headers} fi ;\ $(STAMP) stamp-ext +# Have to deal with nested include directories, gah! Strip off source +# directory before making the link. +# XXX check ${pb_headers} +stamp-pb: + @if [ ! -d "${pb_builddir}" ]; then \ + mkdir -p ${pb_subdirs} ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers1}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers2}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers3}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers4}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers5}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers6}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers7}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + $(STAMP) stamp-pb + +stamp-tr1: ${tr1_headers} + @if [ ! -d "${tr1_builddir}" ]; then \ + mkdir -p ${tr1_builddir} ;\ + fi ;\ + if [ ! -f stamp-tr1 ]; then \ + (cd ${tr1_builddir} && $(LN_S) $? . || true) ;\ + fi ;\ + $(STAMP) stamp-tr1 + stamp-debug: ${debug_headers} @if [ ! -d "${debug_builddir}" ]; then \ mkdir -p ${debug_builddir} ;\ @@ -484,29 +963,62 @@ stamp-host: ${host_headers} ${host_headers_noinst} stamp-${host_alias} $(LN_S) ${glibcxx_srcdir}/$(CSTDIO_H) c++io.h || true ;\ $(LN_S) ${glibcxx_srcdir}/$(CLOCALE_H) c++locale.h || true ;\ $(LN_S) ${glibcxx_srcdir}/$(CLOCALE_INTERNAL_H) . || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(COMPATIBILITY_H) . || true ;\ $(LN_S) ${glibcxx_srcdir}/$(CMESSAGES_H) messages_members.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/$(CTIME_H) time_members.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/$(CCODECVT_H) codecvt_specializations.h || true);\ + $(LN_S) ${glibcxx_srcdir}/$(CTIME_H) time_members.h || true);\ fi ;\ $(STAMP) stamp-host # Host includes dynamic. -${host_builddir}/c++config.h: ${top_builddir}/config.h \ - ${glibcxx_srcdir}/include/bits/c++config \ - stamp-${host_alias} - @cat ${glibcxx_srcdir}/include/bits/c++config > $@ ;\ +if ENABLE_SYMVERS_GNU_NAMESPACE +stamp-namespace-version: + echo 1 > stamp-namespace-version +else +stamp-namespace-version: + echo 0 > stamp-namespace-version +endif + +if ENABLE_VISIBILITY +stamp-visibility: + echo 1 > stamp-visibility +else +stamp-visibility: + echo 0 > stamp-visibility +endif + +${host_builddir}/c++config.h: ${CONFIG_HEADER} \ + ${glibcxx_srcdir}/include/bits/c++config \ + stamp-${host_alias} \ + ${toplevel_srcdir}/gcc/DATESTAMP \ + stamp-namespace-version \ + stamp-visibility + @date=`cat ${toplevel_srcdir}/gcc/DATESTAMP` ;\ + nsa_version=`cat stamp-namespace-version` ;\ + visibility=`cat stamp-visibility` ;\ + ldbl_compat='' ;\ + grep "^[ ]*#[ ]*define[ ][ ]*_GLIBCXX_LONG_DOUBLE_COMPAT[ ][ ]*1[ ]*$$" \ + ${CONFIG_HEADER} > /dev/null 2>&1 \ + && ldbl_compat='s,^#undef _GLIBCXX_LONG_DOUBLE_COMPAT$$,#define _GLIBCXX_LONG_DOUBLE_COMPAT 1,' ;\ + sed -e "s,define __GLIBCXX__,define __GLIBCXX__ $$date," \ + -e "s,define _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION, define _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION $$nsa_version," \ + -e "s,define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY, define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY $$visibility," \ + -e "$$ldbl_compat" \ + < ${glibcxx_srcdir}/include/bits/c++config > $@ ;\ sed -e 's/HAVE_/_GLIBCXX_HAVE_/g' \ -e 's/PACKAGE/_GLIBCXX_PACKAGE/g' \ -e 's/VERSION/_GLIBCXX_VERSION/g' \ -e 's/WORDS_/_GLIBCXX_WORDS_/g' \ + -e '/[ ]_GLIBCXX_LONG_DOUBLE_COMPAT[ ]/d' \ < ${CONFIG_HEADER} >> $@ ;\ - echo "#endif // _CXXCONFIG_" >>$@ + echo "" >> $@ ;\ + echo "#endif // _CXXCONFIG_" >> $@ # Host includes for threads uppercase = [ABCDEFGHIJKLMNOPQRSTUVWXYZ_] ${host_builddir}/gthr.h: ${toplevel_srcdir}/gcc/gthr.h stamp-${host_alias} - sed -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \ + sed -e '/^#pragma/b' \ + -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \ -e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \ -e 's,^#include "\(.*\)",#include ,g' \ < ${toplevel_srcdir}/gcc/gthr.h > $@ @@ -525,6 +1037,14 @@ ${host_builddir}/gthr-posix.h: ${toplevel_srcdir}/gcc/gthr-posix.h \ -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ < ${toplevel_srcdir}/gcc/gthr-posix.h > $@ +${host_builddir}/gthr-tpf.h: ${toplevel_srcdir}/gcc/gthr-tpf.h \ + stamp-${host_alias} + sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ + -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ + -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \ + -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ + < ${toplevel_srcdir}/gcc/gthr-tpf.h > $@ + ${host_builddir}/gthr-default.h: ${toplevel_srcdir}/gcc/${glibcxx_thread_h} \ stamp-${host_alias} sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ @@ -534,14 +1054,36 @@ ${host_builddir}/gthr-default.h: ${toplevel_srcdir}/gcc/${glibcxx_thread_h} \ -e 's,^#include "\(.*\)",#include ,g' \ < ${toplevel_srcdir}/gcc/${glibcxx_thread_h} > $@ -# Build a precompiled C++ include, stdc++.h.gch. -${pch_input}: ${allstamped} ${host_builddir}/c++config.h ${pch_source} - touch ${pch_input}; \ - if [ ! -d "${pch_output_builddir}" ]; then \ - mkdir -p ${pch_output_builddir}; \ +# Build two precompiled C++ includes, stdc++.h.gch/*.gch +${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source} + if [ ! -d "${pch1_output_builddir}" ]; then \ + mkdir -p ${pch1_output_builddir}; \ + fi; \ + $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O0 -g ${pch1_source} -o $@ + touch ${pch1_output_anchor} + +${pch1b_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source} + if [ ! -d "${pch1_output_builddir}" ]; then \ + mkdir -p ${pch1_output_builddir}; \ fi; \ - $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) ${pch_source} -O0 -g -o ${pch_output_builddir}/O0g; \ - $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) ${pch_source} -O2 -g -o ${pch_output_builddir}/O2g; + $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch1_source} -o $@ + touch ${pch1_output_anchor} + +# Build a precompiled TR1 include, stdtr1c++.h.gch/O2.gch +${pch2_output}: ${pch2_source} ${pch1_output} + if [ ! -d "${pch2_output_builddir}" ]; then \ + mkdir -p ${pch2_output_builddir}; \ + fi; \ + $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch2_source} -o $@ + touch ${pch2_output_anchor} + +# Build a precompiled extension include, extc++.h.gch/O2.gch +${pch3_output}: ${pch3_source} ${pch2_output} + if [ ! -d "${pch3_output_builddir}" ]; then \ + mkdir -p ${pch3_output_builddir}; \ + fi; \ + $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch3_source} -o $@ + touch ${pch3_output_anchor} # For robustness sake (in light of junk files or in-source # configuration), copy from the build or source tree to the install @@ -565,9 +1107,9 @@ endif # are copied here. install-freestanding-headers: $(mkinstalldirs) $(DESTDIR)${gxx_include_dir} - $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${host_builddir} + $(mkinstalldirs) $(DESTDIR)${host_installdir} for file in ${host_srcdir}/os_defines.h ${host_builddir}/c++config.h; do \ - $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${host_builddir}; done + $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir} $(INSTALL_DATA) ${std_builddir}/limits $(DESTDIR)${gxx_include_dir}/${std_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir} @@ -586,6 +1128,40 @@ install-headers: $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${ext_builddir} for file in ${ext_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${ext_builddir}; done + $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${pb_builddir} + for dir in ${pb_subdirs}; do \ + $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/$${dir} ; done + for file in ${pb_headers1}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers2}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers3}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers4}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers5}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers6}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers7}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir} + for file in ${tr1_headers}; do \ + $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_builddir}; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir} for file in ${c_base_headers_rename}; do \ $(INSTALL_DATA) ${c_base_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done @@ -601,18 +1177,27 @@ install-headers: $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${debug_builddir} for file in ${debug_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${debug_builddir}; done - $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${host_builddir} + $(mkinstalldirs) $(DESTDIR)${host_installdir} for file in ${host_headers} ${host_headers_extra} \ ${thread_host_headers}; do \ - $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${host_builddir}; done + $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done install-pch: - $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${pch_output_builddir} - for file in ${pch_output_builddir}/*; do \ - $(INSTALL_DATA) $$file $(DESTDIR)${gxx_include_dir}/${pch_output_builddir}; done + $(mkinstalldirs) $(DESTDIR)${pch1_output_installdir} + for file in ${pch1_output_builddir}/*; do \ + $(INSTALL_DATA) $$file $(DESTDIR)${pch1_output_installdir}; done + $(mkinstalldirs) $(DESTDIR)${pch2_output_installdir} + for file in ${pch2_output_builddir}/*; do \ + $(INSTALL_DATA) $$file $(DESTDIR)${pch2_output_installdir}; done + $(INSTALL_DATA) ${pch1_output_anchor} $(DESTDIR)${host_installdir} + $(INSTALL_DATA) ${pch2_output_anchor} $(DESTDIR)${host_installdir} # By adding these files here, automake will remove them for 'make clean' -CLEANFILES = ${pch_input} ${pch_output_builddir}/* +CLEANFILES = ${pch_output} ${pch_output_anchors} + +# To remove directories. +clean-local: + rm -rf ${pch_output_dirs} # Stop implicit '.o' make rules from ever stomping on extensionless # headers, in the improbable case where some foolish, crack-addled diff --git a/contrib/libstdc++/include/Makefile.in b/contrib/libstdc++/include/Makefile.in index 9d110b3..6cf6fc3 100644 --- a/contrib/libstdc++/include/Makefile.in +++ b/contrib/libstdc++/include/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.7.8 from Makefile.am. +# Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 -# Free Software Foundation, Inc. +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -13,7 +13,6 @@ # PARTICULAR PURPOSE. @SET_MAKE@ - srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ @@ -21,7 +20,6 @@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. - am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 @@ -38,6 +36,28 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/fragment.am +subdir = include +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../config/enable.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/no-executables.m4 \ + $(top_srcdir)/../config/unwind_ipinfo.m4 \ + $(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \ + $(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/../config/tls.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +depcomp = +am__depfiles_maybe = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ABI_TWEAKS_SRCDIR = @ABI_TWEAKS_SRCDIR@ ACLOCAL = @ACLOCAL@ ALLOCATOR_H = @ALLOCATOR_H@ ALLOCATOR_NAME = @ALLOCATOR_NAME@ @@ -54,7 +74,6 @@ BASIC_FILE_CC = @BASIC_FILE_CC@ BASIC_FILE_H = @BASIC_FILE_H@ CC = @CC@ CCODECVT_CC = @CCODECVT_CC@ -CCODECVT_H = @CCODECVT_H@ CCOLLATE_CC = @CCOLLATE_CC@ CCTYPE_CC = @CCTYPE_CC@ CFLAGS = @CFLAGS@ @@ -67,6 +86,7 @@ CMONEY_CC = @CMONEY_CC@ CNUMERIC_CC = @CNUMERIC_CC@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CPU_DEFINES_SRCDIR = @CPU_DEFINES_SRCDIR@ CSTDIO_H = @CSTDIO_H@ CTIME_CC = @CTIME_CC@ CTIME_H = @CTIME_H@ @@ -81,14 +101,22 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +ENABLE_SYMVERS_DARWIN_FALSE = @ENABLE_SYMVERS_DARWIN_FALSE@ +ENABLE_SYMVERS_DARWIN_TRUE = @ENABLE_SYMVERS_DARWIN_TRUE@ +ENABLE_SYMVERS_FALSE = @ENABLE_SYMVERS_FALSE@ +ENABLE_SYMVERS_GNU_FALSE = @ENABLE_SYMVERS_GNU_FALSE@ +ENABLE_SYMVERS_GNU_NAMESPACE_FALSE = @ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@ +ENABLE_SYMVERS_GNU_NAMESPACE_TRUE = @ENABLE_SYMVERS_GNU_NAMESPACE_TRUE@ +ENABLE_SYMVERS_GNU_TRUE = @ENABLE_SYMVERS_GNU_TRUE@ +ENABLE_SYMVERS_TRUE = @ENABLE_SYMVERS_TRUE@ +ENABLE_VISIBILITY_FALSE = @ENABLE_VISIBILITY_FALSE@ +ENABLE_VISIBILITY_TRUE = @ENABLE_VISIBILITY_TRUE@ EXEEXT = @EXEEXT@ EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@ GLIBCXX_BUILD_DEBUG_FALSE = @GLIBCXX_BUILD_DEBUG_FALSE@ GLIBCXX_BUILD_DEBUG_TRUE = @GLIBCXX_BUILD_DEBUG_TRUE@ GLIBCXX_BUILD_PCH_FALSE = @GLIBCXX_BUILD_PCH_FALSE@ GLIBCXX_BUILD_PCH_TRUE = @GLIBCXX_BUILD_PCH_TRUE@ -GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE = @GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE@ -GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE = @GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@ GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE = @GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@ GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE = @GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE@ GLIBCXX_C_HEADERS_C_FALSE = @GLIBCXX_C_HEADERS_C_FALSE@ @@ -98,14 +126,13 @@ GLIBCXX_C_HEADERS_C_TRUE = @GLIBCXX_C_HEADERS_C_TRUE@ GLIBCXX_HOSTED_FALSE = @GLIBCXX_HOSTED_FALSE@ GLIBCXX_HOSTED_TRUE = @GLIBCXX_HOSTED_TRUE@ GLIBCXX_INCLUDES = @GLIBCXX_INCLUDES@ -GLIBCXX_TEST_ABI_FALSE = @GLIBCXX_TEST_ABI_FALSE@ -GLIBCXX_TEST_ABI_TRUE = @GLIBCXX_TEST_ABI_TRUE@ -GLIBCXX_TEST_WCHAR_T_FALSE = @GLIBCXX_TEST_WCHAR_T_FALSE@ -GLIBCXX_TEST_WCHAR_T_TRUE = @GLIBCXX_TEST_WCHAR_T_TRUE@ +GLIBCXX_LDBL_COMPAT_FALSE = @GLIBCXX_LDBL_COMPAT_FALSE@ +GLIBCXX_LDBL_COMPAT_TRUE = @GLIBCXX_LDBL_COMPAT_TRUE@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBICONV = @LIBICONV@ LIBMATHOBJS = @LIBMATHOBJS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ @@ -134,7 +161,7 @@ SECTION_LDFLAGS = @SECTION_LDFLAGS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ -SYMVER_MAP = @SYMVER_MAP@ +SYMVER_FILE = @SYMVER_FILE@ TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ @@ -147,6 +174,8 @@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ baseline_dir = @baseline_dir@ bindir = @bindir@ build = @build@ @@ -183,6 +212,7 @@ libexecdir = @libexecdir@ libtool_VERSION = @libtool_VERSION@ localstatedir = @localstatedir@ mandir = @mandir@ +mkdir_p = @mkdir_p@ multi_basedir = @multi_basedir@ oldincludedir = @oldincludedir@ port_specific_symbol_files = @port_specific_symbol_files@ @@ -198,12 +228,12 @@ target_os = @target_os@ target_vendor = @target_vendor@ toplevel_srcdir = @toplevel_srcdir@ +# May be used by various substitution variables. +gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) MAINT_CHARSET = latin1 - mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs PWD_COMMAND = $${PWDCMD-pwd} STAMP = echo timestamp > - toolexecdir = $(glibcxx_toolexecdir) toolexeclibdir = $(glibcxx_toolexeclibdir) @@ -285,12 +315,10 @@ std_headers_rename = \ valarray \ vector - bits_srcdir = ${glibcxx_srcdir}/include/bits bits_builddir = ./bits bits_headers = \ ${bits_srcdir}/allocator.h \ - ${bits_srcdir}/atomicity.h \ ${bits_srcdir}/basic_ios.h \ ${bits_srcdir}/basic_ios.tcc \ ${bits_srcdir}/basic_string.h \ @@ -299,7 +327,6 @@ bits_headers = \ ${bits_srcdir}/char_traits.h \ ${bits_srcdir}/codecvt.h \ ${bits_srcdir}/concept_check.h \ - ${bits_srcdir}/concurrence.h \ ${bits_srcdir}/cpp_type_traits.h \ ${bits_srcdir}/deque.tcc \ ${bits_srcdir}/fstream.tcc \ @@ -316,6 +343,7 @@ bits_headers = \ ${bits_srcdir}/localefwd.h \ ${bits_srcdir}/mask_array.h \ ${bits_srcdir}/ostream.tcc \ + ${bits_srcdir}/ostream_insert.h \ ${bits_srcdir}/postypes.h \ ${bits_srcdir}/stream_iterator.h \ ${bits_srcdir}/streambuf_iterator.h \ @@ -343,20 +371,17 @@ bits_headers = \ ${bits_srcdir}/stl_set.h \ ${bits_srcdir}/stl_stack.h \ ${bits_srcdir}/stl_tempbuf.h \ - ${bits_srcdir}/stl_threads.h \ ${bits_srcdir}/stl_tree.h \ ${bits_srcdir}/stl_uninitialized.h \ ${bits_srcdir}/stl_vector.h \ ${bits_srcdir}/streambuf.tcc \ ${bits_srcdir}/stringfwd.h \ - ${bits_srcdir}/type_traits.h \ ${bits_srcdir}/valarray_array.h \ ${bits_srcdir}/valarray_array.tcc \ ${bits_srcdir}/valarray_before.h \ ${bits_srcdir}/valarray_after.h \ ${bits_srcdir}/vector.tcc - backward_srcdir = ${glibcxx_srcdir}/include/backward backward_builddir = ./backward backward_headers = \ @@ -397,33 +422,416 @@ backward_headers = \ ${backward_srcdir}/strstream \ ${backward_srcdir}/backward_warning.h +pb_srcdir = ${glibcxx_srcdir}/include/ext/pb_ds +pb_builddir = ./ext/pb_ds +pb_subdirs = \ + ${pb_builddir}/detail \ + ${pb_builddir}/detail/pairing_heap_ \ + ${pb_builddir}/detail/splay_tree_ \ + ${pb_builddir}/detail/list_update_map_ \ + ${pb_builddir}/detail/basic_tree_policy \ + ${pb_builddir}/detail/trie_policy \ + ${pb_builddir}/detail/gp_hash_table_map_ \ + ${pb_builddir}/detail/tree_policy \ + ${pb_builddir}/detail/binomial_heap_base_ \ + ${pb_builddir}/detail/resize_policy \ + ${pb_builddir}/detail/bin_search_tree_ \ + ${pb_builddir}/detail/binomial_heap_ \ + ${pb_builddir}/detail/thin_heap_ \ + ${pb_builddir}/detail/pat_trie_ \ + ${pb_builddir}/detail/cc_hash_table_map_ \ + ${pb_builddir}/detail/rc_binomial_heap_ \ + ${pb_builddir}/detail/left_child_next_sibling_heap_ \ + ${pb_builddir}/detail/unordered_iterator \ + ${pb_builddir}/detail/binary_heap_ \ + ${pb_builddir}/detail/ov_tree_map_ \ + ${pb_builddir}/detail/hash_fn \ + ${pb_builddir}/detail/eq_fn \ + ${pb_builddir}/detail/rb_tree_map_ \ + ${pb_builddir}/detail/list_update_policy + + +# The ability for make and the underlying host to deal with this +# unweildy list as one entire entity is not a sure thing, and may +# cause build errors. Thus, split one list into many smaller +# mini-lists, with the maximum size per mini-list of no more than 42. +pb_headers1 = \ + ${pb_srcdir}/assoc_container.hpp \ + ${pb_srcdir}/exception.hpp \ + ${pb_srcdir}/hash_policy.hpp \ + ${pb_srcdir}/list_update_policy.hpp \ + ${pb_srcdir}/priority_queue.hpp \ + ${pb_srcdir}/tag_and_trait.hpp \ + ${pb_srcdir}/tree_policy.hpp \ + ${pb_srcdir}/trie_policy.hpp \ + ${pb_srcdir}/detail/basic_tree_policy/basic_tree_policy_base.hpp \ + ${pb_srcdir}/detail/basic_tree_policy/null_node_metadata.hpp \ + ${pb_srcdir}/detail/basic_tree_policy/traits.hpp \ + ${pb_srcdir}/detail/basic_types.hpp \ + ${pb_srcdir}/detail/binary_heap_/binary_heap_.hpp \ + ${pb_srcdir}/detail/binary_heap_/const_iterator.hpp \ + ${pb_srcdir}/detail/binary_heap_/const_point_iterator.hpp \ + ${pb_srcdir}/detail/binary_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/entry_cmp.hpp \ + ${pb_srcdir}/detail/binary_heap_/entry_pred.hpp \ + ${pb_srcdir}/detail/binary_heap_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/resize_policy.hpp \ + ${pb_srcdir}/detail/binary_heap_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/binary_heap_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/binomial_heap_base_.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_base_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_/binomial_heap_.hpp \ + ${pb_srcdir}/detail/binomial_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/binomial_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/bin_search_tree_.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp + +pb_headers2 = \ + ${pb_srcdir}/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/node_iterators.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/point_iterators.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/r_erase_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/rotate_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/bin_search_tree_/traits.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/cc_ht_map_.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/cmp_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/entry_list_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/resize_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/size_fn_imps.hpp \ + ${pb_srcdir}/detail/cc_hash_table_map_/standard_policies.hpp + +pb_headers3 = \ + ${pb_srcdir}/detail/cc_hash_table_map_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/cond_dealtor.hpp \ + ${pb_srcdir}/detail/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/container_base_dispatch.hpp \ + ${pb_srcdir}/detail/eq_fn/eq_by_less.hpp \ + ${pb_srcdir}/detail/eq_fn/hash_eq_fn.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/gp_ht_map_.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/iterator_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/resize_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/standard_policies.hpp \ + ${pb_srcdir}/detail/gp_hash_table_map_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/hash_fn/direct_mask_range_hashing_imp.hpp \ + ${pb_srcdir}/detail/hash_fn/direct_mod_range_hashing_imp.hpp \ + ${pb_srcdir}/detail/hash_fn/linear_probe_fn_imp.hpp \ + ${pb_srcdir}/detail/hash_fn/mask_based_range_hashing.hpp \ + ${pb_srcdir}/detail/hash_fn/mod_based_range_hashing.hpp \ + ${pb_srcdir}/detail/hash_fn/probe_fn_base.hpp \ + ${pb_srcdir}/detail/hash_fn/quadratic_probe_fn_imp.hpp \ + ${pb_srcdir}/detail/hash_fn/ranged_hash_fn.hpp \ + ${pb_srcdir}/detail/hash_fn/ranged_probe_fn.hpp + +pb_headers4 = \ + ${pb_srcdir}/detail/hash_fn/sample_probe_fn.hpp \ + ${pb_srcdir}/detail/hash_fn/sample_ranged_hash_fn.hpp \ + ${pb_srcdir}/detail/hash_fn/sample_ranged_probe_fn.hpp \ + ${pb_srcdir}/detail/hash_fn/sample_range_hashing.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/const_iterator.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/const_point_iterator.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/node.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/null_metadata.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/constructor_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/entry_metadata_base.hpp \ + ${pb_srcdir}/detail/list_update_map_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_map_/lu_map_.hpp \ + ${pb_srcdir}/detail/list_update_map_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/list_update_policy/counter_lu_metadata.hpp \ + ${pb_srcdir}/detail/list_update_policy/counter_lu_policy_imp.hpp \ + ${pb_srcdir}/detail/list_update_policy/mtf_lu_policy_imp.hpp \ + ${pb_srcdir}/detail/list_update_policy/sample_update_policy.hpp \ + ${pb_srcdir}/detail/map_debug_base.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/cond_dtor.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/node_iterators.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/ov_tree_map_.hpp + +pb_headers5 = \ + ${pb_srcdir}/detail/ov_tree_map_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/ov_tree_map_/traits.hpp \ + ${pb_srcdir}/detail/pairing_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/pairing_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/pairing_heap_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/pairing_heap_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/pairing_heap_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/pairing_heap_/pairing_heap_.hpp \ + ${pb_srcdir}/detail/pairing_heap_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/child_iterator.hpp \ + ${pb_srcdir}/detail/pat_trie_/cond_dtor_entry_dealtor.hpp \ + ${pb_srcdir}/detail/pat_trie_/const_child_iterator.hpp \ + ${pb_srcdir}/detail/pat_trie_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/head.hpp \ + ${pb_srcdir}/detail/pat_trie_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/insert_join_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/internal_node.hpp \ + ${pb_srcdir}/detail/pat_trie_/iterators_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/leaf.hpp \ + ${pb_srcdir}/detail/pat_trie_/node_base.hpp \ + ${pb_srcdir}/detail/pat_trie_/node_iterators.hpp \ + ${pb_srcdir}/detail/pat_trie_/node_metadata_base.hpp \ + ${pb_srcdir}/detail/pat_trie_/pat_trie_.hpp \ + ${pb_srcdir}/detail/pat_trie_/point_iterators.hpp \ + ${pb_srcdir}/detail/pat_trie_/policy_access_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/r_erase_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/rotate_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/split_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/split_join_branch_bag.hpp \ + ${pb_srcdir}/detail/pat_trie_/synth_e_access_traits.hpp \ + ${pb_srcdir}/detail/pat_trie_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/pat_trie_/traits.hpp \ + ${pb_srcdir}/detail/pat_trie_/update_fn_imps.hpp \ + ${pb_srcdir}/detail/priority_queue_base_dispatch.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/debug_fn_imps.hpp + +pb_headers6 = \ + ${pb_srcdir}/detail/rb_tree_map_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/node.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/rb_tree_.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/rb_tree_map_/traits.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/rc_binomial_heap_.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/rc.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/rc_binomial_heap_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp \ + ${pb_srcdir}/detail/resize_policy/hash_exponential_size_policy_imp.hpp \ + ${pb_srcdir}/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp \ + ${pb_srcdir}/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp \ + ${pb_srcdir}/detail/resize_policy/hash_prime_size_policy_imp.hpp \ + ${pb_srcdir}/detail/resize_policy/hash_standard_resize_policy_imp.hpp \ + ${pb_srcdir}/detail/resize_policy/sample_resize_policy.hpp \ + ${pb_srcdir}/detail/resize_policy/sample_resize_trigger.hpp \ + ${pb_srcdir}/detail/resize_policy/sample_size_policy.hpp \ + ${pb_srcdir}/detail/splay_tree_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/erase_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/info_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/node.hpp \ + ${pb_srcdir}/detail/splay_tree_/splay_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/splay_tree_.hpp \ + ${pb_srcdir}/detail/splay_tree_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/splay_tree_/traits.hpp \ + ${pb_srcdir}/detail/standard_policies.hpp \ + ${pb_srcdir}/detail/thin_heap_/constructors_destructor_fn_imps.hpp \ + ${pb_srcdir}/detail/thin_heap_/debug_fn_imps.hpp \ + ${pb_srcdir}/detail/thin_heap_/erase_fn_imps.hpp + +pb_headers7 = \ + ${pb_srcdir}/detail/thin_heap_/find_fn_imps.hpp \ + ${pb_srcdir}/detail/thin_heap_/insert_fn_imps.hpp \ + ${pb_srcdir}/detail/thin_heap_/split_join_fn_imps.hpp \ + ${pb_srcdir}/detail/thin_heap_/thin_heap_.hpp \ + ${pb_srcdir}/detail/thin_heap_/trace_fn_imps.hpp \ + ${pb_srcdir}/detail/tree_policy/node_metadata_selector.hpp \ + ${pb_srcdir}/detail/tree_policy/null_node_update_imp.hpp \ + ${pb_srcdir}/detail/tree_policy/order_statistics_imp.hpp \ + ${pb_srcdir}/detail/tree_policy/sample_tree_node_update.hpp \ + ${pb_srcdir}/detail/tree_trace_base.hpp \ + ${pb_srcdir}/detail/trie_policy/node_metadata_selector.hpp \ + ${pb_srcdir}/detail/trie_policy/null_node_update_imp.hpp \ + ${pb_srcdir}/detail/trie_policy/order_statistics_imp.hpp \ + ${pb_srcdir}/detail/trie_policy/prefix_search_node_update_imp.hpp \ + ${pb_srcdir}/detail/trie_policy/sample_trie_e_access_traits.hpp \ + ${pb_srcdir}/detail/trie_policy/sample_trie_node_update.hpp \ + ${pb_srcdir}/detail/trie_policy/string_trie_e_access_traits_imp.hpp \ + ${pb_srcdir}/detail/trie_policy/trie_policy_base.hpp \ + ${pb_srcdir}/detail/types_traits.hpp \ + ${pb_srcdir}/detail/type_utils.hpp \ + ${pb_srcdir}/detail/unordered_iterator/const_iterator.hpp \ + ${pb_srcdir}/detail/unordered_iterator/const_point_iterator.hpp \ + ${pb_srcdir}/detail/unordered_iterator/iterator.hpp \ + ${pb_srcdir}/detail/unordered_iterator/point_iterator.hpp ext_srcdir = ${glibcxx_srcdir}/include/ext -ext_builddir = ./ext +ext_builddir = ./ext ext_headers = \ ${ext_srcdir}/algorithm \ + ${ext_srcdir}/atomicity.h \ + ${ext_srcdir}/array_allocator.h \ ${ext_srcdir}/bitmap_allocator.h \ + ${ext_srcdir}/codecvt_specializations.h \ + ${ext_srcdir}/concurrence.h \ ${ext_srcdir}/debug_allocator.h \ - ${ext_srcdir}/enc_filebuf.h \ ${ext_srcdir}/stdio_filebuf.h \ ${ext_srcdir}/stdio_sync_filebuf.h \ ${ext_srcdir}/functional \ ${ext_srcdir}/hash_map \ ${ext_srcdir}/hash_set \ + ${ext_srcdir}/hash_fun.h \ + ${ext_srcdir}/hashtable.h \ ${ext_srcdir}/iterator \ ${ext_srcdir}/malloc_allocator.h \ ${ext_srcdir}/memory \ ${ext_srcdir}/mt_allocator.h \ ${ext_srcdir}/new_allocator.h \ ${ext_srcdir}/numeric \ + ${ext_srcdir}/numeric_traits.h \ ${ext_srcdir}/pod_char_traits.h \ ${ext_srcdir}/pool_allocator.h \ ${ext_srcdir}/rb_tree \ ${ext_srcdir}/rope \ ${ext_srcdir}/ropeimpl.h \ ${ext_srcdir}/slist \ - ${ext_srcdir}/hash_fun.h \ - ${ext_srcdir}/hashtable.h + ${ext_srcdir}/throw_allocator.h \ + ${ext_srcdir}/typelist.h \ + ${ext_srcdir}/type_traits.h \ + ${ext_srcdir}/rc_string_base.h \ + ${ext_srcdir}/sso_string_base.h \ + ${ext_srcdir}/vstring.h \ + ${ext_srcdir}/vstring.tcc \ + ${ext_srcdir}/vstring_fwd.h \ + ${ext_srcdir}/vstring_util.h + +tr1_srcdir = ${glibcxx_srcdir}/include/tr1 +tr1_builddir = ./tr1 +tr1_headers = \ + ${tr1_srcdir}/array \ + ${tr1_srcdir}/bind_repeat.h \ + ${tr1_srcdir}/bind_iterate.h \ + ${tr1_srcdir}/boost_shared_ptr.h \ + ${tr1_srcdir}/cctype \ + ${tr1_srcdir}/cfenv \ + ${tr1_srcdir}/cfloat \ + ${tr1_srcdir}/cinttypes \ + ${tr1_srcdir}/climits \ + ${tr1_srcdir}/cmath \ + ${tr1_srcdir}/common.h \ + ${tr1_srcdir}/complex \ + ${tr1_srcdir}/cstdarg \ + ${tr1_srcdir}/cstdbool \ + ${tr1_srcdir}/cstdint \ + ${tr1_srcdir}/cstdio \ + ${tr1_srcdir}/cstdlib \ + ${tr1_srcdir}/ctgmath \ + ${tr1_srcdir}/ctime \ + ${tr1_srcdir}/ctype.h \ + ${tr1_srcdir}/cwchar \ + ${tr1_srcdir}/cwctype \ + ${tr1_srcdir}/fenv.h \ + ${tr1_srcdir}/float.h \ + ${tr1_srcdir}/functional \ + ${tr1_srcdir}/functional_hash.h \ + ${tr1_srcdir}/functional_iterate.h \ + ${tr1_srcdir}/hashtable \ + ${tr1_srcdir}/hashtable_policy.h \ + ${tr1_srcdir}/inttypes.h \ + ${tr1_srcdir}/limits.h \ + ${tr1_srcdir}/math.h \ + ${tr1_srcdir}/memory \ + ${tr1_srcdir}/mu_iterate.h \ + ${tr1_srcdir}/random \ + ${tr1_srcdir}/random.tcc \ + ${tr1_srcdir}/ref_fwd.h \ + ${tr1_srcdir}/ref_wrap_iterate.h \ + ${tr1_srcdir}/repeat.h \ + ${tr1_srcdir}/stdarg.h \ + ${tr1_srcdir}/stdbool.h \ + ${tr1_srcdir}/stdint.h \ + ${tr1_srcdir}/stdio.h \ + ${tr1_srcdir}/stdlib.h \ + ${tr1_srcdir}/tgmath.h \ + ${tr1_srcdir}/tuple \ + ${tr1_srcdir}/tuple_defs.h \ + ${tr1_srcdir}/tuple_iterate.h \ + ${tr1_srcdir}/type_traits \ + ${tr1_srcdir}/type_traits_fwd.h \ + ${tr1_srcdir}/unordered_set \ + ${tr1_srcdir}/unordered_map \ + ${tr1_srcdir}/utility \ + ${tr1_srcdir}/wchar.h \ + ${tr1_srcdir}/wctype.h # This is the common subset of files that all three "C" header models use. @@ -502,6 +910,7 @@ debug_headers = \ ${debug_srcdir}/debug.h \ ${debug_srcdir}/deque \ ${debug_srcdir}/formatter.h \ + ${debug_srcdir}/functions.h \ ${debug_srcdir}/hash_map \ ${debug_srcdir}/hash_map.h \ ${debug_srcdir}/hash_multimap.h \ @@ -510,6 +919,7 @@ debug_headers = \ ${debug_srcdir}/hash_set.h \ ${debug_srcdir}/list \ ${debug_srcdir}/map \ + ${debug_srcdir}/macros.h \ ${debug_srcdir}/map.h \ ${debug_srcdir}/multimap.h \ ${debug_srcdir}/multiset.h \ @@ -529,22 +939,25 @@ debug_headers = \ # For --enable-cheaders=c_std @GLIBCXX_C_HEADERS_C_STD_TRUE@c_base_headers_extra = ${c_base_srcdir}/cmath.tcc @GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra = - @GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = ${c_compatibility_headers} - host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR) host_builddir = ./${host_alias}/bits +host_installdir = ${gxx_include_dir}/${host_alias}$(MULTISUBDIR)/bits host_headers = \ ${host_srcdir}/ctype_base.h \ ${host_srcdir}/ctype_inline.h \ ${host_srcdir}/ctype_noninline.h \ ${host_srcdir}/os_defines.h \ - ${glibcxx_srcdir}/$(ATOMIC_WORD_SRCDIR)/atomic_word.h + ${glibcxx_srcdir}/$(ATOMIC_WORD_SRCDIR)/atomic_word.h \ + ${glibcxx_srcdir}/$(ABI_TWEAKS_SRCDIR)/cxxabi_tweaks.h \ + ${glibcxx_srcdir}/$(CPU_DEFINES_SRCDIR)/cpu_defines.h # Non-installed host_header files. +COMPATIBILITY_H = config/abi/compatibility.h host_headers_noinst = \ - ${glibcxx_srcdir}/$(CLOCALE_INTERNAL_H) + ${glibcxx_srcdir}/$(CLOCALE_INTERNAL_H) \ + ${glibcxx_srcdir}/$(COMPATIBILITY_H) # These host_headers_extra files are all built with ad hoc naming rules. @@ -555,31 +968,50 @@ host_headers_extra = \ ${host_builddir}/c++io.h \ ${host_builddir}/c++locale.h \ ${host_builddir}/messages_members.h \ - ${host_builddir}/time_members.h \ - ${host_builddir}/codecvt_specializations.h - + ${host_builddir}/time_members.h thread_host_headers = \ ${host_builddir}/gthr.h \ ${host_builddir}/gthr-single.h \ ${host_builddir}/gthr-posix.h \ + ${host_builddir}/gthr-tpf.h \ ${host_builddir}/gthr-default.h +pch1_source = ${glibcxx_srcdir}/include/precompiled/stdc++.h +pch1_output_builddir = ${host_builddir}/stdc++.h.gch +pch1_output_anchor = ${host_builddir}/stdc++.h +pch1_output_installdir = ${host_installdir}/stdc++.h.gch +pch1a_output = ${pch1_output_builddir}/O0g.gch +pch1b_output = ${pch1_output_builddir}/O2g.gch +pch1_output = ${pch1a_output} ${pch1b_output} +pch2_source = ${glibcxx_srcdir}/include/precompiled/stdtr1c++.h +pch2_output_builddir = ${host_builddir}/stdtr1c++.h.gch +pch2_output_anchor = ${host_builddir}/stdtr1c++.h +pch2_output_installdir = ${host_installdir}/stdtr1c++.h.gch +pch2_output = ${pch2_output_builddir}/O2g.gch +pch3_source = ${glibcxx_srcdir}/include/precompiled/extc++.h +pch3_output_builddir = ${host_builddir}/extc++.h.gch +pch3_output_anchor = ${host_builddir}/extc++.h +pch3_output_installdir = ${host_installdir}/extc++.h.gch +pch3_output = ${pch3_output_builddir}/O2g.gch +pch_output = ${pch1_output} ${pch2_output} ${pch3_output} +pch_output_dirs = \ + ${pch1_output_builddir} ${pch2_output_builddir} ${pch3_output_builddir} + +pch_output_anchors = \ + ${pch1_output_anchor} ${pch2_output_anchor} ${pch3_output_anchor} -pch_input = ${host_builddir}/stdc++.h -pch_output_builddir = ${host_builddir}/stdc++.h.gch -pch_source = ${glibcxx_srcdir}/include/stdc++.h PCHFLAGS = -Winvalid-pch -Wno-deprecated -x c++-header $(CXXFLAGS) -@GLIBCXX_BUILD_PCH_TRUE@pch_build = ${pch_input} @GLIBCXX_BUILD_PCH_FALSE@pch_build = -@GLIBCXX_BUILD_PCH_TRUE@pch_install = install-pch +@GLIBCXX_BUILD_PCH_TRUE@pch_build = ${pch_output} @GLIBCXX_BUILD_PCH_FALSE@pch_install = +@GLIBCXX_BUILD_PCH_TRUE@pch_install = install-pch # List of all timestamp files. By keeping only one copy of this list, both # CLEANFILES and all-local are kept up-to-date. allstamped = \ stamp-std stamp-bits stamp-c_base stamp-c_compatibility \ - stamp-backward stamp-ext stamp-debug stamp-host + stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-debug stamp-host # List of all files that are created by explicit building, editing, or @@ -594,24 +1026,38 @@ allcreated = \ uppercase = [ABCDEFGHIJKLMNOPQRSTUVWXYZ_] # By adding these files here, automake will remove them for 'make clean' -CLEANFILES = ${pch_input} ${pch_output_builddir}/* -subdir = include -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -depcomp = -am__depfiles_maybe = -DIST_SOURCES = -DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/fragment.am \ - Makefile.am +CLEANFILES = ${pch_output} ${pch_output_anchors} all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/fragment.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/fragment.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign --ignore-deps include/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign include/Makefile -Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) + $(AUTOMAKE) --foreign --ignore-deps include/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh mostlyclean-libtool: -rm -f *.lo @@ -628,13 +1074,9 @@ TAGS: ctags: CTAGS CTAGS: -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) - -top_distdir = .. -distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) - $(mkinstalldirs) $(distdir)/.. + $(mkdir_p) $(distdir)/.. @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ @@ -646,7 +1088,7 @@ distdir: $(DISTFILES) dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ - $(mkinstalldirs) "$(distdir)$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ @@ -664,7 +1106,6 @@ distdir: $(DISTFILES) check-am: all-am check: check-am all-am: Makefile all-local - installdirs: install: install-am install-exec: install-exec-am @@ -677,7 +1118,7 @@ install-am: all-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - INSTALL_STRIP_FLAG=-s \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: @@ -686,14 +1127,14 @@ clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: - -rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-generic clean-libtool mostlyclean-am +clean-am: clean-generic clean-libtool clean-local mostlyclean-am distclean: distclean-am -rm -f Makefile @@ -703,6 +1144,8 @@ dvi: dvi-am dvi-am: +html: html-am + info: info-am info-am: @@ -736,11 +1179,12 @@ ps-am: uninstall-am: uninstall-info-am .PHONY: all all-am all-local check check-am clean clean-generic \ - clean-libtool distclean distclean-generic distclean-libtool \ - distdir dvi dvi-am info info-am install install-am install-data \ - install-data-am install-data-local install-exec install-exec-am \ - install-info install-info-am install-man install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ + clean-libtool clean-local distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-data-local install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \ uninstall-info-am @@ -757,8 +1201,8 @@ stamp-std: ${std_headers} fi ;\ if [ ! -f stamp-std ]; then \ (cd ${std_builddir} && for h in $?; do \ - official_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ - $(LN_S) $$h ./$${official_name} || true ;\ + build_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ + $(LN_S) $$h ./$${build_name} || true ;\ done) ;\ fi ;\ $(STAMP) stamp-std @@ -778,8 +1222,8 @@ stamp-c_base: stamp-bits ${c_base_headers} ${c_base_headers_extra} fi ;\ if [ ! -f stamp-c_base ]; then \ (cd ${c_base_builddir} && for h in ${c_base_headers}; do \ - official_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ - $(LN_S) $$h ./$${official_name} || true ;\ + build_name=`echo $$h | sed -e 's,.*/std_,,' -e 's,\.h$$,,'` ;\ + $(LN_S) $$h ./$${build_name} || true ;\ done) ;\ if [ ! -z "${c_base_headers_extra}" ]; then \ (cd ${bits_builddir} && $(LN_S) ${c_base_headers_extra} . || true) ;\ @@ -816,6 +1260,66 @@ stamp-ext: ${ext_headers} fi ;\ $(STAMP) stamp-ext +# Have to deal with nested include directories, gah! Strip off source +# directory before making the link. +# XXX check ${pb_headers} +stamp-pb: + @if [ ! -d "${pb_builddir}" ]; then \ + mkdir -p ${pb_subdirs} ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers1}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers2}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers3}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers4}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers5}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers6}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + @if [ ! -f stamp-pb ]; then \ + cd ${pb_builddir} && for h in ${pb_headers7}; do \ + build_name=`echo $$h | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(LN_S) $$h $${build_name} || true ;\ + done ;\ + fi + $(STAMP) stamp-pb + +stamp-tr1: ${tr1_headers} + @if [ ! -d "${tr1_builddir}" ]; then \ + mkdir -p ${tr1_builddir} ;\ + fi ;\ + if [ ! -f stamp-tr1 ]; then \ + (cd ${tr1_builddir} && $(LN_S) $? . || true) ;\ + fi ;\ + $(STAMP) stamp-tr1 + stamp-debug: ${debug_headers} @if [ ! -d "${debug_builddir}" ]; then \ mkdir -p ${debug_builddir} ;\ @@ -842,26 +1346,53 @@ stamp-host: ${host_headers} ${host_headers_noinst} stamp-${host_alias} $(LN_S) ${glibcxx_srcdir}/$(CSTDIO_H) c++io.h || true ;\ $(LN_S) ${glibcxx_srcdir}/$(CLOCALE_H) c++locale.h || true ;\ $(LN_S) ${glibcxx_srcdir}/$(CLOCALE_INTERNAL_H) . || true ;\ + $(LN_S) ${glibcxx_srcdir}/$(COMPATIBILITY_H) . || true ;\ $(LN_S) ${glibcxx_srcdir}/$(CMESSAGES_H) messages_members.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/$(CTIME_H) time_members.h || true ;\ - $(LN_S) ${glibcxx_srcdir}/$(CCODECVT_H) codecvt_specializations.h || true);\ + $(LN_S) ${glibcxx_srcdir}/$(CTIME_H) time_members.h || true);\ fi ;\ $(STAMP) stamp-host # Host includes dynamic. -${host_builddir}/c++config.h: ${top_builddir}/config.h \ - ${glibcxx_srcdir}/include/bits/c++config \ - stamp-${host_alias} - @cat ${glibcxx_srcdir}/include/bits/c++config > $@ ;\ +@ENABLE_SYMVERS_GNU_NAMESPACE_TRUE@stamp-namespace-version: +@ENABLE_SYMVERS_GNU_NAMESPACE_TRUE@ echo 1 > stamp-namespace-version +@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@stamp-namespace-version: +@ENABLE_SYMVERS_GNU_NAMESPACE_FALSE@ echo 0 > stamp-namespace-version + +@ENABLE_VISIBILITY_TRUE@stamp-visibility: +@ENABLE_VISIBILITY_TRUE@ echo 1 > stamp-visibility +@ENABLE_VISIBILITY_FALSE@stamp-visibility: +@ENABLE_VISIBILITY_FALSE@ echo 0 > stamp-visibility + +${host_builddir}/c++config.h: ${CONFIG_HEADER} \ + ${glibcxx_srcdir}/include/bits/c++config \ + stamp-${host_alias} \ + ${toplevel_srcdir}/gcc/DATESTAMP \ + stamp-namespace-version \ + stamp-visibility + @date=`cat ${toplevel_srcdir}/gcc/DATESTAMP` ;\ + nsa_version=`cat stamp-namespace-version` ;\ + visibility=`cat stamp-visibility` ;\ + ldbl_compat='' ;\ + grep "^[ ]*#[ ]*define[ ][ ]*_GLIBCXX_LONG_DOUBLE_COMPAT[ ][ ]*1[ ]*$$" \ + ${CONFIG_HEADER} > /dev/null 2>&1 \ + && ldbl_compat='s,^#undef _GLIBCXX_LONG_DOUBLE_COMPAT$$,#define _GLIBCXX_LONG_DOUBLE_COMPAT 1,' ;\ + sed -e "s,define __GLIBCXX__,define __GLIBCXX__ $$date," \ + -e "s,define _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION, define _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION $$nsa_version," \ + -e "s,define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY, define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY $$visibility," \ + -e "$$ldbl_compat" \ + < ${glibcxx_srcdir}/include/bits/c++config > $@ ;\ sed -e 's/HAVE_/_GLIBCXX_HAVE_/g' \ -e 's/PACKAGE/_GLIBCXX_PACKAGE/g' \ -e 's/VERSION/_GLIBCXX_VERSION/g' \ -e 's/WORDS_/_GLIBCXX_WORDS_/g' \ + -e '/[ ]_GLIBCXX_LONG_DOUBLE_COMPAT[ ]/d' \ < ${CONFIG_HEADER} >> $@ ;\ - echo "#endif // _CXXCONFIG_" >>$@ + echo "" >> $@ ;\ + echo "#endif // _CXXCONFIG_" >> $@ ${host_builddir}/gthr.h: ${toplevel_srcdir}/gcc/gthr.h stamp-${host_alias} - sed -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \ + sed -e '/^#pragma/b' \ + -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \ -e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \ -e 's,^#include "\(.*\)",#include ,g' \ < ${toplevel_srcdir}/gcc/gthr.h > $@ @@ -880,6 +1411,14 @@ ${host_builddir}/gthr-posix.h: ${toplevel_srcdir}/gcc/gthr-posix.h \ -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ < ${toplevel_srcdir}/gcc/gthr-posix.h > $@ +${host_builddir}/gthr-tpf.h: ${toplevel_srcdir}/gcc/gthr-tpf.h \ + stamp-${host_alias} + sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ + -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ + -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \ + -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ + < ${toplevel_srcdir}/gcc/gthr-tpf.h > $@ + ${host_builddir}/gthr-default.h: ${toplevel_srcdir}/gcc/${glibcxx_thread_h} \ stamp-${host_alias} sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ @@ -889,14 +1428,36 @@ ${host_builddir}/gthr-default.h: ${toplevel_srcdir}/gcc/${glibcxx_thread_h} \ -e 's,^#include "\(.*\)",#include ,g' \ < ${toplevel_srcdir}/gcc/${glibcxx_thread_h} > $@ -# Build a precompiled C++ include, stdc++.h.gch. -${pch_input}: ${allstamped} ${host_builddir}/c++config.h ${pch_source} - touch ${pch_input}; \ - if [ ! -d "${pch_output_builddir}" ]; then \ - mkdir -p ${pch_output_builddir}; \ +# Build two precompiled C++ includes, stdc++.h.gch/*.gch +${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source} + if [ ! -d "${pch1_output_builddir}" ]; then \ + mkdir -p ${pch1_output_builddir}; \ + fi; \ + $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O0 -g ${pch1_source} -o $@ + touch ${pch1_output_anchor} + +${pch1b_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source} + if [ ! -d "${pch1_output_builddir}" ]; then \ + mkdir -p ${pch1_output_builddir}; \ + fi; \ + $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch1_source} -o $@ + touch ${pch1_output_anchor} + +# Build a precompiled TR1 include, stdtr1c++.h.gch/O2.gch +${pch2_output}: ${pch2_source} ${pch1_output} + if [ ! -d "${pch2_output_builddir}" ]; then \ + mkdir -p ${pch2_output_builddir}; \ + fi; \ + $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch2_source} -o $@ + touch ${pch2_output_anchor} + +# Build a precompiled extension include, extc++.h.gch/O2.gch +${pch3_output}: ${pch3_source} ${pch2_output} + if [ ! -d "${pch3_output_builddir}" ]; then \ + mkdir -p ${pch3_output_builddir}; \ fi; \ - $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) ${pch_source} -O0 -g -o ${pch_output_builddir}/O0g; \ - $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) ${pch_source} -O2 -g -o ${pch_output_builddir}/O2g; + $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g ${pch3_source} -o $@ + touch ${pch3_output_anchor} # For robustness sake (in light of junk files or in-source # configuration), copy from the build or source tree to the install @@ -917,9 +1478,9 @@ ${pch_input}: ${allstamped} ${host_builddir}/c++config.h ${pch_source} # are copied here. install-freestanding-headers: $(mkinstalldirs) $(DESTDIR)${gxx_include_dir} - $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${host_builddir} + $(mkinstalldirs) $(DESTDIR)${host_installdir} for file in ${host_srcdir}/os_defines.h ${host_builddir}/c++config.h; do \ - $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${host_builddir}; done + $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir} $(INSTALL_DATA) ${std_builddir}/limits $(DESTDIR)${gxx_include_dir}/${std_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir} @@ -938,6 +1499,40 @@ install-headers: $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${ext_builddir} for file in ${ext_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${ext_builddir}; done + $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${pb_builddir} + for dir in ${pb_subdirs}; do \ + $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/$${dir} ; done + for file in ${pb_headers1}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers2}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers3}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers4}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers5}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers6}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + for file in ${pb_headers7}; do \ + install_base=$(DESTDIR)${gxx_include_dir}/${pb_builddir} ; \ + relative_name=`echo $$file | sed -e "s|${pb_srcdir}|.|g"` ;\ + $(INSTALL_DATA) $${file} $${install_base}/$${relative_name} ; done + $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir} + for file in ${tr1_headers}; do \ + $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_builddir}; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir} for file in ${c_base_headers_rename}; do \ $(INSTALL_DATA) ${c_base_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done @@ -953,15 +1548,24 @@ install-headers: $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${debug_builddir} for file in ${debug_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${debug_builddir}; done - $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${host_builddir} + $(mkinstalldirs) $(DESTDIR)${host_installdir} for file in ${host_headers} ${host_headers_extra} \ ${thread_host_headers}; do \ - $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${host_builddir}; done + $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done install-pch: - $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${pch_output_builddir} - for file in ${pch_output_builddir}/*; do \ - $(INSTALL_DATA) $$file $(DESTDIR)${gxx_include_dir}/${pch_output_builddir}; done + $(mkinstalldirs) $(DESTDIR)${pch1_output_installdir} + for file in ${pch1_output_builddir}/*; do \ + $(INSTALL_DATA) $$file $(DESTDIR)${pch1_output_installdir}; done + $(mkinstalldirs) $(DESTDIR)${pch2_output_installdir} + for file in ${pch2_output_builddir}/*; do \ + $(INSTALL_DATA) $$file $(DESTDIR)${pch2_output_installdir}; done + $(INSTALL_DATA) ${pch1_output_anchor} $(DESTDIR)${host_installdir} + $(INSTALL_DATA) ${pch2_output_anchor} $(DESTDIR)${host_installdir} + +# To remove directories. +clean-local: + rm -rf ${pch_output_dirs} # Stop implicit '.o' make rules from ever stomping on extensionless # headers, in the improbable case where some foolish, crack-addled diff --git a/contrib/libstdc++/include/backward/algo.h b/contrib/libstdc++/include/backward/algo.h index 6f24835..2474601 100644 --- a/contrib/libstdc++/include/backward/algo.h +++ b/contrib/libstdc++/include/backward/algo.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -143,7 +143,3 @@ using __gnu_cxx::power; using __gnu_cxx::iota; #endif /* _BACKWARD_ALGO_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/algobase.h b/contrib/libstdc++/include/backward/algobase.h index 86028a0..289e988 100644 --- a/contrib/libstdc++/include/backward/algobase.h +++ b/contrib/libstdc++/include/backward/algobase.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -89,7 +89,3 @@ using __gnu_cxx::lexicographical_compare_3way; using __gnu_cxx::uninitialized_copy_n; #endif /* _BACKWARD_ALGOBASE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/alloc.h b/contrib/libstdc++/include/backward/alloc.h index d3c3c73..40a0af1 100644 --- a/contrib/libstdc++/include/backward/alloc.h +++ b/contrib/libstdc++/include/backward/alloc.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/backward/backward_warning.h b/contrib/libstdc++/include/backward/backward_warning.h index 9e13777..80eabfe 100644 --- a/contrib/libstdc++/include/backward/backward_warning.h +++ b/contrib/libstdc++/include/backward/backward_warning.h @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/backward/bvector.h b/contrib/libstdc++/include/backward/bvector.h index 9245792..9a2c44d 100644 --- a/contrib/libstdc++/include/backward/bvector.h +++ b/contrib/libstdc++/include/backward/bvector.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -62,7 +62,3 @@ typedef std::vector > bit_vector; #endif /* _BACKWARD_BVECTOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/complex.h b/contrib/libstdc++/include/backward/complex.h index dfc6714..7972cf7 100644 --- a/contrib/libstdc++/include/backward/complex.h +++ b/contrib/libstdc++/include/backward/complex.h @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -37,7 +37,3 @@ typedef complex double_complex; typedef complex long_double_complex; #endif - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/defalloc.h b/contrib/libstdc++/include/backward/defalloc.h index 76ea52a..ffa9b16 100644 --- a/contrib/libstdc++/include/backward/defalloc.h +++ b/contrib/libstdc++/include/backward/defalloc.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/backward/deque.h b/contrib/libstdc++/include/backward/deque.h index 36c7479..a4a6b41 100644 --- a/contrib/libstdc++/include/backward/deque.h +++ b/contrib/libstdc++/include/backward/deque.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -64,7 +64,3 @@ using std::deque; #endif /* _BACKWARD_DEQUE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/fstream.h b/contrib/libstdc++/include/backward/fstream.h index 6dfd514..92835f9 100644 --- a/contrib/libstdc++/include/backward/fstream.h +++ b/contrib/libstdc++/include/backward/fstream.h @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -46,7 +46,3 @@ using std::wstreampos; #endif #endif - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/function.h b/contrib/libstdc++/include/backward/function.h index 9fc8719..b5be371 100644 --- a/contrib/libstdc++/include/backward/function.h +++ b/contrib/libstdc++/include/backward/function.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -124,7 +124,3 @@ using __gnu_cxx::mem_fun1; using __gnu_cxx::mem_fun1_ref; #endif /* _BACKWARD_FUNCTION_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/hash_map.h b/contrib/libstdc++/include/backward/hash_map.h index bc9c148..aa14522 100644 --- a/contrib/libstdc++/include/backward/hash_map.h +++ b/contrib/libstdc++/include/backward/hash_map.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -66,7 +66,3 @@ using __gnu_cxx::hash_map; using __gnu_cxx::hash_multimap; #endif /* _BACKWARD_HASH_MAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/hash_set.h b/contrib/libstdc++/include/backward/hash_set.h index 89307de..c2c6e39 100644 --- a/contrib/libstdc++/include/backward/hash_set.h +++ b/contrib/libstdc++/include/backward/hash_set.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/backward/hashtable.h b/contrib/libstdc++/include/backward/hashtable.h index abedd55..7b7511b 100644 --- a/contrib/libstdc++/include/backward/hashtable.h +++ b/contrib/libstdc++/include/backward/hashtable.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -70,7 +70,3 @@ using __gnu_cxx::hash; using __gnu_cxx::hashtable; #endif /* _BACKWARD_HASHTABLE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/heap.h b/contrib/libstdc++/include/backward/heap.h index 2f19545..ef2e684 100644 --- a/contrib/libstdc++/include/backward/heap.h +++ b/contrib/libstdc++/include/backward/heap.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -65,7 +65,3 @@ using std::make_heap; using std::sort_heap; #endif /* _BACKWARD_HEAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/iomanip.h b/contrib/libstdc++/include/backward/iomanip.h index 160dbeb..a4099a7 100644 --- a/contrib/libstdc++/include/backward/iomanip.h +++ b/contrib/libstdc++/include/backward/iomanip.h @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -64,7 +64,3 @@ using std::setprecision; using std::setw; #endif - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/iostream.h b/contrib/libstdc++/include/backward/iostream.h index 5a5ccea..ed275ff 100644 --- a/contrib/libstdc++/include/backward/iostream.h +++ b/contrib/libstdc++/include/backward/iostream.h @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -54,7 +54,3 @@ using std::ends; using std::flush; #endif - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/istream.h b/contrib/libstdc++/include/backward/istream.h index 707b575..b1c55d1 100644 --- a/contrib/libstdc++/include/backward/istream.h +++ b/contrib/libstdc++/include/backward/istream.h @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -32,12 +32,3 @@ #include "iostream.h" #endif - -// Local Variables: -// mode:C++ -// End: - - - - - diff --git a/contrib/libstdc++/include/backward/iterator.h b/contrib/libstdc++/include/backward/iterator.h index 8316a83..89496fb 100644 --- a/contrib/libstdc++/include/backward/iterator.h +++ b/contrib/libstdc++/include/backward/iterator.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -185,7 +185,3 @@ template using std::raw_storage_iterator; #endif /* _BACKWARD_ITERATOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/list.h b/contrib/libstdc++/include/backward/list.h index 00c11a6..d70a6e4 100644 --- a/contrib/libstdc++/include/backward/list.h +++ b/contrib/libstdc++/include/backward/list.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -64,7 +64,3 @@ using std::list; #endif /* _BACKWARD_LIST_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/map.h b/contrib/libstdc++/include/backward/map.h index 56d5c69..2ff3cec 100644 --- a/contrib/libstdc++/include/backward/map.h +++ b/contrib/libstdc++/include/backward/map.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -63,7 +63,3 @@ using std::map; #endif /* _BACKWARD_MAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/multimap.h b/contrib/libstdc++/include/backward/multimap.h index aba42f7..515d299 100644 --- a/contrib/libstdc++/include/backward/multimap.h +++ b/contrib/libstdc++/include/backward/multimap.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -63,7 +63,3 @@ using std::multimap; #endif /* _BACKWARD_MULTIMAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/multiset.h b/contrib/libstdc++/include/backward/multiset.h index 7ec0c94..1f857ae 100644 --- a/contrib/libstdc++/include/backward/multiset.h +++ b/contrib/libstdc++/include/backward/multiset.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -63,7 +63,3 @@ using std::multiset; #endif /* _BACKWARD_MULTISET_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/new.h b/contrib/libstdc++/include/backward/new.h index 00a4819..9cfbab2 100644 --- a/contrib/libstdc++/include/backward/new.h +++ b/contrib/libstdc++/include/backward/new.h @@ -15,8 +15,8 @@ // // You should have received a copy of the GNU General Public License // along with GCC; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02110-1301, USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate diff --git a/contrib/libstdc++/include/backward/ostream.h b/contrib/libstdc++/include/backward/ostream.h index a72de09..07ef9b0 100644 --- a/contrib/libstdc++/include/backward/ostream.h +++ b/contrib/libstdc++/include/backward/ostream.h @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -32,7 +32,3 @@ #include "iostream.h" #endif - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/pair.h b/contrib/libstdc++/include/backward/pair.h index cbb3bc7..4985bcb 100644 --- a/contrib/libstdc++/include/backward/pair.h +++ b/contrib/libstdc++/include/backward/pair.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -64,7 +64,3 @@ using std::pair; using std::make_pair; #endif /* _BACKWARD_PAIR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/queue.h b/contrib/libstdc++/include/backward/queue.h index a3e2ff3..da7505c 100644 --- a/contrib/libstdc++/include/backward/queue.h +++ b/contrib/libstdc++/include/backward/queue.h @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -35,7 +35,3 @@ using std::queue; using std::priority_queue; #endif - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/rope.h b/contrib/libstdc++/include/backward/rope.h index fc6715a..71e8815 100644 --- a/contrib/libstdc++/include/backward/rope.h +++ b/contrib/libstdc++/include/backward/rope.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -54,7 +54,3 @@ using __gnu_cxx::crope; using __gnu_cxx::wrope; #endif /* _BACKWARD_ROPE_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/set.h b/contrib/libstdc++/include/backward/set.h index 6a8320b..3c6a390 100644 --- a/contrib/libstdc++/include/backward/set.h +++ b/contrib/libstdc++/include/backward/set.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -63,7 +63,3 @@ using std::set; #endif /* _BACKWARD_SET_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/slist.h b/contrib/libstdc++/include/backward/slist.h index 63db065..9b9a43d 100644 --- a/contrib/libstdc++/include/backward/slist.h +++ b/contrib/libstdc++/include/backward/slist.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -50,7 +50,3 @@ using __gnu_cxx::slist; #endif /* _BACKWARD_SLIST_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/stack.h b/contrib/libstdc++/include/backward/stack.h index 0ff53a4..07df417 100644 --- a/contrib/libstdc++/include/backward/stack.h +++ b/contrib/libstdc++/include/backward/stack.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -66,7 +66,3 @@ using std::stack; #endif /* _BACKWARD_STACK_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/stream.h b/contrib/libstdc++/include/backward/stream.h index 5540c7e..c137601 100644 --- a/contrib/libstdc++/include/backward/stream.h +++ b/contrib/libstdc++/include/backward/stream.h @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -32,7 +32,3 @@ #include "iostream.h" #endif - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/streambuf.h b/contrib/libstdc++/include/backward/streambuf.h index fc9825e..bac2449 100644 --- a/contrib/libstdc++/include/backward/streambuf.h +++ b/contrib/libstdc++/include/backward/streambuf.h @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -34,7 +34,3 @@ using std::streambuf; #endif - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/strstream b/contrib/libstdc++/include/backward/strstream index a5b95c5..d0d5a13 100644 --- a/contrib/libstdc++/include/backward/strstream +++ b/contrib/libstdc++/include/backward/strstream @@ -1,6 +1,6 @@ // Backward-compat support -*- C++ -*- -// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -55,8 +55,8 @@ #include #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // Class strstreambuf, a streambuf class that manages an array of char. // Note that this class is not a template. class strstreambuf : public basic_streambuf > @@ -175,5 +175,7 @@ namespace std private: strstreambuf _M_buf; }; -} // namespace std + +_GLIBCXX_END_NAMESPACE + #endif diff --git a/contrib/libstdc++/include/backward/tempbuf.h b/contrib/libstdc++/include/backward/tempbuf.h index 06de2bd..af6e57d 100644 --- a/contrib/libstdc++/include/backward/tempbuf.h +++ b/contrib/libstdc++/include/backward/tempbuf.h @@ -1,6 +1,6 @@ // Backward-compat support -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -62,7 +62,7 @@ #include #include #include -#include +#include #include #include #include @@ -72,7 +72,3 @@ using std::return_temporary_buffer; using __gnu_cxx::temporary_buffer; #endif /* _BACKWARD_TEMPBUF_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/tree.h b/contrib/libstdc++/include/backward/tree.h index fcfcbf4..88a2f1d 100644 --- a/contrib/libstdc++/include/backward/tree.h +++ b/contrib/libstdc++/include/backward/tree.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -50,6 +50,3 @@ using __gnu_cxx::rb_tree; #endif -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/backward/vector.h b/contrib/libstdc++/include/backward/vector.h index ba9b704..8cd8dd0 100644 --- a/contrib/libstdc++/include/backward/vector.h +++ b/contrib/libstdc++/include/backward/vector.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -64,7 +64,3 @@ using std::vector; #endif /* _BACKWARD_VECTOR_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/bits/allocator.h b/contrib/libstdc++/include/bits/allocator.h index c9200ec..43939c1 100644 --- a/contrib/libstdc++/include/bits/allocator.h +++ b/contrib/libstdc++/include/bits/allocator.h @@ -1,6 +1,7 @@ // Allocators -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -51,11 +52,14 @@ // Define the base class to std::allocator. #include -namespace std -{ +#include // for __is_empty + +_GLIBCXX_BEGIN_NAMESPACE(std) + template class allocator; + /// allocator specialization. template<> class allocator { @@ -72,12 +76,13 @@ namespace std }; /** - * @brief The "standard" allocator, as per [20.4]. + * @brief The "standard" allocator, as per [20.4]. * - * (See @link Allocators allocators info @endlink for more.) + * Further details: + * http://gcc.gnu.org/onlinedocs/libstdc++/20_util/allocator.html */ template - class allocator: public ___glibcxx_base_allocator<_Tp> + class allocator: public __glibcxx_base_allocator<_Tp> { public: typedef size_t size_type; @@ -94,8 +99,8 @@ namespace std allocator() throw() { } - allocator(const allocator& a) throw() - : ___glibcxx_base_allocator<_Tp>(a) { } + allocator(const allocator& __a) throw() + : __glibcxx_base_allocator<_Tp>(__a) { } template allocator(const allocator<_Tp1>&) throw() { } @@ -124,7 +129,25 @@ namespace std #endif // Undefine. -#undef ___glibcxx_base_allocator -} // namespace std +#undef __glibcxx_base_allocator + + // To implement Option 3 of DR 431. + template::__value> + struct __alloc_swap + { static void _S_do_it(_Alloc&, _Alloc&) { } }; + + template + struct __alloc_swap<_Alloc, false> + { + static void + _S_do_it(_Alloc& __one, _Alloc& __two) + { + // Precondition: swappable allocators. + if (__one != __two) + swap(__one, __two); + } + }; + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/basic_ios.h b/contrib/libstdc++/include/bits/basic_ios.h index 7ffe40e..d078431 100644 --- a/contrib/libstdc++/include/bits/basic_ios.h +++ b/contrib/libstdc++/include/bits/basic_ios.h @@ -1,6 +1,6 @@ // Iostreams base classes -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -43,8 +43,8 @@ #include #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // 27.4.5 Template class basic_ios /** * @brief Virtual base class for all stream classes. @@ -458,7 +458,8 @@ namespace std void _M_cache_locale(const locale& __loc); }; -} // namespace std + +_GLIBCXX_END_NAMESPACE #ifndef _GLIBCXX_EXPORT_TEMPLATE #include diff --git a/contrib/libstdc++/include/bits/basic_ios.tcc b/contrib/libstdc++/include/bits/basic_ios.tcc index fcb4b02..e8434a5 100644 --- a/contrib/libstdc++/include/bits/basic_ios.tcc +++ b/contrib/libstdc++/include/bits/basic_ios.tcc @@ -1,6 +1,7 @@ // basic_ios member functions -*- C++ -*- -// Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,13 +28,18 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file basic_ios.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + #ifndef _BASIC_IOS_TCC #define _BASIC_IOS_TCC 1 #pragma GCC system_header -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template void basic_ios<_CharT, _Traits>::clear(iostate __state) @@ -87,11 +93,6 @@ namespace std _M_callbacks = __cb; for (int __i = 0; __i < __rhs._M_word_size; ++__i) __words[__i] = __rhs._M_word[__i]; - if (_M_word != _M_local_word) - { - delete [] _M_word; - _M_word = 0; - } _M_word = __words; _M_word_size = __rhs._M_word_size; @@ -195,6 +196,7 @@ namespace std extern template class basic_ios; #endif #endif -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/basic_string.h b/contrib/libstdc++/include/bits/basic_string.h index 04e1500..e4b7a5b 100644 --- a/contrib/libstdc++/include/bits/basic_string.h +++ b/contrib/libstdc++/include/bits/basic_string.h @@ -1,6 +1,7 @@ // Components for manipulating sequences of characters -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +17,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,25 +29,25 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 21 Strings library -// - /** @file basic_string.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// +// ISO C++ 14882: 21 Strings library +// + #ifndef _BASIC_STRING_H #define _BASIC_STRING_H 1 #pragma GCC system_header -#include +#include #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @class basic_string basic_string.h * @brief Managing sequences of characters and character-like objects. @@ -109,17 +110,19 @@ namespace std template class basic_string { + typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type; + // Types: public: typedef _Traits traits_type; typedef typename _Traits::char_type value_type; typedef _Alloc allocator_type; - typedef typename _Alloc::size_type size_type; - typedef typename _Alloc::difference_type difference_type; - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; - typedef typename _Alloc::pointer pointer; - typedef typename _Alloc::const_pointer const_pointer; + typedef typename _CharT_alloc_type::size_type size_type; + typedef typename _CharT_alloc_type::difference_type difference_type; + typedef typename _CharT_alloc_type::reference reference; + typedef typename _CharT_alloc_type::const_reference const_reference; + typedef typename _CharT_alloc_type::pointer pointer; + typedef typename _CharT_alloc_type::const_pointer const_pointer; typedef __gnu_cxx::__normal_iterator iterator; typedef __gnu_cxx::__normal_iterator const_iterator; @@ -175,7 +178,13 @@ namespace std static _Rep& _S_empty_rep() - { return *reinterpret_cast<_Rep*>(&_S_empty_rep_storage); } + { + // NB: Mild hack to avoid strict-aliasing warnings. Note that + // _S_empty_rep_storage is never modified and the punning should + // be reasonably safe in this case. + void* __p = reinterpret_cast(&_S_empty_rep_storage); + return *reinterpret_cast<_Rep*>(__p); + } bool _M_is_leaked() const @@ -193,6 +202,16 @@ namespace std _M_set_sharable() { this->_M_refcount = 0; } + void + _M_set_length_and_sharable(size_type __n) + { + this->_M_set_sharable(); // One reference. + this->_M_length = __n; + traits_type::assign(this->_M_refdata()[__n], _S_terminal); + // grrr. (per 21.3.4) + // You cannot leave those LWG people alone for a second. + } + _CharT* _M_refdata() throw() { return reinterpret_cast<_CharT*>(this + 1); } @@ -214,7 +233,8 @@ namespace std #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING if (__builtin_expect(this != &_S_empty_rep(), false)) #endif - if (__gnu_cxx::__exchange_and_add(&this->_M_refcount, -1) <= 0) + if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, + -1) <= 0) _M_destroy(__a); } // XXX MT @@ -227,7 +247,7 @@ namespace std #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING if (__builtin_expect(this != &_S_empty_rep(), false)) #endif - __gnu_cxx::__atomic_add(&this->_M_refcount, 1); + __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1); return _M_refdata(); } // XXX MT @@ -248,8 +268,7 @@ namespace std // Data Members (public): // NB: This is an unsigned type, and thus represents the maximum // size that the allocator can hold. - /// @var - /// Value returned by various member functions when they fail. + /// Value returned by various member functions when they fail. static const size_type npos = static_cast(-1); private: @@ -271,10 +290,12 @@ namespace std // For the internal use we have functions similar to `begin'/`end' // but they do not call _M_leak. iterator - _M_ibegin() const { return iterator(_M_data()); } + _M_ibegin() const + { return iterator(_M_data()); } iterator - _M_iend() const { return iterator(_M_data() + this->size()); } + _M_iend() const + { return iterator(_M_data() + this->size()); } void _M_leak() // for use in begin() & non-const op[] @@ -291,6 +312,13 @@ namespace std return __pos; } + void + _M_check_length(size_type __n1, size_type __n2, const char* __s) const + { + if (this->max_size() - (this->size() - __n1) < __n2) + __throw_length_error(__N(__s)); + } + // NB: _M_limit doesn't check for a bad __pos value. size_type _M_limit(size_type __pos, size_type __off) const @@ -299,6 +327,43 @@ namespace std return __testoff ? __off : this->size() - __pos; } + // True if _Rep and source do not overlap. + bool + _M_disjunct(const _CharT* __s) const + { + return (less()(__s, _M_data()) + || less()(_M_data() + this->size(), __s)); + } + + // When __n = 1 way faster than the general multichar + // traits_type::copy/move/assign. + static void + _M_copy(_CharT* __d, const _CharT* __s, size_type __n) + { + if (__n == 1) + traits_type::assign(*__d, *__s); + else + traits_type::copy(__d, __s, __n); + } + + static void + _M_move(_CharT* __d, const _CharT* __s, size_type __n) + { + if (__n == 1) + traits_type::assign(*__d, *__s); + else + traits_type::move(__d, __s, __n); + } + + static void + _M_assign(_CharT* __d, size_type __n, _CharT __c) + { + if (__n == 1) + traits_type::assign(*__d, __c); + else + traits_type::assign(__d, __n, __c); + } + // _S_copy_chars is a separate template to permit specialization // to optimize for the common case of pointers as iterators. template @@ -319,11 +384,11 @@ namespace std static void _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) - { traits_type::copy(__p, __k1, __k2 - __k1); } + { _M_copy(__p, __k1, __k2 - __k1); } static void _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2) - { traits_type::copy(__p, __k1, __k2 - __k1); } + { _M_copy(__p, __k1, __k2 - __k1); } void _M_mutate(size_type __pos, size_type __len1, size_type __len2); @@ -347,7 +412,7 @@ namespace std basic_string(); /** - * @brief Construct an empty string using allocator a. + * @brief Construct an empty string using allocator @a a. */ explicit basic_string(const _Alloc& __a); @@ -382,7 +447,7 @@ namespace std * @param n Number of characters to copy. * @param a Allocator to use (default is default allocator). * - * NB: s must have at least n characters, '\0' has no special + * NB: @a s must have at least @a n characters, '\0' has no special * meaning. */ basic_string(const _CharT* __s, size_type __n, @@ -423,10 +488,7 @@ namespace std */ basic_string& operator=(const basic_string& __str) - { - this->assign(__str); - return *this; - } + { return this->assign(__str); } /** * @brief Copy contents of @a s into this string. @@ -434,10 +496,7 @@ namespace std */ basic_string& operator=(const _CharT* __s) - { - this->assign(__s); - return *this; - } + { return this->assign(__s); } /** * @brief Set value to string of length 1. @@ -533,16 +592,19 @@ namespace std /// Returns the number of characters in the string, not including any /// null-termination. size_type - size() const { return _M_rep()->_M_length; } + size() const + { return _M_rep()->_M_length; } /// Returns the number of characters in the string, not including any /// null-termination. size_type - length() const { return _M_rep()->_M_length; } + length() const + { return _M_rep()->_M_length; } /// Returns the size() of the largest possible %string. size_type - max_size() const { return _Rep::_S_max_size; } + max_size() const + { return _Rep::_S_max_size; } /** * @brief Resizes the %string to the specified number of characters. @@ -568,20 +630,22 @@ namespace std * setting them to 0. */ void - resize(size_type __n) { this->resize(__n, _CharT()); } + resize(size_type __n) + { this->resize(__n, _CharT()); } /** * Returns the total number of characters that the %string can hold * before needing to allocate more memory. */ size_type - capacity() const { return _M_rep()->_M_capacity; } + capacity() const + { return _M_rep()->_M_capacity; } /** * @brief Attempt to preallocate enough memory for specified number of * characters. - * @param n Number of characters required. - * @throw std::length_error If @a n exceeds @c max_size(). + * @param res_arg Number of characters required. + * @throw std::length_error If @a res_arg exceeds @c max_size(). * * This function attempts to reserve enough memory for the * %string to hold the specified number of characters. If the @@ -601,18 +665,20 @@ namespace std * Erases the string, making it empty. */ void - clear() { _M_mutate(0, this->size(), 0); } + clear() + { _M_mutate(0, this->size(), 0); } /** * Returns true if the %string is empty. Equivalent to *this == "". */ bool - empty() const { return this->size() == 0; } + empty() const + { return this->size() == 0; } // Element access: /** * @brief Subscript access to the data contained in the %string. - * @param n The index of the character to access. + * @param pos The index of the character to access. * @return Read-only (constant) reference to the character. * * This operator allows for easy, array-style, data access. @@ -629,7 +695,7 @@ namespace std /** * @brief Subscript access to the data contained in the %string. - * @param n The index of the character to access. + * @param pos The index of the character to access. * @return Read/write reference to the character. * * This operator allows for easy, array-style, data access. @@ -640,7 +706,10 @@ namespace std reference operator[](size_type __pos) { - _GLIBCXX_DEBUG_ASSERT(__pos < size()); + // allow pos == size() as v3 extension: + _GLIBCXX_DEBUG_ASSERT(__pos <= size()); + // but be strict in pedantic mode: + _GLIBCXX_DEBUG_PEDASSERT(__pos < size()); _M_leak(); return _M_data()[__pos]; } @@ -690,7 +759,8 @@ namespace std * @return Reference to this string. */ basic_string& - operator+=(const basic_string& __str) { return this->append(__str); } + operator+=(const basic_string& __str) + { return this->append(__str); } /** * @brief Append a C string. @@ -698,15 +768,20 @@ namespace std * @return Reference to this string. */ basic_string& - operator+=(const _CharT* __s) { return this->append(__s); } + operator+=(const _CharT* __s) + { return this->append(__s); } /** * @brief Append a character. - * @param s The character to append. + * @param c The character to append. * @return Reference to this string. */ basic_string& - operator+=(_CharT __c) { return this->append(size_type(1), __c); } + operator+=(_CharT __c) + { + this->push_back(__c); + return *this; + } /** * @brief Append a string to this string. @@ -761,8 +836,7 @@ namespace std * Appends n copies of c to this string. */ basic_string& - append(size_type __n, _CharT __c) - { return _M_replace_aux(this->size(), size_type(0), __n, __c); } + append(size_type __n, _CharT __c); /** * @brief Append a range of characters. @@ -783,7 +857,13 @@ namespace std */ void push_back(_CharT __c) - { _M_replace_aux(this->size(), size_type(0), size_type(1), __c); } + { + const size_type __len = 1 + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + traits_type::assign(_M_data()[this->size()], __c); + _M_rep()->_M_set_length_and_sharable(__len); + } /** * @brief Set value to contents of another string. @@ -894,7 +974,8 @@ namespace std * of the string doesn't change if an error is thrown. */ template - void insert(iterator __p, _InputIterator __beg, _InputIterator __end) + void + insert(iterator __p, _InputIterator __beg, _InputIterator __end) { this->replace(__p, __p, __beg, __end); } /** @@ -1018,7 +1099,7 @@ namespace std const size_type __pos = __p - _M_ibegin(); _M_replace_aux(__pos, size_type(0), size_type(1), __c); _M_rep()->_M_set_leaked(); - return this->_M_ibegin() + __pos; + return iterator(_M_data() + __pos); } /** @@ -1037,8 +1118,11 @@ namespace std */ basic_string& erase(size_type __pos = 0, size_type __n = npos) - { return _M_replace_safe(_M_check(__pos, "basic_string::erase"), - _M_limit(__pos, __n), NULL, size_type(0)); } + { + _M_mutate(_M_check(__pos, "basic_string::erase"), + _M_limit(__pos, __n), size_type(0)); + return *this; + } /** * @brief Remove one character. @@ -1054,9 +1138,9 @@ namespace std _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin() && __position < _M_iend()); const size_type __pos = __position - _M_ibegin(); - _M_replace_safe(__pos, size_type(1), NULL, size_type(0)); + _M_mutate(__pos, size_type(1), size_type(0)); _M_rep()->_M_set_leaked(); - return _M_ibegin() + __pos; + return iterator(_M_data() + __pos); } /** @@ -1074,9 +1158,9 @@ namespace std _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last && __last <= _M_iend()); const size_type __pos = __first - _M_ibegin(); - _M_replace_safe(__pos, __last - __first, NULL, size_type(0)); + _M_mutate(__pos, __last - __first, size_type(0)); _M_rep()->_M_set_leaked(); - return _M_ibegin() + __pos; + return iterator(_M_data() + __pos); } /** @@ -1128,15 +1212,15 @@ namespace std * @brief Replace characters with value of a C substring. * @param pos Index of first character to replace. * @param n1 Number of characters to be replaced. - * @param str C string to insert. - * @param n2 Number of characters from str to use. + * @param s C string to insert. + * @param n2 Number of characters from @a s to use. * @return Reference to this string. * @throw std::out_of_range If @a pos1 > size(). * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [pos,pos + n1) from this string. - * In place, the first @a n2 characters of @a str are inserted, or all - * of @a str if @a n2 is too large. If @a pos is beyond end of string, + * In place, the first @a n2 characters of @a s are inserted, or all + * of @a s if @a n2 is too large. If @a pos is beyond end of string, * out_of_range is thrown. If the length of result exceeds max_size(), * length_error is thrown. The value of the string doesn't change if * an error is thrown. @@ -1149,13 +1233,13 @@ namespace std * @brief Replace characters with value of a C string. * @param pos Index of first character to replace. * @param n1 Number of characters to be replaced. - * @param str C string to insert. + * @param s C string to insert. * @return Reference to this string. * @throw std::out_of_range If @a pos > size(). * @throw std::length_error If new length exceeds @c max_size(). * * Removes the characters in the range [pos,pos + n1) from this string. - * In place, the first @a n characters of @a str are inserted. If @a + * In place, the first @a n characters of @a s are inserted. If @a * pos is beyond end of string, out_of_range is thrown. If the length * of result exceeds max_size(), length_error is thrown. The value of * the string doesn't change if an error is thrown. @@ -1291,54 +1375,54 @@ namespace std _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); __glibcxx_requires_valid_range(__k1, __k2); - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; + typedef typename std::__is_integer<_InputIterator>::__type _Integral; return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral()); } // Specializations for the common case of pointer and iterator: // useful to avoid the overhead of temporary buffering in _M_replace. basic_string& - replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2) - { - _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 - && __i2 <= _M_iend()); - __glibcxx_requires_valid_range(__k1, __k2); - return this->replace(__i1 - _M_ibegin(), __i2 - __i1, - __k1, __k2 - __k1); - } + replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, + __k1, __k2 - __k1); + } basic_string& - replace(iterator __i1, iterator __i2, - const _CharT* __k1, const _CharT* __k2) - { - _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 - && __i2 <= _M_iend()); - __glibcxx_requires_valid_range(__k1, __k2); - return this->replace(__i1 - _M_ibegin(), __i2 - __i1, - __k1, __k2 - __k1); - } + replace(iterator __i1, iterator __i2, + const _CharT* __k1, const _CharT* __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, + __k1, __k2 - __k1); + } basic_string& - replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2) - { - _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 - && __i2 <= _M_iend()); - __glibcxx_requires_valid_range(__k1, __k2); - return this->replace(__i1 - _M_ibegin(), __i2 - __i1, - __k1.base(), __k2 - __k1); - } + replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, + __k1.base(), __k2 - __k1); + } basic_string& - replace(iterator __i1, iterator __i2, - const_iterator __k1, const_iterator __k2) - { - _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 - && __i2 <= _M_iend()); - __glibcxx_requires_valid_range(__k1, __k2); - return this->replace(__i1 - _M_ibegin(), __i2 - __i1, - __k1.base(), __k2 - __k1); - } - + replace(iterator __i1, iterator __i2, + const_iterator __k1, const_iterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, + __k1.base(), __k2 - __k1); + } + private: template basic_string& @@ -1353,29 +1437,11 @@ namespace std basic_string& _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, - _CharT __c) - { - if (this->max_size() - (this->size() - __n1) < __n2) - __throw_length_error(__N("basic_string::_M_replace_aux")); - _M_mutate(__pos1, __n1, __n2); - if (__n2 == 1) - _M_data()[__pos1] = __c; - else if (__n2) - traits_type::assign(_M_data() + __pos1, __n2, __c); - return *this; - } + _CharT __c); basic_string& _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s, - size_type __n2) - { - _M_mutate(__pos1, __n1, __n2); - if (__n2 == 1) - _M_data()[__pos1] = *__s; - else if (__n2) - traits_type::copy(_M_data() + __pos1, __s, __n2); - return *this; - } + size_type __n2); // _S_construct_aux is used to implement the 21.3.1 para 15 which // requires special behaviour if _InIter is an integral type @@ -1399,7 +1465,7 @@ namespace std static _CharT* _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a) { - typedef typename _Is_integer<_InIterator>::_Integral _Integral; + typedef typename std::__is_integer<_InIterator>::__type _Integral; return _S_construct_aux(__beg, __end, __a, _Integral()); } @@ -1453,7 +1519,8 @@ namespace std * happen. */ const _CharT* - c_str() const { return _M_data(); } + c_str() const + { return _M_data(); } /** * @brief Return const pointer to contents. @@ -1462,13 +1529,15 @@ namespace std * happen. */ const _CharT* - data() const { return _M_data(); } + data() const + { return _M_data(); } /** * @brief Return copy of allocator used to construct this string. */ allocator_type - get_allocator() const { return _M_dataplus; } + get_allocator() const + { return _M_dataplus; } /** * @brief Find position of a C substring. @@ -1559,7 +1628,7 @@ namespace std /** * @brief Find last position of a C string. * @param s C string to locate. - * @param pos Index of character to start search at (default 0). + * @param pos Index of character to start search at (default end). * @return Index of start of last occurrence. * * Starting from @a pos, searches backward for the value of @a s within @@ -1576,7 +1645,7 @@ namespace std /** * @brief Find last position of a character. * @param c Character to locate. - * @param pos Index of character to search back from (default 0). + * @param pos Index of character to search back from (default end). * @return Index of last occurrence. * * Starting from @a pos, searches backward for @a c within this string. @@ -2244,7 +2313,7 @@ namespace std inline bool operator<=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) - { return __rhs.compare(__lhs) >= 0; } + { return __rhs.compare(__lhs) >= 0; } // operator >= /** @@ -2312,6 +2381,10 @@ namespace std operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Alloc>& __str); + template<> + basic_istream& + operator>>(basic_istream& __is, basic_string& __str); + /** * @brief Write string to a stream. * @param os Output stream. @@ -2322,9 +2395,14 @@ namespace std * writing a C string. */ template - basic_ostream<_CharT, _Traits>& + inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, - const basic_string<_CharT, _Traits, _Alloc>& __str); + const basic_string<_CharT, _Traits, _Alloc>& __str) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 586. string inserter not a formatted function + return __ostream_insert(__os, __str.data(), __str.size()); + } /** * @brief Read a line from stream into a string. @@ -2340,7 +2418,7 @@ namespace std * delim was encountered, it is extracted but not stored into @a str. */ template - basic_istream<_CharT,_Traits>& + basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim); @@ -2357,9 +2435,23 @@ namespace std * encountered, it is extracted but not stored into @a str. */ template - inline basic_istream<_CharT,_Traits>& + inline basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, - basic_string<_CharT, _Traits, _Alloc>& __str); -} // namespace std + basic_string<_CharT, _Traits, _Alloc>& __str) + { return getline(__is, __str, __is.widen('\n')); } + + template<> + basic_istream& + getline(basic_istream& __in, basic_string& __str, + char __delim); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + basic_istream& + getline(basic_istream& __in, basic_string& __str, + wchar_t __delim); +#endif + +_GLIBCXX_END_NAMESPACE #endif /* _BASIC_STRING_H */ diff --git a/contrib/libstdc++/include/bits/basic_string.tcc b/contrib/libstdc++/include/bits/basic_string.tcc index fc90111..c2798ef 100644 --- a/contrib/libstdc++/include/bits/basic_string.tcc +++ b/contrib/libstdc++/include/bits/basic_string.tcc @@ -1,6 +1,7 @@ // Components for manipulating sequences of characters -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +17,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,13 +29,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file basic_string.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + // // ISO C++ 14882: 21 Strings library // -// This file is included by . It is not meant to be included -// separately. - // Written by Jason Merrill based upon the specification by Takanori Adachi // in ANSI X3J16/94-0013R2. Rewritten by Nathan Myers to ISO-14882. @@ -43,8 +46,8 @@ #pragma GCC system_header -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template inline bool __is_null_pointer(_Type* __ptr) @@ -101,7 +104,7 @@ namespace std ++__beg; } _Rep* __r = _Rep::_S_create(__len, size_type(0), __a); - traits_type::copy(__r->_M_refdata(), __buf, __len); + _M_copy(__r->_M_refdata(), __buf, __len); try { while (__beg != __end) @@ -110,8 +113,7 @@ namespace std { // Allocate more space. _Rep* __another = _Rep::_S_create(__len + 1, __len, __a); - traits_type::copy(__another->_M_refdata(), - __r->_M_refdata(), __len); + _M_copy(__another->_M_refdata(), __r->_M_refdata(), __len); __r->_M_destroy(__a); __r = __another; } @@ -124,8 +126,7 @@ namespace std __r->_M_destroy(__a); __throw_exception_again; } - __r->_M_length = __len; - __r->_M_refdata()[__len] = _Rep::_S_terminal; // grrr. + __r->_M_set_length_and_sharable(__len); return __r->_M_refdata(); } @@ -155,8 +156,7 @@ namespace std __r->_M_destroy(__a); __throw_exception_again; } - __r->_M_length = __dnew; - __r->_M_refdata()[__dnew] = _Rep::_S_terminal; // grrr. + __r->_M_set_length_and_sharable(__dnew); return __r->_M_refdata(); } @@ -172,10 +172,9 @@ namespace std // Check for out_of_range and length_error exceptions. _Rep* __r = _Rep::_S_create(__n, size_type(0), __a); if (__n) - traits_type::assign(__r->_M_refdata(), __n, __c); + _M_assign(__r->_M_refdata(), __n, __c); - __r->_M_length = __n; - __r->_M_refdata()[__n] = _Rep::_S_terminal; // grrr + __r->_M_set_length_and_sharable(__n); return __r->_M_refdata(); } @@ -259,32 +258,107 @@ namespace std return *this; } - template - basic_string<_CharT, _Traits, _Alloc>& - basic_string<_CharT, _Traits, _Alloc>:: - assign(const _CharT* __s, size_type __n) - { - __glibcxx_requires_string_len(__s, __n); - if (__n > this->max_size()) - __throw_length_error(__N("basic_string::assign")); - if (_M_rep()->_M_is_shared() || less()(__s, _M_data()) - || less()(_M_data() + this->size(), __s)) - return _M_replace_safe(size_type(0), this->size(), __s, __n); - else - { - // Work in-place - const size_type __pos = __s - _M_data(); - if (__pos >= __n) - traits_type::copy(_M_data(), __s, __n); - else if (__pos) - traits_type::move(_M_data(), __s, __n); - _M_rep()->_M_set_sharable(); - _M_rep()->_M_length = __n; - _M_data()[__n] = _Rep::_S_terminal; // grr. - return *this; - } + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + assign(const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + _M_check_length(this->size(), __n, "basic_string::assign"); + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) + return _M_replace_safe(size_type(0), this->size(), __s, __n); + else + { + // Work in-place. + const size_type __pos = __s - _M_data(); + if (__pos >= __n) + _M_copy(_M_data(), __s, __n); + else if (__pos) + _M_move(_M_data(), __s, __n); + _M_rep()->_M_set_length_and_sharable(__n); + return *this; + } } + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(size_type __n, _CharT __c) + { + if (__n) + { + _M_check_length(size_type(0), __n, "basic_string::append"); + const size_type __len = __n + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + _M_assign(_M_data() + this->size(), __n, __c); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + if (__n) + { + _M_check_length(size_type(0), __n, "basic_string::append"); + const size_type __len = __n + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + { + if (_M_disjunct(__s)) + this->reserve(__len); + else + { + const size_type __off = __s - _M_data(); + this->reserve(__len); + __s = _M_data() + __off; + } + } + _M_copy(_M_data() + this->size(), __s, __n); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(const basic_string& __str) + { + const size_type __size = __str.size(); + if (__size) + { + const size_type __len = __size + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + _M_copy(_M_data() + this->size(), __str._M_data(), __size); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(const basic_string& __str, size_type __pos, size_type __n) + { + __str._M_check(__pos, "basic_string::append"); + __n = __str._M_limit(__pos, __n); + if (__n) + { + const size_type __len = __n + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + _M_copy(_M_data() + this->size(), __str._M_data() + __pos, __n); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + template basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>:: @@ -292,29 +366,25 @@ namespace std { __glibcxx_requires_string_len(__s, __n); _M_check(__pos, "basic_string::insert"); - if (this->max_size() - this->size() < __n) - __throw_length_error(__N("basic_string::insert")); - if (_M_rep()->_M_is_shared() || less()(__s, _M_data()) - || less()(_M_data() + this->size(), __s)) + _M_check_length(size_type(0), __n, "basic_string::insert"); + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) return _M_replace_safe(__pos, size_type(0), __s, __n); else { - // Work in-place. If _M_mutate reallocates the string, __s - // does not point anymore to valid data, therefore we save its - // offset, then we restore it. + // Work in-place. const size_type __off = __s - _M_data(); _M_mutate(__pos, 0, __n); __s = _M_data() + __off; _CharT* __p = _M_data() + __pos; if (__s + __n <= __p) - traits_type::copy(__p, __s, __n); + _M_copy(__p, __s, __n); else if (__s >= __p) - traits_type::copy(__p, __s + __n, __n); + _M_copy(__p, __s + __n, __n); else { const size_type __nleft = __p - __s; - traits_type::copy(__p, __s, __nleft); - traits_type::copy(__p + __nleft, __p + __n, __n - __nleft); + _M_copy(__p, __s, __nleft); + _M_copy(__p + __nleft, __p + __n, __n - __nleft); } return *this; } @@ -329,24 +399,18 @@ namespace std __glibcxx_requires_string_len(__s, __n2); _M_check(__pos, "basic_string::replace"); __n1 = _M_limit(__pos, __n1); - if (this->max_size() - (this->size() - __n1) < __n2) - __throw_length_error(__N("basic_string::replace")); + _M_check_length(__n1, __n2, "basic_string::replace"); bool __left; - if (_M_rep()->_M_is_shared() || less()(__s, _M_data()) - || less()(_M_data() + this->size(), __s)) + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) return _M_replace_safe(__pos, __n1, __s, __n2); else if ((__left = __s + __n2 <= _M_data() + __pos) || _M_data() + __pos + __n1 <= __s) { // Work in-place: non-overlapping case. - const size_type __off = __s - _M_data(); + size_type __off = __s - _M_data(); + __left ? __off : (__off += __n2 - __n1); _M_mutate(__pos, __n1, __n2); - if (__left) - traits_type::copy(_M_data() + __pos, - _M_data() + __off, __n2); - else - traits_type::copy(_M_data() + __pos, - _M_data() + __off + __n2 - __n1, __n2); + _M_copy(_M_data() + __pos, _M_data() + __off, __n2); return *this; } else @@ -362,10 +426,6 @@ namespace std basic_string<_CharT, _Traits, _Alloc>::_Rep:: _M_destroy(const _Alloc& __a) throw () { -#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING - if (this == &_S_empty_rep()) - return; -#endif const size_type __size = sizeof(_Rep_base) + (this->_M_capacity + 1) * sizeof(_CharT); _Raw_bytes_alloc(__a).deallocate(reinterpret_cast(this), __size); @@ -373,7 +433,8 @@ namespace std template void - basic_string<_CharT, _Traits, _Alloc>::_M_leak_hard() + basic_string<_CharT, _Traits, _Alloc>:: + _M_leak_hard() { #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING if (_M_rep() == &_S_empty_rep()) @@ -393,41 +454,37 @@ namespace std const size_type __new_size = __old_size + __len2 - __len1; const size_type __how_much = __old_size - __pos - __len1; - if (__new_size > capacity() || _M_rep()->_M_is_shared()) + if (__new_size > this->capacity() || _M_rep()->_M_is_shared()) { // Must reallocate. const allocator_type __a = get_allocator(); - _Rep* __r = _Rep::_S_create(__new_size, capacity(), __a); + _Rep* __r = _Rep::_S_create(__new_size, this->capacity(), __a); if (__pos) - traits_type::copy(__r->_M_refdata(), _M_data(), __pos); + _M_copy(__r->_M_refdata(), _M_data(), __pos); if (__how_much) - traits_type::copy(__r->_M_refdata() + __pos + __len2, - _M_data() + __pos + __len1, __how_much); + _M_copy(__r->_M_refdata() + __pos + __len2, + _M_data() + __pos + __len1, __how_much); _M_rep()->_M_dispose(__a); _M_data(__r->_M_refdata()); } else if (__how_much && __len1 != __len2) { - // Work in-place - traits_type::move(_M_data() + __pos + __len2, - _M_data() + __pos + __len1, __how_much); + // Work in-place. + _M_move(_M_data() + __pos + __len2, + _M_data() + __pos + __len1, __how_much); } - _M_rep()->_M_set_sharable(); - _M_rep()->_M_length = __new_size; - _M_data()[__new_size] = _Rep::_S_terminal; // grrr. (per 21.3.4) - // You cannot leave those LWG people alone for a second. + _M_rep()->_M_set_length_and_sharable(__new_size); } template void - basic_string<_CharT, _Traits, _Alloc>::reserve(size_type __res) + basic_string<_CharT, _Traits, _Alloc>:: + reserve(size_type __res) { if (__res != this->capacity() || _M_rep()->_M_is_shared()) { - if (__res > this->max_size()) - __throw_length_error(__N("basic_string::reserve")); // Make sure we don't shrink below the current size if (__res < this->size()) __res = this->size(); @@ -439,7 +496,9 @@ namespace std } template - void basic_string<_CharT, _Traits, _Alloc>::swap(basic_string& __s) + void + basic_string<_CharT, _Traits, _Alloc>:: + swap(basic_string& __s) { if (_M_rep()->_M_is_leaked()) _M_rep()->_M_set_sharable(); @@ -469,7 +528,6 @@ namespace std _S_create(size_type __capacity, size_type __old_capacity, const _Alloc& __alloc) { - typedef basic_string<_CharT, _Traits, _Alloc> __string_type; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 83. String::npos vs. string::max_size() if (__capacity > _S_max_size) @@ -498,9 +556,8 @@ namespace std // low-balling it (especially when this algorithm is used with // malloc implementations that allocate memory blocks rounded up // to a size which is a power of 2). - const size_type __pagesize = 4096; // must be 2^i * __subpagesize - const size_type __subpagesize = 128; // should be >> __malloc_header_size - const size_type __malloc_header_size = 4 * sizeof (void*); + const size_type __pagesize = 4096; + const size_type __malloc_header_size = 4 * sizeof(void*); // The below implements an exponential growth policy, necessary to // meet amortized linear time requirements of the library: see @@ -508,14 +565,7 @@ namespace std // It's active for allocations requiring an amount of memory above // system pagesize. This is consistent with the requirements of the // standard: http://gcc.gnu.org/ml/libstdc++/2001-07/msg00130.html - - // The biggest string which fits in a memory page - const size_type __page_capacity = ((__pagesize - __malloc_header_size - - sizeof(_Rep) - sizeof(_CharT)) - / sizeof(_CharT)); - - if (__capacity > __old_capacity && __capacity < 2 * __old_capacity - && __capacity > __page_capacity) + if (__capacity > __old_capacity && __capacity < 2 * __old_capacity) __capacity = 2 * __old_capacity; // NB: Need an array of char_type[__capacity], plus a terminating @@ -524,7 +574,7 @@ namespace std size_type __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep); const size_type __adj_size = __size + __malloc_header_size; - if (__adj_size > __pagesize) + if (__adj_size > __pagesize && __capacity > __old_capacity) { const size_type __extra = __pagesize - __adj_size % __pagesize; __capacity += __extra / sizeof(_CharT); @@ -533,20 +583,20 @@ namespace std __capacity = _S_max_size; __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep); } - else if (__size > __subpagesize) - { - const size_type __extra = __subpagesize - __adj_size % __subpagesize; - __capacity += __extra / sizeof(_CharT); - __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep); - } // NB: Might throw, but no worries about a leak, mate: _Rep() // does not throw. void* __place = _Raw_bytes_alloc(__alloc).allocate(__size); _Rep *__p = new (__place) _Rep; __p->_M_capacity = __capacity; - __p->_M_set_sharable(); // One reference. - __p->_M_length = 0; + // ABI compatibility - 3.4.x set in _S_create both + // _M_refcount and _M_length. All callers of _S_create + // in basic_string.tcc then set just _M_length. + // In 4.0.x and later both _M_refcount and _M_length + // are initialized in the callers, unfortunately we can + // have 3.4.x compiled code with _S_create callers inlined + // calling 4.0.x+ _S_create. + __p->_M_set_sharable(); return __p; } @@ -560,21 +610,19 @@ namespace std _Rep* __r = _Rep::_S_create(__requested_cap, this->_M_capacity, __alloc); if (this->_M_length) - traits_type::copy(__r->_M_refdata(), _M_refdata(), - this->_M_length); + _M_copy(__r->_M_refdata(), _M_refdata(), this->_M_length); - __r->_M_length = this->_M_length; - __r->_M_refdata()[this->_M_length] = _Rep::_S_terminal; + __r->_M_set_length_and_sharable(this->_M_length); return __r->_M_refdata(); } template void - basic_string<_CharT, _Traits, _Alloc>::resize(size_type __n, _CharT __c) + basic_string<_CharT, _Traits, _Alloc>:: + resize(size_type __n, _CharT __c) { - if (__n > max_size()) - __throw_length_error(__N("basic_string::resize")); const size_type __size = this->size(); + _M_check_length(__size, __n, "basic_string::resize"); if (__size < __n) this->append(__n - __size, __c); else if (__n < __size) @@ -591,8 +639,7 @@ namespace std { const basic_string __s(__k1, __k2); const size_type __n1 = __i2 - __i1; - if (this->max_size() - (this->size() - __n1) < __s.size()) - __throw_length_error(__N("basic_string::_M_replace_dispatch")); + _M_check_length(__n1, __s.size(), "basic_string::_M_replace_dispatch"); return _M_replace_safe(__i1 - _M_ibegin(), __n1, __s._M_data(), __s.size()); } @@ -600,48 +647,28 @@ namespace std template basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>:: - append(const basic_string& __str) + _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, + _CharT __c) { - // Iff appending itself, string needs to pre-reserve the - // correct size so that _M_mutate does not clobber the - // pointer __str._M_data() formed here. - const size_type __size = __str.size(); - const size_type __len = __size + this->size(); - if (__len > this->capacity()) - this->reserve(__len); - return _M_replace_safe(this->size(), size_type(0), __str._M_data(), - __str.size()); + _M_check_length(__n1, __n2, "basic_string::_M_replace_aux"); + _M_mutate(__pos1, __n1, __n2); + if (__n2) + _M_assign(_M_data() + __pos1, __n2, __c); + return *this; } template basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>:: - append(const basic_string& __str, size_type __pos, size_type __n) + _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s, + size_type __n2) { - // Iff appending itself, string needs to pre-reserve the - // correct size so that _M_mutate does not clobber the - // pointer __str._M_data() formed here. - __str._M_check(__pos, "basic_string::append"); - __n = __str._M_limit(__pos, __n); - const size_type __len = __n + this->size(); - if (__len > this->capacity()) - this->reserve(__len); - return _M_replace_safe(this->size(), size_type(0), __str._M_data() - + __pos, __n); - } - - template - basic_string<_CharT, _Traits, _Alloc>& - basic_string<_CharT, _Traits, _Alloc>:: - append(const _CharT* __s, size_type __n) - { - __glibcxx_requires_string_len(__s, __n); - const size_type __len = __n + this->size(); - if (__len > this->capacity()) - this->reserve(__len); - return _M_replace_safe(this->size(), size_type(0), __s, __n); + _M_mutate(__pos1, __n1, __n2); + if (__n2) + _M_copy(_M_data() + __pos1, __s, __n2); + return *this; } - + template basic_string<_CharT, _Traits, _Alloc> operator+(const _CharT* __lhs, @@ -681,7 +708,7 @@ namespace std __n = _M_limit(__pos, __n); __glibcxx_requires_string_len(__s, __n); if (__n) - traits_type::copy(__s, _M_data() + __pos, __n); + _M_copy(__s, _M_data() + __pos, __n); // 21.3.5.7 par 3: do not append null. (good.) return __n; } @@ -694,9 +721,18 @@ namespace std __glibcxx_requires_string_len(__s, __n); const size_type __size = this->size(); const _CharT* __data = _M_data(); - for (; __pos + __n <= __size; ++__pos) - if (traits_type::compare(__data + __pos, __s, __n) == 0) - return __pos; + + if (__n == 0) + return __pos <= __size ? __pos : npos; + + if (__n <= __size) + { + for (; __pos <= __size - __n; ++__pos) + if (traits_type::eq(__data[__pos], __s[0]) + && traits_type::compare(__data + __pos + 1, + __s + 1, __n - 1) == 0) + return __pos; + } return npos; } @@ -705,8 +741,8 @@ namespace std basic_string<_CharT, _Traits, _Alloc>:: find(_CharT __c, size_type __pos) const { - const size_type __size = this->size(); size_type __ret = npos; + const size_type __size = this->size(); if (__pos < __size) { const _CharT* __data = _M_data(); @@ -970,6 +1006,7 @@ namespace std getline(basic_istream&, wstring&); #endif #endif -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/boost_concept_check.h b/contrib/libstdc++/include/bits/boost_concept_check.h index ff154f7..3d8fe75 100644 --- a/contrib/libstdc++/include/bits/boost_concept_check.h +++ b/contrib/libstdc++/include/bits/boost_concept_check.h @@ -1,4 +1,6 @@ -// Copyright (C) 2004 Free Software Foundation, Inc. +// -*- C++ -*- + +// Copyright (C) 2004, 2005 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 @@ -13,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -32,13 +34,13 @@ // to its suitability for any purpose. // -// GCC Note: based on version 1.12.0 of the Boost library. - /** @file boost_concept_check.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// GCC Note: based on version 1.12.0 of the Boost library. + #ifndef _BOOST_CONCEPT_CHECK_H #define _BOOST_CONCEPT_CHECK_H 1 @@ -48,8 +50,7 @@ #include // for traits and tags #include // for pair<> -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) #define _IsUnused __attribute__ ((__unused__)) @@ -923,7 +924,7 @@ struct _Aux_require_same<_Tp,_Tp> { typedef _Tp _Type; }; // HashedAssociativeContainer -} // namespace __gnu_cxx +_GLIBCXX_END_NAMESPACE #undef _IsUnused diff --git a/contrib/libstdc++/include/bits/c++config b/contrib/libstdc++/include/bits/c++config index 15e4b28..cf20c1b 100644 --- a/contrib/libstdc++/include/bits/c++config +++ b/contrib/libstdc++/include/bits/c++config @@ -1,6 +1,7 @@ // Predefined symbols and macros -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +17,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,14 +29,137 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file c++config.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + #ifndef _CXXCONFIG #define _CXXCONFIG 1 // Pick up any OS-specific definitions. #include +// Pick up any CPU-specific definitions. +#include + // The current version of the C++ library in compressed ISO date format. -#define __GLIBCXX__ 20060311 +#define __GLIBCXX__ + +// Macros for visibility. +#define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY + +#if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY +#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) +#else +#define _GLIBCXX_VISIBILITY(V) +#endif + +// Macros for controlling various namespace association schemes and modes. +#ifdef _GLIBCXX_DEBUG +# define _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG 1 +#endif + +#define _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION + +// Macros for namespace scope. +// _GLIBCXX_BEGIN_NAMESPACE +// _GLIBCXX_END_NAMESPACE +// _GLIBCXX_BEGIN_NESTED_NAMESPACE +// _GLIBCXX_END_NESTED_NAMESPACE +#if _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION +# define _GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y) namespace X { namespace Y _GLIBCXX_VISIBILITY(default) { +# define _GLIBCXX_END_NESTED_NAMESPACE } } +# define _GLIBCXX_BEGIN_NAMESPACE(X) _GLIBCXX_BEGIN_NESTED_NAMESPACE(X, _6) +# define _GLIBCXX_END_NAMESPACE _GLIBCXX_END_NESTED_NAMESPACE +#else +# define _GLIBCXX_BEGIN_NAMESPACE(X) namespace X _GLIBCXX_VISIBILITY(default) { +# define _GLIBCXX_END_NAMESPACE } +# if _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG +# define _GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y) namespace X { namespace Y _GLIBCXX_VISIBILITY(default) { +# define _GLIBCXX_END_NESTED_NAMESPACE } } +# else +# define _GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y) _GLIBCXX_BEGIN_NAMESPACE(X) +# define _GLIBCXX_END_NESTED_NAMESPACE _GLIBCXX_END_NAMESPACE +# endif +#endif + +// Namespace associations for versioning mode. +#if _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION +namespace std +{ + namespace _6 { } + using namespace _6 __attribute__ ((strong)); +} + +// In addition, other supported namespace configurations. +namespace __gnu_cxx +{ + namespace _6 { } + using namespace _6 __attribute__ ((strong)); +} + +namespace std +{ + namespace tr1 + { + namespace _6 { } + using namespace _6 __attribute__ ((strong)); + } +} +#endif + +// Namespace associations for debug mode. +#if _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG +namespace std +{ + namespace __norm { } + namespace __debug { } + using namespace __debug __attribute__ ((strong)); +} + +namespace __gnu_cxx +{ + namespace __norm { } + namespace __debug { } + using namespace __debug __attribute__ ((strong)); +} + +# define _GLIBCXX_STD __norm +# define _GLIBCXX_EXT __norm +# define _GLIBCXX_EXTERN_TEMPLATE 0 +# if __NO_INLINE__ && !__GXX_WEAK__ +# warning debug mode without inlining may fail due to lack of weak symbols +# endif +#else +#if _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION +# define _GLIBCXX_STD _6 +# define _GLIBCXX_EXT _6 +#else +# define _GLIBCXX_STD std +# define _GLIBCXX_EXT __gnu_cxx +#endif +#endif + +/* Define if compatibility should be provided for -mlong-double-64. */ +#undef _GLIBCXX_LONG_DOUBLE_COMPAT + +// XXX GLIBCXX_ABI Deprecated +// Namespace associations for long double 128 mode. +_GLIBCXX_BEGIN_NAMESPACE(std) +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ +# define _GLIBCXX_LDBL_NAMESPACE __gnu_cxx_ldbl128:: +# define _GLIBCXX_BEGIN_LDBL_NAMESPACE namespace __gnu_cxx_ldbl128 { +# define _GLIBCXX_END_LDBL_NAMESPACE } + namespace __gnu_cxx_ldbl128 { } + using namespace __gnu_cxx_ldbl128 __attribute__((__strong__)); +#else +# define _GLIBCXX_LDBL_NAMESPACE +# define _GLIBCXX_BEGIN_LDBL_NAMESPACE +# define _GLIBCXX_END_LDBL_NAMESPACE +#endif +_GLIBCXX_END_NAMESPACE + // Allow use of "export template." This is currently not a feature // that g++ supports. @@ -51,31 +175,14 @@ # define _GLIBCXX_EXTERN_TEMPLATE 1 #endif -// Debug mode support. Debug mode basic_string is not allowed to be -// associated with std, because of locale and exception link -// dependence. -namespace __gnu_debug_def { } -namespace __gnu_debug -{ - using namespace __gnu_debug_def; -} - -#ifdef _GLIBCXX_DEBUG -# define _GLIBCXX_STD __gnu_norm -namespace __gnu_norm -{ - using namespace std; -} -namespace std -{ - using namespace __gnu_debug_def __attribute__ ((strong)); -} -#else -# define _GLIBCXX_STD std +// Certain function definitions that are meant to be overridable from +// user code are decorated with this macro. For some targets, this +// macro causes these definitions to be weak. +#ifndef _GLIBCXX_WEAK_DEFINITION +# define _GLIBCXX_WEAK_DEFINITION #endif - // The remainder of the prewritten config is automatic; all the // user hooks are listed above. @@ -92,4 +199,8 @@ namespace std // for something else under certain OSes (see BADNAMES). #define __N(msgid) (msgid) +// For example, is known to #define min and max as macros... +#undef min +#undef max + // End of prewritten config; the discovered settings follow. diff --git a/contrib/libstdc++/include/bits/char_traits.h b/contrib/libstdc++/include/bits/char_traits.h index 323fdfb..58cddf6 100644 --- a/contrib/libstdc++/include/bits/char_traits.h +++ b/contrib/libstdc++/include/bits/char_traits.h @@ -1,6 +1,6 @@ // Character Traits for use by standard string and iostream -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,15 +28,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 21 Strings library -// - /** @file char_traits.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// +// ISO C++ 14882: 21 Strings library +// + #ifndef _CHAR_TRAITS_H #define _CHAR_TRAITS_H 1 @@ -46,12 +46,11 @@ #include // For copy, lexicographical_compare, fill_n #include // For streampos -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + /** * @brief Mapping from character type to associated types. * - * * @note This is an implementation class for the generic version * of char_traits. It defines int_type, off_type, pos_type, and * state_type. By default these are unsigned long, streamoff, @@ -82,7 +81,8 @@ namespace __gnu_cxx * * See http://gcc.gnu.org/onlinedocs/libstdc++/21_strings/howto.html#5 * for advice on how to make use of this class for "unusual" character - * types. Also, check out include/ext/pod_char_traits.h. */ + * types. Also, check out include/ext/pod_char_traits.h. + */ template struct char_traits { @@ -148,7 +148,7 @@ namespace __gnu_cxx char_traits<_CharT>:: compare(const char_type* __s1, const char_type* __s2, std::size_t __n) { - for (size_t __i = 0; __i < __n; ++__i) + for (std::size_t __i = 0; __i < __n; ++__i) if (lt(__s1[__i], __s2[__i])) return -1; else if (lt(__s2[__i], __s1[__i])) @@ -204,10 +204,11 @@ namespace __gnu_cxx std::fill_n(__s, __n, __a); return __s; } -} -namespace std -{ +_GLIBCXX_END_NAMESPACE + +_GLIBCXX_BEGIN_NAMESPACE(std) + // 21.1 /** * @brief Basis for explicit traits specializations. @@ -222,12 +223,11 @@ namespace std * types. Also, check out include/ext/pod_char_traits.h. */ template - struct char_traits - : public __gnu_cxx::char_traits<_CharT> + struct char_traits : public __gnu_cxx::char_traits<_CharT> { }; - /// 21.1.3.1 char_traits specializations + /// @brief 21.1.3.1 char_traits specializations template<> struct char_traits { @@ -297,7 +297,7 @@ namespace std #ifdef _GLIBCXX_USE_WCHAR_T - /// 21.1.3.2 char_traits specializations + /// @brief 21.1.3.2 char_traits specializations template<> struct char_traits { @@ -362,15 +362,6 @@ namespace std }; #endif //_GLIBCXX_USE_WCHAR_T - template - struct _Char_traits_match - { - _CharT _M_c; - _Char_traits_match(_CharT const& __c) : _M_c(__c) { } - - bool - operator()(_CharT const& __a) { return _Traits::eq(_M_c, __a); } - }; -} // namespace std +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/codecvt.h b/contrib/libstdc++/include/bits/codecvt.h index d31ebf2..d417a6f 100644 --- a/contrib/libstdc++/include/bits/codecvt.h +++ b/contrib/libstdc++/include/bits/codecvt.h @@ -1,6 +1,7 @@ // Locale support (codecvt) -*- C++ -*- -// Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,24 +28,25 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file bits/codecvt.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + // // ISO C++ 14882: 22.2.1.5 Template class codecvt // -// Written by Benjamin Kosnik - -/** @file codecvt.h - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ +// Written by Benjamin Kosnik #ifndef _CODECVT_H #define _CODECVT_H 1 #pragma GCC system_header - // 22.2.1.5 Template class codecvt - /// Base class for codecvt facet providing conversion result enum. +_GLIBCXX_BEGIN_NAMESPACE(std) + + /// @brief Empty base class for codecvt facet [22.2.1.5]. class codecvt_base { public: @@ -57,12 +59,8 @@ }; }; - // Template class __codecvt_abstract_base - // NB: An abstract base class that fills in the public inlines, so - // that the specializations don't have to re-copy the public - // interface. /** - * @brief Common base for codecvt facet + * @brief Common base for codecvt functions. * * This template class provides implementations of the public functions * that forward to the protected virtual functions. @@ -102,11 +100,12 @@ * beginning and carried from a previous call if continuing * conversion. There are no guarantees about how @a state is used. * - * The result returned is a member of codecvt_base::result. If all the - * input is converted, returns codecvt_base::ok. If no conversion is - * necessary, returns codecvt_base::noconv. If the input ends early or - * there is insufficient space in the output, returns codecvt_base::partial. - * Otherwise the conversion failed and codecvt_base::error is returned. + * The result returned is a member of codecvt_base::result. If + * all the input is converted, returns codecvt_base::ok. If no + * conversion is necessary, returns codecvt_base::noconv. If + * the input ends early or there is insufficient space in the + * output, returns codecvt_base::partial. Otherwise the + * conversion failed and codecvt_base::error is returned. * * @param state Persistent conversion state data. * @param from Start of input. @@ -181,11 +180,12 @@ * beginning and carried from a previous call if continuing * conversion. There are no guarantees about how @a state is used. * - * The result returned is a member of codecvt_base::result. If all the - * input is converted, returns codecvt_base::ok. If no conversion is - * necessary, returns codecvt_base::noconv. If the input ends early or - * there is insufficient space in the output, returns codecvt_base::partial. - * Otherwise the conversion failed and codecvt_base::error is returned. + * The result returned is a member of codecvt_base::result. If + * all the input is converted, returns codecvt_base::ok. If no + * conversion is necessary, returns codecvt_base::noconv. If + * the input ends early or there is insufficient space in the + * output, returns codecvt_base::partial. Otherwise the + * conversion failed and codecvt_base::error is returned. * * @param state Persistent conversion state data. * @param from Start of input. @@ -267,8 +267,8 @@ do_max_length() const throw() = 0; }; - // 22.2.1.5 Template class codecvt - // NB: Generic, mostly useless implementation. + /// @brief class codecvt [22.2.1.5]. + /// NB: Generic, mostly useless implementation. template class codecvt : public __codecvt_abstract_base<_InternT, _ExternT, _StateT> @@ -330,7 +330,7 @@ template locale::id codecvt<_InternT, _ExternT, _StateT>::id; - // codecvt required specialization + /// @brief class codecvt specialization. template<> class codecvt : public __codecvt_abstract_base @@ -388,7 +388,7 @@ }; #ifdef _GLIBCXX_USE_WCHAR_T - // codecvt required specialization + /// @brief class codecvt specialization. template<> class codecvt : public __codecvt_abstract_base @@ -448,7 +448,7 @@ }; #endif //_GLIBCXX_USE_WCHAR_T - // 22.2.1.6 Template class codecvt_byname + /// @brief class codecvt_byname [22.2.1.6]. template class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> { @@ -469,10 +469,6 @@ ~codecvt_byname() { } }; - // Include host and configuration specific partial specializations - // with additional functionality, if possible. -#ifdef _GLIBCXX_USE_WCHAR_T - #include -#endif +_GLIBCXX_END_NAMESPACE #endif // _CODECVT_H diff --git a/contrib/libstdc++/include/bits/concept_check.h b/contrib/libstdc++/include/bits/concept_check.h index 80c1439..98cb42d 100644 --- a/contrib/libstdc++/include/bits/concept_check.h +++ b/contrib/libstdc++/include/bits/concept_check.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/bits/cpp_type_traits.h b/contrib/libstdc++/include/bits/cpp_type_traits.h index d4e4ea0..ed9a48a 100644 --- a/contrib/libstdc++/include/bits/cpp_type_traits.h +++ b/contrib/libstdc++/include/bits/cpp_type_traits.h @@ -1,6 +1,7 @@ // The -*- C++ -*- type traits classes for internal use in libstdc++ -// Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,22 +28,24 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// Written by Gabriel Dos Reis - /** @file cpp_type_traits.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// Written by Gabriel Dos Reis + #ifndef _CPP_TYPE_TRAITS_H #define _CPP_TYPE_TRAITS_H 1 #pragma GCC system_header +#include + // // This file provides some compile-time information about various types. // These representations were designed, on purpose, to be constant-expressions -// and not types as found in . In particular, they +// and not types as found in . In particular, they // can be used in control structures and the optimizer hopefully will do // the obvious thing. // @@ -63,70 +66,82 @@ // // -- Gaby (dosreis@cmla.ens-cachan.fr) 2000-03-06. // +// Update 2005: types are also provided and has been +// removed. +// + +// Forward declaration hack, should really include this from somewhere. +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + template + class __normal_iterator; + +_GLIBCXX_END_NAMESPACE -// NB: g++ can not compile these if declared within the class -// __is_pod itself. -namespace __gnu_internal +_GLIBCXX_BEGIN_NAMESPACE(std) + +namespace __detail { + // NB: g++ can not compile these if declared within the class + // __is_pod itself. typedef char __one; typedef char __two[2]; - template - __one __test_type (int _Tp::*); - template - __two& __test_type (...); -} // namespace __gnu_internal + template + __one __test_type(int _Tp::*); + template + __two& __test_type(...); +} // namespace __detail -namespace std -{ - // Compare for equality of types. - template - struct __are_same - { - enum - { - _M_type = 0 - }; - }; - template - struct __are_same<_Tp, _Tp> + struct __true_type { }; + struct __false_type { }; + + template + struct __truth_type + { typedef __false_type __type; }; + + template<> + struct __truth_type + { typedef __true_type __type; }; + + // N.B. The conversions to bool are needed due to the issue + // explained in c++/19404. + template + struct __traitor { - enum - { - _M_type = 1 - }; + enum { __value = bool(_Sp::__value) || bool(_Tp::__value) }; + typedef typename __truth_type<__value>::__type __type; }; - // Define a nested type if some predicate holds. - template - struct __enable_if + // Compare for equality of types. + template + struct __are_same { + enum { __value = 0 }; + typedef __false_type __type; }; template - struct __enable_if<_Tp, true> + struct __are_same<_Tp, _Tp> { - typedef _Tp _M_type; + enum { __value = 1 }; + typedef __true_type __type; }; // Holds if the template-argument is a void type. template struct __is_void { - enum - { - _M_type = 0 - }; + enum { __value = 0 }; + typedef __false_type __type; }; template<> struct __is_void { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; // @@ -135,10 +150,8 @@ namespace std template struct __is_integer { - enum - { - _M_type = 0 - }; + enum { __value = 0 }; + typedef __false_type __type; }; // Thirteen specializations (yes there are eleven standard integer @@ -147,120 +160,94 @@ namespace std template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; # ifdef _GLIBCXX_USE_WCHAR_T template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; # endif template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_integer { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; // @@ -269,77 +256,148 @@ namespace std template struct __is_floating { - enum - { - _M_type = 0 - }; + enum { __value = 0 }; + typedef __false_type __type; }; // three specializations (float, double and 'long double') template<> struct __is_floating { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_floating { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; template<> struct __is_floating { - enum - { - _M_type = 1 - }; + enum { __value = 1 }; + typedef __true_type __type; }; // - // An arithmetic type is an integer type or a floating point type + // Pointer types // template - struct __is_arithmetic + struct __is_pointer { - enum - { - _M_type = __is_integer<_Tp>::_M_type || __is_floating<_Tp>::_M_type - }; + enum { __value = 0 }; + typedef __false_type __type; + }; + + template + struct __is_pointer<_Tp*> + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + // + // Normal iterator type + // + template + struct __is_normal_iterator + { + enum { __value = 0 }; + typedef __false_type __type; }; - + + template + struct __is_normal_iterator< __gnu_cxx::__normal_iterator<_Iterator, + _Container> > + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + // + // An arithmetic type is an integer type or a floating point type + // + template + struct __is_arithmetic + : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> > + { }; + // // A fundamental type is `void' or and arithmetic type // template struct __is_fundamental + : public __traitor<__is_void<_Tp>, __is_arithmetic<_Tp> > + { }; + + // + // A scalar type is an arithmetic type or a pointer type + // + template + struct __is_scalar + : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> > + { }; + + // For the immediate use, the following is a good approximation. + template + struct __is_pod { enum { - _M_type = __is_void<_Tp>::_M_type || __is_arithmetic<_Tp>::_M_type + __value = (sizeof(__detail::__test_type<_Tp>(0)) + != sizeof(__detail::__one)) }; }; // - // For the immediate use, the following is a good approximation + // A stripped-down version of std::tr1::is_empty // template - struct __is_pod - { + struct __is_empty + { + private: + template + struct __first { }; + template + struct __second + : public _Up { }; + + public: enum { - _M_type = (sizeof(__gnu_internal::__test_type<_Tp>(0)) - != sizeof(__gnu_internal::__one)) + __value = sizeof(__first<_Tp>) == sizeof(__second<_Tp>) }; }; -} // namespace std + // + // For use in std::copy and std::find overloads for streambuf iterators. + // + template + struct __is_char + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + template<> + struct __is_char + { + enum { __value = 1 }; + typedef __true_type __type; + }; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + struct __is_char + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + +_GLIBCXX_END_NAMESPACE #endif //_CPP_TYPE_TRAITS_H diff --git a/contrib/libstdc++/include/bits/deque.tcc b/contrib/libstdc++/include/bits/deque.tcc index e8e0438..3f53f20 100644 --- a/contrib/libstdc++/include/bits/deque.tcc +++ b/contrib/libstdc++/include/bits/deque.tcc @@ -1,6 +1,7 @@ // Deque implementation (out of line) -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -61,19 +62,19 @@ #ifndef _DEQUE_TCC #define _DEQUE_TCC 1 -namespace _GLIBCXX_STD -{ +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) + template - deque<_Tp,_Alloc>& - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>& + deque<_Tp, _Alloc>:: operator=(const deque& __x) { const size_type __len = size(); if (&__x != this) { if (__len >= __x.size()) - erase(std::copy(__x.begin(), __x.end(), this->_M_impl._M_start), - this->_M_impl._M_finish); + _M_erase_at_end(std::copy(__x.begin(), __x.end(), + this->_M_impl._M_start)); else { const_iterator __mid = __x.begin() + difference_type(__len); @@ -85,16 +86,16 @@ namespace _GLIBCXX_STD } template - typename deque<_Tp,_Alloc>::iterator - deque<_Tp,_Alloc>:: - insert(iterator position, const value_type& __x) + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: + insert(iterator __position, const value_type& __x) { - if (position._M_cur == this->_M_impl._M_start._M_cur) + if (__position._M_cur == this->_M_impl._M_start._M_cur) { push_front(__x); return this->_M_impl._M_start; } - else if (position._M_cur == this->_M_impl._M_finish._M_cur) + else if (__position._M_cur == this->_M_impl._M_finish._M_cur) { push_back(__x); iterator __tmp = this->_M_impl._M_finish; @@ -102,109 +103,81 @@ namespace _GLIBCXX_STD return __tmp; } else - return _M_insert_aux(position, __x); + return _M_insert_aux(__position, __x); } template - typename deque<_Tp,_Alloc>::iterator - deque<_Tp,_Alloc>:: + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: erase(iterator __position) { iterator __next = __position; ++__next; - size_type __index = __position - this->_M_impl._M_start; - if (__index < (size() >> 1)) + const difference_type __index = __position - begin(); + if (static_cast(__index) < (size() >> 1)) { - std::copy_backward(this->_M_impl._M_start, __position, __next); + if (__position != begin()) + std::copy_backward(begin(), __position, __next); pop_front(); } else { - std::copy(__next, this->_M_impl._M_finish, __position); + if (__next != end()) + std::copy(__next, end(), __position); pop_back(); } - return this->_M_impl._M_start + __index; + return begin() + __index; } template - typename deque<_Tp,_Alloc>::iterator - deque<_Tp,_Alloc>:: + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: erase(iterator __first, iterator __last) { - if (__first == this->_M_impl._M_start && __last == this->_M_impl._M_finish) + if (__first == begin() && __last == end()) { clear(); - return this->_M_impl._M_finish; + return end(); } else { const difference_type __n = __last - __first; - const difference_type __elems_before = __first - this->_M_impl._M_start; - if (static_cast(__elems_before) < (size() - __n) / 2) + const difference_type __elems_before = __first - begin(); + if (static_cast(__elems_before) <= (size() - __n) / 2) { - std::copy_backward(this->_M_impl._M_start, __first, __last); - iterator __new_start = this->_M_impl._M_start + __n; - std::_Destroy(this->_M_impl._M_start, __new_start); - _M_destroy_nodes(this->_M_impl._M_start._M_node, __new_start._M_node); - this->_M_impl._M_start = __new_start; + if (__first != begin()) + std::copy_backward(begin(), __first, __last); + _M_erase_at_begin(begin() + __n); } else { - std::copy(__last, this->_M_impl._M_finish, __first); - iterator __new_finish = this->_M_impl._M_finish - __n; - std::_Destroy(__new_finish, this->_M_impl._M_finish); - _M_destroy_nodes(__new_finish._M_node + 1, - this->_M_impl._M_finish._M_node + 1); - this->_M_impl._M_finish = __new_finish; + if (__last != end()) + std::copy(__last, end(), __first); + _M_erase_at_end(end() - __n); } - return this->_M_impl._M_start + __elems_before; - } - } - - template - void - deque<_Tp,_Alloc>:: - clear() - { - for (_Map_pointer __node = this->_M_impl._M_start._M_node + 1; - __node < this->_M_impl._M_finish._M_node; - ++__node) - { - std::_Destroy(*__node, *__node + _S_buffer_size()); - _M_deallocate_node(*__node); - } - - if (this->_M_impl._M_start._M_node != this->_M_impl._M_finish._M_node) - { - std::_Destroy(this->_M_impl._M_start._M_cur, this->_M_impl._M_start._M_last); - std::_Destroy(this->_M_impl._M_finish._M_first, this->_M_impl._M_finish._M_cur); - _M_deallocate_node(this->_M_impl._M_finish._M_first); + return begin() + __elems_before; } - else - std::_Destroy(this->_M_impl._M_start._M_cur, this->_M_impl._M_finish._M_cur); - - this->_M_impl._M_finish = this->_M_impl._M_start; } template template void - deque<_Tp,_Alloc> - ::_M_assign_aux(_InputIterator __first, _InputIterator __last, - input_iterator_tag) + deque<_Tp, _Alloc>:: + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) { iterator __cur = begin(); - for ( ; __first != __last && __cur != end(); ++__cur, ++__first) + for (; __first != __last && __cur != end(); ++__cur, ++__first) *__cur = *__first; if (__first == __last) - erase(__cur, end()); + _M_erase_at_end(__cur); else insert(end(), __first, __last); } template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_fill_insert(iterator __pos, size_type __n, const value_type& __x) { if (__pos._M_cur == this->_M_impl._M_start._M_cur) @@ -212,12 +185,14 @@ namespace _GLIBCXX_STD iterator __new_start = _M_reserve_elements_at_front(__n); try { - std::uninitialized_fill(__new_start, this->_M_impl._M_start, __x); + std::__uninitialized_fill_a(__new_start, this->_M_impl._M_start, + __x, _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; } catch(...) { - _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); __throw_exception_again; } } @@ -226,7 +201,9 @@ namespace _GLIBCXX_STD iterator __new_finish = _M_reserve_elements_at_back(__n); try { - std::uninitialized_fill(this->_M_impl._M_finish, __new_finish, __x); + std::__uninitialized_fill_a(this->_M_impl._M_finish, + __new_finish, __x, + _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; } catch(...) @@ -242,7 +219,7 @@ namespace _GLIBCXX_STD template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_fill_initialize(const value_type& __value) { _Map_pointer __cur; @@ -251,14 +228,16 @@ namespace _GLIBCXX_STD for (__cur = this->_M_impl._M_start._M_node; __cur < this->_M_impl._M_finish._M_node; ++__cur) - std::uninitialized_fill(*__cur, *__cur + _S_buffer_size(), __value); - std::uninitialized_fill(this->_M_impl._M_finish._M_first, - this->_M_impl._M_finish._M_cur, - __value); + std::__uninitialized_fill_a(*__cur, *__cur + _S_buffer_size(), + __value, _M_get_Tp_allocator()); + std::__uninitialized_fill_a(this->_M_impl._M_finish._M_first, + this->_M_impl._M_finish._M_cur, + __value, _M_get_Tp_allocator()); } catch(...) { - std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur)); + std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur), + _M_get_Tp_allocator()); __throw_exception_again; } } @@ -266,14 +245,14 @@ namespace _GLIBCXX_STD template template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_range_initialize(_InputIterator __first, _InputIterator __last, - input_iterator_tag) + std::input_iterator_tag) { this->_M_initialize_map(0); try { - for ( ; __first != __last; ++__first) + for (; __first != __last; ++__first) push_back(*__first); } catch(...) @@ -286,9 +265,9 @@ namespace _GLIBCXX_STD template template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) + std::forward_iterator_tag) { const size_type __n = std::distance(__first, __last); this->_M_initialize_map(__n); @@ -299,17 +278,22 @@ namespace _GLIBCXX_STD for (__cur_node = this->_M_impl._M_start._M_node; __cur_node < this->_M_impl._M_finish._M_node; ++__cur_node) - { - _ForwardIterator __mid = __first; - std::advance(__mid, _S_buffer_size()); - std::uninitialized_copy(__first, __mid, *__cur_node); - __first = __mid; - } - std::uninitialized_copy(__first, __last, this->_M_impl._M_finish._M_first); + { + _ForwardIterator __mid = __first; + std::advance(__mid, _S_buffer_size()); + std::__uninitialized_copy_a(__first, __mid, *__cur_node, + _M_get_Tp_allocator()); + __first = __mid; + } + std::__uninitialized_copy_a(__first, __last, + this->_M_impl._M_finish._M_first, + _M_get_Tp_allocator()); } catch(...) { - std::_Destroy(this->_M_impl._M_start, iterator(*__cur_node, __cur_node)); + std::_Destroy(this->_M_impl._M_start, + iterator(*__cur_node, __cur_node), + _M_get_Tp_allocator()); __throw_exception_again; } } @@ -317,7 +301,7 @@ namespace _GLIBCXX_STD // Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_last - 1. template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_push_back_aux(const value_type& __t) { value_type __t_copy = __t; @@ -325,8 +309,9 @@ namespace _GLIBCXX_STD *(this->_M_impl._M_finish._M_node + 1) = this->_M_allocate_node(); try { - std::_Construct(this->_M_impl._M_finish._M_cur, __t_copy); - this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node + 1); + this->_M_impl.construct(this->_M_impl._M_finish._M_cur, __t_copy); + this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node + + 1); this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_first; } catch(...) @@ -339,7 +324,7 @@ namespace _GLIBCXX_STD // Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_first. template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_push_front_aux(const value_type& __t) { value_type __t_copy = __t; @@ -347,9 +332,10 @@ namespace _GLIBCXX_STD *(this->_M_impl._M_start._M_node - 1) = this->_M_allocate_node(); try { - this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node - 1); + this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node + - 1); this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_last - 1; - std::_Construct(this->_M_impl._M_start._M_cur, __t_copy); + this->_M_impl.construct(this->_M_impl._M_start._M_cur, __t_copy); } catch(...) { @@ -361,24 +347,25 @@ namespace _GLIBCXX_STD // Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_first. template - void deque<_Tp,_Alloc>:: + void deque<_Tp, _Alloc>:: _M_pop_back_aux() { _M_deallocate_node(this->_M_impl._M_finish._M_first); this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node - 1); this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_last - 1; - std::_Destroy(this->_M_impl._M_finish._M_cur); + this->_M_impl.destroy(this->_M_impl._M_finish._M_cur); } - // Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_last - 1. Note that - // if the deque has at least one element (a precondition for this member - // function), and if _M_impl._M_start._M_cur == _M_impl._M_start._M_last, then the deque - // must have at least two nodes. + // Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_last - 1. + // Note that if the deque has at least one element (a precondition for this + // member function), and if + // _M_impl._M_start._M_cur == _M_impl._M_start._M_last, + // then the deque must have at least two nodes. template - void deque<_Tp,_Alloc>:: + void deque<_Tp, _Alloc>:: _M_pop_front_aux() { - std::_Destroy(this->_M_impl._M_start._M_cur); + this->_M_impl.destroy(this->_M_impl._M_start._M_cur); _M_deallocate_node(this->_M_impl._M_start._M_first); this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node + 1); this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_first; @@ -387,32 +374,34 @@ namespace _GLIBCXX_STD template template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_range_insert_aux(iterator __pos, _InputIterator __first, _InputIterator __last, - input_iterator_tag) + std::input_iterator_tag) { std::copy(__first, __last, std::inserter(*this, __pos)); } template template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_range_insert_aux(iterator __pos, _ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) + std::forward_iterator_tag) { - size_type __n = std::distance(__first, __last); + const size_type __n = std::distance(__first, __last); if (__pos._M_cur == this->_M_impl._M_start._M_cur) { iterator __new_start = _M_reserve_elements_at_front(__n); try { - std::uninitialized_copy(__first, __last, __new_start); + std::__uninitialized_copy_a(__first, __last, __new_start, + _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; } catch(...) { - _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); __throw_exception_again; } } @@ -421,7 +410,9 @@ namespace _GLIBCXX_STD iterator __new_finish = _M_reserve_elements_at_back(__n); try { - std::uninitialized_copy(__first, __last, this->_M_impl._M_finish); + std::__uninitialized_copy_a(__first, __last, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; } catch(...) @@ -437,7 +428,7 @@ namespace _GLIBCXX_STD template typename deque<_Tp, _Alloc>::iterator - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_insert_aux(iterator __pos, const value_type& __x) { difference_type __index = __pos - this->_M_impl._M_start; @@ -470,11 +461,11 @@ namespace _GLIBCXX_STD template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_insert_aux(iterator __pos, size_type __n, const value_type& __x) { const difference_type __elems_before = __pos - this->_M_impl._M_start; - size_type __length = this->size(); + const size_type __length = this->size(); value_type __x_copy = __x; if (__elems_before < difference_type(__length / 2)) { @@ -485,25 +476,30 @@ namespace _GLIBCXX_STD { if (__elems_before >= difference_type(__n)) { - iterator __start_n = this->_M_impl._M_start + difference_type(__n); - std::uninitialized_copy(this->_M_impl._M_start, __start_n, - __new_start); + iterator __start_n = (this->_M_impl._M_start + + difference_type(__n)); + std::__uninitialized_copy_a(this->_M_impl._M_start, + __start_n, __new_start, + _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; std::copy(__start_n, __pos, __old_start); - fill(__pos - difference_type(__n), __pos, __x_copy); + std::fill(__pos - difference_type(__n), __pos, __x_copy); } else { - std::__uninitialized_copy_fill(this->_M_impl._M_start, __pos, - __new_start, - this->_M_impl._M_start, __x_copy); + std::__uninitialized_copy_fill(this->_M_impl._M_start, + __pos, __new_start, + this->_M_impl._M_start, + __x_copy, + _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; std::fill(__old_start, __pos, __x_copy); } } catch(...) { - _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); __throw_exception_again; } } @@ -518,9 +514,12 @@ namespace _GLIBCXX_STD { if (__elems_after > difference_type(__n)) { - iterator __finish_n = this->_M_impl._M_finish - difference_type(__n); - std::uninitialized_copy(__finish_n, this->_M_impl._M_finish, - this->_M_impl._M_finish); + iterator __finish_n = (this->_M_impl._M_finish + - difference_type(__n)); + std::__uninitialized_copy_a(__finish_n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; std::copy_backward(__pos, __finish_n, __old_finish); std::fill(__pos, __pos + difference_type(__n), __x_copy); @@ -530,7 +529,8 @@ namespace _GLIBCXX_STD std::__uninitialized_fill_copy(this->_M_impl._M_finish, __pos + difference_type(__n), __x_copy, __pos, - this->_M_impl._M_finish); + this->_M_impl._M_finish, + _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; std::fill(__pos, __old_finish, __x_copy); } @@ -547,13 +547,13 @@ namespace _GLIBCXX_STD template template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_insert_aux(iterator __pos, _ForwardIterator __first, _ForwardIterator __last, size_type __n) { const difference_type __elemsbefore = __pos - this->_M_impl._M_start; - size_type __length = size(); + const size_type __length = size(); if (static_cast(__elemsbefore) < __length / 2) { iterator __new_start = _M_reserve_elements_at_front(__n); @@ -563,9 +563,11 @@ namespace _GLIBCXX_STD { if (__elemsbefore >= difference_type(__n)) { - iterator __start_n = this->_M_impl._M_start + difference_type(__n); - std::uninitialized_copy(this->_M_impl._M_start, __start_n, - __new_start); + iterator __start_n = (this->_M_impl._M_start + + difference_type(__n)); + std::__uninitialized_copy_a(this->_M_impl._M_start, + __start_n, __new_start, + _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; std::copy(__start_n, __pos, __old_start); std::copy(__first, __last, __pos - difference_type(__n)); @@ -574,15 +576,18 @@ namespace _GLIBCXX_STD { _ForwardIterator __mid = __first; std::advance(__mid, difference_type(__n) - __elemsbefore); - std::__uninitialized_copy_copy(this->_M_impl._M_start, __pos, - __first, __mid, __new_start); + std::__uninitialized_copy_copy(this->_M_impl._M_start, + __pos, __first, __mid, + __new_start, + _M_get_Tp_allocator()); this->_M_impl._M_start = __new_start; std::copy(__mid, __last, __old_start); } } catch(...) { - _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); __throw_exception_again; } } @@ -597,10 +602,12 @@ namespace _GLIBCXX_STD { if (__elemsafter > difference_type(__n)) { - iterator __finish_n = this->_M_impl._M_finish - difference_type(__n); - std::uninitialized_copy(__finish_n, - this->_M_impl._M_finish, - this->_M_impl._M_finish); + iterator __finish_n = (this->_M_impl._M_finish + - difference_type(__n)); + std::__uninitialized_copy_a(__finish_n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; std::copy_backward(__pos, __finish_n, __old_finish); std::copy(__first, __last, __pos); @@ -611,7 +618,8 @@ namespace _GLIBCXX_STD std::advance(__mid, __elemsafter); std::__uninitialized_copy_copy(__mid, __last, __pos, this->_M_impl._M_finish, - this->_M_impl._M_finish); + this->_M_impl._M_finish, + _M_get_Tp_allocator()); this->_M_impl._M_finish = __new_finish; std::copy(__first, __mid, __pos); } @@ -625,13 +633,38 @@ namespace _GLIBCXX_STD } } + template + void + deque<_Tp, _Alloc>:: + _M_destroy_data_aux(iterator __first, iterator __last) + { + for (_Map_pointer __node = __first._M_node + 1; + __node < __last._M_node; ++__node) + std::_Destroy(*__node, *__node + _S_buffer_size(), + _M_get_Tp_allocator()); + + if (__first._M_node != __last._M_node) + { + std::_Destroy(__first._M_cur, __first._M_last, + _M_get_Tp_allocator()); + std::_Destroy(__last._M_first, __last._M_cur, + _M_get_Tp_allocator()); + } + else + std::_Destroy(__first._M_cur, __last._M_cur, + _M_get_Tp_allocator()); + } + template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_new_elements_at_front(size_type __new_elems) { - size_type __new_nodes - = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size(); + if (this->max_size() - this->size() < __new_elems) + __throw_length_error(__N("deque::_M_new_elements_at_front")); + + const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1) + / _S_buffer_size()); _M_reserve_map_at_front(__new_nodes); size_type __i; try @@ -649,11 +682,14 @@ namespace _GLIBCXX_STD template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_new_elements_at_back(size_type __new_elems) { - size_type __new_nodes - = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size(); + if (this->max_size() - this->size() < __new_elems) + __throw_length_error(__N("deque::_M_new_elements_at_back")); + + const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1) + / _S_buffer_size()); _M_reserve_map_at_back(__new_nodes); size_type __i; try @@ -671,12 +707,12 @@ namespace _GLIBCXX_STD template void - deque<_Tp,_Alloc>:: + deque<_Tp, _Alloc>:: _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front) { - size_type __old_num_nodes + const size_type __old_num_nodes = this->_M_impl._M_finish._M_node - this->_M_impl._M_start._M_node + 1; - size_type __new_num_nodes = __old_num_nodes + __nodes_to_add; + const size_type __new_num_nodes = __old_num_nodes + __nodes_to_add; _Map_pointer __new_nstart; if (this->_M_impl._M_map_size > 2 * __new_num_nodes) @@ -686,8 +722,8 @@ namespace _GLIBCXX_STD + (__add_at_front ? __nodes_to_add : 0); if (__new_nstart < this->_M_impl._M_start._M_node) std::copy(this->_M_impl._M_start._M_node, - this->_M_impl._M_finish._M_node + 1, - __new_nstart); + this->_M_impl._M_finish._M_node + 1, + __new_nstart); else std::copy_backward(this->_M_impl._M_start._M_node, this->_M_impl._M_finish._M_node + 1, @@ -714,6 +750,29 @@ namespace _GLIBCXX_STD this->_M_impl._M_start._M_set_node(__new_nstart); this->_M_impl._M_finish._M_set_node(__new_nstart + __old_num_nodes - 1); } -} // namespace std + + // Overload for deque::iterators, exploiting the "segmented-iterator + // optimization". NB: leave const_iterators alone! + template + void + fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>& __first, + const _Deque_iterator<_Tp, _Tp&, _Tp*>& __last, const _Tp& __value) + { + typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self; + + for (typename _Self::_Map_pointer __node = __first._M_node + 1; + __node < __last._M_node; ++__node) + std::fill(*__node, *__node + _Self::_S_buffer_size(), __value); + + if (__first._M_node != __last._M_node) + { + std::fill(__first._M_cur, __first._M_last, __value); + std::fill(__last._M_first, __last._M_cur, __value); + } + else + std::fill(__first._M_cur, __last._M_cur, __value); + } + +_GLIBCXX_END_NESTED_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/fstream.tcc b/contrib/libstdc++/include/bits/fstream.tcc index 3b433ea..5520f9b 100644 --- a/contrib/libstdc++/include/bits/fstream.tcc +++ b/contrib/libstdc++/include/bits/fstream.tcc @@ -1,6 +1,6 @@ // File based streams -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,11 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file fstream.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + // // ISO C++ 14882: 27.8 File-based streams // @@ -37,8 +42,8 @@ #pragma GCC system_header -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template void basic_filebuf<_CharT, _Traits>:: @@ -46,9 +51,9 @@ namespace std { // Allocate internal buffer only if one doesn't already exist // (either allocated or provided by the user via setbuf). - if (!_M_buf_allocated && !this->_M_buf) + if (!_M_buf_allocated && !_M_buf) { - this->_M_buf = new char_type[this->_M_buf_size]; + _M_buf = new char_type[_M_buf_size]; _M_buf_allocated = true; } } @@ -60,8 +65,8 @@ namespace std { if (_M_buf_allocated) { - delete [] this->_M_buf; - this->_M_buf = NULL; + delete [] _M_buf; + _M_buf = NULL; _M_buf_allocated = false; } delete [] _M_ext_buf; @@ -97,7 +102,7 @@ namespace std if (this->is_open()) { _M_allocate_internal_buffer(); - this->_M_mode = __mode; + _M_mode = __mode; // Setup initial buffer to 'uncommitted' mode. _M_reading = false; @@ -137,8 +142,8 @@ namespace std { __testfail = true; } // NB: Do this here so that re-opened filebufs will be cool... - this->_M_mode = ios_base::openmode(0); - this->_M_pback_init = false; + _M_mode = ios_base::openmode(0); + _M_pback_init = false; _M_destroy_internal_buffer(); _M_reading = false; _M_writing = false; @@ -160,13 +165,21 @@ namespace std showmanyc() { streamsize __ret = -1; - const bool __testin = this->_M_mode & ios_base::in; + const bool __testin = _M_mode & ios_base::in; if (__testin && this->is_open()) { // For a stateful encoding (-1) the pending sequence might be just // shift and unshift prefixes with no actual character. __ret = this->egptr() - this->gptr(); + +#if _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM + // About this workaround, see libstdc++/20806. + const bool __testbinary = _M_mode & ios_base::binary; + if (__check_facet(_M_codecvt).encoding() >= 0 + && __testbinary) +#else if (__check_facet(_M_codecvt).encoding() >= 0) +#endif __ret += _M_file.showmanyc() / _M_codecvt->max_length(); } return __ret; @@ -178,7 +191,7 @@ namespace std underflow() { int_type __ret = traits_type::eof(); - const bool __testin = this->_M_mode & ios_base::in; + const bool __testin = _M_mode & ios_base::in; if (__testin && !_M_writing) { // Check for pback madness, and if so swich back to the @@ -190,8 +203,7 @@ namespace std return traits_type::to_int_type(*this->gptr()); // Get and convert input sequence. - const size_t __buflen = this->_M_buf_size > 1 - ? this->_M_buf_size - 1 : 1; + const size_t __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1; // Will be set to true if ::read() returns 0 indicating EOF. bool __got_eof = false; @@ -328,12 +340,12 @@ namespace std pbackfail(int_type __i) { int_type __ret = traits_type::eof(); - const bool __testin = this->_M_mode & ios_base::in; + const bool __testin = _M_mode & ios_base::in; if (__testin && !_M_writing) { // Remember whether the pback buffer is active, otherwise below // we may try to store in it a second char (libstdc++/9761). - const bool __testpb = this->_M_pback_init; + const bool __testpb = _M_pback_init; const bool __testeof = traits_type::eq_int_type(__i, __ret); int_type __tmp; if (this->eback() < this->gptr()) @@ -381,7 +393,7 @@ namespace std { int_type __ret = traits_type::eof(); const bool __testeof = traits_type::eq_int_type(__c, __ret); - const bool __testout = this->_M_mode & ios_base::out; + const bool __testout = _M_mode & ios_base::out; if (__testout && !_M_reading) { if (this->pbase() < this->pptr()) @@ -402,7 +414,7 @@ namespace std __ret = traits_type::not_eof(__c); } } - else if (this->_M_buf_size > 1) + else if (_M_buf_size > 1) { // Overflow in 'uncommitted' mode: set _M_writing, set // the buffer to the initial 'write' mode, and put __c @@ -500,7 +512,7 @@ namespace std { // Clear out pback buffer before going on to the real deal... streamsize __ret = 0; - if (this->_M_pback_init) + if (_M_pback_init) { if (__n > 0 && this->gptr() == this->eback()) { @@ -515,9 +527,9 @@ namespace std // Optimization in the always_noconv() case, to be generalized in the // future: when __n > __buflen we read directly instead of using the // buffer repeatedly. - const bool __testin = this->_M_mode & ios_base::in; - const streamsize __buflen = this->_M_buf_size > 1 ? this->_M_buf_size - 1 - : 1; + const bool __testin = _M_mode & ios_base::in; + const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1; + if (__n > __buflen && __check_facet(_M_codecvt).always_noconv() && __testin && !_M_writing) { @@ -585,7 +597,7 @@ namespace std // future: when __n is sufficiently large we write directly instead of // using the buffer. streamsize __ret = 0; - const bool __testout = this->_M_mode & ios_base::out; + const bool __testout = _M_mode & ios_base::out; if (__check_facet(_M_codecvt).always_noconv() && __testout && !_M_reading) { @@ -594,8 +606,8 @@ namespace std streamsize __bufavail = this->epptr() - this->pptr(); // Don't mistake 'uncommitted' mode buffered with unbuffered. - if (!_M_writing && this->_M_buf_size > 1) - __bufavail = this->_M_buf_size - 1; + if (!_M_writing && _M_buf_size > 1) + __bufavail = _M_buf_size - 1; const streamsize __limit = std::min(__chunk, __bufavail); if (__n >= __limit) @@ -630,7 +642,7 @@ namespace std { if (!this->is_open()) if (__s == 0 && __n == 0) - this->_M_buf_size = 1; + _M_buf_size = 1; else if (__s && __n > 0) { // This is implementation-defined behavior, and assumes that @@ -641,8 +653,8 @@ namespace std // position to host the overflow char of a full put area. // When __n == 1, 1 position will be used for the get area // and 0 for the put area, as in the unbuffered case above. - this->_M_buf = __s; - this->_M_buf_size = __n; + _M_buf = __s; + _M_buf_size = __n; } return this; } @@ -728,12 +740,15 @@ namespace std { // Returns pos_type(off_type(-1)) in case of failure. __ret = pos_type(_M_file.seekoff(__off, __way)); - _M_reading = false; - _M_writing = false; - _M_ext_next = _M_ext_end = _M_ext_buf; - _M_set_buffer(-1); - _M_state_cur = __state; - __ret.state(_M_state_cur); + if (__ret != pos_type(off_type(-1))) + { + _M_reading = false; + _M_writing = false; + _M_ext_next = _M_ext_end = _M_ext_buf; + _M_set_buffer(-1); + _M_state_cur = __state; + __ret.state(_M_state_cur); + } } return __ret; } @@ -841,7 +856,7 @@ namespace std { if (_M_codecvt_tmp && !__check_facet(_M_codecvt_tmp).always_noconv()) - __testvalid = this->seekoff(0, ios_base::cur, this->_M_mode) + __testvalid = this->seekoff(0, ios_base::cur, _M_mode) != pos_type(off_type(-1)); } else @@ -887,6 +902,7 @@ namespace std extern template class basic_fstream; #endif #endif -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/functexcept.h b/contrib/libstdc++/include/bits/functexcept.h index 8b1d16c..59358c4 100644 --- a/contrib/libstdc++/include/bits/functexcept.h +++ b/contrib/libstdc++/include/bits/functexcept.h @@ -1,6 +1,6 @@ // Function-Based Exception Support -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,59 +27,69 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file functexcept.h + * This header provides support for -fno-exceptions. + */ + // // ISO C++ 14882: 19.1 Exception classes // +#ifndef _FUNCTEXCEPT_H +#define _FUNCTEXCEPT_H 1 + +#include #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // Helper for exception objects in void - __throw_bad_exception(void); + __throw_bad_exception(void) __attribute__((__noreturn__)); // Helper for exception objects in void - __throw_bad_alloc(void); + __throw_bad_alloc(void) __attribute__((__noreturn__)); // Helper for exception objects in void - __throw_bad_cast(void); + __throw_bad_cast(void) __attribute__((__noreturn__)); void - __throw_bad_typeid(void); + __throw_bad_typeid(void) __attribute__((__noreturn__)); // Helpers for exception objects in void - __throw_logic_error(const char* __s); + __throw_logic_error(const char*) __attribute__((__noreturn__)); void - __throw_domain_error(const char* __s); + __throw_domain_error(const char*) __attribute__((__noreturn__)); void - __throw_invalid_argument(const char* __s); + __throw_invalid_argument(const char*) __attribute__((__noreturn__)); void - __throw_length_error(const char* __s); + __throw_length_error(const char*) __attribute__((__noreturn__)); void - __throw_out_of_range(const char* __s); + __throw_out_of_range(const char*) __attribute__((__noreturn__)); void - __throw_runtime_error(const char* __s); + __throw_runtime_error(const char*) __attribute__((__noreturn__)); void - __throw_range_error(const char* __s); + __throw_range_error(const char*) __attribute__((__noreturn__)); void - __throw_overflow_error(const char* __s); + __throw_overflow_error(const char*) __attribute__((__noreturn__)); void - __throw_underflow_error(const char* __s); + __throw_underflow_error(const char*) __attribute__((__noreturn__)); // Helpers for exception objects in basic_ios void - __throw_ios_failure(const char* __s); -} // namespace std + __throw_ios_failure(const char*) __attribute__((__noreturn__)); + +_GLIBCXX_END_NAMESPACE +#endif diff --git a/contrib/libstdc++/include/bits/gslice.h b/contrib/libstdc++/include/bits/gslice.h index 78f8a67..12bfc32 100644 --- a/contrib/libstdc++/include/bits/gslice.h +++ b/contrib/libstdc++/include/bits/gslice.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- gslice class. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,19 +28,19 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// Written by Gabriel Dos Reis - /** @file gslice.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// Written by Gabriel Dos Reis + #ifndef _GSLICE_H #define _GSLICE_H 1 #pragma GCC system_header -namespace std { +_GLIBCXX_BEGIN_NAMESPACE(std) /** * @brief Class defining multi-dimensional subset of an array. @@ -60,106 +60,111 @@ namespace std { * slice[0,2]==array[9], slice[1,0]==array[14], slice[1,1]==array[17], * slice[1,2]==array[20]. */ - class gslice + class gslice + { + public: + /// Construct an empty slice. + gslice (); + + /** + * @brief Construct a slice. + * + * Constructs a slice with as many dimensions as the length of the @a l + * and @a s arrays. + * + * @param o Offset in array of first element. + * @param l Array of dimension lengths. + * @param s Array of dimension strides between array elements. + */ + gslice(size_t, const valarray&, const valarray&); + + // XXX: the IS says the copy-ctor and copy-assignment operators are + // synthetized by the compiler but they are just unsuitable + // for a ref-counted semantic + /// Copy constructor. + gslice(const gslice&); + + /// Destructor. + ~gslice(); + + // XXX: See the note above. + /// Assignment operator. + gslice& operator=(const gslice&); + + /// Return array offset of first slice element. + size_t start() const; + + /// Return array of sizes of slice dimensions. + valarray size() const; + + /// Return array of array strides for each dimension. + valarray stride() const; + + private: + struct _Indexer { - public: - /// Construct an empty slice. - gslice (); - - /** - * @brief Construct a slice. - * - * Constructs a slice with as many dimensions as the length of the @a l - * and @a s arrays. - * - * @param o Offset in array of first element. - * @param l Array of dimension lengths. - * @param s Array of dimension strides between array elements. - */ - gslice(size_t, const valarray&, const valarray&); - - // XXX: the IS says the copy-ctor and copy-assignment operators are - // synthetized by the compiler but they are just unsuitable - // for a ref-counted semantic - /// Copy constructor. - gslice(const gslice&); - - /// Destructor. - ~gslice(); - - // XXX: See the note above. - /// Assignment operator. - gslice& operator=(const gslice&); - - /// Return array offset of first slice element. - size_t start() const; - - /// Return array of sizes of slice dimensions. - valarray size() const; - - /// Return array of array strides for each dimension. - valarray stride() const; - - private: - struct _Indexer { - size_t _M_count; - size_t _M_start; - valarray _M_size; - valarray _M_stride; - valarray _M_index; // Linear array of referenced indices - _Indexer(size_t, const valarray&, - const valarray&); - void _M_increment_use() { ++_M_count; } - size_t _M_decrement_use() { return --_M_count; } - }; - - _Indexer* _M_index; - - template friend class valarray; + size_t _M_count; + size_t _M_start; + valarray _M_size; + valarray _M_stride; + valarray _M_index; // Linear array of referenced indices + _Indexer(size_t, const valarray&, + const valarray&); + void + _M_increment_use() + { ++_M_count; } + + size_t + _M_decrement_use() + { return --_M_count; } }; - inline size_t - gslice::start () const - { return _M_index ? _M_index->_M_start : 0; } + _Indexer* _M_index; - inline valarray - gslice::size () const - { return _M_index ? _M_index->_M_size : valarray(); } + template friend class valarray; + }; - inline valarray - gslice::stride () const - { return _M_index ? _M_index->_M_stride : valarray(); } + inline size_t + gslice::start () const + { return _M_index ? _M_index->_M_start : 0; } - inline gslice::gslice () : _M_index(0) {} + inline valarray + gslice::size () const + { return _M_index ? _M_index->_M_size : valarray(); } - inline - gslice::gslice(size_t __o, const valarray& __l, - const valarray& __s) - : _M_index(new gslice::_Indexer(__o, __l, __s)) {} + inline valarray + gslice::stride () const + { return _M_index ? _M_index->_M_stride : valarray(); } - inline - gslice::gslice(const gslice& __g) : _M_index(__g._M_index) - { if (_M_index) _M_index->_M_increment_use(); } + inline gslice::gslice () : _M_index(0) {} - inline - gslice::~gslice() - { if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index; } + inline + gslice::gslice(size_t __o, const valarray& __l, + const valarray& __s) + : _M_index(new gslice::_Indexer(__o, __l, __s)) {} - inline gslice& - gslice::operator= (const gslice& __g) - { - if (__g._M_index) __g._M_index->_M_increment_use(); - if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index; - _M_index = __g._M_index; - return *this; - } + inline + gslice::gslice(const gslice& __g) : _M_index(__g._M_index) + { if (_M_index) _M_index->_M_increment_use(); } + inline + gslice::~gslice() + { + if (_M_index && _M_index->_M_decrement_use() == 0) + delete _M_index; + } -} // std:: + inline gslice& + gslice::operator= (const gslice& __g) + { + if (__g._M_index) + __g._M_index->_M_increment_use(); + if (_M_index && _M_index->_M_decrement_use() == 0) + delete _M_index; + _M_index = __g._M_index; + return *this; + } +_GLIBCXX_END_NAMESPACE #endif /* _GSLICE_H */ - -// Local Variables: -// mode:c++ -// End: diff --git a/contrib/libstdc++/include/bits/gslice_array.h b/contrib/libstdc++/include/bits/gslice_array.h index 7e2e684..55ddc3b 100644 --- a/contrib/libstdc++/include/bits/gslice_array.h +++ b/contrib/libstdc++/include/bits/gslice_array.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- gslice_array class. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,19 +28,19 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// Written by Gabriel Dos Reis - /** @file gslice_array.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// Written by Gabriel Dos Reis + #ifndef _GSLICE_ARRAY_H #define _GSLICE_ARRAY_H 1 #pragma GCC system_header -namespace std { +_GLIBCXX_BEGIN_NAMESPACE(std) /** * @brief Reference to multi-dimensional subset of an array. @@ -97,27 +97,27 @@ namespace std { void operator=(const _Tp&) const; template - void operator=(const _Expr<_Dom,_Tp>&) const; + void operator=(const _Expr<_Dom, _Tp>&) const; template - void operator*=(const _Expr<_Dom,_Tp>&) const; + void operator*=(const _Expr<_Dom, _Tp>&) const; template - void operator/=(const _Expr<_Dom,_Tp>&) const; + void operator/=(const _Expr<_Dom, _Tp>&) const; template - void operator%=(const _Expr<_Dom,_Tp>&) const; + void operator%=(const _Expr<_Dom, _Tp>&) const; template - void operator+=(const _Expr<_Dom,_Tp>&) const; + void operator+=(const _Expr<_Dom, _Tp>&) const; template - void operator-=(const _Expr<_Dom,_Tp>&) const; + void operator-=(const _Expr<_Dom, _Tp>&) const; template - void operator^=(const _Expr<_Dom,_Tp>&) const; + void operator^=(const _Expr<_Dom, _Tp>&) const; template - void operator&=(const _Expr<_Dom,_Tp>&) const; + void operator&=(const _Expr<_Dom, _Tp>&) const; template - void operator|=(const _Expr<_Dom,_Tp>&) const; + void operator|=(const _Expr<_Dom, _Tp>&) const; template - void operator<<=(const _Expr<_Dom,_Tp>&) const; + void operator<<=(const _Expr<_Dom, _Tp>&) const; template - void operator>>=(const _Expr<_Dom,_Tp>&) const; + void operator>>=(const _Expr<_Dom, _Tp>&) const; private: _Array<_Tp> _M_array; @@ -137,13 +137,11 @@ namespace std { const valarray& __i) : _M_array(__a), _M_index(__i) {} - template inline gslice_array<_Tp>::gslice_array(const gslice_array<_Tp>& __a) : _M_array(__a._M_array), _M_index(__a._M_index) {} - template inline gslice_array<_Tp>& gslice_array<_Tp>::operator=(const gslice_array<_Tp>& __a) @@ -186,7 +184,7 @@ namespace std { gslice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \ { \ _Array_augmented_##_Name(_M_array, _Array(_M_index), \ - _Array<_Tp>(__v), __v.size()); \ + _Array<_Tp>(__v), __v.size()); \ } \ \ template \ @@ -211,10 +209,6 @@ _DEFINE_VALARRAY_OPERATOR(>>, __shift_right) #undef _DEFINE_VALARRAY_OPERATOR -} // std:: +_GLIBCXX_END_NAMESPACE #endif /* _GSLICE_ARRAY_H */ - -// Local Variables: -// mode:c++ -// End: diff --git a/contrib/libstdc++/include/bits/indirect_array.h b/contrib/libstdc++/include/bits/indirect_array.h index 912f522..d43d801 100644 --- a/contrib/libstdc++/include/bits/indirect_array.h +++ b/contrib/libstdc++/include/bits/indirect_array.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- indirect_array class. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,28 +28,28 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// Written by Gabriel Dos Reis - /** @file indirect_array.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// Written by Gabriel Dos Reis + #ifndef _INDIRECT_ARRAY_H #define _INDIRECT_ARRAY_H 1 #pragma GCC system_header -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @brief Reference to arbitrary subset of an array. * * An indirect_array is a reference to the actual elements of an array - * specified by an ordered array of indices. The way to get an indirect_array is to - * call operator[](valarray) on a valarray. The returned - * indirect_array then permits carrying operations out on the referenced - * subset of elements in the original valarray. + * specified by an ordered array of indices. The way to get an + * indirect_array is to call operator[](valarray) on a valarray. + * The returned indirect_array then permits carrying operations out on the + * referenced subset of elements in the original valarray. * * For example, if an indirect_array is obtained using the array (4,2,0) as * an argument, and then assigned to an array containing (1,2,3), then the @@ -143,35 +143,35 @@ namespace std : _M_sz(__a._M_sz), _M_index(__a._M_index), _M_array(__a._M_array) {} template - inline - indirect_array<_Tp>::indirect_array(_Array<_Tp> __a, size_t __s, - _Array __i) - : _M_sz(__s), _M_index(__i), _M_array(__a) {} + inline + indirect_array<_Tp>::indirect_array(_Array<_Tp> __a, size_t __s, + _Array __i) + : _M_sz(__s), _M_index(__i), _M_array(__a) {} template - inline indirect_array<_Tp>& - indirect_array<_Tp>::operator=(const indirect_array<_Tp>& __a) - { - std::__valarray_copy(__a._M_array, _M_sz, __a._M_index, _M_array, _M_index); - return *this; - } - + inline indirect_array<_Tp>& + indirect_array<_Tp>::operator=(const indirect_array<_Tp>& __a) + { + std::__valarray_copy(__a._M_array, _M_sz, __a._M_index, _M_array, + _M_index); + return *this; + } template - inline void - indirect_array<_Tp>::operator=(const _Tp& __t) const - { std::__valarray_fill(_M_array, _M_index, _M_sz, __t); } + inline void + indirect_array<_Tp>::operator=(const _Tp& __t) const + { std::__valarray_fill(_M_array, _M_index, _M_sz, __t); } template - inline void - indirect_array<_Tp>::operator=(const valarray<_Tp>& __v) const - { std::__valarray_copy(_Array<_Tp>(__v), _M_sz, _M_array, _M_index); } + inline void + indirect_array<_Tp>::operator=(const valarray<_Tp>& __v) const + { std::__valarray_copy(_Array<_Tp>(__v), _M_sz, _M_array, _M_index); } template - template - inline void - indirect_array<_Tp>::operator=(const _Expr<_Dom,_Tp>& __e) const - { std::__valarray_copy(__e, _M_sz, _M_array, _M_index); } + template + inline void + indirect_array<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) const + { std::__valarray_copy(__e, _M_sz, _M_array, _M_index); } #undef _DEFINE_VALARRAY_OPERATOR #define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \ @@ -203,10 +203,6 @@ _DEFINE_VALARRAY_OPERATOR(>>, __shift_right) #undef _DEFINE_VALARRAY_OPERATOR -} // std:: +_GLIBCXX_END_NAMESPACE #endif /* _INDIRECT_ARRAY_H */ - -// Local Variables: -// mode:c++ -// End: diff --git a/contrib/libstdc++/include/bits/ios_base.h b/contrib/libstdc++/include/bits/ios_base.h index 08c952d..33dc256 100644 --- a/contrib/libstdc++/include/bits/ios_base.h +++ b/contrib/libstdc++/include/bits/ios_base.h @@ -1,6 +1,6 @@ // Iostreams base classes -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,26 +28,26 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 27.4 Iostreams base classes -// - /** @file ios_base.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// +// ISO C++ 14882: 27.4 Iostreams base classes +// + #ifndef _IOS_BASE_H #define _IOS_BASE_H 1 #pragma GCC system_header -#include +#include #include #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // The following definitions of bitmask types are enums, not ints, // as permitted (but not required) in the standard, in order to provide // better type safety in iostream calls. A side effect is that @@ -191,7 +191,7 @@ namespace std // 27.4.2 Class ios_base /** - * @brief The very top of the I/O class hierarchy. + * @brief The base of the I/O class hierarchy. * * This class defines everything that can be defined about I/O that does * not depend on the type of characters being input or output. Most @@ -253,65 +253,65 @@ namespace std typedef _Ios_Fmtflags fmtflags; /// Insert/extract @c bool in alphabetic rather than numeric format. - static const fmtflags boolalpha = fmtflags(__ios_flags::_S_boolalpha); + static const fmtflags boolalpha = _S_boolalpha; /// Converts integer input or generates integer output in decimal base. - static const fmtflags dec = fmtflags(__ios_flags::_S_dec); + static const fmtflags dec = _S_dec; /// Generate floating-point output in fixed-point notation. - static const fmtflags fixed = fmtflags(__ios_flags::_S_fixed); + static const fmtflags fixed = _S_fixed; /// Converts integer input or generates integer output in hexadecimal base. - static const fmtflags hex = fmtflags(__ios_flags::_S_hex); + static const fmtflags hex = _S_hex; /// Adds fill characters at a designated internal point in certain /// generated output, or identical to @c right if no such point is /// designated. - static const fmtflags internal = fmtflags(__ios_flags::_S_internal); + static const fmtflags internal = _S_internal; /// Adds fill characters on the right (final positions) of certain /// generated output. (I.e., the thing you print is flush left.) - static const fmtflags left = fmtflags(__ios_flags::_S_left); + static const fmtflags left = _S_left; /// Converts integer input or generates integer output in octal base. - static const fmtflags oct = fmtflags(__ios_flags::_S_oct); + static const fmtflags oct = _S_oct; /// Adds fill characters on the left (initial positions) of certain /// generated output. (I.e., the thing you print is flush right.) - static const fmtflags right = fmtflags(__ios_flags::_S_right); + static const fmtflags right = _S_right; /// Generates floating-point output in scientific notation. - static const fmtflags scientific = fmtflags(__ios_flags::_S_scientific); + static const fmtflags scientific = _S_scientific; /// Generates a prefix indicating the numeric base of generated integer /// output. - static const fmtflags showbase = fmtflags(__ios_flags::_S_showbase); + static const fmtflags showbase = _S_showbase; /// Generates a decimal-point character unconditionally in generated /// floating-point output. - static const fmtflags showpoint = fmtflags(__ios_flags::_S_showpoint); + static const fmtflags showpoint = _S_showpoint; /// Generates a + sign in non-negative generated numeric output. - static const fmtflags showpos = fmtflags(__ios_flags::_S_showpos); + static const fmtflags showpos = _S_showpos; /// Skips leading white space before certain input operations. - static const fmtflags skipws = fmtflags(__ios_flags::_S_skipws); + static const fmtflags skipws = _S_skipws; /// Flushes output after each output operation. - static const fmtflags unitbuf = fmtflags(__ios_flags::_S_unitbuf); + static const fmtflags unitbuf = _S_unitbuf; /// Replaces certain lowercase letters with their uppercase equivalents /// in generated output. - static const fmtflags uppercase = fmtflags(__ios_flags::_S_uppercase); + static const fmtflags uppercase = _S_uppercase; /// A mask of left|right|internal. Useful for the 2-arg form of @c setf. - static const fmtflags adjustfield = fmtflags(__ios_flags::_S_adjustfield); + static const fmtflags adjustfield = _S_adjustfield; /// A mask of dec|oct|hex. Useful for the 2-arg form of @c setf. - static const fmtflags basefield = fmtflags(__ios_flags::_S_basefield); + static const fmtflags basefield = _S_basefield; /// A mask of scientific|fixed. Useful for the 2-arg form of @c setf. - static const fmtflags floatfield = fmtflags(__ios_flags::_S_floatfield); + static const fmtflags floatfield = _S_floatfield; // 27.4.2.1.3 Type ios_base::iostate /** @@ -329,18 +329,18 @@ namespace std /// Indicates a loss of integrity in an input or output sequence (such /// as an irrecoverable read error from a file). - static const iostate badbit = iostate(__ios_flags::_S_badbit); + static const iostate badbit = _S_badbit; /// Indicates that an input operation reached the end of an input sequence. - static const iostate eofbit = iostate(__ios_flags::_S_eofbit); + static const iostate eofbit = _S_eofbit; /// Indicates that an input operation failed to read the expected /// characters, or that an output operation failed to generate the /// desired characters. - static const iostate failbit = iostate(__ios_flags::_S_failbit); + static const iostate failbit = _S_failbit; /// Indicates all is well. - static const iostate goodbit = iostate(0); + static const iostate goodbit = _S_goodbit; // 27.4.2.1.4 Type ios_base::openmode /** @@ -359,25 +359,25 @@ namespace std typedef _Ios_Openmode openmode; /// Seek to end before each write. - static const openmode app = openmode(__ios_flags::_S_app); + static const openmode app = _S_app; /// Open and seek to end immediately after opening. - static const openmode ate = openmode(__ios_flags::_S_ate); + static const openmode ate = _S_ate; /// Perform input and output in binary mode (as opposed to text mode). /// This is probably not what you think it is; see /// http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#3 and /// http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#7 for more. - static const openmode binary = openmode(__ios_flags::_S_bin); + static const openmode binary = _S_bin; /// Open for input. Default for @c ifstream and fstream. - static const openmode in = openmode(__ios_flags::_S_in); + static const openmode in = _S_in; /// Open for output. Default for @c ofstream and fstream. - static const openmode out = openmode(__ios_flags::_S_out); + static const openmode out = _S_out; /// Open for input. Default for @c ofstream. - static const openmode trunc = openmode(__ios_flags::_S_trunc); + static const openmode trunc = _S_trunc; // 27.4.2.1.5 Type ios_base::seekdir /** @@ -392,15 +392,14 @@ namespace std typedef _Ios_Seekdir seekdir; /// Request a seek relative to the beginning of the stream. - static const seekdir beg = seekdir(0); + static const seekdir beg = _S_beg; /// Request a seek relative to the current position within the sequence. - static const seekdir cur = seekdir(SEEK_CUR); + static const seekdir cur = _S_cur; /// Request a seek relative to the current end of the sequence. - static const seekdir end = seekdir(SEEK_END); + static const seekdir end = _S_end; -#ifdef _GLIBCXX_DEPRECATED // Annex D.6 typedef int io_state; typedef int open_mode; @@ -408,7 +407,6 @@ namespace std typedef std::streampos streampos; typedef std::streamoff streamoff; -#endif // Callbacks; /** @@ -478,12 +476,12 @@ namespace std : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { } void - _M_add_reference() { __gnu_cxx::__atomic_add(&_M_refcount, 1); } + _M_add_reference() { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); } // 0 => OK to delete. int _M_remove_reference() - { return __gnu_cxx::__exchange_and_add(&_M_refcount, -1); } + { return __gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1); } }; _Callback_list* _M_callbacks; @@ -507,7 +505,7 @@ namespace std // Guaranteed storage. // The first 5 iword and pword slots are reserved for internal use. - static const int _S_local_word_size = 8; + enum { _S_local_word_size = 8 }; _Words _M_local_word[_S_local_word_size]; // Allocated storage. @@ -963,7 +961,8 @@ namespace std __base.setf(ios_base::scientific, ios_base::floatfield); return __base; } -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif /* _IOS_BASE_H */ diff --git a/contrib/libstdc++/include/bits/istream.tcc b/contrib/libstdc++/include/bits/istream.tcc index 9decce3..13facc4 100644 --- a/contrib/libstdc++/include/bits/istream.tcc +++ b/contrib/libstdc++/include/bits/istream.tcc @@ -1,6 +1,7 @@ // istream classes -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +17,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +29,11 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file istream.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + // // ISO C++ 14882: 27.6.1 Input streams // @@ -40,8 +46,8 @@ #include #include // For flush() -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template basic_istream<_CharT, _Traits>::sentry:: sentry(basic_istream<_CharT, _Traits>& __in, bool __noskip) : _M_ok(false) @@ -81,331 +87,64 @@ namespace std } template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(__istream_type& (*__pf)(__istream_type&)) - { return __pf(*this); } - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(__ios_type& (*__pf)(__ios_type&)) - { - __pf(*this); - return *this; - } - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(ios_base& (*__pf)(ios_base&)) - { - __pf(*this); - return *this; - } - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(bool& __n) - { - sentry __cerb(*this, false); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __n); - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + _M_extract(_ValueT& __v) + { + sentry __cerb(*this, false); + if (__cerb) + { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + try + { + const __num_get_type& __ng = __check_facet(this->_M_num_get); + __ng.get(*this, 0, *this, __err, __v); + } + catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>:: operator>>(short& __n) { - sentry __cerb(*this, false); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - long __l; - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __l); - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 118. basic_istream uses nonexistent num_get member functions. - if (!(__err & ios_base::failbit) - && (numeric_limits::min() <= __l - && __l <= numeric_limits::max())) - __n = __l; - else - __err |= ios_base::failbit; - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(unsigned short& __n) - { - sentry __cerb(*this, false); - if (__cerb) + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 118. basic_istream uses nonexistent num_get member functions. + long __l; + _M_extract(__l); + if (!this->fail()) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __n); - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); + if (numeric_limits::min() <= __l + && __l <= numeric_limits::max()) + __n = __l; + else + this->setstate(ios_base::failbit); } return *this; } - + template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>:: operator>>(int& __n) { - sentry __cerb(*this, false); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - long __l; - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __l); - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 118. basic_istream uses nonexistent num_get member functions. - if (!(__err & ios_base::failbit) - && (numeric_limits::min() <= __l - && __l <= numeric_limits::max())) - __n = __l; - else - __err |= ios_base::failbit; - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(unsigned int& __n) - { - sentry __cerb(*this, false); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __n); - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(long& __n) - { - sentry __cerb(*this, false); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __n); - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(unsigned long& __n) - { - sentry __cerb(*this, false); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __n); - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - -#ifdef _GLIBCXX_USE_LONG_LONG - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(long long& __n) - { - sentry __cerb(*this, false); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __n); - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(unsigned long long& __n) - { - sentry __cerb(*this, false); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __n); - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } -#endif - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(float& __n) - { - sentry __cerb(*this, false); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __n); - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(double& __n) - { - sentry __cerb(*this, false); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __n); - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(long double& __n) - { - sentry __cerb(*this, false); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __n); - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_istream<_CharT, _Traits>& - basic_istream<_CharT, _Traits>:: - operator>>(void*& __n) - { - sentry __cerb(*this, false); - if (__cerb) + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 118. basic_istream uses nonexistent num_get member functions. + long __l; + _M_extract(__l); + if (!this->fail()) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_get_type& __ng = __check_facet(this->_M_num_get); - __ng.get(*this, 0, *this, __err, __n); - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); + if (numeric_limits::min() <= __l + && __l <= numeric_limits::max()) + __n = __l; + else + this->setstate(ios_base::failbit); } return *this; } @@ -421,8 +160,11 @@ namespace std { try { - if (!__copy_streambufs(this->rdbuf(), __sbout)) + bool __ineof; + if (!__copy_streambufs_eof(this->rdbuf(), __sbout, __ineof)) __err |= ios_base::failbit; + if (__ineof) + __err |= ios_base::eofbit; } catch(...) { this->_M_setstate(ios_base::failbit); } @@ -528,7 +270,10 @@ namespace std catch(...) { this->_M_setstate(ios_base::badbit); } } - *__s = char_type(); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 243. get and getline when sentry reports failure. + if (__n > 0) + *__s = char_type(); if (!_M_gcount) __err |= ios_base::failbit; if (__err) @@ -584,90 +329,71 @@ namespace std ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); sentry __cerb(*this, true); if (__cerb) - { + { try - { - const int_type __idelim = traits_type::to_int_type(__delim); - const int_type __eof = traits_type::eof(); - __streambuf_type* __sb = this->rdbuf(); - int_type __c = __sb->sgetc(); - - while (_M_gcount + 1 < __n - && !traits_type::eq_int_type(__c, __eof) - && !traits_type::eq_int_type(__c, __idelim)) - { - streamsize __size = std::min(streamsize(__sb->egptr() - - __sb->gptr()), - __n - _M_gcount - 1); - if (__size > 1) - { - const char_type* __p = traits_type::find(__sb->gptr(), - __size, - __delim); - if (__p) - __size = __p - __sb->gptr(); - traits_type::copy(__s, __sb->gptr(), __size); - __s += __size; - __sb->gbump(__size); - _M_gcount += __size; - __c = __sb->sgetc(); - } - else - { - *__s++ = traits_type::to_char_type(__c); - ++_M_gcount; - __c = __sb->snextc(); - } - } - - if (traits_type::eq_int_type(__c, __eof)) - __err |= ios_base::eofbit; - else if (traits_type::eq_int_type(__c, __idelim)) - { - ++_M_gcount; - __sb->sbumpc(); - } - else - __err |= ios_base::failbit; - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - } - *__s = char_type(); + { + const int_type __idelim = traits_type::to_int_type(__delim); + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); + + while (_M_gcount + 1 < __n + && !traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __idelim)) + { + *__s++ = traits_type::to_char_type(__c); + __c = __sb->snextc(); + ++_M_gcount; + } + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + else + { + if (traits_type::eq_int_type(__c, __idelim)) + { + __sb->sbumpc(); + ++_M_gcount; + } + else + __err |= ios_base::failbit; + } + } + catch(...) + { this->_M_setstate(ios_base::badbit); } + } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 243. get and getline when sentry reports failure. + if (__n > 0) + *__s = char_type(); if (!_M_gcount) - __err |= ios_base::failbit; + __err |= ios_base::failbit; if (__err) - this->setstate(__err); + this->setstate(__err); return *this; } + // We provide three overloads, since the first two are much simpler + // than the general case. Also, the latter two can thus adopt the + // same "batchy" strategy used by getline above. template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>:: - ignore(streamsize __n, int_type __delim) + ignore(void) { _M_gcount = 0; sentry __cerb(*this, true); - if (__cerb && __n > 0) + if (__cerb) { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); try { const int_type __eof = traits_type::eof(); __streambuf_type* __sb = this->rdbuf(); - int_type __c; - if (__n != numeric_limits::max()) - --__n; - while (_M_gcount <= __n - && !traits_type::eq_int_type(__c = __sb->sbumpc(), __eof)) - { - ++_M_gcount; - if (traits_type::eq_int_type(__c, __delim)) - break; - } - if (traits_type::eq_int_type(__c, __eof)) + if (traits_type::eq_int_type(__sb->sbumpc(), __eof)) __err |= ios_base::eofbit; + else + _M_gcount = 1; } catch(...) { this->_M_setstate(ios_base::badbit); } @@ -678,6 +404,120 @@ namespace std } template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + ignore(streamsize __n) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb && __n > 0) + { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); + + // N.B. On LFS-enabled platforms streamsize is still 32 bits + // wide: if we want to implement the standard mandated behavior + // for n == max() (see 27.6.1.3/24) we are at risk of signed + // integer overflow: thus these contortions. Also note that, + // by definition, when more than 2G chars are actually ignored, + // _M_gcount (the return value of gcount, that is) cannot be + // really correct, being unavoidably too small. + bool __large_ignore = false; + while (true) + { + while (_M_gcount < __n + && !traits_type::eq_int_type(__c, __eof)) + { + ++_M_gcount; + __c = __sb->snextc(); + } + if (__n == numeric_limits::max() + && !traits_type::eq_int_type(__c, __eof)) + { + _M_gcount = numeric_limits::min(); + __large_ignore = true; + } + else + break; + } + + if (__large_ignore) + _M_gcount = numeric_limits::max(); + + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + } + catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + ignore(streamsize __n, int_type __delim) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb && __n > 0) + { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); + + // See comment above. + bool __large_ignore = false; + while (true) + { + while (_M_gcount < __n + && !traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __delim)) + { + ++_M_gcount; + __c = __sb->snextc(); + } + if (__n == numeric_limits::max() + && !traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __delim)) + { + _M_gcount = numeric_limits::min(); + __large_ignore = true; + } + else + break; + } + + if (__large_ignore) + _M_gcount = numeric_limits::max(); + + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + else if (traits_type::eq_int_type(__c, __delim)) + { + if (_M_gcount < numeric_limits::max()) + ++_M_gcount; + __sb->sbumpc(); + } + } + catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>:: peek(void) @@ -851,7 +691,8 @@ namespace std try { if (!this->fail()) - __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in); + __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, + ios_base::in); } catch(...) { this->_M_setstate(ios_base::badbit); } @@ -873,8 +714,8 @@ namespace std // 136. seekp, seekg setting wrong streams? const pos_type __p = this->rdbuf()->pubseekpos(__pos, ios_base::in); - - // 129. Need error indication from seekp() and seekg() + + // 129. Need error indication from seekp() and seekg() if (__p == pos_type(off_type(-1))) __err |= ios_base::failbit; } @@ -901,8 +742,8 @@ namespace std // 136. seekp, seekg setting wrong streams? const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir, ios_base::in); - - // 129. Need error indication from seekp() and seekg() + + // 129. Need error indication from seekp() and seekg() if (__p == pos_type(off_type(-1))) __err |= ios_base::failbit; } @@ -1108,10 +949,7 @@ namespace std { try { - // Avoid reallocation for common case. __str.erase(); - _CharT __buf[128]; - __size_type __len = 0; const __int_type __idelim = _Traits::to_int_type(__delim); const __int_type __eof = _Traits::eof(); __streambuf_type* __sb = __in.rdbuf(); @@ -1121,16 +959,10 @@ namespace std && !_Traits::eq_int_type(__c, __eof) && !_Traits::eq_int_type(__c, __idelim)) { - if (__len == sizeof(__buf) / sizeof(_CharT)) - { - __str.append(__buf, sizeof(__buf) / sizeof(_CharT)); - __len = 0; - } - __buf[__len++] = _Traits::to_char_type(__c); + __str += _Traits::to_char_type(__c); ++__extracted; __c = __sb->snextc(); } - __str.append(__buf, __len); if (_Traits::eq_int_type(__c, __eof)) __err |= ios_base::eofbit; @@ -1157,12 +989,6 @@ namespace std return __in; } - template - inline basic_istream<_CharT,_Traits>& - getline(basic_istream<_CharT, _Traits>& __in, - basic_string<_CharT,_Traits,_Alloc>& __str) - { return getline(__in, __str, __in.widen('\n')); } - // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. @@ -1176,6 +1002,20 @@ namespace std extern template istream& operator>>(istream&, unsigned char*); extern template istream& operator>>(istream&, signed char*); + extern template istream& istream::_M_extract(unsigned short&); + extern template istream& istream::_M_extract(unsigned int&); + extern template istream& istream::_M_extract(long&); + extern template istream& istream::_M_extract(unsigned long&); + extern template istream& istream::_M_extract(bool&); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template istream& istream::_M_extract(long long&); + extern template istream& istream::_M_extract(unsigned long long&); +#endif + extern template istream& istream::_M_extract(float&); + extern template istream& istream::_M_extract(double&); + extern template istream& istream::_M_extract(long double&); + extern template istream& istream::_M_extract(void*&); + extern template class basic_iostream; #ifdef _GLIBCXX_USE_WCHAR_T @@ -1184,9 +1024,24 @@ namespace std extern template wistream& operator>>(wistream&, wchar_t&); extern template wistream& operator>>(wistream&, wchar_t*); + extern template wistream& wistream::_M_extract(unsigned short&); + extern template wistream& wistream::_M_extract(unsigned int&); + extern template wistream& wistream::_M_extract(long&); + extern template wistream& wistream::_M_extract(unsigned long&); + extern template wistream& wistream::_M_extract(bool&); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template wistream& wistream::_M_extract(long long&); + extern template wistream& wistream::_M_extract(unsigned long long&); +#endif + extern template wistream& wistream::_M_extract(float&); + extern template wistream& wistream::_M_extract(double&); + extern template wistream& wistream::_M_extract(long double&); + extern template wistream& wistream::_M_extract(void*&); + extern template class basic_iostream; #endif #endif -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/list.tcc b/contrib/libstdc++/include/bits/list.tcc index aaaa8c3..f2849fb 100644 --- a/contrib/libstdc++/include/bits/list.tcc +++ b/contrib/libstdc++/include/bits/list.tcc @@ -1,6 +1,7 @@ // List implementation (out of line) -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -61,52 +62,52 @@ #ifndef _LIST_TCC #define _LIST_TCC 1 -namespace _GLIBCXX_STD -{ +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) + template void - _List_base<_Tp,_Alloc>:: + _List_base<_Tp, _Alloc>:: _M_clear() { typedef _List_node<_Tp> _Node; _Node* __cur = static_cast<_Node*>(this->_M_impl._M_node._M_next); while (__cur != &this->_M_impl._M_node) - { - _Node* __tmp = __cur; - __cur = static_cast<_Node*>(__cur->_M_next); - std::_Destroy(&__tmp->_M_data); - _M_put_node(__tmp); - } + { + _Node* __tmp = __cur; + __cur = static_cast<_Node*>(__cur->_M_next); + _M_get_Tp_allocator().destroy(&__tmp->_M_data); + _M_put_node(__tmp); + } } template - typename list<_Tp,_Alloc>::iterator - list<_Tp,_Alloc>:: + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: insert(iterator __position, const value_type& __x) { _Node* __tmp = _M_create_node(__x); __tmp->hook(__position._M_node); - return __tmp; + return iterator(__tmp); } template - typename list<_Tp,_Alloc>::iterator - list<_Tp,_Alloc>:: + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: erase(iterator __position) { - iterator __ret = __position._M_node->_M_next; + iterator __ret = iterator(__position._M_node->_M_next); _M_erase(__position); return __ret; } template void - list<_Tp,_Alloc>:: - resize(size_type __new_size, const value_type& __x) + list<_Tp, _Alloc>:: + resize(size_type __new_size, value_type __x) { iterator __i = begin(); size_type __len = 0; - for ( ; __i != end() && __len < __new_size; ++__i, ++__len) + for (; __i != end() && __len < __new_size; ++__i, ++__len) ; if (__len == __new_size) erase(__i, end()); @@ -115,8 +116,8 @@ namespace _GLIBCXX_STD } template - list<_Tp,_Alloc>& - list<_Tp,_Alloc>:: + list<_Tp, _Alloc>& + list<_Tp, _Alloc>:: operator=(const list& __x) { if (this != &__x) @@ -125,8 +126,9 @@ namespace _GLIBCXX_STD iterator __last1 = end(); const_iterator __first2 = __x.begin(); const_iterator __last2 = __x.end(); - while (__first1 != __last1 && __first2 != __last2) - *__first1++ = *__first2++; + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, ++__first2) + *__first1 = *__first2; if (__first2 == __last2) erase(__first1, __last1); else @@ -137,11 +139,11 @@ namespace _GLIBCXX_STD template void - list<_Tp,_Alloc>:: + list<_Tp, _Alloc>:: _M_fill_assign(size_type __n, const value_type& __val) { iterator __i = begin(); - for ( ; __i != end() && __n > 0; ++__i, --__n) + for (; __i != end() && __n > 0; ++__i, --__n) *__i = __val; if (__n > 0) insert(end(), __n, __val); @@ -152,7 +154,7 @@ namespace _GLIBCXX_STD template template void - list<_Tp,_Alloc>:: + list<_Tp, _Alloc>:: _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2, __false_type) { @@ -169,24 +171,24 @@ namespace _GLIBCXX_STD template void - list<_Tp,_Alloc>:: + list<_Tp, _Alloc>:: remove(const value_type& __value) { iterator __first = begin(); iterator __last = end(); while (__first != __last) - { - iterator __next = __first; - ++__next; - if (*__first == __value) - _M_erase(__first); - __first = __next; - } + { + iterator __next = __first; + ++__next; + if (*__first == __value) + _M_erase(__first); + __first = __next; + } } template void - list<_Tp,_Alloc>:: + list<_Tp, _Alloc>:: unique() { iterator __first = begin(); @@ -195,24 +197,26 @@ namespace _GLIBCXX_STD return; iterator __next = __first; while (++__next != __last) - { - if (*__first == *__next) - _M_erase(__next); - else - __first = __next; - __next = __first; - } + { + if (*__first == *__next) + _M_erase(__next); + else + __first = __next; + __next = __first; + } } template void - list<_Tp,_Alloc>:: + list<_Tp, _Alloc>:: merge(list& __x) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 300. list::merge() specification incomplete if (this != &__x) { + _M_check_equal_allocators(__x); + iterator __first1 = begin(); iterator __last1 = end(); iterator __first2 = __x.begin(); @@ -232,8 +236,38 @@ namespace _GLIBCXX_STD } template + template + void + list<_Tp, _Alloc>:: + merge(list& __x, _StrictWeakOrdering __comp) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 300. list::merge() specification incomplete + if (this != &__x) + { + _M_check_equal_allocators(__x); + + iterator __first1 = begin(); + iterator __last1 = end(); + iterator __first2 = __x.begin(); + iterator __last2 = __x.end(); + while (__first1 != __last1 && __first2 != __last2) + if (__comp(*__first2, *__first1)) + { + iterator __next = __first2; + _M_transfer(__first1, __first2, ++__next); + __first2 = __next; + } + else + ++__first1; + if (__first2 != __last2) + _M_transfer(__last1, __first2, __last2); + } + } + + template void - list<_Tp,_Alloc>:: + list<_Tp, _Alloc>:: sort() { // Do nothing if the list has length 0 or 1. @@ -250,7 +284,7 @@ namespace _GLIBCXX_STD __carry.splice(__carry.begin(), *this, begin()); for(__counter = &__tmp[0]; - (__counter != __fill) && !__counter->empty(); + __counter != __fill && !__counter->empty(); ++__counter) { __counter->merge(__carry); @@ -262,82 +296,55 @@ namespace _GLIBCXX_STD } while ( !empty() ); - for (__counter = &__tmp[1]; __counter != __fill; ++__counter) - __counter->merge( *(__counter-1) ); - swap( *(__fill-1) ); + for (__counter = &__tmp[1]; __counter != __fill; ++__counter) + __counter->merge(*(__counter - 1)); + swap( *(__fill - 1) ); } } template template void - list<_Tp,_Alloc>:: + list<_Tp, _Alloc>:: remove_if(_Predicate __pred) { iterator __first = begin(); iterator __last = end(); while (__first != __last) - { - iterator __next = __first; - ++__next; - if (__pred(*__first)) - _M_erase(__first); - __first = __next; - } + { + iterator __next = __first; + ++__next; + if (__pred(*__first)) + _M_erase(__first); + __first = __next; + } } template template void - list<_Tp,_Alloc>:: + list<_Tp, _Alloc>:: unique(_BinaryPredicate __binary_pred) { iterator __first = begin(); iterator __last = end(); - if (__first == __last) return; + if (__first == __last) + return; iterator __next = __first; while (++__next != __last) - { - if (__binary_pred(*__first, *__next)) - _M_erase(__next); - else - __first = __next; - __next = __first; - } - } - - template - template - void - list<_Tp,_Alloc>:: - merge(list& __x, _StrictWeakOrdering __comp) - { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 300. list::merge() specification incomplete - if (this != &__x) { - iterator __first1 = begin(); - iterator __last1 = end(); - iterator __first2 = __x.begin(); - iterator __last2 = __x.end(); - while (__first1 != __last1 && __first2 != __last2) - if (__comp(*__first2, *__first1)) - { - iterator __next = __first2; - _M_transfer(__first1, __first2, ++__next); - __first2 = __next; - } - else - ++__first1; - if (__first2 != __last2) - _M_transfer(__last1, __first2, __last2); + if (__binary_pred(*__first, *__next)) + _M_erase(__next); + else + __first = __next; + __next = __first; } } template template void - list<_Tp,_Alloc>:: + list<_Tp, _Alloc>:: sort(_StrictWeakOrdering __comp) { // Do nothing if the list has length 0 or 1. @@ -354,7 +361,7 @@ namespace _GLIBCXX_STD __carry.splice(__carry.begin(), *this, begin()); for(__counter = &__tmp[0]; - (__counter != __fill) && !__counter->empty(); + __counter != __fill && !__counter->empty(); ++__counter) { __counter->merge(__carry, __comp); @@ -366,12 +373,13 @@ namespace _GLIBCXX_STD } while ( !empty() ); - for (__counter = &__tmp[1]; __counter != __fill; ++__counter) - __counter->merge( *(__counter-1), __comp ); - swap( *(__fill-1) ); + for (__counter = &__tmp[1]; __counter != __fill; ++__counter) + __counter->merge(*(__counter - 1), __comp); + swap(*(__fill - 1)); } } -} // namespace std + +_GLIBCXX_END_NESTED_NAMESPACE #endif /* _LIST_TCC */ diff --git a/contrib/libstdc++/include/bits/locale_classes.h b/contrib/libstdc++/include/bits/locale_classes.h index 95d9c03..547e21d 100644 --- a/contrib/libstdc++/include/bits/locale_classes.h +++ b/contrib/libstdc++/include/bits/locale_classes.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,15 +28,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 22.1 Locales -// - -/** @file localefwd.h +/** @file locale_classes.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// +// ISO C++ 14882: 22.1 Locales +// + #ifndef _LOCALE_CLASSES_H #define _LOCALE_CLASSES_H 1 @@ -45,11 +45,10 @@ #include #include // For strcmp. #include -#include -#include +#include + +_GLIBCXX_BEGIN_NAMESPACE(std) -namespace std -{ // 22.1.1 Class locale /** * @brief Container class for localization functionality. @@ -307,7 +306,7 @@ namespace std // macros. For GNU systems, the following are also valid: // LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT, // and LC_IDENTIFICATION. - static const size_t _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES; + enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES }; #ifdef __GTHREADS static __gthread_once_t _S_once; @@ -400,12 +399,12 @@ namespace std private: inline void _M_add_reference() const throw() - { __gnu_cxx::__atomic_add(&_M_refcount, 1); } + { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); } inline void _M_remove_reference() const throw() { - if (__gnu_cxx::__exchange_and_add(&_M_refcount, -1) == 1) + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1) { try { delete this; } @@ -505,12 +504,12 @@ namespace std inline void _M_add_reference() throw() - { __gnu_cxx::__atomic_add(&_M_refcount, 1); } + { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); } inline void _M_remove_reference() throw() { - if (__gnu_cxx::__exchange_and_add(&_M_refcount, -1) == 1) + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1) { try { delete this; } @@ -534,8 +533,10 @@ namespace std _M_check_same_name() { bool __ret = true; - for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i) - __ret = std::strcmp(_M_names[__i], _M_names[__i + 1]) == 0; + if (_M_names[1]) + // We must actually compare all the _M_names: can be all equal! + for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i) + __ret = std::strcmp(_M_names[__i], _M_names[__i + 1]) == 0; return __ret; } @@ -557,11 +558,7 @@ namespace std { _M_install_facet(&_Facet::id, __facet); } void - _M_install_cache(const facet* __cache, size_t __index) throw() - { - __cache->_M_add_reference(); - _M_caches[__index] = __cache; - } + _M_install_cache(const facet*, size_t); }; template @@ -569,31 +566,17 @@ namespace std { _M_impl = new _Impl(*__other._M_impl, 1); - char* _M_tmp_names[_S_categories_size]; - size_t __i = 0; try - { - for (; __i < _S_categories_size; ++__i) - { - _M_tmp_names[__i] = new char[2]; - std::strcpy(_M_tmp_names[__i], "*"); - } - _M_impl->_M_install_facet(&_Facet::id, __f); - } + { _M_impl->_M_install_facet(&_Facet::id, __f); } catch(...) { _M_impl->_M_remove_reference(); - for (size_t __j = 0; __j < __i; ++__j) - delete [] _M_tmp_names[__j]; __throw_exception_again; } - - for (size_t __k = 0; __k < _S_categories_size; ++__k) - { - delete [] _M_impl->_M_names[__k]; - _M_impl->_M_names[__k] = _M_tmp_names[__k]; - } + delete [] _M_impl->_M_names[0]; + _M_impl->_M_names[0] = 0; // Unnamed. } -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/locale_facets.h b/contrib/libstdc++/include/bits/locale_facets.h index db0e951..e31ae17 100644 --- a/contrib/libstdc++/include/bits/locale_facets.h +++ b/contrib/libstdc++/include/bits/locale_facets.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,15 +28,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 22.1 Locales -// - /** @file locale_facets.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// +// ISO C++ 14882: 22.1 Locales +// + #ifndef _LOCALE_FACETS_H #define _LOCALE_FACETS_H 1 @@ -44,12 +44,14 @@ #include // For struct tm #include // For wctype_t +#include #include #include // For ios_base, ios_base::iostate #include +#include + +_GLIBCXX_BEGIN_NAMESPACE(std) -namespace std -{ // NB: Don't instantiate required wchar_t facets if no wchar_t support. #ifdef _GLIBCXX_USE_WCHAR_T # define _GLIBCXX_NUM_FACETS 28 @@ -129,7 +131,6 @@ namespace std // 22.2.1.1 Template class ctype // Include host and configuration specific ctype enums for ctype_base. - #include // Common base for ctype<_CharT>. /** @@ -1504,10 +1505,7 @@ namespace std use_facet >(const locale& __loc); #endif //_GLIBCXX_USE_WCHAR_T - // Include host and configuration specific ctype inlines. - #include - - // 22.2.1.2 Template class ctype_byname + /// @brief class ctype_byname [22.2.1.2]. template class ctype_byname : public ctype<_CharT> { @@ -1522,15 +1520,22 @@ namespace std ~ctype_byname() { }; }; - // 22.2.1.4 Class ctype_byname specializations. + /// 22.2.1.4 Class ctype_byname specializations. template<> ctype_byname::ctype_byname(const char*, size_t refs); template<> ctype_byname::ctype_byname(const char*, size_t refs); - // 22.2.1.5 Template class codecvt - #include +_GLIBCXX_END_NAMESPACE + +// Include host and configuration specific ctype inlines. +#include + +// 22.2.1.5 Template class codecvt +#include + +_GLIBCXX_BEGIN_NAMESPACE(std) // 22.2.2 The numeric category. class __num_base @@ -1884,6 +1889,7 @@ namespace std numpunct::_M_initialize_numpunct(__c_locale __cloc); #endif + /// @brief class numpunct_byname [22.2.3.2]. template class numpunct_byname : public numpunct<_CharT> { @@ -1909,6 +1915,7 @@ namespace std ~numpunct_byname() { } }; +_GLIBCXX_BEGIN_LDBL_NAMESPACE /** * @brief Facet for parsing number strings. * @@ -1949,7 +1956,7 @@ namespace std * @brief Numeric parsing. * * Parses the input stream into the bool @a v. It does so by calling - * num_put::do_put(). + * num_get::do_get(). * * If ios_base::boolalpha is set, attempts to read * ctype::truename() or ctype::falsename(). Sets @@ -1978,7 +1985,7 @@ namespace std * @brief Numeric parsing. * * Parses the input stream into the integral variable @a v. It does so - * by calling num_put::do_put(). + * by calling num_get::do_get(). * * Parsing is affected by the flag settings in @a io. * @@ -2042,7 +2049,7 @@ namespace std * @brief Numeric parsing. * * Parses the input stream into the integral variable @a v. It does so - * by calling num_put::do_put(). + * by calling num_get::do_get(). * * The input characters are parsed like the scanf %g specifier. The * matching type length modifier is also used. @@ -2083,7 +2090,7 @@ namespace std * @brief Numeric parsing. * * Parses the input stream into the pointer variable @a v. It does so - * by calling num_put::do_put(). + * by calling num_get::do_get(). * * The input characters are parsed like the scanf %p specifier. * @@ -2123,6 +2130,44 @@ namespace std _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&, _ValueT& __v) const; + template + typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, int>::__type + _M_find(const _CharT2*, size_t __len, _CharT2 __c) const + { + int __ret = -1; + if (__len <= 10) + { + if (__c >= _CharT2('0') && __c < _CharT2(_CharT2('0') + __len)) + __ret = __c - _CharT2('0'); + } + else + { + if (__c >= _CharT2('0') && __c <= _CharT2('9')) + __ret = __c - _CharT2('0'); + else if (__c >= _CharT2('a') && __c <= _CharT2('f')) + __ret = 10 + (__c - _CharT2('a')); + else if (__c >= _CharT2('A') && __c <= _CharT2('F')) + __ret = 10 + (__c - _CharT2('A')); + } + return __ret; + } + + template + typename __gnu_cxx::__enable_if::__value, + int>::__type + _M_find(const _CharT2* __zero, size_t __len, _CharT2 __c) const + { + int __ret = -1; + const char_type* __q = char_traits<_CharT2>::find(__zero, __len, __c); + if (__q) + { + __ret = __q - __zero; + if (__ret > 15) + __ret -= 6; + } + return __ret; + } + //@{ /** * @brief Numeric parsing. @@ -2175,13 +2220,27 @@ namespace std do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, double&) const; + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + __do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, + double&) const; +#else virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, long double&) const; +#endif virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, void*&) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, + long double&) const; +#endif //@} }; @@ -2437,17 +2496,30 @@ namespace std virtual iter_type do_put(iter_type, ios_base&, char_type __fill, double __v) const; + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + __do_put(iter_type, ios_base&, char_type __fill, double __v) const; +#else virtual iter_type do_put(iter_type, ios_base&, char_type __fill, long double __v) const; +#endif virtual iter_type do_put(iter_type, ios_base&, char_type __fill, const void* __v) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + do_put(iter_type, ios_base&, char_type __fill, long double __v) const; +#endif //@} }; template locale::id num_put<_CharT, _OutIter>::id; +_GLIBCXX_END_LDBL_NAMESPACE /** * @brief Facet for localized string comparison. @@ -2636,6 +2708,7 @@ namespace std collate::_M_transform(wchar_t*, const wchar_t*, size_t) const; #endif + /// @brief class collate_byname [22.2.4.2]. template class collate_byname : public collate<_CharT> { @@ -2830,6 +2903,8 @@ namespace std explicit __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0); + // FIXME: for error checking purposes _M_put should return the return + // value of strftime/wcsftime. void _M_put(_CharT* __s, size_t __maxlen, const _CharT* __format, const tm* __tm) const; @@ -2959,9 +3034,13 @@ namespace std const tm*) const; #endif +_GLIBCXX_END_NAMESPACE + // Include host and configuration specific timepunct functions. #include +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @brief Facet for parsing dates and times. * @@ -3286,6 +3365,7 @@ namespace std template locale::id time_get<_CharT, _InIter>::id; + /// @brief class time_get_byname [22.2.5.2]. template class time_get_byname : public time_get<_CharT, _InIter> { @@ -3409,6 +3489,7 @@ namespace std template locale::id time_put<_CharT, _OutIter>::id; + /// @brief class time_put_byname [22.2.5.4]. template class time_put_byname : public time_put<_CharT, _OutIter> { @@ -3916,6 +3997,7 @@ namespace std const char*); #endif + /// @brief class moneypunct_byname [22.2.6.4]. template class moneypunct_byname : public moneypunct<_CharT, _Intl> { @@ -3946,6 +4028,7 @@ namespace std template const bool moneypunct_byname<_CharT, _Intl>::intl; +_GLIBCXX_BEGIN_LDBL_NAMESPACE /** * @brief Facet for parsing monetary amounts. * @@ -4057,9 +4140,16 @@ namespace std * value. This function is a hook for derived classes to change the * value returned. @see get() for details. */ + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + __do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, double& __units) const; +#else virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, ios_base::iostate& __err, long double& __units) const; +#endif /** * @brief Read and parse a monetary value. @@ -4072,6 +4162,13 @@ namespace std do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, ios_base::iostate& __err, string_type& __digits) const; + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, long double& __units) const; +#endif + template iter_type _M_extract(iter_type __s, iter_type __end, ios_base& __io, @@ -4184,9 +4281,16 @@ namespace std * @param units Place to store result of parsing. * @return Iterator after writing. */ + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + double __units) const; +#else virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, long double __units) const; +#endif /** * @brief Format and output a monetary value. @@ -4210,6 +4314,13 @@ namespace std do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, const string_type& __digits) const; + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + long double __units) const; +#endif + template iter_type _M_insert(iter_type __s, ios_base& __io, char_type __fill, @@ -4219,6 +4330,8 @@ namespace std template locale::id money_put<_CharT, _OutIter>::id; +_GLIBCXX_END_LDBL_NAMESPACE + /** * @brief Messages facet base class providing catalog typedef. */ @@ -4463,7 +4576,8 @@ namespace std messages::do_get(catalog, int, int, const wstring&) const; #endif - template + /// @brief class messages_byname [22.2.7.2]. + template class messages_byname : public messages<_CharT> { public: @@ -4479,80 +4593,96 @@ namespace std { } }; +_GLIBCXX_END_NAMESPACE + // Include host and configuration specific messages functions. #include +_GLIBCXX_BEGIN_NAMESPACE(std) // Subclause convenience interfaces, inlines. // NB: These are inline because, when used in a loop, some compilers // can hoist the body out of the loop; then it's just as fast as the // C is*() function. - //@{ - /// Convenience interface to ctype.is(). + + /// Convenience interface to ctype.is(ctype_base::space, __c). template inline bool isspace(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::space, __c); } + /// Convenience interface to ctype.is(ctype_base::print, __c). template inline bool isprint(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::print, __c); } + /// Convenience interface to ctype.is(ctype_base::cntrl, __c). template inline bool iscntrl(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::cntrl, __c); } + /// Convenience interface to ctype.is(ctype_base::upper, __c). template inline bool isupper(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::upper, __c); } + /// Convenience interface to ctype.is(ctype_base::lower, __c). template - inline bool islower(_CharT __c, const locale& __loc) + inline bool + islower(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::lower, __c); } + /// Convenience interface to ctype.is(ctype_base::alpha, __c). template inline bool isalpha(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::alpha, __c); } + /// Convenience interface to ctype.is(ctype_base::digit, __c). template inline bool isdigit(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::digit, __c); } + /// Convenience interface to ctype.is(ctype_base::punct, __c). template inline bool ispunct(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::punct, __c); } + /// Convenience interface to ctype.is(ctype_base::xdigit, __c). template inline bool isxdigit(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::xdigit, __c); } + /// Convenience interface to ctype.is(ctype_base::alnum, __c). template inline bool isalnum(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::alnum, __c); } + /// Convenience interface to ctype.is(ctype_base::graph, __c). template inline bool isgraph(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::graph, __c); } + /// Convenience interface to ctype.toupper(__c). template inline _CharT toupper(_CharT __c, const locale& __loc) { return use_facet >(__loc).toupper(__c); } + /// Convenience interface to ctype.tolower(__c). template inline _CharT tolower(_CharT __c, const locale& __loc) { return use_facet >(__loc).tolower(__c); } - //@} -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/locale_facets.tcc b/contrib/libstdc++/include/bits/locale_facets.tcc index 4f65844..d3c47ff 100644 --- a/contrib/libstdc++/include/bits/locale_facets.tcc +++ b/contrib/libstdc++/include/bits/locale_facets.tcc @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,7 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// Warning: this file is not meant for user inclusion. Use . +/** @file locale_facets.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ #ifndef _LOCALE_FACETS_TCC #define _LOCALE_FACETS_TCC 1 @@ -38,9 +41,10 @@ #include // For numeric_limits #include // For bad_cast. #include +#include + +_GLIBCXX_BEGIN_NAMESPACE(std) -namespace std -{ template locale locale::combine(const locale& __other) const @@ -190,7 +194,8 @@ namespace std char* __grouping = new char[_M_grouping_size]; __np.grouping().copy(__grouping, _M_grouping_size); _M_grouping = __grouping; - _M_use_grouping = _M_grouping_size && __np.grouping()[0] != 0; + _M_use_grouping = (_M_grouping_size + && static_cast(__np.grouping()[0]) > 0); _M_truename_size = __np.truename().size(); _CharT* __truename = new _CharT[_M_truename_size]; @@ -225,7 +230,8 @@ namespace std char* __grouping = new char[_M_grouping_size]; __mp.grouping().copy(__grouping, _M_grouping_size); _M_grouping = __grouping; - _M_use_grouping = _M_grouping_size && __mp.grouping()[0] != 0; + _M_use_grouping = (_M_grouping_size + && static_cast(__mp.grouping()[0]) > 0); _M_decimal_point = __mp.decimal_point(); _M_thousands_sep = __mp.thousands_sep(); @@ -267,6 +273,8 @@ namespace std __verify_grouping(const char* __grouping, size_t __grouping_size, const string& __grouping_tmp); +_GLIBCXX_BEGIN_LDBL_NAMESPACE + template _InIter num_get<_CharT, _InIter>:: @@ -274,33 +282,38 @@ namespace std ios_base::iostate& __err, string& __xtrc) const { typedef char_traits<_CharT> __traits_type; - typedef typename numpunct<_CharT>::__cache_type __cache_type; + typedef __numpunct_cache<_CharT> __cache_type; __use_cache<__cache_type> __uc; const locale& __loc = __io._M_getloc(); const __cache_type* __lc = __uc(__loc); const _CharT* __lit = __lc->_M_atoms_in; + char_type __c = char_type(); - // True if a mantissa is found. - bool __found_mantissa = false; + // True if __beg becomes equal to __end. + bool __testeof = __beg == __end; // First check for sign. - if (__beg != __end) + if (!__testeof) { - const char_type __c = *__beg; + __c = *__beg; const bool __plus = __c == __lit[__num_base::_S_iplus]; if ((__plus || __c == __lit[__num_base::_S_iminus]) && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) && !(__c == __lc->_M_decimal_point)) { __xtrc += __plus ? '+' : '-'; - ++__beg; + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; } } // Next, look for leading zeros. - while (__beg != __end) + bool __found_mantissa = false; + int __sep_pos = 0; + while (!__testeof) { - const char_type __c = *__beg; if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep || __c == __lc->_M_decimal_point) break; @@ -311,7 +324,12 @@ namespace std __xtrc += '0'; __found_mantissa = true; } - ++__beg; + ++__sep_pos; + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; } else break; @@ -323,90 +341,150 @@ namespace std string __found_grouping; if (__lc->_M_use_grouping) __found_grouping.reserve(32); - int __sep_pos = 0; const char_type* __lit_zero = __lit + __num_base::_S_izero; - const char_type* __q; - while (__beg != __end) - { - // According to 22.2.2.1.2, p8-9, first look for thousands_sep - // and decimal_point. - const char_type __c = *__beg; - if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) - { - if (!__found_dec && !__found_sci) - { - // NB: Thousands separator at the beginning of a string - // is a no-no, as is two consecutive thousands separators. - if (__sep_pos) - { - __found_grouping += static_cast(__sep_pos); - __sep_pos = 0; - ++__beg; - } - else - { - __err |= ios_base::failbit; - break; - } - } - else - break; - } - else if (__c == __lc->_M_decimal_point) - { - if (!__found_dec && !__found_sci) - { - // If no grouping chars are seen, no grouping check - // is applied. Therefore __found_grouping is adjusted - // only if decimal_point comes after some thousands_sep. - if (__found_grouping.size()) - __found_grouping += static_cast(__sep_pos); - __xtrc += '.'; - __found_dec = true; - ++__beg; - } - else - break; - } - else if (__q = __traits_type::find(__lit_zero, 10, __c)) - { - __xtrc += __num_base::_S_atoms_in[__q - __lit]; - __found_mantissa = true; - ++__sep_pos; - ++__beg; - } - else if ((__c == __lit[__num_base::_S_ie] - || __c == __lit[__num_base::_S_iE]) - && __found_mantissa && !__found_sci) - { - // Scientific notation. - if (__found_grouping.size() && !__found_dec) - __found_grouping += static_cast(__sep_pos); - __xtrc += 'e'; - __found_sci = true; - // Remove optional plus or minus sign, if they exist. - if (++__beg != __end) - { - const bool __plus = *__beg == __lit[__num_base::_S_iplus]; - if ((__plus || *__beg == __lit[__num_base::_S_iminus]) - && !(__lc->_M_use_grouping - && *__beg == __lc->_M_thousands_sep) - && !(*__beg == __lc->_M_decimal_point)) - { + if (!__lc->_M_allocated) + // "C" locale + while (!__testeof) + { + const int __digit = _M_find(__lit_zero, 10, __c); + if (__digit != -1) + { + __xtrc += '0' + __digit; + __found_mantissa = true; + } + else if (__c == __lc->_M_decimal_point + && !__found_dec && !__found_sci) + { + __xtrc += '.'; + __found_dec = true; + } + else if ((__c == __lit[__num_base::_S_ie] + || __c == __lit[__num_base::_S_iE]) + && !__found_sci && __found_mantissa) + { + // Scientific notation. + __xtrc += 'e'; + __found_sci = true; + + // Remove optional plus or minus sign, if they exist. + if (++__beg != __end) + { + __c = *__beg; + const bool __plus = __c == __lit[__num_base::_S_iplus]; + if (__plus || __c == __lit[__num_base::_S_iminus]) __xtrc += __plus ? '+' : '-'; - ++__beg; - } - } - } - else - // Not a valid input item. - break; - } + else + continue; + } + else + { + __testeof = true; + break; + } + } + else + break; + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + else + while (!__testeof) + { + // According to 22.2.2.1.2, p8-9, first look for thousands_sep + // and decimal_point. + if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + { + if (!__found_dec && !__found_sci) + { + // NB: Thousands separator at the beginning of a string + // is a no-no, as is two consecutive thousands separators. + if (__sep_pos) + { + __found_grouping += static_cast(__sep_pos); + __sep_pos = 0; + } + else + { + // NB: __convert_to_v will not assign __v and will + // set the failbit. + __xtrc.clear(); + break; + } + } + else + break; + } + else if (__c == __lc->_M_decimal_point) + { + if (!__found_dec && !__found_sci) + { + // If no grouping chars are seen, no grouping check + // is applied. Therefore __found_grouping is adjusted + // only if decimal_point comes after some thousands_sep. + if (__found_grouping.size()) + __found_grouping += static_cast(__sep_pos); + __xtrc += '.'; + __found_dec = true; + } + else + break; + } + else + { + const char_type* __q = + __traits_type::find(__lit_zero, 10, __c); + if (__q) + { + __xtrc += '0' + (__q - __lit_zero); + __found_mantissa = true; + ++__sep_pos; + } + else if ((__c == __lit[__num_base::_S_ie] + || __c == __lit[__num_base::_S_iE]) + && !__found_sci && __found_mantissa) + { + // Scientific notation. + if (__found_grouping.size() && !__found_dec) + __found_grouping += static_cast(__sep_pos); + __xtrc += 'e'; + __found_sci = true; + + // Remove optional plus or minus sign, if they exist. + if (++__beg != __end) + { + __c = *__beg; + const bool __plus = __c == __lit[__num_base::_S_iplus]; + if ((__plus || __c == __lit[__num_base::_S_iminus]) + && !(__lc->_M_use_grouping + && __c == __lc->_M_thousands_sep) + && !(__c == __lc->_M_decimal_point)) + __xtrc += __plus ? '+' : '-'; + else + continue; + } + else + { + __testeof = true; + break; + } + } + else + break; + } + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } // Digit grouping is checked. If grouping and found_grouping don't // match, then get very very upset, and set failbit. - if (__lc->_M_use_grouping && __found_grouping.size()) + if (__found_grouping.size()) { // Add the ending grouping if a decimal or 'e'/'E' wasn't found. if (!__found_dec && !__found_sci) @@ -419,11 +497,15 @@ namespace std } // Finish up. - if (__beg == __end) + if (__testeof) __err |= ios_base::eofbit; return __beg; } +_GLIBCXX_END_LDBL_NAMESPACE + +_GLIBCXX_BEGIN_LDBL_NAMESPACE + template template _InIter @@ -431,12 +513,15 @@ namespace std _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io, ios_base::iostate& __err, _ValueT& __v) const { - typedef char_traits<_CharT> __traits_type; - typedef typename numpunct<_CharT>::__cache_type __cache_type; + typedef char_traits<_CharT> __traits_type; + using __gnu_cxx::__add_unsigned; + typedef typename __add_unsigned<_ValueT>::__type __unsigned_type; + typedef __numpunct_cache<_CharT> __cache_type; __use_cache<__cache_type> __uc; const locale& __loc = __io._M_getloc(); const __cache_type* __lc = __uc(__loc); const _CharT* __lit = __lc->_M_atoms_in; + char_type __c = char_type(); // NB: Iff __basefield == 0, __base can change based on contents. const ios_base::fmtflags __basefield = __io.flags() @@ -444,165 +529,165 @@ namespace std const bool __oct = __basefield == ios_base::oct; int __base = __oct ? 8 : (__basefield == ios_base::hex ? 16 : 10); - // True if numeric digits are found. - bool __found_num = false; + // True if __beg becomes equal to __end. + bool __testeof = __beg == __end; // First check for sign. bool __negative = false; - if (__beg != __end) + if (!__testeof) { - const char_type __c = *__beg; + __c = *__beg; if (numeric_limits<_ValueT>::is_signed) __negative = __c == __lit[__num_base::_S_iminus]; if ((__negative || __c == __lit[__num_base::_S_iplus]) && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) && !(__c == __lc->_M_decimal_point)) - ++__beg; + { + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } } // Next, look for leading zeros and check required digits // for base formats. - while (__beg != __end) + bool __found_zero = false; + int __sep_pos = 0; + while (!__testeof) { - const char_type __c = *__beg; if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep || __c == __lc->_M_decimal_point) break; else if (__c == __lit[__num_base::_S_izero] - && (!__found_num || __base == 10)) + && (!__found_zero || __base == 10)) { - __found_num = true; - ++__beg; + __found_zero = true; + ++__sep_pos; + if (__basefield == 0) + __base = 8; + if (__base == 8) + __sep_pos = 0; } - else if (__found_num) + else if (__found_zero + && (__c == __lit[__num_base::_S_ix] + || __c == __lit[__num_base::_S_iX])) { - if (__c == __lit[__num_base::_S_ix] - || __c == __lit[__num_base::_S_iX]) + if (__basefield == 0) + __base = 16; + if (__base == 16) { - if (__basefield == 0) - __base = 16; - if (__base == 16) - { - __found_num = false; - ++__beg; - } + __found_zero = false; + __sep_pos = 0; } - else if (__basefield == 0) - __base = 8; - break; + else + break; } else break; - } + if (++__beg != __end) + { + __c = *__beg; + if (!__found_zero) + break; + } + else + __testeof = true; + } + // At this point, base is determined. If not hex, only allow // base digits as valid input. - const size_t __len = __base == 16 ? (__num_base::_S_iend - - __num_base::_S_izero) - : __base; + const size_t __len = (__base == 16 ? __num_base::_S_iend + - __num_base::_S_izero : __base); // Extract. string __found_grouping; if (__lc->_M_use_grouping) __found_grouping.reserve(32); - int __sep_pos = 0; - bool __overflow = false; - _ValueT __result = 0; + bool __testfail = false; + const __unsigned_type __max = __negative ? + -numeric_limits<_ValueT>::min() : numeric_limits<_ValueT>::max(); + const __unsigned_type __smax = __max / __base; + __unsigned_type __result = 0; + int __digit = 0; const char_type* __lit_zero = __lit + __num_base::_S_izero; - const char_type* __q; - if (__negative) - { - const _ValueT __min = numeric_limits<_ValueT>::min() / __base; - for (; __beg != __end; ++__beg) - { - // According to 22.2.2.1.2, p8-9, first look for thousands_sep - // and decimal_point. - const char_type __c = *__beg; - if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) - { - // NB: Thousands separator at the beginning of a string - // is a no-no, as is two consecutive thousands separators. - if (__sep_pos) - { - __found_grouping += static_cast(__sep_pos); - __sep_pos = 0; - } - else - { - __err |= ios_base::failbit; - break; - } - } - else if (__c == __lc->_M_decimal_point) - break; - else if (__q = __traits_type::find(__lit_zero, __len, __c)) - { - int __digit = __q - __lit_zero; - if (__digit > 15) - __digit -= 6; - if (__result < __min) - __overflow = true; - else - { - const _ValueT __new_result = __result * __base - - __digit; - __overflow |= __new_result > __result; - __result = __new_result; - ++__sep_pos; - __found_num = true; - } - } - else - // Not a valid input item. - break; - } - } - else - { - const _ValueT __max = numeric_limits<_ValueT>::max() / __base; - for (; __beg != __end; ++__beg) - { - const char_type __c = *__beg; - if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) - { - if (__sep_pos) - { - __found_grouping += static_cast(__sep_pos); - __sep_pos = 0; - } - else - { - __err |= ios_base::failbit; - break; - } - } - else if (__c == __lc->_M_decimal_point) - break; - else if (__q = __traits_type::find(__lit_zero, __len, __c)) - { - int __digit = __q - __lit_zero; - if (__digit > 15) - __digit -= 6; - if (__result > __max) - __overflow = true; - else - { - const _ValueT __new_result = __result * __base - + __digit; - __overflow |= __new_result < __result; - __result = __new_result; - ++__sep_pos; - __found_num = true; - } - } - else - break; - } - } + if (!__lc->_M_allocated) + // "C" locale + while (!__testeof) + { + __digit = _M_find(__lit_zero, __len, __c); + if (__digit == -1) + break; + + if (__result > __smax) + __testfail = true; + else + { + __result *= __base; + __testfail |= __result > __max - __digit; + __result += __digit; + ++__sep_pos; + } + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + else + while (!__testeof) + { + // According to 22.2.2.1.2, p8-9, first look for thousands_sep + // and decimal_point. + if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + { + // NB: Thousands separator at the beginning of a string + // is a no-no, as is two consecutive thousands separators. + if (__sep_pos) + { + __found_grouping += static_cast(__sep_pos); + __sep_pos = 0; + } + else + { + __testfail = true; + break; + } + } + else if (__c == __lc->_M_decimal_point) + break; + else + { + const char_type* __q = + __traits_type::find(__lit_zero, __len, __c); + if (!__q) + break; + + __digit = __q - __lit_zero; + if (__digit > 15) + __digit -= 6; + if (__result > __smax) + __testfail = true; + else + { + __result *= __base; + __testfail |= __result > __max - __digit; + __result += __digit; + ++__sep_pos; + } + } + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + // Digit grouping is checked. If grouping and found_grouping don't // match, then get very very upset, and set failbit. - if (__lc->_M_use_grouping && __found_grouping.size()) + if (__found_grouping.size()) { // Add the ending grouping. __found_grouping += static_cast(__sep_pos); @@ -613,13 +698,13 @@ namespace std __err |= ios_base::failbit; } - if (!(__err & ios_base::failbit) && !__overflow - && __found_num) - __v = __result; + if (!__testfail && (__sep_pos || __found_zero + || __found_grouping.size())) + __v = __negative ? -__result : __result; else __err |= ios_base::failbit; - if (__beg == __end) + if (__testeof) __err |= ios_base::eofbit; return __beg; } @@ -647,8 +732,7 @@ namespace std else { // Parse bool values as alphanumeric. - typedef char_traits<_CharT> __traits_type; - typedef typename numpunct<_CharT>::__cache_type __cache_type; + typedef __numpunct_cache<_CharT> __cache_type; __use_cache<__cache_type> __uc; const locale& __loc = __io._M_getloc(); const __cache_type* __lc = __uc(__loc); @@ -656,22 +740,28 @@ namespace std bool __testf = true; bool __testt = true; size_t __n; - for (__n = 0; __beg != __end; ++__n, ++__beg) + bool __testeof = __beg == __end; + for (__n = 0; !__testeof; ++__n) { + const char_type __c = *__beg; + if (__testf) if (__n < __lc->_M_falsename_size) - __testf = *__beg == __lc->_M_falsename[__n]; + __testf = __c == __lc->_M_falsename[__n]; else break; if (__testt) if (__n < __lc->_M_truename_size) - __testt = *__beg == __lc->_M_truename[__n]; + __testt = __c == __lc->_M_truename[__n]; else break; if (!__testf && !__testt) break; + + if (++__beg == __end) + __testeof = true; } if (__testf && __n == __lc->_M_falsename_size) __v = 0; @@ -680,7 +770,7 @@ namespace std else __err |= ios_base::failbit; - if (__beg == __end) + if (__testeof) __err |= ios_base::eofbit; } return __beg; @@ -756,6 +846,21 @@ namespace std return __beg; } +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + template + _InIter + num_get<_CharT, _InIter>:: + __do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, double& __v) const + { + string __xtrc; + __xtrc.reserve(32); + __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc); + std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale()); + return __beg; + } +#endif + template _InIter num_get<_CharT, _InIter>:: @@ -788,8 +893,6 @@ namespace std if (!(__err & ios_base::failbit)) __v = reinterpret_cast(__ul); - else - __err |= ios_base::failbit; return __beg; } @@ -808,92 +911,33 @@ namespace std __len = static_cast(__w); } - // Forwarding functions to peel signed from unsigned integer types. - template - inline int - __int_to_char(_CharT* __bufend, long __v, const _CharT* __lit, - ios_base::fmtflags __flags) - { - unsigned long __ul = static_cast(__v); - bool __neg = false; - if (__v < 0) - { - __ul = -__ul; - __neg = true; - } - return __int_to_char(__bufend, __ul, __lit, __flags, __neg); - } - - template - inline int - __int_to_char(_CharT* __bufend, unsigned long __v, const _CharT* __lit, - ios_base::fmtflags __flags) - { - // About showpos, see Table 60 and C99 7.19.6.1, p6 (+). - return __int_to_char(__bufend, __v, __lit, - __flags & ~ios_base::showpos, false); - } - -#ifdef _GLIBCXX_USE_LONG_LONG - template - inline int - __int_to_char(_CharT* __bufend, long long __v, const _CharT* __lit, - ios_base::fmtflags __flags) - { - unsigned long long __ull = static_cast(__v); - bool __neg = false; - if (__v < 0) - { - __ull = -__ull; - __neg = true; - } - return __int_to_char(__bufend, __ull, __lit, __flags, __neg); - } - - template - inline int - __int_to_char(_CharT* __bufend, unsigned long long __v, - const _CharT* __lit, ios_base::fmtflags __flags) - { return __int_to_char(__bufend, __v, __lit, - __flags & ~ios_base::showpos, false); } -#endif +_GLIBCXX_END_LDBL_NAMESPACE template int __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit, - ios_base::fmtflags __flags, bool __neg) + ios_base::fmtflags __flags, bool __dec) { - // Don't write base if already 0. - const bool __showbase = (__flags & ios_base::showbase) && __v; - const ios_base::fmtflags __basefield = __flags & ios_base::basefield; - _CharT* __buf = __bufend - 1; - - if (__builtin_expect(__basefield != ios_base::oct && - __basefield != ios_base::hex, true)) + _CharT* __buf = __bufend; + if (__builtin_expect(__dec, true)) { // Decimal. do { - *__buf-- = __lit[(__v % 10) + __num_base::_S_odigits]; + *--__buf = __lit[(__v % 10) + __num_base::_S_odigits]; __v /= 10; } while (__v != 0); - if (__neg) - *__buf-- = __lit[__num_base::_S_ominus]; - else if (__flags & ios_base::showpos) - *__buf-- = __lit[__num_base::_S_oplus]; } - else if (__basefield == ios_base::oct) + else if ((__flags & ios_base::basefield) == ios_base::oct) { // Octal. do { - *__buf-- = __lit[(__v & 0x7) + __num_base::_S_odigits]; + *--__buf = __lit[(__v & 0x7) + __num_base::_S_odigits]; __v >>= 3; } while (__v != 0); - if (__showbase) - *__buf-- = __lit[__num_base::_S_odigits]; } else { @@ -903,54 +947,27 @@ namespace std : __num_base::_S_odigits; do { - *__buf-- = __lit[(__v & 0xf) + __case_offset]; + *--__buf = __lit[(__v & 0xf) + __case_offset]; __v >>= 4; } while (__v != 0); - if (__showbase) - { - // 'x' or 'X' - *__buf-- = __lit[__num_base::_S_ox + __uppercase]; - // '0' - *__buf-- = __lit[__num_base::_S_odigits]; - } } - return __bufend - __buf - 1; + return __bufend - __buf; } +_GLIBCXX_BEGIN_LDBL_NAMESPACE + template void num_put<_CharT, _OutIter>:: _M_group_int(const char* __grouping, size_t __grouping_size, _CharT __sep, - ios_base& __io, _CharT* __new, _CharT* __cs, int& __len) const + ios_base&, _CharT* __new, _CharT* __cs, int& __len) const { - // By itself __add_grouping cannot deal correctly with __cs when - // ios::showbase is set and ios_base::oct || ios_base::hex. - // Therefore we take care "by hand" of the initial 0, 0x or 0X. - // However, remember that the latter do not occur if the number - // printed is '0' (__len == 1). - streamsize __off = 0; - const ios_base::fmtflags __basefield = __io.flags() - & ios_base::basefield; - if ((__io.flags() & ios_base::showbase) && __len > 1) - if (__basefield == ios_base::oct) - { - __off = 1; - __new[0] = __cs[0]; - } - else if (__basefield == ios_base::hex) - { - __off = 2; - __new[0] = __cs[0]; - __new[1] = __cs[1]; - } - _CharT* __p; - __p = std::__add_grouping(__new + __off, __sep, __grouping, - __grouping_size, __cs + __off, - __cs + __len); + _CharT* __p = std::__add_grouping(__new, __sep, __grouping, + __grouping_size, __cs, __cs + __len); __len = __p - __new; } - + template template _OutIter @@ -958,33 +975,68 @@ namespace std _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill, _ValueT __v) const { - typedef typename numpunct<_CharT>::__cache_type __cache_type; + using __gnu_cxx::__add_unsigned; + typedef typename __add_unsigned<_ValueT>::__type __unsigned_type; + typedef __numpunct_cache<_CharT> __cache_type; __use_cache<__cache_type> __uc; const locale& __loc = __io._M_getloc(); const __cache_type* __lc = __uc(__loc); const _CharT* __lit = __lc->_M_atoms_out; + const ios_base::fmtflags __flags = __io.flags(); // Long enough to hold hex, dec, and octal representations. - const int __ilen = 4 * sizeof(_ValueT); + const int __ilen = 5 * sizeof(_ValueT); _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __ilen)); // [22.2.2.2.2] Stage 1, numeric conversion to character. // Result is returned right-justified in the buffer. - int __len; - __len = __int_to_char(__cs + __ilen, __v, __lit, __io.flags()); + const ios_base::fmtflags __basefield = __flags & ios_base::basefield; + const bool __dec = (__basefield != ios_base::oct + && __basefield != ios_base::hex); + const __unsigned_type __u = (__v > 0 || !__dec) ? __v : -__v; + int __len = __int_to_char(__cs + __ilen, __u, __lit, __flags, __dec); __cs += __ilen - __len; // Add grouping, if necessary. if (__lc->_M_use_grouping) { - // Grouping can add (almost) as many separators as the - // number of digits, but no more. + // Grouping can add (almost) as many separators as the number + // of digits + space is reserved for numeric base or sign. _CharT* __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) - * __len * 2)); + * (__len + 1) + * 2)); _M_group_int(__lc->_M_grouping, __lc->_M_grouping_size, - __lc->_M_thousands_sep, __io, __cs2, __cs, __len); - __cs = __cs2; + __lc->_M_thousands_sep, __io, __cs2 + 2, __cs, __len); + __cs = __cs2 + 2; + } + + // Complete Stage 1, prepend numeric base or sign. + if (__builtin_expect(__dec, true)) + { + // Decimal. + if (__v > 0) + { + if (__flags & ios_base::showpos + && numeric_limits<_ValueT>::is_signed) + *--__cs = __lit[__num_base::_S_oplus], ++__len; + } + else if (__v) + *--__cs = __lit[__num_base::_S_ominus], ++__len; + } + else if (__flags & ios_base::showbase && __v) + { + if (__basefield == ios_base::oct) + *--__cs = __lit[__num_base::_S_odigits], ++__len; + else + { + // 'x' or 'X' + const bool __uppercase = __flags & ios_base::uppercase; + *--__cs = __lit[__num_base::_S_ox + __uppercase]; + // '0' + *--__cs = __lit[__num_base::_S_odigits]; + __len += 2; + } } // Pad. @@ -1013,10 +1065,10 @@ namespace std // _GLIBCXX_RESOLVE_LIB_DEFECTS // 282. What types does numpunct grouping refer to? // Add grouping, if necessary. - _CharT* __p2; const int __declen = __p ? __p - __cs : __len; - __p2 = std::__add_grouping(__new, __sep, __grouping, __grouping_size, - __cs, __cs + __declen); + _CharT* __p2 = std::__add_grouping(__new, __sep, __grouping, + __grouping_size, + __cs, __cs + __declen); // Tack on decimal part. int __newlen = __p2 - __new; @@ -1028,7 +1080,7 @@ namespace std __len = __newlen; } - // The following code uses snprintf (or sprintf(), when + // The following code uses vsnprintf (or vsprintf(), when // _GLIBCXX_USE_C99 is not defined) to convert floating point values // for insertion into a stream. An optimization would be to replace // them with code that works directly on a wide buffer and then use @@ -1045,15 +1097,13 @@ namespace std _M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod, _ValueT __v) const { - typedef typename numpunct<_CharT>::__cache_type __cache_type; + typedef __numpunct_cache<_CharT> __cache_type; __use_cache<__cache_type> __uc; const locale& __loc = __io._M_getloc(); const __cache_type* __lc = __uc(__loc); // Use default precision if out of range. - streamsize __prec = __io.precision(); - if (__prec < static_cast(0)) - __prec = static_cast(6); + const streamsize __prec = __io.precision() < 0 ? 6 : __io.precision(); const int __max_digits = numeric_limits<_ValueT>::digits10; @@ -1061,24 +1111,23 @@ namespace std int __len; // Long enough for the max format spec. char __fbuf[16]; + __num_base::_S_format_float(__io, __fbuf, __mod); #ifdef _GLIBCXX_USE_C99 // First try a buffer perhaps big enough (most probably sufficient // for non-ios_base::fixed outputs) int __cs_size = __max_digits * 3; char* __cs = static_cast(__builtin_alloca(__cs_size)); - - __num_base::_S_format_float(__io, __fbuf, __mod); - __len = std::__convert_from_v(__cs, __cs_size, __fbuf, __v, - _S_get_c_locale(), __prec); + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __prec, __v); // If the buffer was not large enough, try again with the correct size. if (__len >= __cs_size) { __cs_size = __len + 1; __cs = static_cast(__builtin_alloca(__cs_size)); - __len = std::__convert_from_v(__cs, __cs_size, __fbuf, __v, - _S_get_c_locale(), __prec); + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __prec, __v); } #else // Consider the possibility of long ios_base::fixed outputs @@ -1094,55 +1143,71 @@ namespace std const int __cs_size = __fixed ? __max_exp + __prec + 4 : __max_digits * 2 + __prec; char* __cs = static_cast(__builtin_alloca(__cs_size)); - - __num_base::_S_format_float(__io, __fbuf, __mod); - __len = std::__convert_from_v(__cs, 0, __fbuf, __v, - _S_get_c_locale(), __prec); + __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, __fbuf, + __prec, __v); #endif - // [22.2.2.2.2] Stage 2, convert to char_type, using correct - // numpunct.decimal_point() values for '.' and adding grouping. - const ctype<_CharT>& __ctype = use_facet >(__loc); - - _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) - * __len)); - __ctype.widen(__cs, __cs + __len, __ws); - - // Replace decimal point. - const _CharT __cdec = __ctype.widen('.'); - const _CharT __dec = __lc->_M_decimal_point; - const _CharT* __p; - if (__p = char_traits<_CharT>::find(__ws, __len, __cdec)) - __ws[__p - __ws] = __dec; - - // Add grouping, if necessary. - if (__lc->_M_use_grouping) - { - // Grouping can add (almost) as many separators as the - // number of digits, but no more. - _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) - * __len * 2)); - _M_group_float(__lc->_M_grouping, __lc->_M_grouping_size, - __lc->_M_thousands_sep, __p, __ws2, __ws, __len); - __ws = __ws2; - } - - // Pad. - const streamsize __w = __io.width(); - if (__w > static_cast(__len)) - { - _CharT* __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) - * __w)); - _M_pad(__fill, __w, __io, __ws3, __ws, __len); - __ws = __ws3; - } - __io.width(0); + // [22.2.2.2.2] Stage 2, convert to char_type, using correct + // numpunct.decimal_point() values for '.' and adding grouping. + const ctype<_CharT>& __ctype = use_facet >(__loc); + + _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __len)); + __ctype.widen(__cs, __cs + __len, __ws); + + // Replace decimal point. + _CharT* __wp = 0; + const char* __p = char_traits::find(__cs, __len, '.'); + if (__p) + { + __wp = __ws + (__p - __cs); + *__wp = __lc->_M_decimal_point; + } + + // Add grouping, if necessary. + // N.B. Make sure to not group things like 2e20, i.e., no decimal + // point, scientific notation. + if (__lc->_M_use_grouping + && (__wp || __len < 3 || (__cs[1] <= '9' && __cs[2] <= '9' + && __cs[1] >= '0' && __cs[2] >= '0'))) + { + // Grouping can add (almost) as many separators as the + // number of digits, but no more. + _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __len * 2)); + + streamsize __off = 0; + if (__cs[0] == '-' || __cs[0] == '+') + { + __off = 1; + __ws2[0] = __ws[0]; + __len -= 1; + } + + _M_group_float(__lc->_M_grouping, __lc->_M_grouping_size, + __lc->_M_thousands_sep, __wp, __ws2 + __off, + __ws + __off, __len); + __len += __off; + + __ws = __ws2; + } - // [22.2.2.2.2] Stage 4. - // Write resulting, fully-formatted string to output iterator. - return std::__write(__s, __ws, __len); + // Pad. + const streamsize __w = __io.width(); + if (__w > static_cast(__len)) + { + _CharT* __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __w)); + _M_pad(__fill, __w, __io, __ws3, __ws, __len); + __ws = __ws3; + } + __io.width(0); + + // [22.2.2.2.2] Stage 4. + // Write resulting, fully-formatted string to output iterator. + return std::__write(__s, __ws, __len); } - + template _OutIter num_put<_CharT, _OutIter>:: @@ -1156,7 +1221,7 @@ namespace std } else { - typedef typename numpunct<_CharT>::__cache_type __cache_type; + typedef __numpunct_cache<_CharT> __cache_type; __use_cache<__cache_type> __uc; const locale& __loc = __io._M_getloc(); const __cache_type* __lc = __uc(__loc); @@ -1198,8 +1263,8 @@ namespace std template _OutIter num_put<_CharT, _OutIter>:: - do_put(iter_type __s, ios_base& __b, char_type __fill, long long __v) const - { return _M_insert_int(__s, __b, __fill, __v); } + do_put(iter_type __s, ios_base& __io, char_type __fill, long long __v) const + { return _M_insert_int(__s, __io, __fill, __v); } template _OutIter @@ -1215,6 +1280,14 @@ namespace std do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const { return _M_insert_float(__s, __io, __fill, char(), __v); } +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + template + _OutIter + num_put<_CharT, _OutIter>:: + __do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const + { return _M_insert_float(__s, __io, __fill, char(), __v); } +#endif + template _OutIter num_put<_CharT, _OutIter>:: @@ -1250,8 +1323,7 @@ namespace std typedef char_traits<_CharT> __traits_type; typedef typename string_type::size_type size_type; typedef money_base::part part; - typedef moneypunct<_CharT, _Intl> __moneypunct_type; - typedef typename __moneypunct_type::__cache_type __cache_type; + typedef __moneypunct_cache<_CharT, _Intl> __cache_type; const locale& __loc = __io._M_getloc(); const ctype<_CharT>& __ctype = use_facet >(__loc); @@ -1285,8 +1357,7 @@ namespace std __res.reserve(32); const char_type* __lit_zero = __lit + money_base::_S_zero; - const char_type* __q; - const money_base::pattern __p = __lc->_M_neg_format; + const money_base::pattern __p = __lc->_M_neg_format; for (int __i = 0; __i < 4 && __testvalid; ++__i) { const part __which = static_cast(__p.field[__i]); @@ -1347,35 +1418,41 @@ namespace std // Extract digits, remove and stash away the // grouping of found thousands separators. for (; __beg != __end; ++__beg) - if (__q = __traits_type::find(__lit_zero, 10, *__beg)) - { - __res += money_base::_S_atoms[__q - __lit]; - ++__n; - } - else if (*__beg == __lc->_M_decimal_point && !__testdecfound) - { - __last_pos = __n; - __n = 0; - __testdecfound = true; - } - else if (__lc->_M_use_grouping - && *__beg == __lc->_M_thousands_sep - && !__testdecfound) - { - if (__n) - { - // Mark position for later analysis. - __grouping_tmp += static_cast(__n); - __n = 0; - } - else - { - __testvalid = false; - break; - } - } - else - break; + { + const char_type __c = *__beg; + const char_type* __q = __traits_type::find(__lit_zero, + 10, __c); + if (__q != 0) + { + __res += money_base::_S_atoms[__q - __lit]; + ++__n; + } + else if (__c == __lc->_M_decimal_point + && !__testdecfound) + { + __last_pos = __n; + __n = 0; + __testdecfound = true; + } + else if (__lc->_M_use_grouping + && __c == __lc->_M_thousands_sep + && !__testdecfound) + { + if (__n) + { + // Mark position for later analysis. + __grouping_tmp += static_cast(__n); + __n = 0; + } + else + { + __testvalid = false; + break; + } + } + else + break; + } if (__res.empty()) __testvalid = false; break; @@ -1431,7 +1508,7 @@ namespace std if (!std::__verify_grouping(__lc->_M_grouping, __lc->_M_grouping_size, __grouping_tmp)) - __testvalid = false; + __err |= ios_base::failbit; } // Iff not enough digits were supplied after the decimal-point. @@ -1440,19 +1517,33 @@ namespace std __testvalid = false; } - // Iff no more characters are available. - if (__beg == __end) - __err |= ios_base::eofbit; - // Iff valid sequence is not recognized. if (!__testvalid) __err |= ios_base::failbit; else __units.swap(__res); + // Iff no more characters are available. + if (__beg == __end) + __err |= ios_base::eofbit; return __beg; } +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + template + _InIter + money_get<_CharT, _InIter>:: + __do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, double& __units) const + { + string __str; + __beg = __intl ? _M_extract(__beg, __end, __io, __err, __str) + : _M_extract(__beg, __end, __io, __err, __str); + std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale()); + return __beg; + } +#endif + template _InIter money_get<_CharT, _InIter>:: @@ -1460,10 +1551,8 @@ namespace std ios_base::iostate& __err, long double& __units) const { string __str; - if (__intl) - __beg = _M_extract(__beg, __end, __io, __err, __str); - else - __beg = _M_extract(__beg, __end, __io, __err, __str); + __beg = __intl ? _M_extract(__beg, __end, __io, __err, __str) + : _M_extract(__beg, __end, __io, __err, __str); std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale()); return __beg; } @@ -1472,7 +1561,7 @@ namespace std _InIter money_get<_CharT, _InIter>:: do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, - ios_base::iostate& __err, string_type& __units) const + ios_base::iostate& __err, string_type& __digits) const { typedef typename string::size_type size_type; @@ -1480,20 +1569,15 @@ namespace std const ctype<_CharT>& __ctype = use_facet >(__loc); string __str; - const iter_type __ret = __intl ? _M_extract(__beg, __end, __io, - __err, __str) - : _M_extract(__beg, __end, __io, - __err, __str); + __beg = __intl ? _M_extract(__beg, __end, __io, __err, __str) + : _M_extract(__beg, __end, __io, __err, __str); const size_type __len = __str.size(); if (__len) { - _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) - * __len)); - __ctype.widen(__str.data(), __str.data() + __len, __ws); - __units.assign(__ws, __len); + __digits.resize(__len); + __ctype.widen(__str.data(), __str.data() + __len, &__digits[0]); } - - return __ret; + return __beg; } template @@ -1505,8 +1589,7 @@ namespace std { typedef typename string_type::size_type size_type; typedef money_base::part part; - typedef moneypunct<_CharT, _Intl> __moneypunct_type; - typedef typename __moneypunct_type::__cache_type __cache_type; + typedef __moneypunct_cache<_CharT, _Intl> __cache_type; const locale& __loc = __io._M_getloc(); const ctype<_CharT>& __ctype = use_facet >(__loc); @@ -1522,7 +1605,7 @@ namespace std money_base::pattern __p; const char_type* __sign; size_type __sign_size; - if (*__beg != __lit[money_base::_S_minus]) + if (!(*__beg == __lit[money_base::_S_minus])) { __p = __lc->_M_pos_format; __sign = __lc->_M_positive_sign; @@ -1550,22 +1633,20 @@ namespace std // Add thousands separators to non-decimal digits, per // grouping rules. - int __paddec = __len - __lc->_M_frac_digits; + long __paddec = __len - __lc->_M_frac_digits; if (__paddec > 0) { if (__lc->_M_frac_digits < 0) __paddec = __len; if (__lc->_M_grouping_size) { - _CharT* __ws = - static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) - * 2 * __len)); - _CharT* __ws_end = - std::__add_grouping(__ws, __lc->_M_thousands_sep, + __value.assign(2 * __paddec, char_type()); + _CharT* __vend = + std::__add_grouping(&__value[0], __lc->_M_thousands_sep, __lc->_M_grouping, __lc->_M_grouping_size, __beg, __beg + __paddec); - __value.assign(__ws, __ws_end - __ws); + __value.erase(__vend - &__value[0]); } else __value.assign(__beg, __paddec); @@ -1658,7 +1739,16 @@ namespace std __io.width(0); return __s; } - + +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + template + _OutIter + money_put<_CharT, _OutIter>:: + __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + double __units) const + { return this->do_put(__s, __intl, __io, __fill, (long double) __units); } +#endif + template _OutIter money_put<_CharT, _OutIter>:: @@ -1673,27 +1763,25 @@ namespace std char* __cs = static_cast(__builtin_alloca(__cs_size)); // _GLIBCXX_RESOLVE_LIB_DEFECTS // 328. Bad sprintf format modifier in money_put<>::do_put() - int __len = std::__convert_from_v(__cs, __cs_size, "%.*Lf", __units, - _S_get_c_locale(), 0); + int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + "%.*Lf", 0, __units); // If the buffer was not large enough, try again with the correct size. if (__len >= __cs_size) { __cs_size = __len + 1; __cs = static_cast(__builtin_alloca(__cs_size)); - __len = std::__convert_from_v(__cs, __cs_size, "%.*Lf", __units, - _S_get_c_locale(), 0); + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + "%.*Lf", 0, __units); } #else // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'. const int __cs_size = numeric_limits::max_exponent10 + 3; char* __cs = static_cast(__builtin_alloca(__cs_size)); - int __len = std::__convert_from_v(__cs, 0, "%.*Lf", __units, - _S_get_c_locale(), 0); + int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf", + 0, __units); #endif - _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) - * __cs_size)); - __ctype.widen(__cs, __cs + __len, __ws); - const string_type __digits(__ws, __len); + string_type __digits(__len, char_type()); + __ctype.widen(__cs, __cs + __len, &__digits[0]); return __intl ? _M_insert(__s, __io, __fill, __digits) : _M_insert(__s, __io, __fill, __digits); } @@ -1706,6 +1794,7 @@ namespace std { return __intl ? _M_insert(__s, __io, __fill, __digits) : _M_insert(__s, __io, __fill, __digits); } +_GLIBCXX_END_LDBL_NAMESPACE // NB: Not especially useful. Without an ios_base object or some // kind of locale reference, we are left clawing at the air where @@ -1729,7 +1818,8 @@ namespace std const ctype<_CharT>& __ctype = use_facet >(__loc); const size_t __len = char_traits<_CharT>::length(__format); - for (size_t __i = 0; __beg != __end && __i < __len && !__err; ++__i) + ios_base::iostate __tmperr = ios_base::goodbit; + for (size_t __i = 0; __beg != __end && __i < __len && !__tmperr; ++__i) { if (__ctype.narrow(__format[__i], 0) == '%') { @@ -1747,14 +1837,14 @@ namespace std const char_type* __days1[7]; __tp._M_days_abbreviated(__days1); __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1, - 7, __io, __err); + 7, __io, __tmperr); break; case 'A': // Weekday name [tm_wday]. const char_type* __days2[7]; __tp._M_days(__days2); __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2, - 7, __io, __err); + 7, __io, __tmperr); break; case 'h': case 'b': @@ -1762,77 +1852,77 @@ namespace std const char_type* __months1[12]; __tp._M_months_abbreviated(__months1); __beg = _M_extract_name(__beg, __end, __tm->tm_mon, - __months1, 12, __io, __err); + __months1, 12, __io, __tmperr); break; case 'B': // Month name [tm_mon]. const char_type* __months2[12]; __tp._M_months(__months2); __beg = _M_extract_name(__beg, __end, __tm->tm_mon, - __months2, 12, __io, __err); + __months2, 12, __io, __tmperr); break; case 'c': // Default time and date representation. const char_type* __dt[2]; __tp._M_date_time_formats(__dt); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __dt[0]); break; case 'd': // Day [01, 31]. [tm_mday] __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2, - __io, __err); + __io, __tmperr); break; case 'e': // Day [1, 31], with single digits preceded by // space. [tm_mday] if (__ctype.is(ctype_base::space, *__beg)) __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9, - 1, __io, __err); + 1, __io, __tmperr); else __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31, - 2, __io, __err); + 2, __io, __tmperr); break; case 'D': // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year] __cs = "%m/%d/%y"; __ctype.widen(__cs, __cs + 9, __wcs); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __wcs); break; case 'H': // Hour [00, 23]. [tm_hour] __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2, - __io, __err); + __io, __tmperr); break; case 'I': // Hour [01, 12]. [tm_hour] __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2, - __io, __err); + __io, __tmperr); break; case 'm': // Month [01, 12]. [tm_mon] __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2, - __io, __err); - if (!__err) + __io, __tmperr); + if (!__tmperr) __tm->tm_mon = __mem - 1; break; case 'M': // Minute [00, 59]. [tm_min] __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2, - __io, __err); + __io, __tmperr); break; case 'n': if (__ctype.narrow(*__beg, 0) == '\n') ++__beg; else - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; break; case 'R': // Equivalent to (%H:%M). __cs = "%H:%M"; __ctype.widen(__cs, __cs + 6, __wcs); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __wcs); break; case 'S': @@ -1843,46 +1933,46 @@ namespace std #else __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2, #endif - __io, __err); + __io, __tmperr); break; case 't': if (__ctype.narrow(*__beg, 0) == '\t') ++__beg; else - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; break; case 'T': // Equivalent to (%H:%M:%S). __cs = "%H:%M:%S"; __ctype.widen(__cs, __cs + 9, __wcs); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __wcs); break; case 'x': // Locale's date. const char_type* __dates[2]; __tp._M_date_formats(__dates); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __dates[0]); break; case 'X': // Locale's time. const char_type* __times[2]; __tp._M_time_formats(__times); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, __tm, __times[0]); break; case 'y': case 'C': // C99 // Two digit year. [tm_year] __beg = _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2, - __io, __err); + __io, __tmperr); break; case 'Y': // Year [1900). [tm_year] __beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4, - __io, __err); - if (!__err) + __io, __tmperr); + if (!__tmperr) __tm->tm_year = __mem - 1900; break; case 'Z': @@ -1892,25 +1982,25 @@ namespace std int __tmp; __beg = _M_extract_name(__beg, __end, __tmp, __timepunct_cache<_CharT>::_S_timezones, - 14, __io, __err); + 14, __io, __tmperr); // GMT requires special effort. - if (__beg != __end && !__err && __tmp == 0 + if (__beg != __end && !__tmperr && __tmp == 0 && (*__beg == __ctype.widen('-') || *__beg == __ctype.widen('+'))) { __beg = _M_extract_num(__beg, __end, __tmp, 0, 23, 2, - __io, __err); + __io, __tmperr); __beg = _M_extract_num(__beg, __end, __tmp, 0, 59, 2, - __io, __err); + __io, __tmperr); } } else - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; break; default: // Not recognized. - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; } } else @@ -1919,9 +2009,13 @@ namespace std if (__format[__i] == *__beg) ++__beg; else - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; } } + + if (__tmperr) + __err |= ios_base::failbit; + return __beg; } @@ -1959,6 +2053,7 @@ namespace std __member = __value; else __err |= ios_base::failbit; + return __beg; } @@ -2007,7 +2102,7 @@ namespace std for (size_t __i3 = 0; __i3 < __nmatches;) { __name = __names[__matches[__i3]]; - if (__name[__pos] != *__beg) + if (!(__name[__pos] == *__beg)) __matches[__i3] = __matches[--__nmatches]; else ++__i3; @@ -2034,6 +2129,7 @@ namespace std __testvalid = false; if (!__testvalid) __err |= ios_base::failbit; + return __beg; } @@ -2064,7 +2160,7 @@ namespace std const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc); const char_type* __dates[2]; __tp._M_date_formats(__dates); - __beg = _M_extract_via_format(__beg, __end, __io, __err, + __beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __dates[0]); if (__beg == __end) __err |= ios_base::eofbit; @@ -2084,7 +2180,9 @@ namespace std const char_type* __days[7]; __tp._M_days_abbreviated(__days); int __tmpwday; - __beg = _M_extract_name(__beg, __end, __tmpwday, __days, 7, __io, __err); + ios_base::iostate __tmperr = ios_base::goodbit; + __beg = _M_extract_name(__beg, __end, __tmpwday, __days, 7, + __io, __tmperr); // Check to see if non-abbreviated name exists, and extract. // NB: Assumes both _M_days and _M_days_abbreviated organized in @@ -2092,7 +2190,7 @@ namespace std // __days array with the same index points to a day, and that // day's abbreviated form. // NB: Also assumes that an abbreviated name is a subset of the name. - if (!__err && __beg != __end) + if (!__tmperr && __beg != __end) { size_t __pos = __traits_type::length(__days[__tmpwday]); __tp._M_days(__days); @@ -2105,12 +2203,14 @@ namespace std && __name[__pos] == *__beg) ++__beg, ++__pos; if (__len != __pos) - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; } } - if (!__err) + if (!__tmperr) __tm->tm_wday = __tmpwday; - + else + __err |= ios_base::failbit; + if (__beg == __end) __err |= ios_base::eofbit; return __beg; @@ -2129,8 +2229,9 @@ namespace std const char_type* __months[12]; __tp._M_months_abbreviated(__months); int __tmpmon; + ios_base::iostate __tmperr = ios_base::goodbit; __beg = _M_extract_name(__beg, __end, __tmpmon, __months, 12, - __io, __err); + __io, __tmperr); // Check to see if non-abbreviated name exists, and extract. // NB: Assumes both _M_months and _M_months_abbreviated organized in @@ -2138,7 +2239,7 @@ namespace std // __months array with the same index points to a month, and that // month's abbreviated form. // NB: Also assumes that an abbreviated name is a subset of the name. - if (!__err && __beg != __end) + if (!__tmperr && __beg != __end) { size_t __pos = __traits_type::length(__months[__tmpmon]); __tp._M_months(__months); @@ -2151,11 +2252,13 @@ namespace std && __name[__pos] == *__beg) ++__beg, ++__pos; if (__len != __pos) - __err |= ios_base::failbit; + __tmperr |= ios_base::failbit; } } - if (!__err) + if (!__tmperr) __tm->tm_mon = __tmpmon; + else + __err |= ios_base::failbit; if (__beg == __end) __err |= ios_base::eofbit; @@ -2185,6 +2288,7 @@ namespace std __tm->tm_year = __i == 2 ? __value : __value - 1900; else __err |= ios_base::failbit; + if (__beg == __end) __err |= ios_base::eofbit; return __beg; @@ -2266,7 +2370,6 @@ namespace std return std::__write(__s, __res, char_traits::length(__res)); } - // Generic version does nothing. template int @@ -2323,43 +2426,55 @@ namespace std collate<_CharT>:: do_transform(const _CharT* __lo, const _CharT* __hi) const { + string_type __ret; + // strxfrm assumes zero-terminated strings so we make a copy - string_type __str(__lo, __hi); + const string_type __str(__lo, __hi); const _CharT* __p = __str.c_str(); const _CharT* __pend = __str.data() + __str.length(); size_t __len = (__hi - __lo) * 2; - string_type __ret; + _CharT* __c = new _CharT[__len]; - // strxfrm stops when it sees a nul character so we break - // the string into zero-terminated substrings and pass those - // to strxfrm. - for (;;) + try { - // First try a buffer perhaps big enough. - _CharT* __c = - static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len)); - size_t __res = _M_transform(__c, __p, __len); - // If the buffer was not large enough, try again with the - // correct size. - if (__res >= __len) + // strxfrm stops when it sees a nul character so we break + // the string into zero-terminated substrings and pass those + // to strxfrm. + for (;;) { - __len = __res + 1; - __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) - * __len)); - __res = _M_transform(__c, __p, __res + 1); - } + // First try a buffer perhaps big enough. + size_t __res = _M_transform(__c, __p, __len); + // If the buffer was not large enough, try again with the + // correct size. + if (__res >= __len) + { + __len = __res + 1; + delete [] __c, __c = 0; + __c = new _CharT[__len]; + __res = _M_transform(__c, __p, __len); + } - __ret.append(__c, __res); - __p += char_traits<_CharT>::length(__p); - if (__p == __pend) - return __ret; + __ret.append(__c, __res); + __p += char_traits<_CharT>::length(__p); + if (__p == __pend) + break; - __p++; - __ret.push_back(_CharT()); + __p++; + __ret.push_back(_CharT()); + } + } + catch(...) + { + delete [] __c; + __throw_exception_again; } + + delete [] __c; + + return __ret; } template @@ -2443,7 +2558,7 @@ namespace std const string& __grouping_tmp) { const size_t __n = __grouping_tmp.size() - 1; - const size_t __min = std::min(__n, __grouping_size - 1); + const size_t __min = std::min(__n, size_t(__grouping_size - 1)); size_t __i = __n; bool __test = true; @@ -2454,9 +2569,11 @@ namespace std __test = __grouping_tmp[__i] == __grouping[__j]; for (; __i && __test; --__i) __test = __grouping_tmp[__i] == __grouping[__min]; - // ... but the last parsed grouping can be <= numpunct - // grouping. - __test &= __grouping_tmp[0] <= __grouping[__min]; + // ... but the first parsed grouping can be <= numpunct + // grouping (only do the check if the numpunct char is > 0 + // because <= 0 means any size is ok). + if (static_cast(__grouping[__min]) > 0) + __test &= __grouping_tmp[0] <= __grouping[__min]; return __test; } @@ -2466,18 +2583,33 @@ namespace std const char* __gbeg, size_t __gsize, const _CharT* __first, const _CharT* __last) { - if (__last - __first > *__gbeg) + size_t __idx = 0; + size_t __ctr = 0; + + while (__last - __first > __gbeg[__idx] + && static_cast(__gbeg[__idx]) > 0) { - const bool __bump = __gsize != 1; - __s = std::__add_grouping(__s, __sep, __gbeg + __bump, - __gsize - __bump, __first, - __last - *__gbeg); - __first = __last - *__gbeg; - *__s++ = __sep; + __last -= __gbeg[__idx]; + __idx < __gsize - 1 ? ++__idx : ++__ctr; } - do + + while (__first != __last) *__s++ = *__first++; - while (__first != __last); + + while (__ctr--) + { + *__s++ = __sep; + for (char __i = __gbeg[__idx]; __i > 0; --__i) + *__s++ = *__first++; + } + + while (__idx--) + { + *__s++ = __sep; + for (char __i = __gbeg[__idx]; __i > 0; --__i) + *__s++ = *__first++; + } + return __s; } @@ -2489,12 +2621,12 @@ namespace std extern template class moneypunct; extern template class moneypunct_byname; extern template class moneypunct_byname; - extern template class money_get; - extern template class money_put; + extern template class _GLIBCXX_LDBL_NAMESPACE money_get; + extern template class _GLIBCXX_LDBL_NAMESPACE money_put; extern template class numpunct; extern template class numpunct_byname; - extern template class num_get; - extern template class num_put; + extern template class _GLIBCXX_LDBL_NAMESPACE num_get; + extern template class _GLIBCXX_LDBL_NAMESPACE num_put; extern template class __timepunct; extern template class time_put; extern template class time_put_byname; @@ -2616,12 +2748,12 @@ namespace std extern template class moneypunct; extern template class moneypunct_byname; extern template class moneypunct_byname; - extern template class money_get; - extern template class money_put; + extern template class _GLIBCXX_LDBL_NAMESPACE money_get; + extern template class _GLIBCXX_LDBL_NAMESPACE money_put; extern template class numpunct; extern template class numpunct_byname; - extern template class num_get; - extern template class num_put; + extern template class _GLIBCXX_LDBL_NAMESPACE num_get; + extern template class _GLIBCXX_LDBL_NAMESPACE num_put; extern template class __timepunct; extern template class time_put; extern template class time_put_byname; @@ -2739,6 +2871,7 @@ namespace std has_facet >(const locale&); #endif #endif -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/localefwd.h b/contrib/libstdc++/include/bits/localefwd.h index 247158d..b858668 100644 --- a/contrib/libstdc++/include/bits/localefwd.h +++ b/contrib/libstdc++/include/bits/localefwd.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,15 +28,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 22.1 Locales -// - /** @file localefwd.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// +// ISO C++ 14882: 22.1 Locales +// + #ifndef _LOCALE_FWD_H #define _LOCALE_FWD_H 1 @@ -47,8 +47,8 @@ #include // For ostreambuf_iterator, istreambuf_iterator #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // 22.1.1 Locale class locale; @@ -129,10 +129,12 @@ namespace std class codecvt_byname; // 22.2.2 and 22.2.3 numeric +_GLIBCXX_BEGIN_LDBL_NAMESPACE template > class num_get; template > class num_put; +_GLIBCXX_END_LDBL_NAMESPACE template class numpunct; template class numpunct_byname; @@ -155,10 +157,12 @@ namespace std // 22.2.6 money class money_base; +_GLIBCXX_BEGIN_LDBL_NAMESPACE template > class money_get; template > class money_put; +_GLIBCXX_END_LDBL_NAMESPACE template class moneypunct; template @@ -187,6 +191,7 @@ namespace std __throw_bad_cast(); return *__f; } -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/mask_array.h b/contrib/libstdc++/include/bits/mask_array.h index 1a694f3..98c8bfb 100644 --- a/contrib/libstdc++/include/bits/mask_array.h +++ b/contrib/libstdc++/include/bits/mask_array.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- mask_array class. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,19 +28,19 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// Written by Gabriel Dos Reis - /** @file mask_array.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// Written by Gabriel Dos Reis + #ifndef _MASK_ARRAY_H #define _MASK_ARRAY_H 1 #pragma GCC system_header -namespace std { +_GLIBCXX_BEGIN_NAMESPACE(std) /** * @brief Reference to selected subset of an array. @@ -128,13 +128,12 @@ namespace std { const size_t _M_sz; const _Array _M_mask; - const _Array<_Tp> _M_array; + const _Array<_Tp> _M_array; // not implemented mask_array(); }; - template inline mask_array<_Tp>::mask_array(const mask_array<_Tp>& a) : _M_sz(a._M_sz), _M_mask(a._M_mask), _M_array(a._M_array) {} @@ -200,10 +199,6 @@ _DEFINE_VALARRAY_OPERATOR(>>, __shift_right) #undef _DEFINE_VALARRAY_OPERATOR -} // std:: +_GLIBCXX_END_NAMESPACE #endif /* _MASK_ARRAY_H */ - -// Local Variables: -// mode:c++ -// End: diff --git a/contrib/libstdc++/include/bits/ostream.tcc b/contrib/libstdc++/include/bits/ostream.tcc index 2d1b5b4..36853e8 100644 --- a/contrib/libstdc++/include/bits/ostream.tcc +++ b/contrib/libstdc++/include/bits/ostream.tcc @@ -1,6 +1,7 @@ // ostream classes -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +// 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +17,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +29,11 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file ostream.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + // // ISO C++ 14882: 27.6.2 Output streams // @@ -39,8 +45,8 @@ #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template basic_ostream<_CharT, _Traits>::sentry:: sentry(basic_ostream<_CharT, _Traits>& __os) @@ -57,249 +63,57 @@ namespace std } template - basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>:: - operator<<(__ostream_type& (*__pf)(__ostream_type&)) - { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // DR 60. What is a formatted input function? - // The inserters for manipulators are *not* formatted output functions. - return __pf(*this); - } + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + _M_insert(_ValueT __v) + { + sentry __cerb(*this); + if (__cerb) + { + ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + try + { + const __num_put_type& __np = __check_facet(this->_M_num_put); + if (__np.put(*this, *this, this->fill(), __v).failed()) + __err |= ios_base::badbit; + } + catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>:: - operator<<(__ios_type& (*__pf)(__ios_type&)) + operator<<(short __n) { // _GLIBCXX_RESOLVE_LIB_DEFECTS - // DR 60. What is a formatted input function? - // The inserters for manipulators are *not* formatted output functions. - __pf(*this); - return *this; + // 117. basic_ostream uses nonexistent num_put member functions. + const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield; + if (__fmt == ios_base::oct || __fmt == ios_base::hex) + return _M_insert(static_cast(static_cast(__n))); + else + return _M_insert(static_cast(__n)); } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>:: - operator<<(ios_base& (*__pf)(ios_base&)) + operator<<(int __n) { // _GLIBCXX_RESOLVE_LIB_DEFECTS - // DR 60. What is a formatted input function? - // The inserters for manipulators are *not* formatted output functions. - __pf(*this); - return *this; - } - - template - basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>:: - operator<<(bool __n) - { - sentry __cerb(*this); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_put_type& __np = __check_facet(this->_M_num_put); - if (__np.put(*this, *this, this->fill(), __n).failed()) - __err |= ios_base::badbit; - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>:: - operator<<(long __n) - { - sentry __cerb(*this); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - bool __b = false; - const char_type __c = this->fill(); - const ios_base::fmtflags __fmt = (this->flags() - & ios_base::basefield); - const __num_put_type& __np = __check_facet(this->_M_num_put); - if ((__fmt & ios_base::oct) || (__fmt & ios_base::hex)) - { - const unsigned long __l = static_cast(__n); - __b = __np.put(*this, *this, __c, __l).failed(); - } - else - __b = __np.put(*this, *this, __c, __n).failed(); - if (__b) - __err |= ios_base::badbit; - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>:: - operator<<(unsigned long __n) - { - sentry __cerb(*this); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_put_type& __np = __check_facet(this->_M_num_put); - if (__np.put(*this, *this, this->fill(), __n).failed()) - __err |= ios_base::badbit; - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - -#ifdef _GLIBCXX_USE_LONG_LONG - template - basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>:: - operator<<(long long __n) - { - sentry __cerb(*this); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - bool __b = false; - const char_type __c = this->fill(); - const ios_base::fmtflags __fmt = (this->flags() - & ios_base::basefield); - const __num_put_type& __np = __check_facet(this->_M_num_put); - if ((__fmt & ios_base::oct) || (__fmt & ios_base::hex)) - { - const unsigned long long __l = (static_cast< - unsigned long long>(__n)); - __b = __np.put(*this, *this, __c, __l).failed(); - } - else - __b = __np.put(*this, *this, __c, __n).failed(); - if (__b) - __err |= ios_base::badbit; - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>:: - operator<<(unsigned long long __n) - { - sentry __cerb(*this); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_put_type& __np = __check_facet(this->_M_num_put); - if (__np.put(*this, *this, this->fill(), __n).failed()) - __err |= ios_base::badbit; - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } -#endif - - template - basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>:: - operator<<(double __n) - { - sentry __cerb(*this); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_put_type& __np = __check_facet(this->_M_num_put); - if (__np.put(*this, *this, this->fill(), __n).failed()) - __err |= ios_base::badbit; - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>:: - operator<<(long double __n) - { - sentry __cerb(*this); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_put_type& __np = __check_facet(this->_M_num_put); - if (__np.put(*this, *this, this->fill(), __n).failed()) - __err |= ios_base::badbit; - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; - } - - template - basic_ostream<_CharT, _Traits>& - basic_ostream<_CharT, _Traits>:: - operator<<(const void* __n) - { - sentry __cerb(*this); - if (__cerb) - { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - try - { - const __num_put_type& __np = __check_facet(this->_M_num_put); - if (__np.put(*this, *this, this->fill(), __n).failed()) - __err |= ios_base::badbit; - } - catch(...) - { this->_M_setstate(ios_base::badbit); } - if (__err) - this->setstate(__err); - } - return *this; + // 117. basic_ostream uses nonexistent num_put member functions. + const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield; + if (__fmt == ios_base::oct || __fmt == ios_base::hex) + return _M_insert(static_cast(static_cast(__n))); + else + return _M_insert(static_cast(__n)); } - + template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>:: @@ -467,203 +281,41 @@ namespace std return *this; } - // 27.6.2.5.4 Character inserters. template basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) - { - typedef basic_ostream<_CharT, _Traits> __ostream_type; - typename __ostream_type::sentry __cerb(__out); - if (__cerb) - { - try - { - const streamsize __w = __out.width(); - streamsize __len = 1; - _CharT* __cs = &__c; - if (__w > __len) - { - __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) - * __w)); - __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs, - &__c, __w, __len, false); - __len = __w; - } - __out._M_write(__cs, __len); - __out.width(0); - } - catch(...) - { __out._M_setstate(ios_base::badbit); } - } - return __out; - } - - // Specializations. - template - basic_ostream& - operator<<(basic_ostream& __out, char __c) - { - typedef basic_ostream __ostream_type; - typename __ostream_type::sentry __cerb(__out); - if (__cerb) - { - try - { - const streamsize __w = __out.width(); - streamsize __len = 1; - char* __cs = &__c; - if (__w > __len) - { - __cs = static_cast(__builtin_alloca(__w)); - __pad::_S_pad(__out, __out.fill(), __cs, - &__c, __w, __len, false); - __len = __w; - } - __out._M_write(__cs, __len); - __out.width(0); - } - catch(...) - { __out._M_setstate(ios_base::badbit); } - } - return __out; - } - - template - basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) + operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) { - typedef basic_ostream<_CharT, _Traits> __ostream_type; - typename __ostream_type::sentry __cerb(__out); - if (__cerb && __s) + if (!__s) + __out.setstate(ios_base::badbit); + else { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 167. Improper use of traits_type::length() + const size_t __clen = char_traits::length(__s); + _CharT* __ws = 0; try - { - const streamsize __w = __out.width(); - streamsize __len = static_cast(_Traits::length(__s)); - if (__w > __len) - { - _CharT* __cs = (static_cast< - _CharT*>(__builtin_alloca(sizeof(_CharT) - * __w))); - __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs, - __s, __w, __len, false); - __s = __cs; - __len = __w; - } - __out._M_write(__s, __len); - __out.width(0); + { + __ws = new _CharT[__clen]; + for (size_t __i = 0; __i < __clen; ++__i) + __ws[__i] = __out.widen(__s[__i]); } catch(...) - { __out._M_setstate(ios_base::badbit); } - } - else if (!__s) - __out.setstate(ios_base::badbit); - return __out; - } - - template - basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) - { - typedef basic_ostream<_CharT, _Traits> __ostream_type; - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 167. Improper use of traits_type::length() - // Note that this is only in 'Review' status. - typedef char_traits __traits_type; - typename __ostream_type::sentry __cerb(__out); - if (__cerb && __s) - { - size_t __clen = __traits_type::length(__s); - _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) - * __clen)); - for (size_t __i = 0; __i < __clen; ++__i) - __ws[__i] = __out.widen(__s[__i]); - _CharT* __str = __ws; - - try { - const streamsize __w = __out.width(); - streamsize __len = static_cast(__clen); - if (__w > __len) - { - _CharT* __cs = (static_cast< - _CharT*>(__builtin_alloca(sizeof(_CharT) - * __w))); - __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs, - __ws, __w, __len, false); - __str = __cs; - __len = __w; - } - __out._M_write(__str, __len); - __out.width(0); + delete [] __ws; + __out._M_setstate(ios_base::badbit); + return __out; } - catch(...) - { __out._M_setstate(ios_base::badbit); } - } - else if (!__s) - __out.setstate(ios_base::badbit); - return __out; - } - // Partial specializations. - template - basic_ostream& - operator<<(basic_ostream& __out, const char* __s) - { - typedef basic_ostream __ostream_type; - typename __ostream_type::sentry __cerb(__out); - if (__cerb && __s) - { try { - const streamsize __w = __out.width(); - streamsize __len = static_cast(_Traits::length(__s)); - if (__w > __len) - { - char* __cs = static_cast(__builtin_alloca(__w)); - __pad::_S_pad(__out, __out.fill(), __cs, - __s, __w, __len, false); - __s = __cs; - __len = __w; - } - __out._M_write(__s, __len); - __out.width(0); + __ostream_insert(__out, __ws, __clen); + delete [] __ws; } catch(...) - { __out._M_setstate(ios_base::badbit); } - } - else if (!__s) - __out.setstate(ios_base::badbit); - return __out; - } - - // 21.3.7.9 basic_string::operator<< - template - basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>& __out, - const basic_string<_CharT, _Traits, _Alloc>& __str) - { - typedef basic_ostream<_CharT, _Traits> __ostream_type; - typename __ostream_type::sentry __cerb(__out); - if (__cerb) - { - const streamsize __w = __out.width(); - streamsize __len = static_cast(__str.size()); - const _CharT* __s = __str.data(); - - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 25. String operator<< uses width() value wrong - if (__w > __len) { - _CharT* __cs = (static_cast< - _CharT*>(__builtin_alloca(sizeof(_CharT) * __w))); - __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs, __s, - __w, __len, false); - __s = __cs; - __len = __w; + delete [] __ws; + __throw_exception_again; } - __out._M_write(__s, __len); - __out.width(0); } return __out; } @@ -682,6 +334,18 @@ namespace std extern template ostream& operator<<(ostream&, const char*); extern template ostream& operator<<(ostream&, const unsigned char*); extern template ostream& operator<<(ostream&, const signed char*); + extern template ostream& __ostream_insert(ostream&, const char*, streamsize); + + extern template ostream& ostream::_M_insert(long); + extern template ostream& ostream::_M_insert(unsigned long); + extern template ostream& ostream::_M_insert(bool); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template ostream& ostream::_M_insert(long long); + extern template ostream& ostream::_M_insert(unsigned long long); +#endif + extern template ostream& ostream::_M_insert(double); + extern template ostream& ostream::_M_insert(long double); + extern template ostream& ostream::_M_insert(const void*); #ifdef _GLIBCXX_USE_WCHAR_T extern template class basic_ostream; @@ -692,8 +356,22 @@ namespace std extern template wostream& operator<<(wostream&, char); extern template wostream& operator<<(wostream&, const wchar_t*); extern template wostream& operator<<(wostream&, const char*); + extern template wostream& __ostream_insert(wostream&, const wchar_t*, + streamsize); + + extern template wostream& wostream::_M_insert(long); + extern template wostream& wostream::_M_insert(unsigned long); + extern template wostream& wostream::_M_insert(bool); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template wostream& wostream::_M_insert(long long); + extern template wostream& wostream::_M_insert(unsigned long long); +#endif + extern template wostream& wostream::_M_insert(double); + extern template wostream& wostream::_M_insert(long double); + extern template wostream& wostream::_M_insert(const void*); #endif #endif -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/ostream_insert.h b/contrib/libstdc++/include/bits/ostream_insert.h new file mode 100644 index 0000000..f3ed801 --- /dev/null +++ b/contrib/libstdc++/include/bits/ostream_insert.h @@ -0,0 +1,114 @@ +// Helpers for ostream inserters -*- C++ -*- + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file ostream_insert.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +#ifndef _OSTREAM_INSERT_H +#define _OSTREAM_INSERT_H 1 + +#pragma GCC system_header + +#include + +_GLIBCXX_BEGIN_NAMESPACE(std) + + template + inline void + __ostream_write(basic_ostream<_CharT, _Traits>& __out, + const _CharT* __s, streamsize __n) + { + typedef basic_ostream<_CharT, _Traits> __ostream_type; + typedef typename __ostream_type::ios_base __ios_base; + + const streamsize __put = __out.rdbuf()->sputn(__s, __n); + if (__put != __n) + __out.setstate(__ios_base::badbit); + } + + template + inline void + __ostream_fill(basic_ostream<_CharT, _Traits>& __out, streamsize __n) + { + typedef basic_ostream<_CharT, _Traits> __ostream_type; + typedef typename __ostream_type::ios_base __ios_base; + + const _CharT __c = __out.fill(); + for (; __n > 0; --__n) + { + const typename _Traits::int_type __put = __out.rdbuf()->sputc(__c); + if (_Traits::eq_int_type(__put, _Traits::eof())) + { + __out.setstate(__ios_base::badbit); + break; + } + } + } + + template + basic_ostream<_CharT, _Traits>& + __ostream_insert(basic_ostream<_CharT, _Traits>& __out, + const _CharT* __s, streamsize __n) + { + typedef basic_ostream<_CharT, _Traits> __ostream_type; + typedef typename __ostream_type::ios_base __ios_base; + + typename __ostream_type::sentry __cerb(__out); + if (__cerb) + { + try + { + const streamsize __w = __out.width(); + if (__w > __n) + { + const bool __left = ((__out.flags() + & __ios_base::adjustfield) + == __ios_base::left); + if (!__left) + __ostream_fill(__out, __w - __n); + if (__out.good()) + __ostream_write(__out, __s, __n); + if (__left && __out.good()) + __ostream_fill(__out, __w - __n); + } + else + __ostream_write(__out, __s, __n); + __out.width(0); + } + catch(...) + { __out._M_setstate(__ios_base::badbit); } + } + return __out; + } + +_GLIBCXX_END_NAMESPACE + +#endif /* _OSTREAM_INSERT_H */ diff --git a/contrib/libstdc++/include/bits/postypes.h b/contrib/libstdc++/include/bits/postypes.h index 0cfb61b..40570d9 100644 --- a/contrib/libstdc++/include/bits/postypes.h +++ b/contrib/libstdc++/include/bits/postypes.h @@ -1,6 +1,6 @@ // Position types -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,16 +28,16 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 27.4.1 - Types -// ISO C++ 14882: 27.4.3 - Template class fpos -// - /** @file postypes.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// +// ISO C++ 14882: 27.4.1 - Types +// ISO C++ 14882: 27.4.3 - Template class fpos +// + #ifndef _GLIBCXX_POSTYPES_H #define _GLIBCXX_POSTYPES_H 1 @@ -49,8 +49,8 @@ #include // For int64_t #endif -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // The types streamoff, streampos and wstreampos and the class // template fpos<> are described in clauses 21.1.2, 21.1.3, 27.1.2, // 27.2, 27.4.1, 27.4.3 and D.6. Despite all this verbage, the @@ -129,20 +129,6 @@ namespace std state() const { return _M_state; } - // The standard only requires that operator== must be an - // equivalence relation. In this implementation two fpos - // objects belong to the same equivalence class if the contained - // offsets compare equal. - /// Test if equivalent to another position. - bool - operator==(const fpos& __other) const - { return _M_off == __other._M_off; } - - /// Test if not equivalent to another position. - bool - operator!=(const fpos& __other) const - { return _M_off != __other._M_off; } - // The standard requires that this operator must be defined, but // gives no semantics. In this implemenation it just adds it's // argument to the stored offset and returns *this. @@ -203,6 +189,21 @@ namespace std { return _M_off - __other._M_off; } }; + // The standard only requires that operator== must be an + // equivalence relation. In this implementation two fpos + // objects belong to the same equivalence class if the contained + // offsets compare equal. + /// Test if equivalent to another position. + template + inline bool + operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) + { return streamoff(__lhs) == streamoff(__rhs); } + + template + inline bool + operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) + { return streamoff(__lhs) != streamoff(__rhs); } + // Clauses 21.1.3.1 and 21.1.3.2 describe streampos and wstreampos // as implementation defined types, but clause 27.2 requires that // they must both be typedefs for fpos @@ -210,6 +211,7 @@ namespace std typedef fpos streampos; /// File position for wchar_t streams. typedef fpos wstreampos; -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/slice_array.h b/contrib/libstdc++/include/bits/slice_array.h index 31c89bc..8eaf90d 100644 --- a/contrib/libstdc++/include/bits/slice_array.h +++ b/contrib/libstdc++/include/bits/slice_array.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- slice_array class. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,20 +28,20 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// Written by Gabriel Dos Reis - /** @file slice_array.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// Written by Gabriel Dos Reis + #ifndef _SLICE_ARRAY_H #define _SLICE_ARRAY_H 1 #pragma GCC system_header -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @brief Class defining one-dimensional subset of an array. * @@ -90,7 +90,7 @@ namespace std inline slice::slice(size_t __o, size_t __d, size_t __s) - : _M_off(__o), _M_sz(__d), _M_st(__s) {} + : _M_off(__o), _M_sz(__d), _M_st(__s) {} inline size_t slice::start() const @@ -160,34 +160,34 @@ namespace std // ~slice_array (); template - void operator=(const _Expr<_Dom,_Tp>&) const; + void operator=(const _Expr<_Dom, _Tp>&) const; template - void operator*=(const _Expr<_Dom,_Tp>&) const; + void operator*=(const _Expr<_Dom, _Tp>&) const; template - void operator/=(const _Expr<_Dom,_Tp>&) const; + void operator/=(const _Expr<_Dom, _Tp>&) const; template - void operator%=(const _Expr<_Dom,_Tp>&) const; + void operator%=(const _Expr<_Dom, _Tp>&) const; template - void operator+=(const _Expr<_Dom,_Tp>&) const; + void operator+=(const _Expr<_Dom, _Tp>&) const; template - void operator-=(const _Expr<_Dom,_Tp>&) const; + void operator-=(const _Expr<_Dom, _Tp>&) const; template - void operator^=(const _Expr<_Dom,_Tp>&) const; + void operator^=(const _Expr<_Dom, _Tp>&) const; template - void operator&=(const _Expr<_Dom,_Tp>&) const; + void operator&=(const _Expr<_Dom, _Tp>&) const; template - void operator|=(const _Expr<_Dom,_Tp>&) const; + void operator|=(const _Expr<_Dom, _Tp>&) const; template - void operator<<=(const _Expr<_Dom,_Tp>&) const; + void operator<<=(const _Expr<_Dom, _Tp>&) const; template - void operator>>=(const _Expr<_Dom,_Tp>&) const; + void operator>>=(const _Expr<_Dom, _Tp>&) const; private: friend class valarray<_Tp>; slice_array(_Array<_Tp>, const slice&); - const size_t _M_sz; - const size_t _M_stride; + const size_t _M_sz; + const size_t _M_stride; const _Array<_Tp> _M_array; // not implemented @@ -264,10 +264,6 @@ _DEFINE_VALARRAY_OPERATOR(>>, __shift_right) #undef _DEFINE_VALARRAY_OPERATOR -} // std:: +_GLIBCXX_END_NAMESPACE #endif /* _SLICE_ARRAY_H */ - -// Local Variables: -// mode:c++ -// End: diff --git a/contrib/libstdc++/include/bits/sstream.tcc b/contrib/libstdc++/include/bits/sstream.tcc index 03f49fb..4de1c81 100644 --- a/contrib/libstdc++/include/bits/sstream.tcc +++ b/contrib/libstdc++/include/bits/sstream.tcc @@ -1,6 +1,6 @@ // String based streams -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,11 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file sstream.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + // // ISO C++ 14882: 27.7 String-based streams // @@ -39,32 +44,37 @@ #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type basic_stringbuf<_CharT, _Traits, _Alloc>:: pbackfail(int_type __c) { int_type __ret = traits_type::eof(); - const bool __testeof = traits_type::eq_int_type(__c, __ret); - if (this->eback() < this->gptr()) { - const bool __testeq = traits_type::eq(traits_type::to_char_type(__c), - this->gptr()[-1]); - this->gbump(-1); - // Try to put back __c into input sequence in one of three ways. // Order these tests done in is unspecified by the standard. - if (!__testeof && __testeq) - __ret = __c; - else if (__testeof) - __ret = traits_type::not_eof(__c); + const bool __testeof = traits_type::eq_int_type(__c, __ret); + if (!__testeof) + { + const bool __testeq = traits_type::eq(traits_type:: + to_char_type(__c), + this->gptr()[-1]); + const bool __testout = this->_M_mode & ios_base::out; + if (__testeq || __testout) + { + this->gbump(-1); + if (!__testeq) + *this->gptr() = traits_type::to_char_type(__c); + __ret = __c; + } + } else { - *this->gptr() = traits_type::to_char_type(__c); - __ret = __c; + this->gbump(-1); + __ret = traits_type::not_eof(__c); } } return __ret; @@ -91,25 +101,34 @@ namespace std // Try to append __c into output sequence in one of two ways. // Order these tests done in is unspecified by the standard. + const char_type __conv = traits_type::to_char_type(__c); if (!__testput) { - // NB: Start ostringstream buffers at 512 chars. This is an + // NB: Start ostringstream buffers at 512 chars. This is an // experimental value (pronounced "arbitrary" in some of the // hipper english-speaking countries), and can be changed to // suit particular needs. - // Then, in virtue of DR 169 (TC) we are allowed to grow more - // than one char. + // + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 169. Bad efficiency of overflow() mandated + // 432. stringbuf::overflow() makes only one write position + // available const __size_type __opt_len = std::max(__size_type(2 * __capacity), __size_type(512)); const __size_type __len = std::min(__opt_len, __max_size); __string_type __tmp; __tmp.reserve(__len); - __tmp.assign(_M_string.data(), this->epptr() - this->pbase()); + if (this->pbase()) + __tmp.assign(this->pbase(), this->epptr() - this->pbase()); + __tmp.push_back(__conv); _M_string.swap(__tmp); _M_sync(const_cast(_M_string.data()), this->gptr() - this->eback(), this->pptr() - this->pbase()); } - return this->sputc(traits_type::to_char_type(__c)); + else + *this->pptr() = __conv; + this->pbump(1); + return __c; } template @@ -149,28 +168,28 @@ namespace std { _M_update_egptr(); - off_type __newoffi = 0; - off_type __newoffo = 0; + off_type __newoffi = __off; + off_type __newoffo = __newoffi; if (__way == ios_base::cur) { - __newoffi = this->gptr() - __beg; - __newoffo = this->pptr() - __beg; + __newoffi += this->gptr() - __beg; + __newoffo += this->pptr() - __beg; } else if (__way == ios_base::end) - __newoffo = __newoffi = this->egptr() - __beg; + __newoffo = __newoffi += this->egptr() - __beg; if ((__testin || __testboth) - && __newoffi + __off >= 0 - && this->egptr() - __beg >= __newoffi + __off) + && __newoffi >= 0 + && this->egptr() - __beg >= __newoffi) { - this->gbump((__beg + __newoffi + __off) - this->gptr()); + this->gbump((__beg + __newoffi) - this->gptr()); __ret = pos_type(__newoffi); } if ((__testout || __testboth) - && __newoffo + __off >= 0 - && this->egptr() - __beg >= __newoffo + __off) + && __newoffo >= 0 + && this->egptr() - __beg >= __newoffo) { - this->pbump((__beg + __newoffo + __off) - this->pptr()); + this->pbump((__beg + __newoffo) - this->pptr()); __ret = pos_type(__newoffo); } } @@ -187,14 +206,14 @@ namespace std const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0; const char_type* __beg = __testin ? this->eback() : this->pbase(); - if (__beg) + if ((__beg || !off_type(__sp)) && (__testin || __testout)) { _M_update_egptr(); - off_type __pos(__sp); - const bool __testpos = 0 <= __pos - && __pos <= this->egptr() - __beg; - if ((__testin || __testout) && __testpos) + const off_type __pos(__sp); + const bool __testpos = (0 <= __pos + && __pos <= this->egptr() - __beg); + if (__testpos) { if (__testin) this->gbump((__beg + __pos) - this->gptr()); @@ -206,6 +225,38 @@ namespace std return __ret; } + template + void + basic_stringbuf<_CharT, _Traits, _Alloc>:: + _M_sync(char_type* __base, __size_type __i, __size_type __o) + { + const bool __testin = _M_mode & ios_base::in; + const bool __testout = _M_mode & ios_base::out; + char_type* __endg = __base + _M_string.size(); + char_type* __endp = __base + _M_string.capacity(); + + if (__base != _M_string.data()) + { + // setbuf: __i == size of buffer area (_M_string.size() == 0). + __endg += __i; + __i = 0; + __endp = __endg; + } + + if (__testin) + this->setg(__base, __base + __i, __endg); + if (__testout) + { + this->setp(__base, __endp); + this->pbump(__o); + // egptr() always tracks the string end. When !__testin, + // for the correct functioning of the streambuf inlines + // the other get area pointers are identical. + if (!__testin) + this->setg(__endg, __endg, __endg); + } + } + // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. @@ -222,6 +273,7 @@ namespace std extern template class basic_stringstream; #endif #endif -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/stl_algo.h b/contrib/libstdc++/include/bits/stl_algo.h index 74956d7..cf3cd71 100644 --- a/contrib/libstdc++/include/bits/stl_algo.h +++ b/contrib/libstdc++/include/bits/stl_algo.h @@ -1,6 +1,7 @@ // Algorithm implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -67,8 +68,8 @@ // See concept_check.h for the __glibcxx_*_requires macros. -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @brief Find the median of three values. * @param a A value. @@ -166,8 +167,8 @@ namespace std */ template inline _InputIterator - find(_InputIterator __first, _InputIterator __last, - const _Tp& __val, input_iterator_tag) + __find(_InputIterator __first, _InputIterator __last, + const _Tp& __val, input_iterator_tag) { while (__first != __last && !(*__first == __val)) ++__first; @@ -181,8 +182,8 @@ namespace std */ template inline _InputIterator - find_if(_InputIterator __first, _InputIterator __last, - _Predicate __pred, input_iterator_tag) + __find_if(_InputIterator __first, _InputIterator __last, + _Predicate __pred, input_iterator_tag) { while (__first != __last && !__pred(*__first)) ++__first; @@ -196,8 +197,8 @@ namespace std */ template _RandomAccessIterator - find(_RandomAccessIterator __first, _RandomAccessIterator __last, - const _Tp& __val, random_access_iterator_tag) + __find(_RandomAccessIterator __first, _RandomAccessIterator __last, + const _Tp& __val, random_access_iterator_tag) { typename iterator_traits<_RandomAccessIterator>::difference_type __trip_count = (__last - __first) >> 2; @@ -248,8 +249,8 @@ namespace std */ template _RandomAccessIterator - find_if(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Predicate __pred, random_access_iterator_tag) + __find_if(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Predicate __pred, random_access_iterator_tag) { typename iterator_traits<_RandomAccessIterator>::difference_type __trip_count = (__last - __first) >> 2; @@ -294,6 +295,17 @@ namespace std } /** + * @if maint + * This is an overload of find() for streambuf iterators. + * @endif + */ + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + istreambuf_iterator<_CharT> >::__type + find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, + const _CharT&); + + /** * @brief Find the first occurrence of a value in a sequence. * @param first An input iterator. * @param last An input iterator. @@ -311,8 +323,8 @@ namespace std __glibcxx_function_requires(_EqualOpConcept< typename iterator_traits<_InputIterator>::value_type, _Tp>) __glibcxx_requires_valid_range(__first, __last); - return std::find(__first, __last, __val, - std::__iterator_category(__first)); + return std::__find(__first, __last, __val, + std::__iterator_category(__first)); } /** @@ -333,8 +345,8 @@ namespace std __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, typename iterator_traits<_InputIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); - return std::find_if(__first, __last, __pred, - std::__iterator_category(__first)); + return std::__find_if(__first, __last, __pred, + std::__iterator_category(__first)); } /** @@ -413,9 +425,8 @@ namespace std { // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) - __glibcxx_function_requires(_EqualityComparableConcept< - typename iterator_traits<_InputIterator>::value_type >) - __glibcxx_function_requires(_EqualityComparableConcept<_Tp>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator>::value_type, _Tp>) __glibcxx_requires_valid_range(__first, __last); typename iterator_traits<_InputIterator>::difference_type __n = 0; for ( ; __first != __last; ++__first) @@ -608,6 +619,92 @@ namespace std } /** + * @if maint + * This is an uglified + * search_n(_ForwardIterator, _ForwardIterator, _Integer, const _Tp&) + * overloaded for forward iterators. + * @endif + */ + template + _ForwardIterator + __search_n(_ForwardIterator __first, _ForwardIterator __last, + _Integer __count, const _Tp& __val, + std::forward_iterator_tag) + { + __first = std::find(__first, __last, __val); + while (__first != __last) + { + typename iterator_traits<_ForwardIterator>::difference_type + __n = __count; + _ForwardIterator __i = __first; + ++__i; + while (__i != __last && __n != 1 && *__i == __val) + { + ++__i; + --__n; + } + if (__n == 1) + return __first; + if (__i == __last) + return __last; + __first = std::find(++__i, __last, __val); + } + return __last; + } + + /** + * @if maint + * This is an uglified + * search_n(_ForwardIterator, _ForwardIterator, _Integer, const _Tp&) + * overloaded for random access iterators. + * @endif + */ + template + _RandomAccessIter + __search_n(_RandomAccessIter __first, _RandomAccessIter __last, + _Integer __count, const _Tp& __val, + std::random_access_iterator_tag) + { + + typedef typename std::iterator_traits<_RandomAccessIter>::difference_type + _DistanceType; + + _DistanceType __tailSize = __last - __first; + const _DistanceType __pattSize = __count; + + if (__tailSize < __pattSize) + return __last; + + const _DistanceType __skipOffset = __pattSize - 1; + _RandomAccessIter __lookAhead = __first + __skipOffset; + __tailSize -= __pattSize; + + while (1) // the main loop... + { + // __lookAhead here is always pointing to the last element of next + // possible match. + while (!(*__lookAhead == __val)) // the skip loop... + { + if (__tailSize < __pattSize) + return __last; // Failure + __lookAhead += __pattSize; + __tailSize -= __pattSize; + } + _DistanceType __remainder = __skipOffset; + for (_RandomAccessIter __backTrack = __lookAhead - 1; + *__backTrack == __val; --__backTrack) + { + if (--__remainder == 0) + return (__lookAhead - __skipOffset); // Success + } + if (__remainder > __tailSize) + return __last; // Failure + __lookAhead += __remainder; + __tailSize -= __remainder; + } + } + + /** * @brief Search a sequence for a number of consecutive values. * @param first A forward iterator. * @param last A forward iterator. @@ -627,33 +724,109 @@ namespace std { // concept requirements __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) - __glibcxx_function_requires(_EqualityComparableConcept< - typename iterator_traits<_ForwardIterator>::value_type>) - __glibcxx_function_requires(_EqualityComparableConcept<_Tp>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) __glibcxx_requires_valid_range(__first, __last); if (__count <= 0) return __first; - else + if (__count == 1) + return std::find(__first, __last, __val); + return std::__search_n(__first, __last, __count, __val, + std::__iterator_category(__first)); + } + + /** + * @if maint + * This is an uglified + * search_n(_ForwardIterator, _ForwardIterator, _Integer, const _Tp&, + * _BinaryPredicate) + * overloaded for forward iterators. + * @endif + */ + template + _ForwardIterator + __search_n(_ForwardIterator __first, _ForwardIterator __last, + _Integer __count, const _Tp& __val, + _BinaryPredicate __binary_pred, std::forward_iterator_tag) + { + while (__first != __last && !__binary_pred(*__first, __val)) + ++__first; + + while (__first != __last) { - __first = std::find(__first, __last, __val); - while (__first != __last) + typename iterator_traits<_ForwardIterator>::difference_type + __n = __count; + _ForwardIterator __i = __first; + ++__i; + while (__i != __last && __n != 1 && __binary_pred(*__i, __val)) { - typename iterator_traits<_ForwardIterator>::difference_type - __n = __count; - _ForwardIterator __i = __first; ++__i; - while (__i != __last && __n != 1 && *__i == __val) - { - ++__i; - --__n; - } - if (__n == 1) - return __first; - else - __first = std::find(__i, __last, __val); + --__n; } - return __last; + if (__n == 1) + return __first; + if (__i == __last) + return __last; + __first = ++__i; + while (__first != __last && !__binary_pred(*__first, __val)) + ++__first; + } + return __last; + } + + /** + * @if maint + * This is an uglified + * search_n(_ForwardIterator, _ForwardIterator, _Integer, const _Tp&, + * _BinaryPredicate) + * overloaded for random access iterators. + * @endif + */ + template + _RandomAccessIter + __search_n(_RandomAccessIter __first, _RandomAccessIter __last, + _Integer __count, const _Tp& __val, + _BinaryPredicate __binary_pred, std::random_access_iterator_tag) + { + + typedef typename std::iterator_traits<_RandomAccessIter>::difference_type + _DistanceType; + + _DistanceType __tailSize = __last - __first; + const _DistanceType __pattSize = __count; + + if (__tailSize < __pattSize) + return __last; + + const _DistanceType __skipOffset = __pattSize - 1; + _RandomAccessIter __lookAhead = __first + __skipOffset; + __tailSize -= __pattSize; + + while (1) // the main loop... + { + // __lookAhead here is always pointing to the last element of next + // possible match. + while (!__binary_pred(*__lookAhead, __val)) // the skip loop... + { + if (__tailSize < __pattSize) + return __last; // Failure + __lookAhead += __pattSize; + __tailSize -= __pattSize; + } + _DistanceType __remainder = __skipOffset; + for (_RandomAccessIter __backTrack = __lookAhead - 1; + __binary_pred(*__backTrack, __val); --__backTrack) + { + if (--__remainder == 0) + return (__lookAhead - __skipOffset); // Success + } + if (__remainder > __tailSize) + return __last; // Failure + __lookAhead += __remainder; + __tailSize -= __remainder; } } @@ -687,40 +860,14 @@ namespace std if (__count <= 0) return __first; - else + if (__count == 1) { - while (__first != __last) - { - if (__binary_pred(*__first, __val)) - break; - ++__first; - } - while (__first != __last) - { - typename iterator_traits<_ForwardIterator>::difference_type - __n = __count; - _ForwardIterator __i = __first; - ++__i; - while (__i != __last && __n != 1 && __binary_pred(*__i, __val)) - { - ++__i; - --__n; - } - if (__n == 1) - return __first; - else - { - while (__i != __last) - { - if (__binary_pred(*__i, __val)) - break; - ++__i; - } - __first = __i; - } - } - return __last; + while (__first != __last && !__binary_pred(*__first, __val)) + ++__first; + return __first; } + return std::__search_n(__first, __last, __count, __val, __binary_pred, + std::__iterator_category(__first)); } /** @@ -918,7 +1065,10 @@ namespace std __glibcxx_requires_valid_range(__first, __last); for ( ; __first != __last; ++__first, ++__result) - *__result = *__first == __old_value ? __new_value : *__first; + if (*__first == __old_value) + *__result = __new_value; + else + *__result = *__first; return __result; } @@ -952,7 +1102,10 @@ namespace std __glibcxx_requires_valid_range(__first, __last); for ( ; __first != __last; ++__first, ++__result) - *__result = __pred(*__first) ? __new_value : *__first; + if (__pred(*__first)) + *__result = __new_value; + else + *__result = *__first; return __result; } @@ -1153,14 +1306,39 @@ namespace std * @if maint * This is an uglified unique_copy(_InputIterator, _InputIterator, * _OutputIterator) - * overloaded for output iterators. + * overloaded for forward iterators and output iterator as result. + * @endif + */ + template + _OutputIterator + __unique_copy(_ForwardIterator __first, _ForwardIterator __last, + _OutputIterator __result, + forward_iterator_tag, output_iterator_tag) + { + // concept requirements -- taken care of in dispatching function + _ForwardIterator __next = __first; + *__result = *__first; + while (++__next != __last) + if (!(*__first == *__next)) + { + __first = __next; + *++__result = *__first; + } + return ++__result; + } + + /** + * @if maint + * This is an uglified unique_copy(_InputIterator, _InputIterator, + * _OutputIterator) + * overloaded for input iterators and output iterator as result. * @endif */ template _OutputIterator __unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, - output_iterator_tag) + input_iterator_tag, output_iterator_tag) { // concept requirements -- taken care of in dispatching function typename iterator_traits<_InputIterator>::value_type __value = *__first; @@ -1178,14 +1356,14 @@ namespace std * @if maint * This is an uglified unique_copy(_InputIterator, _InputIterator, * _OutputIterator) - * overloaded for forward iterators. + * overloaded for input iterators and forward iterator as result. * @endif */ template _ForwardIterator __unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, - forward_iterator_tag) + input_iterator_tag, forward_iterator_tag) { // concept requirements -- taken care of in dispatching function *__result = *__first; @@ -1200,16 +1378,46 @@ namespace std * This is an uglified * unique_copy(_InputIterator, _InputIterator, _OutputIterator, * _BinaryPredicate) - * overloaded for output iterators. + * overloaded for forward iterators and output iterator as result. + * @endif + */ + template + _OutputIterator + __unique_copy(_ForwardIterator __first, _ForwardIterator __last, + _OutputIterator __result, _BinaryPredicate __binary_pred, + forward_iterator_tag, output_iterator_tag) + { + // concept requirements -- iterators already checked + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + + _ForwardIterator __next = __first; + *__result = *__first; + while (++__next != __last) + if (!__binary_pred(*__first, *__next)) + { + __first = __next; + *++__result = *__first; + } + return ++__result; + } + + /** + * @if maint + * This is an uglified + * unique_copy(_InputIterator, _InputIterator, _OutputIterator, + * _BinaryPredicate) + * overloaded for input iterators and output iterator as result. * @endif */ template _OutputIterator __unique_copy(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, - _BinaryPredicate __binary_pred, - output_iterator_tag) + _OutputIterator __result, _BinaryPredicate __binary_pred, + input_iterator_tag, output_iterator_tag) { // concept requirements -- iterators already checked __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, @@ -1232,25 +1440,25 @@ namespace std * This is an uglified * unique_copy(_InputIterator, _InputIterator, _OutputIterator, * _BinaryPredicate) - * overloaded for forward iterators. + * overloaded for input iterators and forward iterator as result. * @endif */ template _ForwardIterator __unique_copy(_InputIterator __first, _InputIterator __last, - _ForwardIterator __result, - _BinaryPredicate __binary_pred, - forward_iterator_tag) + _ForwardIterator __result, _BinaryPredicate __binary_pred, + input_iterator_tag, forward_iterator_tag) { // concept requirements -- iterators already checked __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, - typename iterator_traits<_ForwardIterator>::value_type, - typename iterator_traits<_InputIterator>::value_type>) + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_InputIterator>::value_type>) *__result = *__first; while (++__first != __last) - if (!__binary_pred(*__result, *__first)) *++__result = *__first; + if (!__binary_pred(*__result, *__first)) + *++__result = *__first; return ++__result; } @@ -1266,6 +1474,15 @@ namespace std * from groups of consecutive elements that compare equal. * unique_copy() is stable, so the relative order of elements that are * copied is unchanged. + * + * @if maint + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 241. Does unique_copy() require CopyConstructible and Assignable? + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 538. 241 again: Does unique_copy() require CopyConstructible and + * Assignable? + * @endif */ template inline _OutputIterator @@ -1280,11 +1497,11 @@ namespace std typename iterator_traits<_InputIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); - typedef typename iterator_traits<_OutputIterator>::iterator_category - _IterType; - - if (__first == __last) return __result; - return std::__unique_copy(__first, __last, __result, _IterType()); + if (__first == __last) + return __result; + return std::__unique_copy(__first, __last, __result, + std::__iterator_category(__first), + std::__iterator_category(__result)); } /** @@ -1301,6 +1518,11 @@ namespace std * true. * unique_copy() is stable, so the relative order of elements that are * copied is unchanged. + * + * @if maint + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 241. Does unique_copy() require CopyConstructible and Assignable? + * @endif */ template @@ -1315,12 +1537,11 @@ namespace std typename iterator_traits<_InputIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); - typedef typename iterator_traits<_OutputIterator>::iterator_category - _IterType; - - if (__first == __last) return __result; - return std::__unique_copy(__first, __last, __result, - __binary_pred, _IterType()); + if (__first == __last) + return __result; + return std::__unique_copy(__first, __last, __result, __binary_pred, + std::__iterator_category(__first), + std::__iterator_category(__result)); } /** @@ -1412,29 +1633,39 @@ namespace std template void __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, - bidirectional_iterator_tag) + bidirectional_iterator_tag) { while (true) if (__first == __last || __first == --__last) return; else - std::iter_swap(__first++, __last); + { + std::iter_swap(__first, __last); + ++__first; + } } /** * @if maint * This is an uglified reverse(_BidirectionalIterator, * _BidirectionalIterator) - * overloaded for bidirectional iterators. + * overloaded for random access iterators. * @endif */ template void __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, - random_access_iterator_tag) + random_access_iterator_tag) { + if (__first == __last) + return; + --__last; while (__first < __last) - std::iter_swap(__first++, --__last); + { + std::iter_swap(__first, __last); + ++__first; + --__last; + } } /** @@ -1454,7 +1685,7 @@ namespace std { // concept requirements __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept< - _BidirectionalIterator>) + _BidirectionalIterator>) __glibcxx_requires_valid_range(__first, __last); std::__reverse(__first, __last, std::__iterator_category(__first)); } @@ -1525,15 +1756,17 @@ namespace std __rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, - forward_iterator_tag) + forward_iterator_tag) { - if ((__first == __middle) || (__last == __middle)) + if (__first == __middle || __last == __middle) return; _ForwardIterator __first2 = __middle; do { - swap(*__first++, *__first2++); + swap(*__first, *__first2); + ++__first; + ++__first2; if (__first == __middle) __middle = __first2; } @@ -1543,7 +1776,9 @@ namespace std while (__first2 != __last) { - swap(*__first++, *__first2++); + swap(*__first, *__first2); + ++__first; + ++__first2; if (__first == __middle) __middle = __first2; else if (__first2 == __last) @@ -1565,16 +1800,19 @@ namespace std { // concept requirements __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept< - _BidirectionalIterator>) + _BidirectionalIterator>) - if ((__first == __middle) || (__last == __middle)) + if (__first == __middle || __last == __middle) return; std::__reverse(__first, __middle, bidirectional_iterator_tag()); std::__reverse(__middle, __last, bidirectional_iterator_tag()); while (__first != __middle && __middle != __last) - swap(*__first++, *--__last); + { + swap(*__first, *--__last); + ++__first; + } if (__first == __middle) std::__reverse(__middle, __last, bidirectional_iterator_tag()); @@ -1596,9 +1834,9 @@ namespace std { // concept requirements __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< - _RandomAccessIterator>) + _RandomAccessIterator>) - if ((__first == __middle) || (__last == __middle)) + if (__first == __middle || __last == __middle) return; typedef typename iterator_traits<_RandomAccessIterator>::difference_type @@ -1620,7 +1858,7 @@ namespace std for (_Distance __i = 0; __i < __d; __i++) { - const _ValueType __tmp = *__first; + _ValueType __tmp = *__first; _RandomAccessIterator __p = __first; if (__k < __l) @@ -1719,7 +1957,8 @@ namespace std __glibcxx_requires_valid_range(__first, __middle); __glibcxx_requires_valid_range(__middle, __last); - return std::copy(__first, __middle, copy(__middle, __last, __result)); + return std::copy(__first, __middle, + std::copy(__middle, __last, __result)); } /** @@ -2194,10 +2433,10 @@ namespace std __final_insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) { - if (__last - __first > _S_threshold) + if (__last - __first > int(_S_threshold)) { - std::__insertion_sort(__first, __first + _S_threshold); - std::__unguarded_insertion_sort(__first + _S_threshold, __last); + std::__insertion_sort(__first, __first + int(_S_threshold)); + std::__unguarded_insertion_sort(__first + int(_S_threshold), __last); } else std::__insertion_sort(__first, __last); @@ -2213,10 +2452,10 @@ namespace std __final_insertion_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { - if (__last - __first > _S_threshold) + if (__last - __first > int(_S_threshold)) { - std::__insertion_sort(__first, __first + _S_threshold, __comp); - std::__unguarded_insertion_sort(__first + _S_threshold, __last, + std::__insertion_sort(__first, __first + int(_S_threshold), __comp); + std::__unguarded_insertion_sort(__first + int(_S_threshold), __last, __comp); } else @@ -2225,7 +2464,47 @@ namespace std /** * @if maint - * This is a helper function for the sort routine. + * This is a helper function for the sort routines. + * @endif + */ + template + void + __heap_select(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + + std::make_heap(__first, __middle); + for (_RandomAccessIterator __i = __middle; __i < __last; ++__i) + if (*__i < *__first) + std::__pop_heap(__first, __middle, __i, _ValueType(*__i)); + } + + /** + * @if maint + * This is a helper function for the sort routines. + * @endif + */ + template + void + __heap_select(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last, _Compare __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + + std::make_heap(__first, __middle, __comp); + for (_RandomAccessIterator __i = __middle; __i < __last; ++__i) + if (__comp(*__i, *__first)) + std::__pop_heap(__first, __middle, __i, _ValueType(*__i), __comp); + } + + /** + * @if maint + * This is a helper function for the sort routines. * @endif */ template @@ -2254,7 +2533,7 @@ namespace std * the range @p [middle,last) then @p *j<*i and @p *k<*i are both false. */ template - void + inline void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last) @@ -2269,10 +2548,7 @@ namespace std __glibcxx_requires_valid_range(__first, __middle); __glibcxx_requires_valid_range(__middle, __last); - std::make_heap(__first, __middle); - for (_RandomAccessIterator __i = __middle; __i < __last; ++__i) - if (*__i < *__first) - std::__pop_heap(__first, __middle, __i, _ValueType(*__i)); + std::__heap_select(__first, __middle, __last); std::sort_heap(__first, __middle); } @@ -2295,7 +2571,7 @@ namespace std * are both false. */ template - void + inline void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, @@ -2312,10 +2588,7 @@ namespace std __glibcxx_requires_valid_range(__first, __middle); __glibcxx_requires_valid_range(__middle, __last); - std::make_heap(__first, __middle, __comp); - for (_RandomAccessIterator __i = __middle; __i < __last; ++__i) - if (__comp(*__i, *__first)) - std::__pop_heap(__first, __middle, __i, _ValueType(*__i), __comp); + std::__heap_select(__first, __middle, __last, __comp); std::sort_heap(__first, __middle, __comp); } @@ -2353,8 +2626,9 @@ namespace std __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_ConvertibleConcept<_InputValueType, _OutputValueType>) + __glibcxx_function_requires(_LessThanOpConcept<_InputValueType, + _OutputValueType>) __glibcxx_function_requires(_LessThanComparableConcept<_OutputValueType>) - __glibcxx_function_requires(_LessThanComparableConcept<_InputValueType>) __glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__result_first, __result_last); @@ -2421,6 +2695,8 @@ namespace std __glibcxx_function_requires(_ConvertibleConcept<_InputValueType, _OutputValueType>) __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _InputValueType, _OutputValueType>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, _OutputValueType, _OutputValueType>) __glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__result_first, __result_last); @@ -2463,7 +2739,7 @@ namespace std typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType; - while (__last - __first > _S_threshold) + while (__last - __first > int(_S_threshold)) { if (__depth_limit == 0) { @@ -2499,7 +2775,7 @@ namespace std typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType; - while (__last - __first > _S_threshold) + while (__last - __first > int(_S_threshold)) { if (__depth_limit == 0) { @@ -2550,7 +2826,8 @@ namespace std if (__first != __last) { - std::__introsort_loop(__first, __last, __lg(__last - __first) * 2); + std::__introsort_loop(__first, __last, + std::__lg(__last - __first) * 2); std::__final_insertion_sort(__first, __last); } } @@ -2586,8 +2863,8 @@ namespace std if (__first != __last) { - std::__introsort_loop(__first, __last, __lg(__last - __first) * 2, - __comp); + std::__introsort_loop(__first, __last, + std::__lg(__last - __first) * 2, __comp); std::__final_insertion_sort(__first, __last, __comp); } } @@ -2613,13 +2890,8 @@ namespace std _DistanceType; // concept requirements - // Note that these are slightly stricter than those of the 4-argument - // version, defined next. The difference is in the strictness of the - // comparison operations... so for looser checking, define your own - // comparison function, as was intended. __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) - __glibcxx_function_requires(_SameTypeConcept<_Tp, _ValueType>) - __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType, _Tp>) __glibcxx_requires_partitioned(__first, __last, __val); _DistanceType __len = std::distance(__first, __last); @@ -2715,10 +2987,8 @@ namespace std _DistanceType; // concept requirements - // See comments on lower_bound. __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) - __glibcxx_function_requires(_SameTypeConcept<_Tp, _ValueType>) - __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) + __glibcxx_function_requires(_LessThanOpConcept<_Tp, _ValueType>) __glibcxx_requires_partitioned(__first, __last, __val); _DistanceType __len = std::distance(__first, __last); @@ -2961,16 +3231,19 @@ namespace std _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, - typename iterator_traits<_InputIterator1>::value_type>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) - __glibcxx_function_requires(_LessThanComparableConcept< - typename iterator_traits<_InputIterator1>::value_type>) + _ValueType1>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>) __glibcxx_requires_sorted(__first1, __last1); __glibcxx_requires_sorted(__first2, __last2); @@ -3019,17 +3292,20 @@ namespace std _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, - typename iterator_traits<_InputIterator1>::value_type>) + _ValueType1>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType2>) __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) + _ValueType2, _ValueType1>) __glibcxx_requires_sorted_pred(__first1, __last1, __comp); __glibcxx_requires_sorted_pred(__first2, __last2, __comp); @@ -3610,13 +3886,13 @@ namespace std __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>) __glibcxx_requires_valid_range(__first, __last); - _Temporary_buffer<_RandomAccessIterator, _ValueType> - buf(__first, __last); - if (buf.begin() == 0) + _Temporary_buffer<_RandomAccessIterator, _ValueType> __buf(__first, + __last); + if (__buf.begin() == 0) std::__inplace_stable_sort(__first, __last); else - std::__stable_sort_adaptive(__first, __last, buf.begin(), - _DistanceType(buf.size())); + std::__stable_sort_adaptive(__first, __last, __buf.begin(), + _DistanceType(__buf.size())); } /** @@ -3654,12 +3930,86 @@ namespace std _ValueType>) __glibcxx_requires_valid_range(__first, __last); - _Temporary_buffer<_RandomAccessIterator, _ValueType> buf(__first, __last); - if (buf.begin() == 0) + _Temporary_buffer<_RandomAccessIterator, _ValueType> __buf(__first, + __last); + if (__buf.begin() == 0) std::__inplace_stable_sort(__first, __last, __comp); else - std::__stable_sort_adaptive(__first, __last, buf.begin(), - _DistanceType(buf.size()), __comp); + std::__stable_sort_adaptive(__first, __last, __buf.begin(), + _DistanceType(__buf.size()), __comp); + } + + + template + void + __introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth, + _RandomAccessIterator __last, _Size __depth_limit) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + + while (__last - __first > 3) + { + if (__depth_limit == 0) + { + std::__heap_select(__first, __nth + 1, __last); + // Place the nth largest element in its final position. + std::iter_swap(__first, __nth); + return; + } + --__depth_limit; + _RandomAccessIterator __cut = + std::__unguarded_partition(__first, __last, + _ValueType(std::__median(*__first, + *(__first + + (__last + - __first) + / 2), + *(__last + - 1)))); + if (__cut <= __nth) + __first = __cut; + else + __last = __cut; + } + std::__insertion_sort(__first, __last); + } + + template + void + __introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth, + _RandomAccessIterator __last, _Size __depth_limit, + _Compare __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + + while (__last - __first > 3) + { + if (__depth_limit == 0) + { + std::__heap_select(__first, __nth + 1, __last, __comp); + // Place the nth largest element in its final position. + std::iter_swap(__first, __nth); + return; + } + --__depth_limit; + _RandomAccessIterator __cut = + std::__unguarded_partition(__first, __last, + _ValueType(std::__median(*__first, + *(__first + + (__last + - __first) + / 2), + *(__last - 1), + __comp)), + __comp); + if (__cut <= __nth) + __first = __cut; + else + __last = __cut; + } + std::__insertion_sort(__first, __last, __comp); } /** @@ -3678,9 +4028,8 @@ namespace std * holds that @p *j<*i is false. */ template - void - nth_element(_RandomAccessIterator __first, - _RandomAccessIterator __nth, + inline void + nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) { typedef typename iterator_traits<_RandomAccessIterator>::value_type @@ -3693,23 +4042,11 @@ namespace std __glibcxx_requires_valid_range(__first, __nth); __glibcxx_requires_valid_range(__nth, __last); - while (__last - __first > 3) - { - _RandomAccessIterator __cut = - std::__unguarded_partition(__first, __last, - _ValueType(std::__median(*__first, - *(__first - + (__last - - __first) - / 2), - *(__last - - 1)))); - if (__cut <= __nth) - __first = __cut; - else - __last = __cut; - } - std::__insertion_sort(__first, __last); + if (__first == __last || __nth == __last) + return; + + std::__introselect(__first, __nth, __last, + std::__lg(__last - __first) * 2); } /** @@ -3729,11 +4066,9 @@ namespace std * holds that @p comp(*j,*i) is false. */ template - void - nth_element(_RandomAccessIterator __first, - _RandomAccessIterator __nth, - _RandomAccessIterator __last, - _Compare __comp) + inline void + nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, + _RandomAccessIterator __last, _Compare __comp) { typedef typename iterator_traits<_RandomAccessIterator>::value_type _ValueType; @@ -3746,23 +4081,11 @@ namespace std __glibcxx_requires_valid_range(__first, __nth); __glibcxx_requires_valid_range(__nth, __last); - while (__last - __first > 3) - { - _RandomAccessIterator __cut = - std::__unguarded_partition(__first, __last, - _ValueType(std::__median(*__first, - *(__first - + (__last - - __first) - / 2), - *(__last - 1), - __comp)), __comp); - if (__cut <= __nth) - __first = __cut; - else - __last = __cut; - } - std::__insertion_sort(__first, __last, __comp); + if (__first == __last || __nth == __last) + return; + + std::__introselect(__first, __nth, __last, + std::__lg(__last - __first) * 2, __comp); } /** @@ -3792,10 +4115,9 @@ namespace std _DistanceType; // concept requirements - // See comments on lower_bound. __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) - __glibcxx_function_requires(_SameTypeConcept<_Tp, _ValueType>) - __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType, _Tp>) + __glibcxx_function_requires(_LessThanOpConcept<_Tp, _ValueType>) __glibcxx_requires_partitioned(__first, __last, __val); _DistanceType __len = std::distance(__first, __last); @@ -3906,12 +4228,12 @@ namespace std binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val) { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + // concept requirements - // See comments on lower_bound. __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) - __glibcxx_function_requires(_SameTypeConcept<_Tp, - typename iterator_traits<_ForwardIterator>::value_type>) - __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) + __glibcxx_function_requires(_LessThanOpConcept<_Tp, _ValueType>) __glibcxx_requires_partitioned(__first, __last, __val); _ForwardIterator __i = std::lower_bound(__first, __last, __val); @@ -3938,12 +4260,13 @@ namespace std binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __val, _Compare __comp) { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + // concept requirements __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, - typename iterator_traits<_ForwardIterator>::value_type, _Tp>) - __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, _Tp, - typename iterator_traits<_ForwardIterator>::value_type>) + _Tp, _ValueType>) __glibcxx_requires_partitioned_pred(__first, __last, __val, __comp); _ForwardIterator __i = std::lower_bound(__first, __last, __val, __comp); @@ -3976,14 +4299,16 @@ namespace std includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) - __glibcxx_function_requires(_LessThanComparableConcept< - typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>) __glibcxx_requires_sorted(__first1, __last1); __glibcxx_requires_sorted(__first2, __last2); @@ -4023,15 +4348,18 @@ namespace std includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) + _ValueType1, _ValueType2>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _ValueType2, _ValueType1>) __glibcxx_requires_sorted_pred(__first1, __last1, __comp); __glibcxx_requires_sorted_pred(__first2, __last2, __comp); @@ -4070,16 +4398,20 @@ namespace std _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, - typename iterator_traits<_InputIterator1>::value_type>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) - __glibcxx_function_requires(_LessThanComparableConcept< - typename iterator_traits<_InputIterator1>::value_type>) + _ValueType1>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>) __glibcxx_requires_sorted(__first1, __last1); __glibcxx_requires_sorted(__first2, __last2); @@ -4132,17 +4464,22 @@ namespace std _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, - typename iterator_traits<_InputIterator1>::value_type>) + _ValueType1>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType2>) __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) + _ValueType1, _ValueType2>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _ValueType2, _ValueType1>) __glibcxx_requires_sorted_pred(__first1, __last1, __comp); __glibcxx_requires_sorted_pred(__first2, __last2, __comp); @@ -4193,16 +4530,18 @@ namespace std _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, - typename iterator_traits<_InputIterator1>::value_type>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) - __glibcxx_function_requires(_LessThanComparableConcept< - typename iterator_traits<_InputIterator1>::value_type>) + _ValueType1>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>) __glibcxx_requires_sorted(__first1, __last1); __glibcxx_requires_sorted(__first2, __last2); @@ -4247,17 +4586,20 @@ namespace std _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, - typename iterator_traits<_InputIterator1>::value_type>) + _ValueType1>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _ValueType1, _ValueType2>) __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) + _ValueType2, _ValueType1>) __glibcxx_requires_sorted_pred(__first1, __last1, __comp); __glibcxx_requires_sorted_pred(__first2, __last2, __comp); @@ -4301,16 +4643,18 @@ namespace std _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, - typename iterator_traits<_InputIterator1>::value_type>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) - __glibcxx_function_requires(_LessThanComparableConcept< - typename iterator_traits<_InputIterator1>::value_type>) + _ValueType1>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>) __glibcxx_requires_sorted(__first1, __last1); __glibcxx_requires_sorted(__first2, __last2); @@ -4359,17 +4703,20 @@ namespace std _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, - typename iterator_traits<_InputIterator1>::value_type>) + _ValueType1>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _ValueType1, _ValueType2>) __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) + _ValueType2, _ValueType1>) __glibcxx_requires_sorted_pred(__first1, __last1, __comp); __glibcxx_requires_sorted_pred(__first2, __last2, __comp); @@ -4413,16 +4760,20 @@ namespace std _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, - typename iterator_traits<_InputIterator1>::value_type>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) - __glibcxx_function_requires(_LessThanComparableConcept< - typename iterator_traits<_InputIterator1>::value_type>) + _ValueType1>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>) __glibcxx_requires_sorted(__first1, __last1); __glibcxx_requires_sorted(__first2, __last2); @@ -4475,17 +4826,22 @@ namespace std _OutputIterator __result, _Compare __comp) { + typedef typename iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_InputIterator2>::value_type + _ValueType2; + // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) - __glibcxx_function_requires(_SameTypeConcept< - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, - typename iterator_traits<_InputIterator1>::value_type>) + _ValueType1>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType2>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _ValueType1, _ValueType2>) __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, - typename iterator_traits<_InputIterator1>::value_type, - typename iterator_traits<_InputIterator2>::value_type>) + _ValueType2, _ValueType1>) __glibcxx_requires_sorted_pred(__first1, __last1, __comp); __glibcxx_requires_sorted_pred(__first2, __last2, __comp); @@ -5143,6 +5499,6 @@ namespace std __comp); } -} // namespace std +_GLIBCXX_END_NAMESPACE #endif /* _ALGO_H */ diff --git a/contrib/libstdc++/include/bits/stl_algobase.h b/contrib/libstdc++/include/bits/stl_algobase.h index d482529..6f19feb 100644 --- a/contrib/libstdc++/include/bits/stl_algobase.h +++ b/contrib/libstdc++/include/bits/stl_algobase.h @@ -1,6 +1,7 @@ // Bits and pieces used in algorithms -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -66,18 +67,68 @@ #include #include #include -#include #include #include -#include +#include +#include #include #include #include #include #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + + /** + * @brief Swaps two values. + * @param a A thing of arbitrary type. + * @param b Another thing of arbitrary type. + * @return Nothing. + * + * This is the simple classic generic implementation. It will work on + * any type which has a copy constructor and an assignment operator. + */ + template + inline void + swap(_Tp& __a, _Tp& __b) + { + // concept requirements + __glibcxx_function_requires(_SGIAssignableConcept<_Tp>) + + _Tp __tmp = __a; + __a = __b; + __b = __tmp; + } + + // See http://gcc.gnu.org/ml/libstdc++/2004-08/msg00167.html: in a + // nutshell, we are partially implementing the resolution of DR 187, + // when it's safe, i.e., the value_types are equal. + template + struct __iter_swap + { + template + static void + iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) + { + typedef typename iterator_traits<_ForwardIterator1>::value_type + _ValueType1; + _ValueType1 __tmp = *__a; + *__a = *__b; + *__b = __tmp; + } + }; + + template<> + struct __iter_swap + { + template + static void + iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) + { + swap(*__a, *__b); + } + }; + /** * @brief Swaps the contents of two iterators. * @param a An iterator. @@ -106,36 +157,17 @@ namespace std __glibcxx_function_requires(_ConvertibleConcept<_ValueType2, _ValueType1>) - const _ValueType1 __tmp = *__a; - *__a = *__b; - *__b = __tmp; + typedef typename iterator_traits<_ForwardIterator1>::reference + _ReferenceType1; + typedef typename iterator_traits<_ForwardIterator2>::reference + _ReferenceType2; + std::__iter_swap<__are_same<_ValueType1, _ValueType2>::__value && + __are_same<_ValueType1 &, _ReferenceType1>::__value && + __are_same<_ValueType2 &, _ReferenceType2>::__value>:: + iter_swap(__a, __b); } /** - * @brief Swaps two values. - * @param a A thing of arbitrary type. - * @param b Another thing of arbitrary type. - * @return Nothing. - * - * This is the simple classic generic implementation. It will work on - * any type which has a copy constructor and an assignment operator. - */ - template - inline void - swap(_Tp& __a, _Tp& __b) - { - // concept requirements - __glibcxx_function_requires(_SGIAssignableConcept<_Tp>) - - const _Tp __tmp = __a; - __a = __b; - __b = __tmp; - } - - #undef min - #undef max - - /** * @brief This does what you think it does. * @param a A thing of arbitrary type. * @param b Another thing of arbitrary type. @@ -219,113 +251,122 @@ namespace std return __a; } - // All of these auxiliary functions serve two purposes. (1) Replace + // All of these auxiliary structs serve two purposes. (1) Replace // calls to copy with memmove whenever possible. (Memmove, not memcpy, // because the input and output ranges are permitted to overlap.) // (2) If we're using random access iterators, then write the loop as // a for loop with an explicit count. - template - inline _OutputIterator - __copy(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, input_iterator_tag) + template + struct __copy { - for (; __first != __last; ++__result, ++__first) - *__result = *__first; - return __result; - } + template + static _OI + copy(_II __first, _II __last, _OI __result) + { + for (; __first != __last; ++__result, ++__first) + *__result = *__first; + return __result; + } + }; - template - inline _OutputIterator - __copy(_RandomAccessIterator __first, _RandomAccessIterator __last, - _OutputIterator __result, random_access_iterator_tag) - { - typedef typename iterator_traits<_RandomAccessIterator>::difference_type - _Distance; - for (_Distance __n = __last - __first; __n > 0; --__n) - { - *__result = *__first; - ++__first; - ++__result; + template + struct __copy<_BoolType, random_access_iterator_tag> + { + template + static _OI + copy(_II __first, _II __last, _OI __result) + { + typedef typename iterator_traits<_II>::difference_type _Distance; + for(_Distance __n = __last - __first; __n > 0; --__n) + { + *__result = *__first; + ++__first; + ++__result; + } + return __result; } - return __result; - } + }; - template - inline _Tp* - __copy_trivial(const _Tp* __first, const _Tp* __last, _Tp* __result) + template<> + struct __copy { - std::memmove(__result, __first, sizeof(_Tp) * (__last - __first)); - return __result + (__last - __first); - } - - template - inline _OutputIterator - __copy_aux2(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, __false_type) - { return std::__copy(__first, __last, __result, - std::__iterator_category(__first)); } - - template - inline _OutputIterator - __copy_aux2(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, __true_type) - { return std::__copy(__first, __last, __result, - std::__iterator_category(__first)); } - - template - inline _Tp* - __copy_aux2(_Tp* __first, _Tp* __last, _Tp* __result, __true_type) - { return std::__copy_trivial(__first, __last, __result); } + template + static _Tp* + copy(const _Tp* __first, const _Tp* __last, _Tp* __result) + { + std::memmove(__result, __first, sizeof(_Tp) * (__last - __first)); + return __result + (__last - __first); + } + }; - template - inline _Tp* - __copy_aux2(const _Tp* __first, const _Tp* __last, _Tp* __result, - __true_type) - { return std::__copy_trivial(__first, __last, __result); } + template + inline _OI + __copy_aux(_II __first, _II __last, _OI __result) + { + typedef typename iterator_traits<_II>::value_type _ValueTypeI; + typedef typename iterator_traits<_OI>::value_type _ValueTypeO; + typedef typename iterator_traits<_II>::iterator_category _Category; + const bool __simple = (__is_scalar<_ValueTypeI>::__value + && __is_pointer<_II>::__value + && __is_pointer<_OI>::__value + && __are_same<_ValueTypeI, _ValueTypeO>::__value); - template - inline _OutputIterator - __copy_ni2(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, __true_type) - { - typedef typename iterator_traits<_InputIterator>::value_type - _ValueType; - typedef typename __type_traits< - _ValueType>::has_trivial_assignment_operator _Trivial; - return _OutputIterator(std::__copy_aux2(__first, __last, __result.base(), - _Trivial())); + return std::__copy<__simple, _Category>::copy(__first, __last, __result); } - template - inline _OutputIterator - __copy_ni2(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, __false_type) + // Helpers for streambuf iterators (either istream or ostream). + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + __copy_aux(_CharT*, _CharT*, ostreambuf_iterator<_CharT>); + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + __copy_aux(const _CharT*, const _CharT*, ostreambuf_iterator<_CharT>); + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, _CharT*>::__type + __copy_aux(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, + _CharT*); + + template + struct __copy_normal + { + template + static _OI + __copy_n(_II __first, _II __last, _OI __result) + { return std::__copy_aux(__first, __last, __result); } + }; + + template<> + struct __copy_normal { - typedef typename iterator_traits<_InputIterator>::value_type _ValueType; - typedef typename __type_traits< - _ValueType>::has_trivial_assignment_operator _Trivial; - return std::__copy_aux2(__first, __last, __result, _Trivial()); - } + template + static _OI + __copy_n(_II __first, _II __last, _OI __result) + { return std::__copy_aux(__first.base(), __last.base(), __result); } + }; - template - inline _OutputIterator - __copy_ni1(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, __true_type) + template<> + struct __copy_normal { - typedef typename _Is_normal_iterator<_OutputIterator>::_Normal __Normal; - return std::__copy_ni2(__first.base(), __last.base(), - __result, __Normal()); - } + template + static _OI + __copy_n(_II __first, _II __last, _OI __result) + { return _OI(std::__copy_aux(__first, __last, __result.base())); } + }; - template - inline _OutputIterator - __copy_ni1(_InputIterator __first, _InputIterator __last, - _OutputIterator __result, __false_type) + template<> + struct __copy_normal { - typedef typename _Is_normal_iterator<_OutputIterator>::_Normal __Normal; - return std::__copy_ni2(__first, __last, __result, __Normal()); - } + template + static _OI + __copy_n(_II __first, _II __last, _OI __result) + { return _OI(std::__copy_aux(__first.base(), __last.base(), + __result.base())); } + }; /** * @brief Copies the range [first,last) into result. @@ -354,116 +395,114 @@ namespace std typename iterator_traits<_InputIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); - typedef typename _Is_normal_iterator<_InputIterator>::_Normal __Normal; - return std::__copy_ni1(__first, __last, __result, __Normal()); - } - - template - inline _BidirectionalIterator2 - __copy_backward(_BidirectionalIterator1 __first, - _BidirectionalIterator1 __last, - _BidirectionalIterator2 __result, - bidirectional_iterator_tag) - { - while (__first != __last) - *--__result = *--__last; - return __result; - } - - template - inline _BidirectionalIterator - __copy_backward(_RandomAccessIterator __first, _RandomAccessIterator __last, - _BidirectionalIterator __result, random_access_iterator_tag) - { - typename iterator_traits<_RandomAccessIterator>::difference_type __n; - for (__n = __last - __first; __n > 0; --__n) - *--__result = *--__last; - return __result; + const bool __in = __is_normal_iterator<_InputIterator>::__value; + const bool __out = __is_normal_iterator<_OutputIterator>::__value; + return std::__copy_normal<__in, __out>::__copy_n(__first, __last, + __result); } - - // This dispatch class is a workaround for compilers that do not - // have partial ordering of function templates. All we're doing is - // creating a specialization so that we can turn a call to copy_backward - // into a memmove whenever possible. - template - struct __copy_backward_dispatch - { - static _BidirectionalIterator2 - copy(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, - _BidirectionalIterator2 __result) - { return std::__copy_backward(__first, __last, __result, - std::__iterator_category(__first)); } + // Overload for streambuf iterators. + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + copy(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, + ostreambuf_iterator<_CharT>); + + template + struct __copy_backward + { + template + static _BI2 + __copy_b(_BI1 __first, _BI1 __last, _BI2 __result) + { + while (__first != __last) + *--__result = *--__last; + return __result; + } }; - template - struct __copy_backward_dispatch<_Tp*, _Tp*, __true_type> - { - static _Tp* - copy(const _Tp* __first, const _Tp* __last, _Tp* __result) - { - const ptrdiff_t _Num = __last - __first; - std::memmove(__result - _Num, __first, sizeof(_Tp) * _Num); - return __result - _Num; - } + template + struct __copy_backward<_BoolType, random_access_iterator_tag> + { + template + static _BI2 + __copy_b(_BI1 __first, _BI1 __last, _BI2 __result) + { + typename iterator_traits<_BI1>::difference_type __n; + for (__n = __last - __first; __n > 0; --__n) + *--__result = *--__last; + return __result; + } }; - template - struct __copy_backward_dispatch - { - static _Tp* - copy(const _Tp* __first, const _Tp* __last, _Tp* __result) - { - return std::__copy_backward_dispatch<_Tp*, _Tp*, __true_type> - ::copy(__first, __last, __result); - } + template<> + struct __copy_backward + { + template + static _Tp* + __copy_b(const _Tp* __first, const _Tp* __last, _Tp* __result) + { + const ptrdiff_t _Num = __last - __first; + std::memmove(__result - _Num, __first, sizeof(_Tp) * _Num); + return __result - _Num; + } }; template inline _BI2 __copy_backward_aux(_BI1 __first, _BI1 __last, _BI2 __result) { - typedef typename __type_traits::value_type> - ::has_trivial_assignment_operator _Trivial; - return - std::__copy_backward_dispatch<_BI1, _BI2, _Trivial>::copy(__first, - __last, - __result); + typedef typename iterator_traits<_BI1>::value_type _ValueType1; + typedef typename iterator_traits<_BI2>::value_type _ValueType2; + typedef typename iterator_traits<_BI1>::iterator_category _Category; + const bool __simple = (__is_scalar<_ValueType1>::__value + && __is_pointer<_BI1>::__value + && __is_pointer<_BI2>::__value + && __are_same<_ValueType1, _ValueType2>::__value); + + return std::__copy_backward<__simple, _Category>::__copy_b(__first, + __last, + __result); } - template - inline _BI2 - __copy_backward_output_normal_iterator(_BI1 __first, _BI1 __last, - _BI2 __result, __true_type) - { return _BI2(std::__copy_backward_aux(__first, __last, __result.base())); } + template + struct __copy_backward_normal + { + template + static _BI2 + __copy_b_n(_BI1 __first, _BI1 __last, _BI2 __result) + { return std::__copy_backward_aux(__first, __last, __result); } + }; - template - inline _BI2 - __copy_backward_output_normal_iterator(_BI1 __first, _BI1 __last, - _BI2 __result, __false_type) - { return std::__copy_backward_aux(__first, __last, __result); } + template<> + struct __copy_backward_normal + { + template + static _BI2 + __copy_b_n(_BI1 __first, _BI1 __last, _BI2 __result) + { return std::__copy_backward_aux(__first.base(), __last.base(), + __result); } + }; - template - inline _BI2 - __copy_backward_input_normal_iterator(_BI1 __first, _BI1 __last, - _BI2 __result, __true_type) + template<> + struct __copy_backward_normal { - typedef typename _Is_normal_iterator<_BI2>::_Normal __Normal; - return std::__copy_backward_output_normal_iterator(__first.base(), - __last.base(), - __result, __Normal()); - } + template + static _BI2 + __copy_b_n(_BI1 __first, _BI1 __last, _BI2 __result) + { return _BI2(std::__copy_backward_aux(__first, __last, + __result.base())); } + }; - template - inline _BI2 - __copy_backward_input_normal_iterator(_BI1 __first, _BI1 __last, - _BI2 __result, __false_type) + template<> + struct __copy_backward_normal { - typedef typename _Is_normal_iterator<_BI2>::_Normal __Normal; - return std::__copy_backward_output_normal_iterator(__first, __last, - __result, __Normal()); - } + template + static _BI2 + __copy_b_n(_BI1 __first, _BI1 __last, _BI2 __result) + { return _BI2(std::__copy_backward_aux(__first.base(), __last.base(), + __result.base())); } + }; /** * @brief Copies the range [first,last) into result. @@ -494,11 +533,39 @@ namespace std typename iterator_traits<_BI2>::value_type>) __glibcxx_requires_valid_range(__first, __last); - typedef typename _Is_normal_iterator<_BI1>::_Normal __Normal; - return std::__copy_backward_input_normal_iterator(__first, __last, - __result, __Normal()); + const bool __bi1 = __is_normal_iterator<_BI1>::__value; + const bool __bi2 = __is_normal_iterator<_BI2>::__value; + return std::__copy_backward_normal<__bi1, __bi2>::__copy_b_n(__first, + __last, + __result); } + template + struct __fill + { + template + static void + fill(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value) + { + for (; __first != __last; ++__first) + *__first = __value; + } + }; + + template<> + struct __fill + { + template + static void + fill(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value) + { + const _Tp __tmp = __value; + for (; __first != __last; ++__first) + *__first = __tmp; + } + }; /** * @brief Fills the range [first,last) with copies of value. @@ -520,31 +587,8 @@ namespace std _ForwardIterator>) __glibcxx_requires_valid_range(__first, __last); - for ( ; __first != __last; ++__first) - *__first = __value; - } - - /** - * @brief Fills the range [first,first+n) with copies of value. - * @param first An output iterator. - * @param n The count of copies to perform. - * @param value A reference-to-const of arbitrary type. - * @return The iterator at first+n. - * - * This function fills a range with copies of the same value. For one-byte - * types filling contiguous areas of memory, this becomes an inline call to - * @c memset. - */ - template - _OutputIterator - fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) - { - // concept requirements - __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,_Tp>) - - for ( ; __n > 0; --__n, ++__first) - *__first = __value; - return __first; + const bool __scalar = __is_scalar<_Tp>::__value; + std::__fill<__scalar>::fill(__first, __last, __value); } // Specialization: for one-byte types we can use memset. @@ -572,6 +616,55 @@ namespace std std::memset(__first, static_cast(__tmp), __last - __first); } + template + struct __fill_n + { + template + static _OutputIterator + fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) + { + for (; __n > 0; --__n, ++__first) + *__first = __value; + return __first; + } + }; + + template<> + struct __fill_n + { + template + static _OutputIterator + fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) + { + const _Tp __tmp = __value; + for (; __n > 0; --__n, ++__first) + *__first = __tmp; + return __first; + } + }; + + /** + * @brief Fills the range [first,first+n) with copies of value. + * @param first An output iterator. + * @param n The count of copies to perform. + * @param value A reference-to-const of arbitrary type. + * @return The iterator at first+n. + * + * This function fills a range with copies of the same value. For one-byte + * types filling contiguous areas of memory, this becomes an inline call to + * @c memset. + */ + template + _OutputIterator + fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) + { + // concept requirements + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _Tp>) + + const bool __scalar = __is_scalar<_Tp>::__value; + return std::__fill_n<__scalar>::fill_n(__first, __n, __value); + } + template inline unsigned char* fill_n(unsigned char* __first, _Size __n, const unsigned char& __c) @@ -582,7 +675,7 @@ namespace std template inline signed char* - fill_n(char* __first, _Size __n, const signed char& __c) + fill_n(signed char* __first, _Size __n, const signed char& __c) { std::fill(__first, __first + __n, __c); return __first + __n; @@ -596,7 +689,6 @@ namespace std return __first + __n; } - /** * @brief Finds the places in ranges which don't match. * @param first1 An input iterator. @@ -686,8 +778,8 @@ namespace std typename iterator_traits<_InputIterator1>::value_type, typename iterator_traits<_InputIterator2>::value_type>) __glibcxx_requires_valid_range(__first1, __last1); - - for ( ; __first1 != __last1; ++__first1, ++__first2) + + for (; __first1 != __last1; ++__first1, ++__first2) if (!(*__first1 == *__first2)) return false; return true; @@ -718,7 +810,7 @@ namespace std __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_requires_valid_range(__first1, __last1); - for ( ; __first1 != __last1; ++__first1, ++__first2) + for (; __first1 != __last1; ++__first1, ++__first2) if (!__binary_pred(*__first1, *__first2)) return false; return true; @@ -755,7 +847,8 @@ namespace std __glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first2, __last2); - for (;__first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, ++__first2) { if (*__first1 < *__first2) return true; @@ -790,8 +883,8 @@ namespace std __glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first2, __last2); - for ( ; __first1 != __last1 && __first2 != __last2 - ; ++__first1, ++__first2) + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, ++__first2) { if (__comp(*__first1, *__first2)) return true; @@ -837,6 +930,6 @@ namespace std #endif /* CHAR_MAX == SCHAR_MAX */ } -} // namespace std +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/stl_bvector.h b/contrib/libstdc++/include/bits/stl_bvector.h index afae738..9dc2656 100644 --- a/contrib/libstdc++/include/bits/stl_bvector.h +++ b/contrib/libstdc++/include/bits/stl_bvector.h @@ -1,6 +1,7 @@ // vector specialization -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -61,8 +62,8 @@ #ifndef _BVECTOR_H #define _BVECTOR_H 1 -namespace _GLIBCXX_STD -{ +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) + typedef unsigned long _Bit_type; enum { _S_word_bit = int(CHAR_BIT * sizeof(_Bit_type)) }; @@ -76,7 +77,8 @@ namespace _GLIBCXX_STD _Bit_reference() : _M_p(0), _M_mask(0) { } - operator bool() const { return !!(*_M_p & _M_mask); } + operator bool() const + { return !!(*_M_p & _M_mask); } _Bit_reference& operator=(bool __x) @@ -101,10 +103,12 @@ namespace _GLIBCXX_STD { return !bool(*this) && bool(__x); } void - flip() { *_M_p ^= _M_mask; } + flip() + { *_M_p ^= _M_mask; } }; - struct _Bit_iterator_base : public iterator + struct _Bit_iterator_base + : public std::iterator { _Bit_type * _M_p; unsigned int _M_offset; @@ -115,7 +119,7 @@ namespace _GLIBCXX_STD void _M_bump_up() { - if (_M_offset++ == _S_word_bit - 1) + if (_M_offset++ == int(_S_word_bit) - 1) { _M_offset = 0; ++_M_p; @@ -127,7 +131,7 @@ namespace _GLIBCXX_STD { if (_M_offset-- == 0) { - _M_offset = _S_word_bit - 1; + _M_offset = int(_S_word_bit) - 1; --_M_p; } } @@ -136,15 +140,14 @@ namespace _GLIBCXX_STD _M_incr(ptrdiff_t __i) { difference_type __n = __i + _M_offset; - _M_p += __n / _S_word_bit; - __n = __n % _S_word_bit; + _M_p += __n / int(_S_word_bit); + __n = __n % int(_S_word_bit); if (__n < 0) { - _M_offset = static_cast(__n + _S_word_bit); + __n += int(_S_word_bit); --_M_p; } - else - _M_offset = static_cast(__n); + _M_offset = static_cast(__n); } bool @@ -178,7 +181,8 @@ namespace _GLIBCXX_STD inline ptrdiff_t operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { - return _S_word_bit * (__x._M_p - __y._M_p) + __x._M_offset - __y._M_offset; + return (int(_S_word_bit) * (__x._M_p - __y._M_p) + + __x._M_offset - __y._M_offset); } struct _Bit_iterator : public _Bit_iterator_base @@ -188,11 +192,13 @@ namespace _GLIBCXX_STD typedef _Bit_iterator iterator; _Bit_iterator() : _Bit_iterator_base(0, 0) { } + _Bit_iterator(_Bit_type * __x, unsigned int __y) : _Bit_iterator_base(__x, __y) { } reference - operator*() const { return reference(_M_p, 1UL << _M_offset); } + operator*() const + { return reference(_M_p, 1UL << _M_offset); } iterator& operator++() @@ -253,13 +259,13 @@ namespace _GLIBCXX_STD } reference - operator[](difference_type __i) + operator[](difference_type __i) const { return *(*this + __i); } }; inline _Bit_iterator - operator+(ptrdiff_t __n, const _Bit_iterator& __x) { return __x + __n; } - + operator+(ptrdiff_t __n, const _Bit_iterator& __x) + { return __x + __n; } struct _Bit_const_iterator : public _Bit_iterator_base { @@ -269,8 +275,10 @@ namespace _GLIBCXX_STD typedef _Bit_const_iterator const_iterator; _Bit_const_iterator() : _Bit_iterator_base(0, 0) { } + _Bit_const_iterator(_Bit_type * __x, unsigned int __y) : _Bit_iterator_base(__x, __y) { } + _Bit_const_iterator(const _Bit_iterator& __x) : _Bit_iterator_base(__x._M_p, __x._M_offset) { } @@ -323,7 +331,8 @@ namespace _GLIBCXX_STD } const_iterator - operator+(difference_type __i) const { + operator+(difference_type __i) const + { const_iterator __tmp = *this; return __tmp += __i; } @@ -336,7 +345,7 @@ namespace _GLIBCXX_STD } const_reference - operator[](difference_type __i) + operator[](difference_type __i) const { return *(*this + __i); } }; @@ -344,13 +353,34 @@ namespace _GLIBCXX_STD operator+(ptrdiff_t __n, const _Bit_const_iterator& __x) { return __x + __n; } + inline void + __fill_bvector(_Bit_iterator __first, _Bit_iterator __last, bool __x) + { + for (; __first != __last; ++__first) + *__first = __x; + } + + inline void + fill(_Bit_iterator __first, _Bit_iterator __last, const bool& __x) + { + if (__first._M_p != __last._M_p) + { + std::fill(__first._M_p + 1, __last._M_p, __x ? ~0 : 0); + __fill_bvector(__first, _Bit_iterator(__first._M_p + 1, 0), __x); + __fill_bvector(_Bit_iterator(__last._M_p, 0), __last, __x); + } + else + __fill_bvector(__first, __last, __x); + } + template - class _Bvector_base + struct _Bvector_base { typedef typename _Alloc::template rebind<_Bit_type>::other _Bit_alloc_type; - struct _Bvector_impl : public _Bit_alloc_type + struct _Bvector_impl + : public _Bit_alloc_type { _Bit_iterator _M_start; _Bit_iterator _M_finish; @@ -363,36 +393,47 @@ namespace _GLIBCXX_STD public: typedef _Alloc allocator_type; + _Bit_alloc_type& + _M_get_Bit_allocator() + { return *static_cast<_Bit_alloc_type*>(&this->_M_impl); } + + const _Bit_alloc_type& + _M_get_Bit_allocator() const + { return *static_cast(&this->_M_impl); } + allocator_type get_allocator() const - { return *static_cast(&this->_M_impl); } + { return allocator_type(_M_get_Bit_allocator()); } _Bvector_base(const allocator_type& __a) : _M_impl(__a) { } - ~_Bvector_base() { this->_M_deallocate(); } + ~_Bvector_base() + { this->_M_deallocate(); } protected: _Bvector_impl _M_impl; _Bit_type* _M_allocate(size_t __n) - { return _M_impl.allocate((__n + _S_word_bit - 1) / _S_word_bit); } + { return _M_impl.allocate((__n + int(_S_word_bit) - 1) + / int(_S_word_bit)); } void _M_deallocate() { if (_M_impl._M_start._M_p) _M_impl.deallocate(_M_impl._M_start._M_p, - _M_impl._M_end_of_storage - _M_impl._M_start._M_p); + _M_impl._M_end_of_storage - _M_impl._M_start._M_p); } }; -} // namespace std + +_GLIBCXX_END_NESTED_NAMESPACE // Declare a partial specialization of vector. #include -namespace _GLIBCXX_STD -{ +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) + /** * @brief A specialization of vector for booleans which offers fixed time * access to individual elements in any order. @@ -412,345 +453,223 @@ namespace _GLIBCXX_STD * also provided as with C-style arrays. */ template - class vector : public _Bvector_base<_Alloc> + class vector : protected _Bvector_base<_Alloc> { - public: - typedef bool value_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Bit_reference reference; - typedef bool const_reference; - typedef _Bit_reference* pointer; - typedef const bool* const_pointer; + typedef _Bvector_base<_Alloc> _Base; - typedef _Bit_iterator iterator; - typedef _Bit_const_iterator const_iterator; - - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; - - typedef typename _Bvector_base<_Alloc>::allocator_type allocator_type; + public: + typedef bool value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Bit_reference reference; + typedef bool const_reference; + typedef _Bit_reference* pointer; + typedef const bool* const_pointer; + typedef _Bit_iterator iterator; + typedef _Bit_const_iterator const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef _Alloc allocator_type; allocator_type get_allocator() const - { return _Bvector_base<_Alloc>::get_allocator(); } + { return _Base::get_allocator(); } protected: - using _Bvector_base<_Alloc>::_M_allocate; - using _Bvector_base<_Alloc>::_M_deallocate; + using _Base::_M_allocate; + using _Base::_M_deallocate; + using _Base::_M_get_Bit_allocator; - protected: - void _M_initialize(size_type __n) + public: + explicit + vector(const allocator_type& __a = allocator_type()) + : _Base(__a) { } + + explicit + vector(size_type __n, const bool& __value = bool(), + const allocator_type& __a = allocator_type()) + : _Base(__a) { - _Bit_type* __q = this->_M_allocate(__n); - this->_M_impl._M_end_of_storage = __q - + (__n + _S_word_bit - 1) / _S_word_bit; - this->_M_impl._M_start = iterator(__q, 0); - this->_M_impl._M_finish = this->_M_impl._M_start + difference_type(__n); + _M_initialize(__n); + std::fill(this->_M_impl._M_start._M_p, this->_M_impl._M_end_of_storage, + __value ? ~0 : 0); } - void _M_insert_aux(iterator __position, bool __x) + vector(const vector& __x) + : _Base(__x._M_get_Bit_allocator()) { - if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage) - { - std::copy_backward(__position, this->_M_impl._M_finish, - this->_M_impl._M_finish + 1); - *__position = __x; - ++this->_M_impl._M_finish; - } - else - { - const size_type __len = size() ? 2 * size() - : static_cast(_S_word_bit); - _Bit_type * __q = this->_M_allocate(__len); - iterator __i = std::copy(begin(), __position, iterator(__q, 0)); - *__i++ = __x; - this->_M_impl._M_finish = std::copy(__position, end(), __i); - this->_M_deallocate(); - this->_M_impl._M_end_of_storage = __q + (__len + _S_word_bit - 1) - / _S_word_bit; - this->_M_impl._M_start = iterator(__q, 0); - } + _M_initialize(__x.size()); + _M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start); } template - void _M_initialize_range(_InputIterator __first, _InputIterator __last, - input_iterator_tag) - { - this->_M_impl._M_start = iterator(); - this->_M_impl._M_finish = iterator(); - this->_M_impl._M_end_of_storage = 0; - for ( ; __first != __last; ++__first) - push_back(*__first); - } + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } - template - void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) - { - const size_type __n = std::distance(__first, __last); - _M_initialize(__n); - std::copy(__first, __last, this->_M_impl._M_start); - } + ~vector() { } - template - void _M_insert_range(iterator __pos, _InputIterator __first, - _InputIterator __last, input_iterator_tag) + vector& + operator=(const vector& __x) { - for ( ; __first != __last; ++__first) + if (&__x == this) + return *this; + if (__x.size() > capacity()) { - __pos = insert(__pos, *__first); - ++__pos; + this->_M_deallocate(); + _M_initialize(__x.size()); } + this->_M_impl._M_finish = _M_copy_aligned(__x.begin(), __x.end(), + begin()); + return *this; } - template - void _M_insert_range(iterator __position, _ForwardIterator __first, - _ForwardIterator __last, forward_iterator_tag) - { - if (__first != __last) - { - size_type __n = std::distance(__first, __last); - if (capacity() - size() >= __n) - { - std::copy_backward(__position, end(), - this->_M_impl._M_finish + difference_type(__n)); - std::copy(__first, __last, __position); - this->_M_impl._M_finish += difference_type(__n); - } - else - { - const size_type __len = size() + std::max(size(), __n); - _Bit_type * __q = this->_M_allocate(__len); - iterator __i = std::copy(begin(), __position, iterator(__q, 0)); - __i = std::copy(__first, __last, __i); - this->_M_impl._M_finish = std::copy(__position, end(), __i); - this->_M_deallocate(); - this->_M_impl._M_end_of_storage = __q + (__len + _S_word_bit - 1) - / _S_word_bit; - this->_M_impl._M_start = iterator(__q, 0); - } - } - } + // assign(), a generalized assignment member function. Two + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + void + assign(size_type __n, const bool& __x) + { _M_fill_assign(__n, __x); } - public: - iterator begin() + template + void + assign(_InputIterator __first, _InputIterator __last) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } + + iterator + begin() { return this->_M_impl._M_start; } - const_iterator begin() const + const_iterator + begin() const { return this->_M_impl._M_start; } - iterator end() + iterator + end() { return this->_M_impl._M_finish; } - const_iterator end() const + const_iterator + end() const { return this->_M_impl._M_finish; } - reverse_iterator rbegin() + reverse_iterator + rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const + const_reverse_iterator + rbegin() const { return const_reverse_iterator(end()); } - reverse_iterator rend() + reverse_iterator + rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const + const_reverse_iterator + rend() const { return const_reverse_iterator(begin()); } - size_type size() const + size_type + size() const { return size_type(end() - begin()); } - size_type max_size() const - { return size_type(-1); } - - size_type capacity() const - { return size_type(const_iterator(this->_M_impl._M_end_of_storage, 0) - - begin()); } - bool empty() const - { return begin() == end(); } - - reference operator[](size_type __n) - { return *(begin() + difference_type(__n)); } - - const_reference operator[](size_type __n) const - { return *(begin() + difference_type(__n)); } - - void _M_range_check(size_type __n) const - { - if (__n >= this->size()) - __throw_out_of_range(__N("vector::_M_range_check")); - } - - reference at(size_type __n) - { _M_range_check(__n); return (*this)[__n]; } - - const_reference at(size_type __n) const - { _M_range_check(__n); return (*this)[__n]; } - - explicit vector(const allocator_type& __a = allocator_type()) - : _Bvector_base<_Alloc>(__a) { } - - vector(size_type __n, bool __value, - const allocator_type& __a = allocator_type()) - : _Bvector_base<_Alloc>(__a) - { - _M_initialize(__n); - std::fill(this->_M_impl._M_start._M_p, this->_M_impl._M_end_of_storage, - __value ? ~0 : 0); - } - - explicit vector(size_type __n) - : _Bvector_base<_Alloc>(allocator_type()) + size_type + max_size() const { - _M_initialize(__n); - std::fill(this->_M_impl._M_start._M_p, - this->_M_impl._M_end_of_storage, 0); - } - - vector(const vector& __x) : _Bvector_base<_Alloc>(__x.get_allocator()) - { - _M_initialize(__x.size()); - std::copy(__x.begin(), __x.end(), this->_M_impl._M_start); + const size_type __asize = _M_get_Bit_allocator().max_size(); + return (__asize <= size_type(-1) / int(_S_word_bit) ? + __asize * int(_S_word_bit) : size_type(-1)); } - // Check whether it's an integral type. If so, it's not an iterator. - template - void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) - { - _M_initialize(__n); - std::fill(this->_M_impl._M_start._M_p, - this->_M_impl._M_end_of_storage, __x ? ~0 : 0); - } - - template - void - _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, - __false_type) - { _M_initialize_range(__first, __last, - std::__iterator_category(__first)); } - - template - vector(_InputIterator __first, _InputIterator __last, - const allocator_type& __a = allocator_type()) - : _Bvector_base<_Alloc>(__a) - { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_initialize_dispatch(__first, __last, _Integral()); - } + size_type + capacity() const + { return size_type(const_iterator(this->_M_impl._M_end_of_storage, 0) + - begin()); } - ~vector() { } + bool + empty() const + { return begin() == end(); } - vector& operator=(const vector& __x) + reference + operator[](size_type __n) { - if (&__x == this) - return *this; - if (__x.size() > capacity()) - { - this->_M_deallocate(); - _M_initialize(__x.size()); - } - std::copy(__x.begin(), __x.end(), begin()); - this->_M_impl._M_finish = begin() + difference_type(__x.size()); - return *this; + return *iterator(this->_M_impl._M_start._M_p + + __n / int(_S_word_bit), __n % int(_S_word_bit)); } - // assign(), a generalized assignment member function. Two - // versions: one that takes a count, and one that takes a range. - // The range version is a member template, so we dispatch on whether - // or not the type is an integer. - - void _M_fill_assign(size_t __n, bool __x) + const_reference + operator[](size_type __n) const { - if (__n > size()) - { - std::fill(this->_M_impl._M_start._M_p, - this->_M_impl._M_end_of_storage, __x ? ~0 : 0); - insert(end(), __n - size(), __x); - } - else - { - erase(begin() + __n, end()); - std::fill(this->_M_impl._M_start._M_p, - this->_M_impl._M_end_of_storage, __x ? ~0 : 0); - } + return *const_iterator(this->_M_impl._M_start._M_p + + __n / int(_S_word_bit), __n % int(_S_word_bit)); } - void assign(size_t __n, bool __x) - { _M_fill_assign(__n, __x); } - - template - void assign(_InputIterator __first, _InputIterator __last) + protected: + void + _M_range_check(size_type __n) const { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_assign_dispatch(__first, __last, _Integral()); + if (__n >= this->size()) + __throw_out_of_range(__N("vector::_M_range_check")); } - template - void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) - { _M_fill_assign((size_t) __n, (bool) __val); } - - template - void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, - __false_type) - { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } - - template - void _M_assign_aux(_InputIterator __first, _InputIterator __last, - input_iterator_tag) - { - iterator __cur = begin(); - for ( ; __first != __last && __cur != end(); ++__cur, ++__first) - *__cur = *__first; - if (__first == __last) - erase(__cur, end()); - else - insert(end(), __first, __last); - } + public: + reference + at(size_type __n) + { _M_range_check(__n); return (*this)[__n]; } - template - void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) - { - const size_type __len = std::distance(__first, __last); - if (__len < size()) - erase(std::copy(__first, __last, begin()), end()); - else - { - _ForwardIterator __mid = __first; - std::advance(__mid, size()); - std::copy(__first, __mid, begin()); - insert(end(), __mid, __last); - } - } + const_reference + at(size_type __n) const + { _M_range_check(__n); return (*this)[__n]; } - void reserve(size_type __n) + void + reserve(size_type __n) { if (__n > this->max_size()) __throw_length_error(__N("vector::reserve")); if (this->capacity() < __n) { _Bit_type* __q = this->_M_allocate(__n); - this->_M_impl._M_finish = std::copy(begin(), end(), - iterator(__q, 0)); + this->_M_impl._M_finish = _M_copy_aligned(begin(), end(), + iterator(__q, 0)); this->_M_deallocate(); this->_M_impl._M_start = iterator(__q, 0); - this->_M_impl._M_end_of_storage = __q + (__n + _S_word_bit - 1) / _S_word_bit; + this->_M_impl._M_end_of_storage = (__q + (__n + int(_S_word_bit) - 1) + / int(_S_word_bit)); } } - reference front() + reference + front() { return *begin(); } - const_reference front() const + const_reference + front() const { return *begin(); } - reference back() + reference + back() { return *(end() - 1); } - const_reference back() const + const_reference + back() const { return *(end() - 1); } - void push_back(bool __x) + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + // N.B. DR 464 says nothing about vector but we need something + // here due to the way we are implementing DR 464 in the debug-mode + // vector class. + void + data() { } + + void + push_back(bool __x) { if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage) *this->_M_impl._M_finish++ = __x; @@ -758,23 +677,31 @@ template _M_insert_aux(end(), __x); } - void swap(vector& __x) + void + swap(vector& __x) { std::swap(this->_M_impl._M_start, __x._M_impl._M_start); std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); std::swap(this->_M_impl._M_end_of_storage, __x._M_impl._M_end_of_storage); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 431. Swapping containers with unequal allocators. + std::__alloc_swap:: + _S_do_it(_M_get_Bit_allocator(), __x._M_get_Bit_allocator()); } // [23.2.5]/1, third-to-last entry in synopsis listing - static void swap(reference __x, reference __y) + static void + swap(reference __x, reference __y) { bool __tmp = __x; __x = __y; __y = __tmp; } - iterator insert(iterator __position, bool __x = bool()) + iterator + insert(iterator __position, const bool& __x = bool()) { const difference_type __n = __position - begin(); if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage @@ -785,29 +712,195 @@ template return begin() + __n; } - // Check whether it's an integral type. If so, it's not an iterator. + template + void + insert(iterator __position, + _InputIterator __first, _InputIterator __last) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_insert_dispatch(__position, __first, __last, _Integral()); + } + void + insert(iterator __position, size_type __n, const bool& __x) + { _M_fill_insert(__position, __n, __x); } + + void + pop_back() + { --this->_M_impl._M_finish; } + + iterator + erase(iterator __position) + { + if (__position + 1 != end()) + std::copy(__position + 1, end(), __position); + --this->_M_impl._M_finish; + return __position; + } + + iterator + erase(iterator __first, iterator __last) + { + _M_erase_at_end(std::copy(__last, end(), __first)); + return __first; + } + + void + resize(size_type __new_size, bool __x = bool()) + { + if (__new_size < size()) + _M_erase_at_end(begin() + difference_type(__new_size)); + else + insert(end(), __new_size - size(), __x); + } + + void + flip() + { + for (_Bit_type * __p = this->_M_impl._M_start._M_p; + __p != this->_M_impl._M_end_of_storage; ++__p) + *__p = ~*__p; + } + + void + clear() + { _M_erase_at_end(begin()); } + + + protected: + // Precondition: __first._M_offset == 0 && __result._M_offset == 0. + iterator + _M_copy_aligned(const_iterator __first, const_iterator __last, + iterator __result) + { + _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p); + return std::copy(const_iterator(__last._M_p, 0), __last, + iterator(__q, 0)); + } + + void + _M_initialize(size_type __n) + { + _Bit_type* __q = this->_M_allocate(__n); + this->_M_impl._M_end_of_storage = (__q + + ((__n + int(_S_word_bit) - 1) + / int(_S_word_bit))); + this->_M_impl._M_start = iterator(__q, 0); + this->_M_impl._M_finish = this->_M_impl._M_start + difference_type(__n); + } + + // Check whether it's an integral type. If so, it's not an iterator. template - void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, - __true_type) - { _M_fill_insert(__pos, __n, __x); } + void + _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) + { + _M_initialize(__n); + std::fill(this->_M_impl._M_start._M_p, + this->_M_impl._M_end_of_storage, __x ? ~0 : 0); + } template - void _M_insert_dispatch(iterator __pos, - _InputIterator __first, _InputIterator __last, - __false_type) - { _M_insert_range(__pos, __first, __last, - std::__iterator_category(__first)); } + void + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { _M_initialize_range(__first, __last, + std::__iterator_category(__first)); } template - void insert(iterator __position, - _InputIterator __first, _InputIterator __last) + void + _M_initialize_range(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + for (; __first != __last; ++__first) + push_back(*__first); + } + + template + void + _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __n = std::distance(__first, __last); + _M_initialize(__n); + std::copy(__first, __last, this->_M_impl._M_start); + } + + template + void + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + { _M_fill_assign((size_t) __n, (bool) __val); } + + template + void + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } + + void + _M_fill_assign(size_t __n, bool __x) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_insert_dispatch(__position, __first, __last, _Integral()); + if (__n > size()) + { + std::fill(this->_M_impl._M_start._M_p, + this->_M_impl._M_end_of_storage, __x ? ~0 : 0); + insert(end(), __n - size(), __x); + } + else + { + _M_erase_at_end(begin() + __n); + std::fill(this->_M_impl._M_start._M_p, + this->_M_impl._M_end_of_storage, __x ? ~0 : 0); + } } - void _M_fill_insert(iterator __position, size_type __n, bool __x) + template + void + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + iterator __cur = begin(); + for (; __first != __last && __cur != end(); ++__cur, ++__first) + *__cur = *__first; + if (__first == __last) + _M_erase_at_end(__cur); + else + insert(end(), __first, __last); + } + + template + void + _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __len = std::distance(__first, __last); + if (__len < size()) + _M_erase_at_end(std::copy(__first, __last, begin())); + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, size()); + std::copy(__first, __mid, begin()); + insert(end(), __mid, __last); + } + } + + // Check whether it's an integral type. If so, it's not an iterator. + template + void + _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, + __true_type) + { _M_fill_insert(__pos, __n, __x); } + + template + void + _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + __false_type) + { _M_insert_range(__pos, __first, __last, + std::__iterator_category(__first)); } + + void + _M_fill_insert(iterator __position, size_type __n, bool __x) { if (__n == 0) return; @@ -822,55 +915,97 @@ template { const size_type __len = size() + std::max(size(), __n); _Bit_type * __q = this->_M_allocate(__len); - iterator __i = std::copy(begin(), __position, iterator(__q, 0)); - std::fill_n(__i, __n, __x); + iterator __i = _M_copy_aligned(begin(), __position, + iterator(__q, 0)); + std::fill(__i, __i + difference_type(__n), __x); this->_M_impl._M_finish = std::copy(__position, end(), __i + difference_type(__n)); this->_M_deallocate(); - this->_M_impl._M_end_of_storage = __q + (__len + _S_word_bit - 1) - / _S_word_bit; + this->_M_impl._M_end_of_storage = (__q + ((__len + + int(_S_word_bit) - 1) + / int(_S_word_bit))); this->_M_impl._M_start = iterator(__q, 0); } } - void insert(iterator __position, size_type __n, bool __x) - { _M_fill_insert(__position, __n, __x); } - - void pop_back() - { --this->_M_impl._M_finish; } - - iterator erase(iterator __position) - { - if (__position + 1 != end()) - std::copy(__position + 1, end(), __position); - --this->_M_impl._M_finish; - return __position; - } + template + void + _M_insert_range(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag) + { + for (; __first != __last; ++__first) + { + __pos = insert(__pos, *__first); + ++__pos; + } + } - iterator erase(iterator __first, iterator __last) - { - this->_M_impl._M_finish = std::copy(__last, end(), __first); - return __first; - } + template + void + _M_insert_range(iterator __position, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag) + { + if (__first != __last) + { + size_type __n = std::distance(__first, __last); + if (capacity() - size() >= __n) + { + std::copy_backward(__position, end(), + this->_M_impl._M_finish + + difference_type(__n)); + std::copy(__first, __last, __position); + this->_M_impl._M_finish += difference_type(__n); + } + else + { + const size_type __len = size() + std::max(size(), __n); + _Bit_type * __q = this->_M_allocate(__len); + iterator __i = _M_copy_aligned(begin(), __position, + iterator(__q, 0)); + __i = std::copy(__first, __last, __i); + this->_M_impl._M_finish = std::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_impl._M_end_of_storage = (__q + + ((__len + + int(_S_word_bit) - 1) + / int(_S_word_bit))); + this->_M_impl._M_start = iterator(__q, 0); + } + } + } - void resize(size_type __new_size, bool __x = bool()) + void + _M_insert_aux(iterator __position, bool __x) { - if (__new_size < size()) - erase(begin() + difference_type(__new_size), end()); + if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage) + { + std::copy_backward(__position, this->_M_impl._M_finish, + this->_M_impl._M_finish + 1); + *__position = __x; + ++this->_M_impl._M_finish; + } else - insert(end(), __new_size - size(), __x); - } - - void flip() - { - for (_Bit_type * __p = this->_M_impl._M_start._M_p; - __p != this->_M_impl._M_end_of_storage; ++__p) - *__p = ~*__p; + { + const size_type __len = size() ? 2 * size() + : static_cast(_S_word_bit); + _Bit_type * __q = this->_M_allocate(__len); + iterator __i = _M_copy_aligned(begin(), __position, + iterator(__q, 0)); + *__i++ = __x; + this->_M_impl._M_finish = std::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_impl._M_end_of_storage = (__q + ((__len + + int(_S_word_bit) - 1) + / int(_S_word_bit))); + this->_M_impl._M_start = iterator(__q, 0); + } } - void clear() - { erase(begin(), end()); } + void + _M_erase_at_end(iterator __pos) + { this->_M_impl._M_finish = __pos; } }; -} // namespace std + +_GLIBCXX_END_NESTED_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/stl_construct.h b/contrib/libstdc++/include/bits/stl_construct.h index afb3387..0a03fb7 100644 --- a/contrib/libstdc++/include/bits/stl_construct.h +++ b/contrib/libstdc++/include/bits/stl_construct.h @@ -1,6 +1,6 @@ // nonstandard construct and destroy functions -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -61,11 +61,11 @@ #ifndef _STL_CONSTRUCT_H #define _STL_CONSTRUCT_H 1 -#include +#include #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @if maint * Constructs an object in existing memory by invoking an allocated @@ -117,7 +117,10 @@ namespace std inline void __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type) - { for ( ; __first != __last; ++__first) std::_Destroy(&*__first); } + { + for (; __first != __last; ++__first) + std::_Destroy(&*__first); + } /** * @if maint @@ -146,12 +149,40 @@ namespace std { typedef typename iterator_traits<_ForwardIterator>::value_type _Value_type; - typedef typename __type_traits<_Value_type>::has_trivial_destructor - _Has_trivial_destructor; + typedef typename std::__is_scalar<_Value_type>::__type + _Has_trivial_destructor; std::__destroy_aux(__first, __last, _Has_trivial_destructor()); } -} // namespace std + + /** + * @if maint + * Destroy a range of objects using the supplied allocator. For + * nondefault allocators we do not optimize away invocation of + * destroy() even if _Tp has a trivial destructor. + * @endif + */ + + template class allocator; + + template + void + _Destroy(_ForwardIterator __first, _ForwardIterator __last, + _Allocator __alloc) + { + for (; __first != __last; ++__first) + __alloc.destroy(&*__first); + } + + template + inline void + _Destroy(_ForwardIterator __first, _ForwardIterator __last, + allocator<_Tp>) + { + _Destroy(__first, __last); + } + +_GLIBCXX_END_NAMESPACE #endif /* _STL_CONSTRUCT_H */ diff --git a/contrib/libstdc++/include/bits/stl_deque.h b/contrib/libstdc++/include/bits/stl_deque.h index 54dadf2..9da0bb7 100644 --- a/contrib/libstdc++/include/bits/stl_deque.h +++ b/contrib/libstdc++/include/bits/stl_deque.h @@ -1,6 +1,7 @@ // Deque implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -65,8 +66,8 @@ #include #include -namespace _GLIBCXX_STD -{ +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) + /** * @if maint * @brief This function controls the size of memory nodes. @@ -87,10 +88,11 @@ namespace _GLIBCXX_STD /** * @brief A deque::iterator. * - * Quite a bit of intelligence here. Much of the functionality of deque is - * actually passed off to this class. A deque holds two of these internally, - * marking its valid range. Access to elements is done as offsets of either - * of those two, relying on operator overloading in this class. + * Quite a bit of intelligence here. Much of the functionality of + * deque is actually passed off to this class. A deque holds two + * of these internally, marking its valid range. Access to + * elements is done as offsets of either of those two, relying on + * operator overloading in this class. * * @if maint * All the functions are op overloads except for _M_set_node. @@ -105,14 +107,14 @@ namespace _GLIBCXX_STD static size_t _S_buffer_size() { return __deque_buf_size(sizeof(_Tp)); } - typedef random_access_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Ptr pointer; - typedef _Ref reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Tp** _Map_pointer; - typedef _Deque_iterator _Self; + typedef std::random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Ptr pointer; + typedef _Ref reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp** _Map_pointer; + typedef _Deque_iterator _Self; _Tp* _M_cur; _Tp* _M_first; @@ -219,9 +221,9 @@ namespace _GLIBCXX_STD { return *(*this + __n); } /** @if maint - * Prepares to traverse new_node. Sets everything except _M_cur, which - * should therefore be set by the caller immediately afterwards, based on - * _M_first and _M_last. + * Prepares to traverse new_node. Sets everything except + * _M_cur, which should therefore be set by the caller + * immediately afterwards, based on _M_first and _M_last. * @endif */ void @@ -320,6 +322,17 @@ namespace _GLIBCXX_STD // According to the resolution of DR179 not only the various comparison // operators but also operator- must accept mixed iterator/const_iterator // parameters. + template + inline typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type + operator-(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, + const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) + { + return typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type + (_Deque_iterator<_Tp, _Ref, _Ptr>::_S_buffer_size()) + * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first) + + (__y._M_last - __y._M_cur); + } + template inline typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type @@ -337,6 +350,11 @@ namespace _GLIBCXX_STD operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x) { return __x + __n; } + template + void + fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>& __first, + const _Deque_iterator<_Tp, _Tp&, _Tp*>& __last, const _Tp& __value); + /** * @if maint * Deque base class. This class provides the unified face for %deque's @@ -357,17 +375,17 @@ namespace _GLIBCXX_STD allocator_type get_allocator() const - { return *static_cast(&this->_M_impl); } + { return allocator_type(_M_get_Tp_allocator()); } - typedef _Deque_iterator<_Tp,_Tp&,_Tp*> iterator; - typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator; + typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator; + typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator; _Deque_base(const allocator_type& __a, size_t __num_elements) - : _M_impl(__a) + : _M_impl(__a) { _M_initialize_map(__num_elements); } _Deque_base(const allocator_type& __a) - : _M_impl(__a) + : _M_impl(__a) { } ~_Deque_base(); @@ -376,29 +394,47 @@ namespace _GLIBCXX_STD //This struct encapsulates the implementation of the std::deque //standard container and at the same time makes use of the EBO //for empty allocators. + typedef typename _Alloc::template rebind<_Tp*>::other _Map_alloc_type; + + typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type; + struct _Deque_impl - : public _Alloc { + : public _Tp_alloc_type + { _Tp** _M_map; size_t _M_map_size; iterator _M_start; iterator _M_finish; - _Deque_impl(const _Alloc& __a) - : _Alloc(__a), _M_map(0), _M_map_size(0), _M_start(), _M_finish() + _Deque_impl(const _Tp_alloc_type& __a) + : _Tp_alloc_type(__a), _M_map(0), _M_map_size(0), + _M_start(), _M_finish() { } }; - typedef typename _Alloc::template rebind<_Tp*>::other _Map_alloc_type; - _Map_alloc_type _M_get_map_allocator() const - { return _Map_alloc_type(this->get_allocator()); } + _Tp_alloc_type& + _M_get_Tp_allocator() + { return *static_cast<_Tp_alloc_type*>(&this->_M_impl); } + + const _Tp_alloc_type& + _M_get_Tp_allocator() const + { return *static_cast(&this->_M_impl); } + + _Map_alloc_type + _M_get_map_allocator() const + { return _Map_alloc_type(_M_get_Tp_allocator()); } _Tp* _M_allocate_node() - { return _M_impl._Alloc::allocate(__deque_buf_size(sizeof(_Tp))); } + { + return _M_impl._Tp_alloc_type::allocate(__deque_buf_size(sizeof(_Tp))); + } void _M_deallocate_node(_Tp* __p) - { _M_impl._Alloc::deallocate(__p, __deque_buf_size(sizeof(_Tp))); } + { + _M_impl._Tp_alloc_type::deallocate(__p, __deque_buf_size(sizeof(_Tp))); + } _Tp** _M_allocate_map(size_t __n) @@ -418,14 +454,16 @@ namespace _GLIBCXX_STD }; template - _Deque_base<_Tp,_Alloc>::~_Deque_base() - { - if (this->_M_impl._M_map) + _Deque_base<_Tp, _Alloc>:: + ~_Deque_base() { - _M_destroy_nodes(this->_M_impl._M_start._M_node, this->_M_impl._M_finish._M_node + 1); - _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); + if (this->_M_impl._M_map) + { + _M_destroy_nodes(this->_M_impl._M_start._M_node, + this->_M_impl._M_finish._M_node + 1); + _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); + } } - } /** * @if maint @@ -439,12 +477,14 @@ namespace _GLIBCXX_STD */ template void - _Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements) + _Deque_base<_Tp, _Alloc>:: + _M_initialize_map(size_t __num_elements) { - size_t __num_nodes = __num_elements / __deque_buf_size(sizeof(_Tp)) + 1; + const size_t __num_nodes = (__num_elements/ __deque_buf_size(sizeof(_Tp)) + + 1); this->_M_impl._M_map_size = std::max((size_t) _S_initial_map_size, - __num_nodes + 2); + size_t(__num_nodes + 2)); this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size); // For "small" maps (needing less than _M_map_size nodes), allocation @@ -452,7 +492,8 @@ namespace _GLIBCXX_STD // the beginning of _M_map, but for small maps it may be as far in as // _M_map+3. - _Tp** __nstart = this->_M_impl._M_map + (this->_M_impl._M_map_size - __num_nodes) / 2; + _Tp** __nstart = (this->_M_impl._M_map + + (this->_M_impl._M_map_size - __num_nodes) / 2); _Tp** __nfinish = __nstart + __num_nodes; try @@ -468,13 +509,15 @@ namespace _GLIBCXX_STD this->_M_impl._M_start._M_set_node(__nstart); this->_M_impl._M_finish._M_set_node(__nfinish - 1); this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first; - this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_first + __num_elements - % __deque_buf_size(sizeof(_Tp)); + this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first + + __num_elements + % __deque_buf_size(sizeof(_Tp))); } template void - _Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart, _Tp** __nfinish) + _Deque_base<_Tp, _Alloc>:: + _M_create_nodes(_Tp** __nstart, _Tp** __nfinish) { _Tp** __cur; try @@ -491,7 +534,8 @@ namespace _GLIBCXX_STD template void - _Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish) + _Deque_base<_Tp, _Alloc>:: + _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish) { for (_Tp** __n = __nstart; __n < __nfinish; ++__n) _M_deallocate_node(*__n); @@ -521,28 +565,27 @@ namespace _GLIBCXX_STD * - size_t _M_map_size * - iterator _M_start, _M_finish * - * map_size is at least 8. %map is an array of map_size pointers-to-"nodes". - * (The name %map has nothing to do with the std::map class, and "nodes" - * should not be confused with std::list's usage of "node".) - * - * A "node" has no specific type name as such, but it is referred to as - * "node" in this file. It is a simple array-of-Tp. If Tp is very large, - * there will be one Tp element per node (i.e., an "array" of one). - * For non-huge Tp's, node size is inversely related to Tp size: the - * larger the Tp, the fewer Tp's will fit in a node. The goal here is to - * keep the total size of a node relatively small and constant over different - * Tp's, to improve allocator efficiency. + * map_size is at least 8. %map is an array of map_size + * pointers-to-"nodes". (The name %map has nothing to do with the + * std::map class, and "nodes" should not be confused with + * std::list's usage of "node".) * - * **** As I write this, the nodes are /not/ allocated using the high-speed - * memory pool. There are 20 hours left in the year; perhaps I can fix - * this before 2002. + * A "node" has no specific type name as such, but it is referred + * to as "node" in this file. It is a simple array-of-Tp. If Tp + * is very large, there will be one Tp element per node (i.e., an + * "array" of one). For non-huge Tp's, node size is inversely + * related to Tp size: the larger the Tp, the fewer Tp's will fit + * in a node. The goal here is to keep the total size of a node + * relatively small and constant over different Tp's, to improve + * allocator efficiency. * - * Not every pointer in the %map array will point to a node. If the initial - * number of elements in the deque is small, the /middle/ %map pointers will - * be valid, and the ones at the edges will be unused. This same situation - * will arise as the %map grows: available %map pointers, if any, will be on - * the ends. As new nodes are created, only a subset of the %map's pointers - * need to be copied "outward". + * Not every pointer in the %map array will point to a node. If + * the initial number of elements in the deque is small, the + * /middle/ %map pointers will be valid, and the ones at the edges + * will be unused. This same situation will arise as the %map + * grows: available %map pointers, if any, will be on the ends. As + * new nodes are created, only a subset of the %map's pointers need + * to be copied "outward". * * Class invariants: * - For any nonsingular iterator i: @@ -554,16 +597,17 @@ namespace _GLIBCXX_STD * - i.cur is a pointer in the range [i.first, i.last). NOTE: * the implication of this is that i.cur is always a dereferenceable * pointer, even if i is a past-the-end iterator. - * - Start and Finish are always nonsingular iterators. NOTE: this means that - * an empty deque must have one node, a deque with > + template > class deque : protected _Deque_base<_Tp, _Alloc> { // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; __glibcxx_class_requires(_Tp, _SGIAssignableConcept) + __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) typedef _Deque_base<_Tp, _Alloc> _Base; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; public: - typedef _Tp value_type; - typedef typename _Alloc::pointer pointer; - typedef typename _Alloc::const_pointer const_pointer; - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; - typedef typename _Base::iterator iterator; - typedef typename _Base::const_iterator const_iterator; - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; + typedef _Tp value_type; + typedef typename _Tp_alloc_type::pointer pointer; + typedef typename _Tp_alloc_type::const_pointer const_pointer; + typedef typename _Tp_alloc_type::reference reference; + typedef typename _Tp_alloc_type::const_reference const_reference; + typedef typename _Base::iterator iterator; + typedef typename _Base::const_iterator const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; typedef size_t size_type; typedef ptrdiff_t difference_type; - typedef typename _Base::allocator_type allocator_type; + typedef _Alloc allocator_type; protected: typedef pointer* _Map_pointer; @@ -617,6 +664,7 @@ namespace _GLIBCXX_STD using _Base::_M_deallocate_node; using _Base::_M_allocate_map; using _Base::_M_deallocate_map; + using _Base::_M_get_Tp_allocator; /** @if maint * A total of four data members accumulated down the heirarchy. @@ -642,24 +690,13 @@ namespace _GLIBCXX_STD * * This constructor fills the %deque with @a n copies of @a value. */ - deque(size_type __n, const value_type& __value, + explicit + deque(size_type __n, const value_type& __value = value_type(), const allocator_type& __a = allocator_type()) : _Base(__a, __n) { _M_fill_initialize(__value); } /** - * @brief Create a %deque with default elements. - * @param n The number of elements to initially create. - * - * This constructor fills the %deque with @a n copies of a - * default-constructed element. - */ - explicit - deque(size_type __n) - : _Base(allocator_type(), __n) - { _M_fill_initialize(value_type()); } - - /** * @brief %Deque copy constructor. * @param x A %deque of identical element and allocator types. * @@ -667,8 +704,10 @@ namespace _GLIBCXX_STD * by @a x. */ deque(const deque& __x) - : _Base(__x.get_allocator(), __x.size()) - { std::uninitialized_copy(__x.begin(), __x.end(), this->_M_impl._M_start); } + : _Base(__x._M_get_Tp_allocator(), __x.size()) + { std::__uninitialized_copy_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); } /** * @brief Builds a %deque from a range. @@ -690,7 +729,7 @@ namespace _GLIBCXX_STD : _Base(__a) { // Check whether it's an integral type. If so, it's not an iterator. - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; + typedef typename std::__is_integer<_InputIterator>::__type _Integral; _M_initialize_dispatch(__first, __last, _Integral()); } @@ -700,7 +739,7 @@ namespace _GLIBCXX_STD * way. Managing the pointer is the user's responsibilty. */ ~deque() - { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); } + { _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); } /** * @brief %Deque assignment operator. @@ -717,10 +756,10 @@ namespace _GLIBCXX_STD * @param n Number of elements to be assigned. * @param val Value to be assigned. * - * This function fills a %deque with @a n copies of the given value. - * Note that the assignment completely changes the %deque and that the - * resulting %deque's size is the same as the number of elements assigned. - * Old data may be lost. + * This function fills a %deque with @a n copies of the given + * value. Note that the assignment completely changes the + * %deque and that the resulting %deque's size is the same as + * the number of elements assigned. Old data may be lost. */ void assign(size_type __n, const value_type& __val) @@ -742,7 +781,7 @@ namespace _GLIBCXX_STD void assign(_InputIterator __first, _InputIterator __last) { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; + typedef typename std::__is_integer<_InputIterator>::__type _Integral; _M_assign_dispatch(__first, __last, _Integral()); } @@ -769,50 +808,54 @@ namespace _GLIBCXX_STD { return this->_M_impl._M_start; } /** - * Returns a read/write iterator that points one past the last element in - * the %deque. Iteration is done in ordinary element order. + * Returns a read/write iterator that points one past the last + * element in the %deque. Iteration is done in ordinary + * element order. */ iterator end() { return this->_M_impl._M_finish; } /** - * Returns a read-only (constant) iterator that points one past the last - * element in the %deque. Iteration is done in ordinary element order. + * Returns a read-only (constant) iterator that points one past + * the last element in the %deque. Iteration is done in + * ordinary element order. */ const_iterator end() const { return this->_M_impl._M_finish; } /** - * Returns a read/write reverse iterator that points to the last element - * in the %deque. Iteration is done in reverse element order. + * Returns a read/write reverse iterator that points to the + * last element in the %deque. Iteration is done in reverse + * element order. */ reverse_iterator rbegin() { return reverse_iterator(this->_M_impl._M_finish); } /** - * Returns a read-only (constant) reverse iterator that points to the - * last element in the %deque. Iteration is done in reverse element - * order. + * Returns a read-only (constant) reverse iterator that points + * to the last element in the %deque. Iteration is done in + * reverse element order. */ const_reverse_iterator rbegin() const { return const_reverse_iterator(this->_M_impl._M_finish); } /** - * Returns a read/write reverse iterator that points to one before the - * first element in the %deque. Iteration is done in reverse element - * order. + * Returns a read/write reverse iterator that points to one + * before the first element in the %deque. Iteration is done + * in reverse element order. */ reverse_iterator - rend() { return reverse_iterator(this->_M_impl._M_start); } + rend() + { return reverse_iterator(this->_M_impl._M_start); } /** - * Returns a read-only (constant) reverse iterator that points to one - * before the first element in the %deque. Iteration is done in reverse - * element order. + * Returns a read-only (constant) reverse iterator that points + * to one before the first element in the %deque. Iteration is + * done in reverse element order. */ const_reverse_iterator rend() const @@ -827,43 +870,32 @@ namespace _GLIBCXX_STD /** Returns the size() of the largest possible %deque. */ size_type max_size() const - { return size_type(-1); } + { return _M_get_Tp_allocator().max_size(); } /** * @brief Resizes the %deque to the specified number of elements. * @param new_size Number of elements the %deque should contain. * @param x Data with which new elements should be populated. * - * This function will %resize the %deque to the specified number of - * elements. If the number is smaller than the %deque's current size the - * %deque is truncated, otherwise the %deque is extended and new elements - * are populated with given data. + * This function will %resize the %deque to the specified + * number of elements. If the number is smaller than the + * %deque's current size the %deque is truncated, otherwise the + * %deque is extended and new elements are populated with given + * data. */ void - resize(size_type __new_size, const value_type& __x) + resize(size_type __new_size, value_type __x = value_type()) { const size_type __len = size(); if (__new_size < __len) - erase(this->_M_impl._M_start + __new_size, this->_M_impl._M_finish); + _M_erase_at_end(this->_M_impl._M_start + difference_type(__new_size)); else insert(this->_M_impl._M_finish, __new_size - __len, __x); } /** - * @brief Resizes the %deque to the specified number of elements. - * @param new_size Number of elements the %deque should contain. - * - * This function will resize the %deque to the specified number of - * elements. If the number is smaller than the %deque's current size the - * %deque is truncated, otherwise the %deque is extended and new elements - * are default-constructed. - */ - void - resize(size_type new_size) - { resize(new_size, value_type()); } - - /** - * Returns true if the %deque is empty. (Thus begin() would equal end().) + * Returns true if the %deque is empty. (Thus begin() would + * equal end().) */ bool empty() const @@ -871,26 +903,30 @@ namespace _GLIBCXX_STD // element access /** - * @brief Subscript access to the data contained in the %deque. - * @param n The index of the element for which data should be accessed. + * @brief Subscript access to the data contained in the %deque. + * @param n The index of the element for which data should be + * accessed. * @return Read/write reference to data. * * This operator allows for easy, array-style, data access. - * Note that data access with this operator is unchecked and out_of_range - * lookups are not defined. (For checked lookups see at().) + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) */ reference operator[](size_type __n) { return this->_M_impl._M_start[difference_type(__n)]; } /** - * @brief Subscript access to the data contained in the %deque. - * @param n The index of the element for which data should be accessed. + * @brief Subscript access to the data contained in the %deque. + * @param n The index of the element for which data should be + * accessed. * @return Read-only (constant) reference to data. * * This operator allows for easy, array-style, data access. - * Note that data access with this operator is unchecked and out_of_range - * lookups are not defined. (For checked lookups see at().) + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) */ const_reference operator[](size_type __n) const @@ -908,21 +944,26 @@ namespace _GLIBCXX_STD public: /** * @brief Provides access to the data contained in the %deque. - * @param n The index of the element for which data should be accessed. + * @param n The index of the element for which data should be + * accessed. * @return Read/write reference to data. * @throw std::out_of_range If @a n is an invalid index. * - * This function provides for safer data access. The parameter is first - * checked that it is in the range of the deque. The function throws - * out_of_range if the check fails. + * This function provides for safer data access. The parameter + * is first checked that it is in the range of the deque. The + * function throws out_of_range if the check fails. */ reference at(size_type __n) - { _M_range_check(__n); return (*this)[__n]; } + { + _M_range_check(__n); + return (*this)[__n]; + } /** * @brief Provides access to the data contained in the %deque. - * @param n The index of the element for which data should be accessed. + * @param n The index of the element for which data should be + * accessed. * @return Read-only (constant) reference to data. * @throw std::out_of_range If @a n is an invalid index. * @@ -938,12 +979,12 @@ namespace _GLIBCXX_STD } /** - * Returns a read/write reference to the data at the first element of the - * %deque. + * Returns a read/write reference to the data at the first + * element of the %deque. */ reference front() - { return *this->_M_impl._M_start; } + { return *begin(); } /** * Returns a read-only (constant) reference to the data at the first @@ -951,7 +992,7 @@ namespace _GLIBCXX_STD */ const_reference front() const - { return *this->_M_impl._M_start; } + { return *begin(); } /** * Returns a read/write reference to the data at the last element of the @@ -960,7 +1001,7 @@ namespace _GLIBCXX_STD reference back() { - iterator __tmp = this->_M_impl._M_finish; + iterator __tmp = end(); --__tmp; return *__tmp; } @@ -972,7 +1013,7 @@ namespace _GLIBCXX_STD const_reference back() const { - const_iterator __tmp = this->_M_impl._M_finish; + const_iterator __tmp = end(); --__tmp; return *__tmp; } @@ -982,16 +1023,17 @@ namespace _GLIBCXX_STD * @brief Add data to the front of the %deque. * @param x Data to be added. * - * This is a typical stack operation. The function creates an element at - * the front of the %deque and assigns the given data to it. Due to the - * nature of a %deque this operation can be done in constant time. + * This is a typical stack operation. The function creates an + * element at the front of the %deque and assigns the given + * data to it. Due to the nature of a %deque this operation + * can be done in constant time. */ void push_front(const value_type& __x) { if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first) { - std::_Construct(this->_M_impl._M_start._M_cur - 1, __x); + this->_M_impl.construct(this->_M_impl._M_start._M_cur - 1, __x); --this->_M_impl._M_start._M_cur; } else @@ -1002,16 +1044,18 @@ namespace _GLIBCXX_STD * @brief Add data to the end of the %deque. * @param x Data to be added. * - * This is a typical stack operation. The function creates an element at - * the end of the %deque and assigns the given data to it. Due to the - * nature of a %deque this operation can be done in constant time. + * This is a typical stack operation. The function creates an + * element at the end of the %deque and assigns the given data + * to it. Due to the nature of a %deque this operation can be + * done in constant time. */ void push_back(const value_type& __x) { - if (this->_M_impl._M_finish._M_cur != this->_M_impl._M_finish._M_last - 1) + if (this->_M_impl._M_finish._M_cur + != this->_M_impl._M_finish._M_last - 1) { - std::_Construct(this->_M_impl._M_finish._M_cur, __x); + this->_M_impl.construct(this->_M_impl._M_finish._M_cur, __x); ++this->_M_impl._M_finish._M_cur; } else @@ -1029,9 +1073,10 @@ namespace _GLIBCXX_STD void pop_front() { - if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_last - 1) + if (this->_M_impl._M_start._M_cur + != this->_M_impl._M_start._M_last - 1) { - std::_Destroy(this->_M_impl._M_start._M_cur); + this->_M_impl.destroy(this->_M_impl._M_start._M_cur); ++this->_M_impl._M_start._M_cur; } else @@ -1049,10 +1094,11 @@ namespace _GLIBCXX_STD void pop_back() { - if (this->_M_impl._M_finish._M_cur != this->_M_impl._M_finish._M_first) + if (this->_M_impl._M_finish._M_cur + != this->_M_impl._M_finish._M_first) { --this->_M_impl._M_finish._M_cur; - std::_Destroy(this->_M_impl._M_finish._M_cur); + this->_M_impl.destroy(this->_M_impl._M_finish._M_cur); } else _M_pop_back_aux(); @@ -1068,7 +1114,7 @@ namespace _GLIBCXX_STD * specified location. */ iterator - insert(iterator position, const value_type& __x); + insert(iterator __position, const value_type& __x); /** * @brief Inserts a number of copies of given data into the %deque. @@ -1089,9 +1135,9 @@ namespace _GLIBCXX_STD * @param first An input iterator. * @param last An input iterator. * - * This function will insert copies of the data in the range [first,last) - * into the %deque before the location specified by @a pos. This is - * known as "range insert." + * This function will insert copies of the data in the range + * [first,last) into the %deque before the location specified + * by @a pos. This is known as "range insert." */ template void @@ -1099,7 +1145,7 @@ namespace _GLIBCXX_STD _InputIterator __last) { // Check whether it's an integral type. If so, it's not an iterator. - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; + typedef typename std::__is_integer<_InputIterator>::__type _Integral; _M_insert_dispatch(__position, __first, __last, _Integral()); } @@ -1154,6 +1200,11 @@ namespace _GLIBCXX_STD std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); std::swap(this->_M_impl._M_map, __x._M_impl._M_map); std::swap(this->_M_impl._M_map_size, __x._M_impl._M_map_size); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 431. Swapping containers with unequal allocators. + std::__alloc_swap<_Tp_alloc_type>::_S_do_it(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); } /** @@ -1162,7 +1213,9 @@ namespace _GLIBCXX_STD * pointed-to memory is not touched in any way. Managing the pointer is * the user's responsibilty. */ - void clear(); + void + clear() + { _M_erase_at_end(begin()); } protected: // Internal constructor functions follow. @@ -1182,8 +1235,8 @@ namespace _GLIBCXX_STD _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, __false_type) { - typedef typename iterator_traits<_InputIterator>::iterator_category - _IterCategory; + typedef typename std::iterator_traits<_InputIterator>:: + iterator_category _IterCategory; _M_range_initialize(__first, __last, _IterCategory()); } @@ -1204,13 +1257,13 @@ namespace _GLIBCXX_STD template void _M_range_initialize(_InputIterator __first, _InputIterator __last, - input_iterator_tag); + std::input_iterator_tag); // called by the second initialize_dispatch above template void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag); + std::forward_iterator_tag); //@} /** @@ -1218,8 +1271,8 @@ namespace _GLIBCXX_STD * @brief Fills the %deque with copies of value. * @param value Initial value. * @return Nothing. - * @pre _M_start and _M_finish have already been initialized, but none of - * the %deque's elements have yet been constructed. + * @pre _M_start and _M_finish have already been initialized, + * but none of the %deque's elements have yet been constructed. * * This function is called only when the user provides an explicit size * (with or without an explicit exemplar value). @@ -1246,8 +1299,8 @@ namespace _GLIBCXX_STD _M_assign_dispatch(_InputIterator __first, _InputIterator __last, __false_type) { - typedef typename iterator_traits<_InputIterator>::iterator_category - _IterCategory; + typedef typename std::iterator_traits<_InputIterator>:: + iterator_category _IterCategory; _M_assign_aux(__first, __last, _IterCategory()); } @@ -1255,13 +1308,13 @@ namespace _GLIBCXX_STD template void _M_assign_aux(_InputIterator __first, _InputIterator __last, - input_iterator_tag); + std::input_iterator_tag); // called by the second assign_dispatch above template void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) + std::forward_iterator_tag) { const size_type __len = std::distance(__first, __last); if (__len > size()) @@ -1272,11 +1325,11 @@ namespace _GLIBCXX_STD insert(end(), __mid, __last); } else - erase(std::copy(__first, __last, begin()), end()); + _M_erase_at_end(std::copy(__first, __last, begin())); } - // Called by assign(n,t), and the range assign when it turns out to be the - // same thing. + // Called by assign(n,t), and the range assign when it turns out + // to be the same thing. void _M_fill_assign(size_type __n, const value_type& __val) { @@ -1287,7 +1340,7 @@ namespace _GLIBCXX_STD } else { - erase(begin() + __n, end()); + _M_erase_at_end(begin() + difference_type(__n)); std::fill(begin(), end(), __val); } } @@ -1299,8 +1352,11 @@ namespace _GLIBCXX_STD * @endif */ void _M_push_back_aux(const value_type&); + void _M_push_front_aux(const value_type&); + void _M_pop_back_aux(); + void _M_pop_front_aux(); //@} @@ -1324,8 +1380,8 @@ namespace _GLIBCXX_STD _InputIterator __first, _InputIterator __last, __false_type) { - typedef typename iterator_traits<_InputIterator>::iterator_category - _IterCategory; + typedef typename std::iterator_traits<_InputIterator>:: + iterator_category _IterCategory; _M_range_insert_aux(__pos, __first, __last, _IterCategory()); } @@ -1333,13 +1389,13 @@ namespace _GLIBCXX_STD template void _M_range_insert_aux(iterator __pos, _InputIterator __first, - _InputIterator __last, input_iterator_tag); + _InputIterator __last, std::input_iterator_tag); // called by the second insert_dispatch above template void _M_range_insert_aux(iterator __pos, _ForwardIterator __first, - _ForwardIterator __last, forward_iterator_tag); + _ForwardIterator __last, std::forward_iterator_tag); // Called by insert(p,n,x), and the range insert when it turns out to be // the same thing. Can use fill functions in optimal situations, @@ -1362,6 +1418,55 @@ namespace _GLIBCXX_STD _ForwardIterator __first, _ForwardIterator __last, size_type __n); + + // Internal erase functions follow. + + void + _M_destroy_data_aux(iterator __first, iterator __last); + + void + _M_destroy_data_dispatch(iterator, iterator, __true_type) { } + + void + _M_destroy_data_dispatch(iterator __first, iterator __last, __false_type) + { _M_destroy_data_aux(__first, __last); } + + // Called by ~deque(). + // NB: Doesn't deallocate the nodes. + template + void + _M_destroy_data(iterator __first, iterator __last, const _Alloc1&) + { _M_destroy_data_aux(__first, __last); } + + void + _M_destroy_data(iterator __first, iterator __last, + const std::allocator<_Tp>&) + { + typedef typename std::__is_scalar::__type + _Has_trivial_destructor; + _M_destroy_data_dispatch(__first, __last, _Has_trivial_destructor()); + } + + // Called by erase(q1, q2). + void + _M_erase_at_begin(iterator __pos) + { + _M_destroy_data(begin(), __pos, _M_get_Tp_allocator()); + _M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node); + this->_M_impl._M_start = __pos; + } + + // Called by erase(q1, q2), resize(), clear(), _M_assign_aux, + // _M_fill_assign, operator=. + void + _M_erase_at_end(iterator __pos) + { + _M_destroy_data(__pos, end(), _M_get_Tp_allocator()); + _M_destroy_nodes(__pos._M_node + 1, + this->_M_impl._M_finish._M_node + 1); + this->_M_impl._M_finish = __pos; + } + //@{ /** * @if maint @@ -1402,13 +1507,13 @@ namespace _GLIBCXX_STD * @if maint * @brief Memory-handling helpers for the major %map. * - * Makes sure the _M_map has space for new nodes. Does not actually add - * the nodes. Can invalidate _M_map pointers. (And consequently, %deque - * iterators.) + * Makes sure the _M_map has space for new nodes. Does not + * actually add the nodes. Can invalidate _M_map pointers. + * (And consequently, %deque iterators.) * @endif */ void - _M_reserve_map_at_back (size_type __nodes_to_add = 1) + _M_reserve_map_at_back(size_type __nodes_to_add = 1) { if (__nodes_to_add + 1 > this->_M_impl._M_map_size - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map)) @@ -1416,9 +1521,10 @@ namespace _GLIBCXX_STD } void - _M_reserve_map_at_front (size_type __nodes_to_add = 1) + _M_reserve_map_at_front(size_type __nodes_to_add = 1) { - if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node - this->_M_impl._M_map)) + if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node + - this->_M_impl._M_map)) _M_reallocate_map(__nodes_to_add, true); } @@ -1460,8 +1566,8 @@ namespace _GLIBCXX_STD inline bool operator<(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) - { return lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); } + { return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); } /// Based on operator== template @@ -1496,6 +1602,7 @@ namespace _GLIBCXX_STD inline void swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) { __x.swap(__y); } -} // namespace std + +_GLIBCXX_END_NESTED_NAMESPACE #endif /* _DEQUE_H */ diff --git a/contrib/libstdc++/include/bits/stl_function.h b/contrib/libstdc++/include/bits/stl_function.h index 74ddcce..db213dc 100644 --- a/contrib/libstdc++/include/bits/stl_function.h +++ b/contrib/libstdc++/include/bits/stl_function.h @@ -1,6 +1,6 @@ // Functor implementations -*- C++ -*- -// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -61,8 +61,8 @@ #ifndef _FUNCTION_H #define _FUNCTION_H 1 -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // 20.3.1 base classes /** @defgroup s20_3_1_base Functor Base Classes * Function objects, or @e functors, are objects with an @c operator() @@ -88,7 +88,7 @@ namespace std * \endcode * The addition and negation functions will be inlined directly. * - * The standard functiors are derived from structs named @c unary_function + * The standard functors are derived from structs named @c unary_function * and @c binary_function. These two classes contain nothing but typedefs, * to aid in generic (template) programming. If you write your own * functors, you might consider doing the same. @@ -360,7 +360,7 @@ namespace std /** @defgroup s20_3_6_binder Binder Classes * Binders turn functions/functors with two arguments into functors with * a single argument, storing an argument to be applied later. For - * example, an variable @c B of type @c binder1st is constructed from a + * example, a variable @c B of type @c binder1st is constructed from a * functor @c f and an argument @c x. Later, B's @c operator() is called * with a single argument @c y. The return value is the value of @c f(x,y). * @c B can be "called" with various arguments (y1, y2, ...) and will in @@ -566,19 +566,11 @@ namespace std // 20.3.8 adaptors pointers members /** @defgroup s20_3_8_memadaptors Adaptors for pointers to members - * There are a total of 16 = 2^4 function objects in this family. + * There are a total of 8 = 2^3 function objects in this family. * (1) Member functions taking no arguments vs member functions taking * one argument. * (2) Call through pointer vs call through reference. - * (3) Member function with void return type vs member function with - * non-void return type. - * (4) Const vs non-const member function. - * - * Note that choice (3) is nothing more than a workaround: according - * to the draft, compilers should handle void and non-void the same way. - * This feature is not yet widely implemented, though. You can only use - * member functions returning void if your compiler supports partial - * specialization. + * (3) Const vs non-const member function. * * All of this complexity is in the function objects themselves. You can * ignore it by using the helper function mem_fun and mem_fun_ref, @@ -714,137 +706,6 @@ namespace std _Ret (_Tp::*_M_f)(_Arg) const; }; - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class mem_fun_t : public unary_function<_Tp*, void> - { - public: - explicit - mem_fun_t(void (_Tp::*__pf)()) - : _M_f(__pf) {} - - void - operator()(_Tp* __p) const - { (__p->*_M_f)(); } - private: - void (_Tp::*_M_f)(); - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class const_mem_fun_t : public unary_function - { - public: - explicit - const_mem_fun_t(void (_Tp::*__pf)() const) - : _M_f(__pf) {} - - void - operator()(const _Tp* __p) const - { (__p->*_M_f)(); } - private: - void (_Tp::*_M_f)() const; - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class mem_fun_ref_t : public unary_function<_Tp, void> - { - public: - explicit - mem_fun_ref_t(void (_Tp::*__pf)()) - : _M_f(__pf) {} - - void - operator()(_Tp& __r) const - { (__r.*_M_f)(); } - private: - void (_Tp::*_M_f)(); - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class const_mem_fun_ref_t : public unary_function<_Tp, void> - { - public: - explicit - const_mem_fun_ref_t(void (_Tp::*__pf)() const) - : _M_f(__pf) {} - - void - operator()(const _Tp& __r) const - { (__r.*_M_f)(); } - private: - void (_Tp::*_M_f)() const; - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class mem_fun1_t : public binary_function<_Tp*, _Arg, void> - { - public: - explicit - mem_fun1_t(void (_Tp::*__pf)(_Arg)) - : _M_f(__pf) {} - - void - operator()(_Tp* __p, _Arg __x) const - { (__p->*_M_f)(__x); } - private: - void (_Tp::*_M_f)(_Arg); - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class const_mem_fun1_t - : public binary_function - { - public: - explicit - const_mem_fun1_t(void (_Tp::*__pf)(_Arg) const) - : _M_f(__pf) {} - - void - operator()(const _Tp* __p, _Arg __x) const - { (__p->*_M_f)(__x); } - private: - void (_Tp::*_M_f)(_Arg) const; - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class mem_fun1_ref_t - : public binary_function<_Tp, _Arg, void> - { - public: - explicit - mem_fun1_ref_t(void (_Tp::*__pf)(_Arg)) - : _M_f(__pf) {} - - void - operator()(_Tp& __r, _Arg __x) const - { (__r.*_M_f)(__x); } - private: - void (_Tp::*_M_f)(_Arg); - }; - - /// One of the @link s20_3_8_memadaptors adaptors for member pointers@endlink. - template - class const_mem_fun1_ref_t - : public binary_function<_Tp, _Arg, void> - { - public: - explicit - const_mem_fun1_ref_t(void (_Tp::*__pf)(_Arg) const) - : _M_f(__pf) {} - - void - operator()(const _Tp& __r, _Arg __x) const - { (__r.*_M_f)(__x); } - private: - void (_Tp::*_M_f)(_Arg) const; - }; - // Mem_fun adaptor helper functions. There are only two: // mem_fun and mem_fun_ref. template @@ -889,10 +750,6 @@ namespace std /** @} */ -} // namespace std +_GLIBCXX_END_NAMESPACE #endif /* _FUNCTION_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/bits/stl_heap.h b/contrib/libstdc++/include/bits/stl_heap.h index eff7fd3..2f0d04c 100644 --- a/contrib/libstdc++/include/bits/stl_heap.h +++ b/contrib/libstdc++/include/bits/stl_heap.h @@ -1,6 +1,6 @@ // Heap implementation -*- C++ -*- -// Copyright (C) 2001, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2004, 2005, 2006 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -62,8 +62,8 @@ #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // is_heap, a predicate testing whether or not a range is // a heap. This function is an extension, not part of the C++ // standard. @@ -430,7 +430,7 @@ namespace std // __glibcxx_requires_heap(__first, __last); while (__last - __first > 1) - std::pop_heap(__first, __last--); + std::pop_heap(__first, _RandomAccessIterator(__last--)); } /** @@ -455,13 +455,9 @@ namespace std __glibcxx_requires_heap_pred(__first, __last, __comp); while (__last - __first > 1) - std::pop_heap(__first, __last--, __comp); + std::pop_heap(__first, _RandomAccessIterator(__last--), __comp); } -} // namespace std +_GLIBCXX_END_NAMESPACE #endif /* _STL_HEAP_H */ - -// Local Variables: -// mode:C++ -// End: diff --git a/contrib/libstdc++/include/bits/stl_iterator.h b/contrib/libstdc++/include/bits/stl_iterator.h index cc56431..f9425aa 100644 --- a/contrib/libstdc++/include/bits/stl_iterator.h +++ b/contrib/libstdc++/include/bits/stl_iterator.h @@ -1,6 +1,7 @@ // Iterators -*- C++ -*- -// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -65,8 +66,11 @@ #ifndef _ITERATOR_H #define _ITERATOR_H 1 -namespace std -{ +#include +#include + +_GLIBCXX_BEGIN_NAMESPACE(std) + // 24.4.1 Reverse iterators /** * "Bidirectional and random access iterators have corresponding reverse @@ -203,7 +207,8 @@ namespace std * * @doctodo */ - reverse_iterator operator--(int) + reverse_iterator + operator--(int) { reverse_iterator __tmp = *this; ++current; @@ -299,7 +304,7 @@ namespace std template inline bool operator<=(const reverse_iterator<_Iterator>& __x, - const reverse_iterator<_Iterator>& __y) + const reverse_iterator<_Iterator>& __y) { return !(__y < __x); } template @@ -319,6 +324,50 @@ namespace std operator+(typename reverse_iterator<_Iterator>::difference_type __n, const reverse_iterator<_Iterator>& __x) { return reverse_iterator<_Iterator>(__x.base() - __n); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 280. Comparison of reverse_iterator to const reverse_iterator. + template + inline bool + operator==(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() == __y.base(); } + + template + inline bool + operator<(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __y.base() < __x.base(); } + + template + inline bool + operator!=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return !(__x == __y); } + + template + inline bool + operator>(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __y < __x; } + + template + inline bool + operator<=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return !(__y < __x); } + + template + inline bool + operator>=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return !(__x < __y); } + + template + inline typename reverse_iterator<_IteratorL>::difference_type + operator-(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __y.base() - __x.base(); } //@} // 24.4.2.2.1 back_insert_iterator @@ -569,10 +618,11 @@ namespace std return insert_iterator<_Container>(__x, typename _Container::iterator(__i)); } -} // namespace std -namespace __gnu_cxx -{ +_GLIBCXX_END_NAMESPACE + +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + // This iterator adapter is 'normal' in the sense that it does not // change the semantics of any of the operators of its iterator // parameter. Its primary purpose is to convert an iterator that is @@ -604,9 +654,11 @@ namespace __gnu_cxx // Allow iterator to const_iterator conversion template - inline __normal_iterator(const __normal_iterator<_Iter, - _Container>& __i) - : _M_current(__i.base()) { } + __normal_iterator(const __normal_iterator<_Iter, + typename __enable_if< + (std::__are_same<_Iter, typename _Container::pointer>::__value), + _Container>::__type>& __i) + : _M_current(__i.base()) { } // Forward iterator requirements reference @@ -759,14 +811,17 @@ namespace __gnu_cxx { return __lhs.base() - __rhs.base(); } template + inline typename __normal_iterator<_Iterator, _Container>::difference_type + operator-(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + { return __lhs.base() - __rhs.base(); } + + template inline __normal_iterator<_Iterator, _Container> operator+(typename __normal_iterator<_Iterator, _Container>::difference_type __n, const __normal_iterator<_Iterator, _Container>& __i) { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); } -} // namespace __gnu_cxx -#endif +_GLIBCXX_END_NAMESPACE -// Local Variables: -// mode:C++ -// End: +#endif diff --git a/contrib/libstdc++/include/bits/stl_iterator_base_funcs.h b/contrib/libstdc++/include/bits/stl_iterator_base_funcs.h index c514e81..79fb667 100644 --- a/contrib/libstdc++/include/bits/stl_iterator_base_funcs.h +++ b/contrib/libstdc++/include/bits/stl_iterator_base_funcs.h @@ -1,6 +1,7 @@ // Functions used by iterators -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -67,8 +68,8 @@ #pragma GCC system_header #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template inline typename iterator_traits<_InputIterator>::difference_type __distance(_InputIterator __first, _InputIterator __last, @@ -131,7 +132,7 @@ namespace std template inline void __advance(_BidirectionalIterator& __i, _Distance __n, - bidirectional_iterator_tag) + bidirectional_iterator_tag) { // concept requirements __glibcxx_function_requires(_BidirectionalIteratorConcept< @@ -172,8 +173,10 @@ namespace std advance(_InputIterator& __i, _Distance __n) { // concept requirements -- taken care of in __advance - std::__advance(__i, __n, std::__iterator_category(__i)); + typename iterator_traits<_InputIterator>::difference_type __d = __n; + std::__advance(__i, __d, std::__iterator_category(__i)); } -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif /* _ITERATOR_BASE_FUNCS_H */ diff --git a/contrib/libstdc++/include/bits/stl_iterator_base_types.h b/contrib/libstdc++/include/bits/stl_iterator_base_types.h index c3bb1c5..c02cd26 100644 --- a/contrib/libstdc++/include/bits/stl_iterator_base_types.h +++ b/contrib/libstdc++/include/bits/stl_iterator_base_types.h @@ -1,6 +1,6 @@ // Types used in iterator implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -66,8 +66,8 @@ #pragma GCC system_header -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + //@{ /** * @defgroup iterator_tags Iterator Tags @@ -164,7 +164,7 @@ namespace std __iterator_category(const _Iter&) { return typename iterator_traits<_Iter>::iterator_category(); } -} // namespace std +_GLIBCXX_END_NAMESPACE #endif /* _ITERATOR_BASE_TYPES_H */ diff --git a/contrib/libstdc++/include/bits/stl_list.h b/contrib/libstdc++/include/bits/stl_list.h index afb118b..e37e5ee 100644 --- a/contrib/libstdc++/include/bits/stl_list.h +++ b/contrib/libstdc++/include/bits/stl_list.h @@ -1,6 +1,7 @@ // List implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -63,8 +64,8 @@ #include -namespace _GLIBCXX_STD -{ +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) + // Supporting structures are split into common and templated types; the // latter publicly inherits from the former in an effort to reduce code // duplication. This results in some "needless" static_cast'ing later on, @@ -110,18 +111,19 @@ namespace _GLIBCXX_STD template struct _List_iterator { - typedef _List_iterator<_Tp> _Self; - typedef _List_node<_Tp> _Node; + typedef _List_iterator<_Tp> _Self; + typedef _List_node<_Tp> _Node; - typedef ptrdiff_t difference_type; - typedef bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _Tp* pointer; - typedef _Tp& reference; + typedef ptrdiff_t difference_type; + typedef std::bidirectional_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Tp* pointer; + typedef _Tp& reference; _List_iterator() : _M_node() { } + explicit _List_iterator(_List_node_base* __x) : _M_node(__x) { } @@ -186,19 +188,20 @@ namespace _GLIBCXX_STD template struct _List_const_iterator { - typedef _List_const_iterator<_Tp> _Self; - typedef const _List_node<_Tp> _Node; - typedef _List_iterator<_Tp> iterator; + typedef _List_const_iterator<_Tp> _Self; + typedef const _List_node<_Tp> _Node; + typedef _List_iterator<_Tp> iterator; - typedef ptrdiff_t difference_type; - typedef bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef const _Tp* pointer; - typedef const _Tp& reference; + typedef ptrdiff_t difference_type; + typedef std::bidirectional_iterator_tag iterator_category; + typedef _Tp value_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; _List_const_iterator() : _M_node() { } + explicit _List_const_iterator(const _List_node_base* __x) : _M_node(__x) { } @@ -290,17 +293,20 @@ namespace _GLIBCXX_STD // // We put this to the test in the constructors and in // get_allocator, where we use conversions between - // allocator_type and _Node_Alloc_type. The conversion is + // allocator_type and _Node_alloc_type. The conversion is // required by table 32 in [20.1.5]. typedef typename _Alloc::template rebind<_List_node<_Tp> >::other + _Node_alloc_type; - _Node_Alloc_type; + typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type; struct _List_impl - : public _Node_Alloc_type { + : public _Node_alloc_type + { _List_node_base _M_node; - _List_impl (const _Node_Alloc_type& __a) - : _Node_Alloc_type(__a) + + _List_impl(const _Node_alloc_type& __a) + : _Node_alloc_type(__a), _M_node() { } }; @@ -308,21 +314,33 @@ namespace _GLIBCXX_STD _List_node<_Tp>* _M_get_node() - { return _M_impl._Node_Alloc_type::allocate(1); } + { return _M_impl._Node_alloc_type::allocate(1); } void _M_put_node(_List_node<_Tp>* __p) - { _M_impl._Node_Alloc_type::deallocate(__p, 1); } + { _M_impl._Node_alloc_type::deallocate(__p, 1); } public: typedef _Alloc allocator_type; + _Node_alloc_type& + _M_get_Node_allocator() + { return *static_cast<_Node_alloc_type*>(&this->_M_impl); } + + const _Node_alloc_type& + _M_get_Node_allocator() const + { return *static_cast(&this->_M_impl); } + + _Tp_alloc_type + _M_get_Tp_allocator() const + { return _Tp_alloc_type(_M_get_Node_allocator()); } + allocator_type get_allocator() const - { return allocator_type(*static_cast(&this->_M_impl)); } + { return allocator_type(_M_get_Node_allocator()); } _List_base(const allocator_type& __a) - : _M_impl(__a) + : _M_impl(__a) { _M_init(); } // This is what actually destroys the list. @@ -385,42 +403,41 @@ namespace _GLIBCXX_STD * iterator's next/previous pointers refer to itself, the %list is * %empty. @endif */ - template > + template > class list : protected _List_base<_Tp, _Alloc> { // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; __glibcxx_class_requires(_Tp, _SGIAssignableConcept) + __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) - typedef _List_base<_Tp, _Alloc> _Base; + typedef _List_base<_Tp, _Alloc> _Base; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; public: typedef _Tp value_type; - typedef typename _Alloc::pointer pointer; - typedef typename _Alloc::const_pointer const_pointer; - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; + typedef typename _Tp_alloc_type::pointer pointer; + typedef typename _Tp_alloc_type::const_pointer const_pointer; + typedef typename _Tp_alloc_type::reference reference; + typedef typename _Tp_alloc_type::const_reference const_reference; typedef _List_iterator<_Tp> iterator; typedef _List_const_iterator<_Tp> const_iterator; typedef std::reverse_iterator const_reverse_iterator; typedef std::reverse_iterator reverse_iterator; typedef size_t size_type; typedef ptrdiff_t difference_type; - typedef typename _Base::allocator_type allocator_type; + typedef _Alloc allocator_type; protected: // Note that pointers-to-_Node's can be ctor-converted to // iterator types. - typedef _List_node<_Tp> _Node; + typedef _List_node<_Tp> _Node; - /** @if maint - * One data member plus two memory-handling functions. If the - * _Alloc type requires separate instances, then one of those - * will also be included, accumulated from the topmost parent. - * @endif - */ using _Base::_M_impl; using _Base::_M_put_node; using _Base::_M_get_node; + using _Base::_M_get_Tp_allocator; + using _Base::_M_get_Node_allocator; /** * @if maint @@ -435,29 +452,7 @@ namespace _GLIBCXX_STD _Node* __p = this->_M_get_node(); try { - std::_Construct(&__p->_M_data, __x); - } - catch(...) - { - _M_put_node(__p); - __throw_exception_again; - } - return __p; - } - - /** - * @if maint - * Allocates space for a new node and default-constructs a new - * instance of @c value_type in it. - * @endif - */ - _Node* - _M_create_node() - { - _Node* __p = this->_M_get_node(); - try - { - std::_Construct(&__p->_M_data); + _M_get_Tp_allocator().construct(&__p->_M_data, __x); } catch(...) { @@ -484,22 +479,11 @@ namespace _GLIBCXX_STD * * This constructor fills the %list with @a n copies of @a value. */ - list(size_type __n, const value_type& __value, + explicit + list(size_type __n, const value_type& __value = value_type(), const allocator_type& __a = allocator_type()) : _Base(__a) - { this->insert(begin(), __n, __value); } - - /** - * @brief Create a %list with default elements. - * @param n The number of elements to initially create. - * - * This constructor fills the %list with @a n copies of a - * default-constructed element. - */ - explicit - list(size_type __n) - : _Base(allocator_type()) - { this->insert(begin(), __n, value_type()); } + { _M_fill_initialize(__n, __value); } /** * @brief %List copy constructor. @@ -509,8 +493,8 @@ namespace _GLIBCXX_STD * by @a x. */ list(const list& __x) - : _Base(__x.get_allocator()) - { this->insert(begin(), __x.begin(), __x.end()); } + : _Base(__x._M_get_Node_allocator()) + { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); } /** * @brief Builds a %list from a range. @@ -520,17 +504,16 @@ namespace _GLIBCXX_STD * Create a %list consisting of copies of the elements from * [@a first,@a last). This is linear in N (where N is * distance(@a first,@a last)). - * - * @if maint - * We don't need any dispatching tricks here, because insert does all of - * that anyway. - * @endif */ template list(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(__a) - { this->insert(begin(), __first, __last); } + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } /** * No explicit dtor needed as the _Base dtor takes care of @@ -581,7 +564,7 @@ namespace _GLIBCXX_STD assign(_InputIterator __first, _InputIterator __last) { // Check whether it's an integral type. If so, it's not an iterator. - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; + typedef typename std::__is_integer<_InputIterator>::__type _Integral; _M_assign_dispatch(__first, __last, _Integral()); } @@ -597,7 +580,7 @@ namespace _GLIBCXX_STD */ iterator begin() - { return this->_M_impl._M_node._M_next; } + { return iterator(this->_M_impl._M_node._M_next); } /** * Returns a read-only (constant) iterator that points to the @@ -606,7 +589,7 @@ namespace _GLIBCXX_STD */ const_iterator begin() const - { return this->_M_impl._M_node._M_next; } + { return const_iterator(this->_M_impl._M_node._M_next); } /** * Returns a read/write iterator that points one past the last @@ -614,7 +597,8 @@ namespace _GLIBCXX_STD * order. */ iterator - end() { return &this->_M_impl._M_node; } + end() + { return iterator(&this->_M_impl._M_node); } /** * Returns a read-only (constant) iterator that points one past @@ -623,7 +607,7 @@ namespace _GLIBCXX_STD */ const_iterator end() const - { return &this->_M_impl._M_node; } + { return const_iterator(&this->_M_impl._M_node); } /** * Returns a read/write reverse iterator that points to the last @@ -678,7 +662,7 @@ namespace _GLIBCXX_STD /** Returns the size() of the largest possible %list. */ size_type max_size() const - { return size_type(-1); } + { return _M_get_Tp_allocator().max_size(); } /** * @brief Resizes the %list to the specified number of elements. @@ -691,20 +675,7 @@ namespace _GLIBCXX_STD * extended and new elements are populated with given data. */ void - resize(size_type __new_size, const value_type& __x); - - /** - * @brief Resizes the %list to the specified number of elements. - * @param new_size Number of elements the %list should contain. - * - * This function will resize the %list to the specified number of - * elements. If the number is smaller than the %list's current - * size the %list is truncated, otherwise the %list is extended - * and new elements are default-constructed. - */ - void - resize(size_type __new_size) - { this->resize(__new_size, value_type()); } + resize(size_type __new_size, value_type __x = value_type()); // element access /** @@ -729,7 +700,11 @@ namespace _GLIBCXX_STD */ reference back() - { return *(--end()); } + { + iterator __tmp = end(); + --__tmp; + return *__tmp; + } /** * Returns a read-only (constant) reference to the data at the last @@ -737,7 +712,11 @@ namespace _GLIBCXX_STD */ const_reference back() const - { return *(--end()); } + { + const_iterator __tmp = end(); + --__tmp; + return *__tmp; + } // [23.2.2.3] modifiers /** @@ -797,7 +776,7 @@ namespace _GLIBCXX_STD */ void pop_back() - { this->_M_erase(this->_M_impl._M_node._M_prev); } + { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); } /** * @brief Inserts given value into %list before specified iterator. @@ -822,13 +801,15 @@ namespace _GLIBCXX_STD * This function will insert a specified number of copies of the * given data before the location specified by @a position. * - * Due to the nature of a %list this operation can be done in - * constant time, and does not invalidate iterators and - * references. + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. */ void insert(iterator __position, size_type __n, const value_type& __x) - { _M_fill_insert(__position, __n, __x); } + { + list __tmp(__n, __x, _M_get_Node_allocator()); + splice(__position, __tmp); + } /** * @brief Inserts a range into the %list. @@ -840,18 +821,16 @@ namespace _GLIBCXX_STD * first,@a last) into the %list before the location specified by * @a position. * - * Due to the nature of a %list this operation can be done in - * constant time, and does not invalidate iterators and - * references. + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. */ template void insert(iterator __position, _InputIterator __first, _InputIterator __last) { - // Check whether it's an integral type. If so, it's not an iterator. - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - _M_insert_dispatch(__position, __first, __last, _Integral()); + list __tmp(__first, __last, _M_get_Node_allocator()); + splice(__position, __tmp); } /** @@ -883,13 +862,12 @@ namespace _GLIBCXX_STD * This function will erase the elements in the range @a * [first,last) and shorten the %list accordingly. * - * Due to the nature of a %list this operation can be done in - * constant time, and only invalidates iterators/references to - * the element being removed. The user is also cautioned that - * this function only erases the elements, and that if the - * elements themselves are pointers, the pointed-to memory is not - * touched in any way. Managing the pointer is the user's - * responsibilty. + * This operation is linear time in the size of the range and only + * invalidates iterators/references to the element being removed. + * The user is also cautioned that this function only erases the + * elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibilty. */ iterator erase(iterator __first, iterator __last) @@ -910,7 +888,14 @@ namespace _GLIBCXX_STD */ void swap(list& __x) - { _List_node_base::swap(this->_M_impl._M_node,__x._M_impl._M_node); } + { + _List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 431. Swapping containers with unequal allocators. + std::__alloc_swap:: + _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()); + } /** * Erases all the elements. Note that this function only erases @@ -934,12 +919,18 @@ namespace _GLIBCXX_STD * The elements of @a x are inserted in constant time in front of * the element referenced by @a position. @a x becomes an empty * list. + * + * Requires this != @a x. */ void splice(iterator __position, list& __x) { if (!__x.empty()) - this->_M_transfer(__position, __x.begin(), __x.end()); + { + _M_check_equal_allocators(__x); + + this->_M_transfer(__position, __x.begin(), __x.end()); + } } /** @@ -952,12 +943,16 @@ namespace _GLIBCXX_STD * inserts it into the current list before @a position. */ void - splice(iterator __position, list&, iterator __i) + splice(iterator __position, list& __x, iterator __i) { iterator __j = __i; ++__j; if (__position == __i || __position == __j) return; + + if (this != &__x) + _M_check_equal_allocators(__x); + this->_M_transfer(__position, __i, __j); } @@ -974,10 +969,15 @@ namespace _GLIBCXX_STD * Undefined if @a position is in [first,last). */ void - splice(iterator __position, list&, iterator __first, iterator __last) + splice(iterator __position, list& __x, iterator __first, iterator __last) { if (__first != __last) - this->_M_transfer(__position, __first, __last); + { + if (this != &__x) + _M_check_equal_allocators(__x); + + this->_M_transfer(__position, __first, __last); + } } /** @@ -1006,8 +1006,8 @@ namespace _GLIBCXX_STD * responsibilty. */ template - void - remove_if(_Predicate); + void + remove_if(_Predicate); /** * @brief Remove consecutive duplicate elements. @@ -1095,66 +1095,64 @@ namespace _GLIBCXX_STD sort(_StrictWeakOrdering); protected: - // Internal assign functions follow. + // Internal constructor functions follow. - // Called by the range assign to implement [23.1.1]/9 + // Called by the range constructor to implement [23.1.1]/9 template void - _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) { - _M_fill_assign(static_cast(__n), - static_cast(__val)); + _M_fill_initialize(static_cast(__n), + static_cast(__x)); } - // Called by the range assign to implement [23.1.1]/9 + // Called by the range constructor to implement [23.1.1]/9 template void - _M_assign_dispatch(_InputIterator __first, _InputIterator __last, - __false_type); + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { + for (; __first != __last; ++__first) + push_back(*__first); + } - // Called by assign(n,t), and the range assign when it turns out + // Called by list(n,v,a), and the range constructor when it turns out // to be the same thing. void - _M_fill_assign(size_type __n, const value_type& __val); + _M_fill_initialize(size_type __n, const value_type& __x) + { + for (; __n > 0; --__n) + push_back(__x); + } - // Internal insert functions follow. + // Internal assign functions follow. - // Called by the range insert to implement [23.1.1]/9 + // Called by the range assign to implement [23.1.1]/9 template void - _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, - __true_type) + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) { - _M_fill_insert(__pos, static_cast(__n), - static_cast(__x)); + _M_fill_assign(static_cast(__n), + static_cast(__val)); } - // Called by the range insert to implement [23.1.1]/9 + // Called by the range assign to implement [23.1.1]/9 template void - _M_insert_dispatch(iterator __pos, - _InputIterator __first, _InputIterator __last, - __false_type) - { - for ( ; __first != __last; ++__first) - _M_insert(__pos, *__first); - } + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + __false_type); - // Called by insert(p,n,x), and the range insert when it turns out + // Called by assign(n,t), and the range assign when it turns out // to be the same thing. void - _M_fill_insert(iterator __pos, size_type __n, const value_type& __x) - { - for ( ; __n > 0; --__n) - _M_insert(__pos, __x); - } + _M_fill_assign(size_type __n, const value_type& __val); // Moves the elements from [first,last) before position. void _M_transfer(iterator __position, iterator __first, iterator __last) - { __position._M_node->transfer(__first._M_node,__last._M_node); } + { __position._M_node->transfer(__first._M_node, __last._M_node); } // Inserts new element at position given and with value given. void @@ -1170,9 +1168,17 @@ namespace _GLIBCXX_STD { __position._M_node->unhook(); _Node* __n = static_cast<_Node*>(__position._M_node); - std::_Destroy(&__n->_M_data); + _M_get_Tp_allocator().destroy(&__n->_M_data); _M_put_node(__n); } + + // To implement the splice (and merge) bits of N1599. + void + _M_check_equal_allocators(list& __x) + { + if (_M_get_Node_allocator() != __x._M_get_Node_allocator()) + __throw_runtime_error(__N("list::_M_check_equal_allocators")); + } }; /** @@ -1187,9 +1193,9 @@ namespace _GLIBCXX_STD */ template inline bool - operator==(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y) + operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { - typedef typename list<_Tp,_Alloc>::const_iterator const_iterator; + typedef typename list<_Tp, _Alloc>::const_iterator const_iterator; const_iterator __end1 = __x.end(); const_iterator __end2 = __y.end(); @@ -1216,32 +1222,32 @@ namespace _GLIBCXX_STD */ template inline bool - operator<(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y) + operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); } /// Based on operator== template inline bool - operator!=(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y) + operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { return !(__x == __y); } /// Based on operator< template inline bool - operator>(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y) + operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { return __y < __x; } /// Based on operator< template inline bool - operator<=(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y) + operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { return !(__y < __x); } /// Based on operator< template inline bool - operator>=(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y) + operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { return !(__x < __y); } /// See std::list::swap(). @@ -1249,7 +1255,8 @@ namespace _GLIBCXX_STD inline void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) { __x.swap(__y); } -} // namespace std + +_GLIBCXX_END_NESTED_NAMESPACE #endif /* _LIST_H */ diff --git a/contrib/libstdc++/include/bits/stl_map.h b/contrib/libstdc++/include/bits/stl_map.h index 8535ae5..13e62bc 100644 --- a/contrib/libstdc++/include/bits/stl_map.h +++ b/contrib/libstdc++/include/bits/stl_map.h @@ -1,6 +1,7 @@ // Map implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -61,10 +62,11 @@ #ifndef _MAP_H #define _MAP_H 1 +#include #include -namespace _GLIBCXX_STD -{ +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) + /** * @brief A standard container made up of (key,value) pairs, which can be * retrieved based on a key, in logarithmic time. @@ -86,25 +88,30 @@ namespace _GLIBCXX_STD * called (*_unique versus *_equal, same as the standard). * @endif */ - template , - typename _Alloc = allocator > > + template , + typename _Alloc = std::allocator > > class map { + public: + typedef _Key key_type; + typedef _Tp mapped_type; + typedef std::pair value_type; + typedef _Compare key_compare; + typedef _Alloc allocator_type; + + private: // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; __glibcxx_class_requires(_Tp, _SGIAssignableConcept) __glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept) + __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept) public: - typedef _Key key_type; - typedef _Tp mapped_type; - typedef pair value_type; - typedef _Compare key_compare; - class value_compare - : public binary_function + : public std::binary_function { - friend class map<_Key,_Tp,_Compare,_Alloc>; + friend class map<_Key, _Tp, _Compare, _Alloc>; protected: _Compare comp; @@ -118,19 +125,22 @@ namespace _GLIBCXX_STD private: /// @if maint This turns a red-black tree into a [multi]map. @endif - typedef _Rb_tree, key_compare, _Alloc> _Rep_type; + typedef typename _Alloc::template rebind::other + _Pair_alloc_type; + + typedef _Rb_tree, + key_compare, _Pair_alloc_type> _Rep_type; + /// @if maint The actual tree structure. @endif _Rep_type _M_t; public: // many of these are specified differently in ISO, but the following are // "functionally equivalent" - typedef typename _Alloc::pointer pointer; - typedef typename _Alloc::const_pointer const_pointer; - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; - typedef typename _Rep_type::allocator_type allocator_type; + typedef typename _Pair_alloc_type::pointer pointer; + typedef typename _Pair_alloc_type::const_pointer const_pointer; + typedef typename _Pair_alloc_type::reference reference; + typedef typename _Pair_alloc_type::const_reference const_reference; typedef typename _Rep_type::iterator iterator; typedef typename _Rep_type::const_iterator const_iterator; typedef typename _Rep_type::size_type size_type; @@ -177,7 +187,7 @@ namespace _GLIBCXX_STD template map(_InputIterator __first, _InputIterator __last) : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } + { _M_t._M_insert_unique(__first, __last); } /** * @brief Builds a %map from a range. @@ -194,11 +204,11 @@ namespace _GLIBCXX_STD map(_InputIterator __first, _InputIterator __last, const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_t(__comp, __a) - { _M_t.insert_unique(__first, __last); } + { _M_t._M_insert_unique(__first, __last); } - // FIXME There is no dtor declared, but we should have something generated - // by Doxygen. I don't know what tags to add to this paragraph to make - // that happen: + // FIXME There is no dtor declared, but we should have something + // generated by Doxygen. I don't know what tags to add to this + // paragraph to make that happen: /** * The dtor only erases the elements, and note that if the elements * themselves are pointers, the pointed-to memory is not touched in any @@ -244,8 +254,9 @@ namespace _GLIBCXX_STD { return _M_t.begin(); } /** - * Returns a read/write iterator that points one past the last pair in - * the %map. Iteration is done in ascending order according to the keys. + * Returns a read/write iterator that points one past the last + * pair in the %map. Iteration is done in ascending order + * according to the keys. */ iterator end() @@ -320,10 +331,10 @@ namespace _GLIBCXX_STD * @param k The key for which data should be retrieved. * @return A reference to the data of the (key,data) %pair. * - * Allows for easy lookup with the subscript ( @c [] ) operator. Returns - * data associated with the key specified in subscript. If the key does - * not exist, a pair with that key is created using default values, which - * is then returned. + * Allows for easy lookup with the subscript ( @c [] ) + * operator. Returns data associated with the key specified in + * subscript. If the key does not exist, a pair with that key + * is created using default values, which is then returned. * * Lookup requires logarithmic time. */ @@ -340,14 +351,43 @@ namespace _GLIBCXX_STD return (*__i).second; } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + /** + * @brief Access to %map data. + * @param k The key for which data should be retrieved. + * @return A reference to the data whose key is equivalent to @a k, if + * such a data is present in the %map. + * @throw std::out_of_range If no such data is present. + */ + mapped_type& + at(const key_type& __k) + { + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + __throw_out_of_range(__N("map::at")); + return (*__i).second; + } + + const mapped_type& + at(const key_type& __k) const + { + const_iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + __throw_out_of_range(__N("map::at")); + return (*__i).second; + } + // modifiers /** * @brief Attempts to insert a std::pair into the %map. - * @param x Pair to be inserted (see std::make_pair for easy creation of - * pairs). - * @return A pair, of which the first element is an iterator that points - * to the possibly inserted pair, and the second is a bool that - * is true if the pair was actually inserted. + + * @param x Pair to be inserted (see std::make_pair for easy creation + * of pairs). + + * @return A pair, of which the first element is an iterator that + * points to the possibly inserted pair, and the second is + * a bool that is true if the pair was actually inserted. * * This function attempts to insert a (key, value) %pair into the %map. * A %map relies on unique keys and thus a %pair is only inserted if its @@ -355,36 +395,39 @@ namespace _GLIBCXX_STD * * Insertion requires logarithmic time. */ - pair + std::pair insert(const value_type& __x) - { return _M_t.insert_unique(__x); } + { return _M_t._M_insert_unique(__x); } /** * @brief Attempts to insert a std::pair into the %map. * @param position An iterator that serves as a hint as to where the * pair should be inserted. - * @param x Pair to be inserted (see std::make_pair for easy creation of - * pairs). + * @param x Pair to be inserted (see std::make_pair for easy creation + * of pairs). * @return An iterator that points to the element with key of @a x (may * or may not be the %pair passed in). * - * This function is not concerned about whether the insertion took place, - * and thus does not return a boolean like the single-argument - * insert() does. Note that the first parameter is only a hint and can - * potentially improve the performance of the insertion process. A bad - * hint would cause no gains in efficiency. + + * This function is not concerned about whether the insertion + * took place, and thus does not return a boolean like the + * single-argument insert() does. Note that the first + * parameter is only a hint and can potentially improve the + * performance of the insertion process. A bad hint would + * cause no gains in efficiency. * - * See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4 + * See + * http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4 * for more on "hinting". * * Insertion requires logarithmic time (if the hint is not taken). */ iterator - insert(iterator position, const value_type& __x) - { return _M_t.insert_unique(position, __x); } + insert(iterator __position, const value_type& __x) + { return _M_t._M_insert_unique(__position, __x); } /** - * @brief A template function that attemps to insert a range of elements. + * @brief Template function that attemps to insert a range of elements. * @param first Iterator pointing to the start of the range to be * inserted. * @param last Iterator pointing to the end of the range. @@ -394,16 +437,17 @@ namespace _GLIBCXX_STD template void insert(_InputIterator __first, _InputIterator __last) - { _M_t.insert_unique(__first, __last); } + { _M_t._M_insert_unique(__first, __last); } /** * @brief Erases an element from a %map. * @param position An iterator pointing to the element to be erased. * - * This function erases an element, pointed to by the given iterator, - * from a %map. Note that this function only erases the element, and - * that if the element is itself a pointer, the pointed-to memory is not - * touched in any way. Managing the pointer is the user's responsibilty. + * This function erases an element, pointed to by the given + * iterator, from a %map. Note that this function only erases + * the element, and that if the element is itself a pointer, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibilty. */ void erase(iterator __position) @@ -443,22 +487,22 @@ namespace _GLIBCXX_STD * @brief Swaps data with another %map. * @param x A %map of the same element and allocator types. * - * This exchanges the elements between two maps in constant time. - * (It is only swapping a pointer, an integer, and an instance of - * the @c Compare type (which itself is often stateless and empty), so it - * should be quite fast.) - * Note that the global std::swap() function is specialized such that - * std::swap(m1,m2) will feed to this function. + * This exchanges the elements between two maps in constant + * time. (It is only swapping a pointer, an integer, and an + * instance of the @c Compare type (which itself is often + * stateless and empty), so it should be quite fast.) Note + * that the global std::swap() function is specialized such + * that std::swap(m1,m2) will feed to this function. */ void swap(map& __x) { _M_t.swap(__x._M_t); } /** - * Erases all elements in a %map. Note that this function only erases - * the elements, and that if the elements themselves are pointers, the - * pointed-to memory is not touched in any way. Managing the pointer is - * the user's responsibilty. + * Erases all elements in a %map. Note that this function only + * erases the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibilty. */ void clear() @@ -589,7 +633,7 @@ namespace _GLIBCXX_STD * * This function probably only makes sense for multimaps. */ - pair + std::pair equal_range(const key_type& __x) { return _M_t.equal_range(__x); } @@ -608,19 +652,19 @@ namespace _GLIBCXX_STD * * This function probably only makes sense for multimaps. */ - pair + std::pair equal_range(const key_type& __x) const { return _M_t.equal_range(__x); } template friend bool - operator== (const map<_K1,_T1,_C1,_A1>&, - const map<_K1,_T1,_C1,_A1>&); + operator== (const map<_K1, _T1, _C1, _A1>&, + const map<_K1, _T1, _C1, _A1>&); template friend bool - operator< (const map<_K1,_T1,_C1,_A1>&, - const map<_K1,_T1,_C1,_A1>&); + operator< (const map<_K1, _T1, _C1, _A1>&, + const map<_K1, _T1, _C1, _A1>&); }; /** @@ -635,8 +679,8 @@ namespace _GLIBCXX_STD */ template inline bool - operator==(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) + operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) { return __x._M_t == __y._M_t; } /** @@ -652,43 +696,45 @@ namespace _GLIBCXX_STD */ template inline bool - operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) + operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) { return __x._M_t < __y._M_t; } /// Based on operator== template inline bool - operator!=(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) + operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x == __y); } /// Based on operator< template inline bool - operator>(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) + operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) { return __y < __x; } /// Based on operator< template inline bool - operator<=(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) + operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__y < __x); } /// Based on operator< template inline bool - operator>=(const map<_Key,_Tp,_Compare,_Alloc>& __x, - const map<_Key,_Tp,_Compare,_Alloc>& __y) + operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x < __y); } /// See std::map::swap(). template inline void - swap(map<_Key,_Tp,_Compare,_Alloc>& __x, map<_Key,_Tp,_Compare,_Alloc>& __y) + swap(map<_Key, _Tp, _Compare, _Alloc>& __x, + map<_Key, _Tp, _Compare, _Alloc>& __y) { __x.swap(__y); } -} // namespace std + +_GLIBCXX_END_NESTED_NAMESPACE #endif /* _MAP_H */ diff --git a/contrib/libstdc++/include/bits/stl_multimap.h b/contrib/libstdc++/include/bits/stl_multimap.h index e080f9a..b11b6e4 100644 --- a/contrib/libstdc++/include/bits/stl_multimap.h +++ b/contrib/libstdc++/include/bits/stl_multimap.h @@ -1,6 +1,6 @@ // Multimap implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004, 2005, 2006 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -63,24 +63,7 @@ #include -namespace _GLIBCXX_STD -{ - // Forward declaration of operators < and ==, needed for friend declaration. - - template , - typename _Alloc = allocator > > - class multimap; - - template - inline bool - operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y); - - template - inline bool - operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y); +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) /** * @brief A standard container made up of (key,value) pairs, which can be @@ -103,24 +86,31 @@ namespace _GLIBCXX_STD * called (*_unique versus *_equal, same as the standard). * @endif */ - template + template , + typename _Alloc = std::allocator > > class multimap { + public: + typedef _Key key_type; + typedef _Tp mapped_type; + typedef std::pair value_type; + typedef _Compare key_compare; + typedef _Alloc allocator_type; + + private: // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; __glibcxx_class_requires(_Tp, _SGIAssignableConcept) __glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept) + __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept) public: - typedef _Key key_type; - typedef _Tp mapped_type; - typedef pair value_type; - typedef _Compare key_compare; - class value_compare - : public binary_function + : public std::binary_function { - friend class multimap<_Key,_Tp,_Compare,_Alloc>; + friend class multimap<_Key, _Tp, _Compare, _Alloc>; protected: _Compare comp; @@ -134,19 +124,21 @@ namespace _GLIBCXX_STD private: /// @if maint This turns a red-black tree into a [multi]map. @endif - typedef _Rb_tree, key_compare, _Alloc> _Rep_type; + typedef typename _Alloc::template rebind::other + _Pair_alloc_type; + + typedef _Rb_tree, + key_compare, _Pair_alloc_type> _Rep_type; /// @if maint The actual tree structure. @endif _Rep_type _M_t; public: // many of these are specified differently in ISO, but the following are // "functionally equivalent" - typedef typename _Alloc::pointer pointer; - typedef typename _Alloc::const_pointer const_pointer; - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; - typedef typename _Rep_type::allocator_type allocator_type; + typedef typename _Pair_alloc_type::pointer pointer; + typedef typename _Pair_alloc_type::const_pointer const_pointer; + typedef typename _Pair_alloc_type::reference reference; + typedef typename _Pair_alloc_type::const_reference const_reference; typedef typename _Rep_type::iterator iterator; typedef typename _Rep_type::const_iterator const_iterator; typedef typename _Rep_type::size_type size_type; @@ -193,7 +185,7 @@ namespace _GLIBCXX_STD template multimap(_InputIterator __first, _InputIterator __last) : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } + { _M_t._M_insert_equal(__first, __last); } /** * @brief Builds a %multimap from a range. @@ -211,7 +203,7 @@ namespace _GLIBCXX_STD const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_t(__comp, __a) - { _M_t.insert_equal(__first, __last); } + { _M_t._M_insert_equal(__first, __last); } // FIXME There is no dtor declared, but we should have something generated // by Doxygen. I don't know what tags to add to this paragraph to make @@ -345,7 +337,7 @@ namespace _GLIBCXX_STD */ iterator insert(const value_type& __x) - { return _M_t.insert_equal(__x); } + { return _M_t._M_insert_equal(__x); } /** * @brief Inserts a std::pair into the %multimap. @@ -369,7 +361,7 @@ namespace _GLIBCXX_STD */ iterator insert(iterator __position, const value_type& __x) - { return _M_t.insert_equal(__position, __x); } + { return _M_t._M_insert_equal(__position, __x); } /** * @brief A template function that attemps to insert a range of elements. @@ -382,7 +374,7 @@ namespace _GLIBCXX_STD template void insert(_InputIterator __first, _InputIterator __last) - { _M_t.insert_equal(__first, __last); } + { _M_t._M_insert_equal(__first, __last); } /** * @brief Erases an element from a %multimap. @@ -573,7 +565,7 @@ namespace _GLIBCXX_STD * @endcode * (but is faster than making the calls separately). */ - pair + std::pair equal_range(const key_type& __x) { return _M_t.equal_range(__x); } @@ -590,19 +582,19 @@ namespace _GLIBCXX_STD * @endcode * (but is faster than making the calls separately). */ - pair + std::pair equal_range(const key_type& __x) const { return _M_t.equal_range(__x); } template friend bool - operator== (const multimap<_K1,_T1,_C1,_A1>&, - const multimap<_K1,_T1,_C1,_A1>&); + operator== (const multimap<_K1, _T1, _C1, _A1>&, + const multimap<_K1, _T1, _C1, _A1>&); template friend bool - operator< (const multimap<_K1,_T1,_C1,_A1>&, - const multimap<_K1,_T1,_C1,_A1>&); + operator< (const multimap<_K1, _T1, _C1, _A1>&, + const multimap<_K1, _T1, _C1, _A1>&); }; /** @@ -617,8 +609,8 @@ namespace _GLIBCXX_STD */ template inline bool - operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) + operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return __x._M_t == __y._M_t; } /** @@ -634,44 +626,45 @@ namespace _GLIBCXX_STD */ template inline bool - operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) + operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return __x._M_t < __y._M_t; } /// Based on operator== template inline bool - operator!=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) + operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x == __y); } /// Based on operator< template inline bool - operator>(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) + operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return __y < __x; } /// Based on operator< template inline bool - operator<=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) + operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__y < __x); } /// Based on operator< template inline bool - operator>=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, - const multimap<_Key,_Tp,_Compare,_Alloc>& __y) + operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x < __y); } /// See std::multimap::swap(). template inline void - swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x, - multimap<_Key,_Tp,_Compare,_Alloc>& __y) + swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x, + multimap<_Key, _Tp, _Compare, _Alloc>& __y) { __x.swap(__y); } -} // namespace std + +_GLIBCXX_END_NESTED_NAMESPACE #endif /* _MULTIMAP_H */ diff --git a/contrib/libstdc++/include/bits/stl_multiset.h b/contrib/libstdc++/include/bits/stl_multiset.h index c82dee6..8c499c3 100644 --- a/contrib/libstdc++/include/bits/stl_multiset.h +++ b/contrib/libstdc++/include/bits/stl_multiset.h @@ -1,6 +1,6 @@ // Multiset implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004, 2005, 2006 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -63,23 +63,7 @@ #include -namespace _GLIBCXX_STD -{ - - // Forward declaration of operators < and ==, needed for friend declaration. - template , - class _Alloc = allocator<_Key> > - class multiset; - - template - inline bool - operator==(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y); - - template - inline bool - operator<(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y); +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) /** * @brief A standard container made up of elements, which can be retrieved @@ -101,13 +85,16 @@ namespace _GLIBCXX_STD * called (*_unique versus *_equal, same as the standard). * @endif */ - template + template , + class _Alloc = std::allocator<_Key> > class multiset { // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; __glibcxx_class_requires(_Key, _SGIAssignableConcept) __glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept) + __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept) public: // typedefs: @@ -115,35 +102,37 @@ namespace _GLIBCXX_STD typedef _Key value_type; typedef _Compare key_compare; typedef _Compare value_compare; + typedef _Alloc allocator_type; private: /// @if maint This turns a red-black tree into a [multi]set. @endif - typedef _Rb_tree, key_compare, _Alloc> _Rep_type; + typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type; + + typedef _Rb_tree, + key_compare, _Key_alloc_type> _Rep_type; /// @if maint The actual tree structure. @endif _Rep_type _M_t; public: - typedef typename _Alloc::pointer pointer; - typedef typename _Alloc::const_pointer const_pointer; - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; + typedef typename _Key_alloc_type::pointer pointer; + typedef typename _Key_alloc_type::const_pointer const_pointer; + typedef typename _Key_alloc_type::reference reference; + typedef typename _Key_alloc_type::const_reference const_reference; // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 103. set::iterator is required to be modifiable, // but this allows modification of keys. - typedef typename _Rep_type::const_iterator iterator; - typedef typename _Rep_type::const_iterator const_iterator; - typedef typename _Rep_type::const_reverse_iterator reverse_iterator; - typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; - typedef typename _Rep_type::size_type size_type; - typedef typename _Rep_type::difference_type difference_type; - typedef typename _Rep_type::allocator_type allocator_type; - - // allocation/deallocation - - /** - * @brief Default constructor creates no elements. - */ + typedef typename _Rep_type::const_iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::const_reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + + // allocation/deallocation + + /** + * @brief Default constructor creates no elements. + */ multiset() : _M_t(_Compare(), allocator_type()) { } @@ -164,7 +153,7 @@ namespace _GLIBCXX_STD template multiset(_InputIterator __first, _InputIterator __last) : _M_t(_Compare(), allocator_type()) - { _M_t.insert_equal(__first, __last); } + { _M_t._M_insert_equal(__first, __last); } /** * @brief Builds a %multiset from a range. @@ -182,7 +171,7 @@ namespace _GLIBCXX_STD const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_t(__comp, __a) - { _M_t.insert_equal(__first, __last); } + { _M_t._M_insert_equal(__first, __last); } /** * @brief %Multiset copy constructor. @@ -286,7 +275,7 @@ namespace _GLIBCXX_STD * std::swap(s1,s2) will feed to this function. */ void - swap(multiset<_Key,_Compare,_Alloc>& __x) + swap(multiset<_Key, _Compare, _Alloc>& __x) { _M_t.swap(__x._M_t); } // insert/erase @@ -303,7 +292,7 @@ namespace _GLIBCXX_STD */ iterator insert(const value_type& __x) - { return _M_t.insert_equal(__x); } + { return _M_t._M_insert_equal(__x); } /** * @brief Inserts an element into the %multiset. @@ -327,10 +316,7 @@ namespace _GLIBCXX_STD */ iterator insert(iterator __position, const value_type& __x) - { - typedef typename _Rep_type::iterator _Rep_iterator; - return _M_t.insert_equal((_Rep_iterator&)__position, __x); - } + { return _M_t._M_insert_equal(__position, __x); } /** * @brief A template function that attemps to insert a range of elements. @@ -343,7 +329,7 @@ namespace _GLIBCXX_STD template void insert(_InputIterator __first, _InputIterator __last) - { _M_t.insert_equal(__first, __last); } + { _M_t._M_insert_equal(__first, __last); } /** * @brief Erases an element from a %multiset. @@ -357,10 +343,7 @@ namespace _GLIBCXX_STD */ void erase(iterator __position) - { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__position); - } + { _M_t.erase(__position); } /** * @brief Erases elements according to the provided key. @@ -390,10 +373,7 @@ namespace _GLIBCXX_STD */ void erase(iterator __first, iterator __last) - { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last); - } + { _M_t.erase(__first, __last); } /** * Erases all elements in a %multiset. Note that this function only @@ -492,23 +472,23 @@ namespace _GLIBCXX_STD * * This function probably only makes sense for multisets. */ - pair + std::pair equal_range(const key_type& __x) { return _M_t.equal_range(__x); } - pair + std::pair equal_range(const key_type& __x) const { return _M_t.equal_range(__x); } template friend bool - operator== (const multiset<_K1,_C1,_A1>&, - const multiset<_K1,_C1,_A1>&); + operator== (const multiset<_K1, _C1, _A1>&, + const multiset<_K1, _C1, _A1>&); template friend bool - operator< (const multiset<_K1,_C1,_A1>&, - const multiset<_K1,_C1,_A1>&); + operator< (const multiset<_K1, _C1, _A1>&, + const multiset<_K1, _C1, _A1>&); }; /** @@ -524,8 +504,8 @@ namespace _GLIBCXX_STD */ template inline bool - operator==(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) + operator==(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) { return __x._M_t == __y._M_t; } /** @@ -541,15 +521,15 @@ namespace _GLIBCXX_STD */ template inline bool - operator<(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) + operator<(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) { return __x._M_t < __y._M_t; } /// Returns !(x == y). template inline bool - operator!=(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) + operator!=(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) { return !(__x == __y); } /// Returns y < x. @@ -562,24 +542,24 @@ namespace _GLIBCXX_STD /// Returns !(y < x) template inline bool - operator<=(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) + operator<=(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) { return !(__y < __x); } /// Returns !(x < y) template inline bool - operator>=(const multiset<_Key,_Compare,_Alloc>& __x, - const multiset<_Key,_Compare,_Alloc>& __y) + operator>=(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) { return !(__x < __y); } /// See std::multiset::swap(). template inline void - swap(multiset<_Key,_Compare,_Alloc>& __x, - multiset<_Key,_Compare,_Alloc>& __y) + swap(multiset<_Key, _Compare, _Alloc>& __x, + multiset<_Key, _Compare, _Alloc>& __y) { __x.swap(__y); } -} // namespace std +_GLIBCXX_END_NESTED_NAMESPACE #endif /* _MULTISET_H */ diff --git a/contrib/libstdc++/include/bits/stl_numeric.h b/contrib/libstdc++/include/bits/stl_numeric.h index 58762a4..82bee21 100644 --- a/contrib/libstdc++/include/bits/stl_numeric.h +++ b/contrib/libstdc++/include/bits/stl_numeric.h @@ -1,6 +1,6 @@ // Numeric functions implementation -*- C++ -*- -// Copyright (C) 2001, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -63,8 +63,7 @@ #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) /** * @brief Accumulate values in a range. @@ -85,7 +84,7 @@ namespace std __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_requires_valid_range(__first, __last); - for ( ; __first != __last; ++__first) + for (; __first != __last; ++__first) __init = __init + *__first; return __init; } @@ -112,7 +111,7 @@ namespace std __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_requires_valid_range(__first, __last); - for ( ; __first != __last; ++__first) + for (; __first != __last; ++__first) __init = __binary_op(__init, *__first); return __init; } @@ -141,7 +140,7 @@ namespace std __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_requires_valid_range(__first1, __last1); - for ( ; __first1 != __last1; ++__first1, ++__first2) + for (; __first1 != __last1; ++__first1, ++__first2) __init = __init + (*__first1 * *__first2); return __init; } @@ -175,7 +174,7 @@ namespace std __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_requires_valid_range(__first1, __last1); - for ( ; __first1 != __last1; ++__first1, ++__first2) + for (; __first1 != __last1; ++__first1, ++__first2) __init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); return __init; } @@ -203,16 +202,19 @@ namespace std // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) - __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) __glibcxx_requires_valid_range(__first, __last); - if (__first == __last) return __result; - *__result = *__first; + if (__first == __last) + return __result; _ValueType __value = *__first; - while (++__first != __last) { - __value = __value + *__first; - *++__result = __value; - } + *__result = __value; + while (++__first != __last) + { + __value = __value + *__first; + *++__result = __value; + } return ++__result; } @@ -230,7 +232,8 @@ namespace std * @param result Output to write sums to. * @return Iterator pointing just beyond the values written to result. */ - template + template _OutputIterator partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOperation __binary_op) @@ -239,16 +242,19 @@ namespace std // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) - __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) __glibcxx_requires_valid_range(__first, __last); - if (__first == __last) return __result; - *__result = *__first; + if (__first == __last) + return __result; _ValueType __value = *__first; - while (++__first != __last) { - __value = __binary_op(__value, *__first); - *++__result = __value; - } + *__result = __value; + while (++__first != __last) + { + __value = __binary_op(__value, *__first); + *++__result = __value; + } return ++__result; } @@ -272,17 +278,20 @@ namespace std // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) - __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) __glibcxx_requires_valid_range(__first, __last); - if (__first == __last) return __result; - *__result = *__first; + if (__first == __last) + return __result; _ValueType __value = *__first; - while (++__first != __last) { - _ValueType __tmp = *__first; - *++__result = __tmp - __value; - __value = __tmp; - } + *__result = __value; + while (++__first != __last) + { + _ValueType __tmp = *__first; + *++__result = __tmp - __value; + __value = __tmp; + } return ++__result; } @@ -298,7 +307,8 @@ namespace std * @param result Output to write sums to. * @return Iterator pointing just beyond the values written to result. */ - template + template _OutputIterator adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOperation __binary_op) @@ -307,20 +317,23 @@ namespace std // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) - __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, _ValueType>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) __glibcxx_requires_valid_range(__first, __last); - if (__first == __last) return __result; - *__result = *__first; + if (__first == __last) + return __result; _ValueType __value = *__first; - while (++__first != __last) { - _ValueType __tmp = *__first; - *++__result = __binary_op(__tmp, __value); - __value = __tmp; - } + *__result = __value; + while (++__first != __last) + { + _ValueType __tmp = *__first; + *++__result = __binary_op(__tmp, __value); + __value = __tmp; + } return ++__result; } -} // namespace std +_GLIBCXX_END_NAMESPACE #endif /* _STL_NUMERIC_H */ diff --git a/contrib/libstdc++/include/bits/stl_pair.h b/contrib/libstdc++/include/bits/stl_pair.h index d5146bb..b4bb00c 100644 --- a/contrib/libstdc++/include/bits/stl_pair.h +++ b/contrib/libstdc++/include/bits/stl_pair.h @@ -1,6 +1,6 @@ // Pair implementation -*- C++ -*- -// Copyright (C) 2001, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -61,8 +61,8 @@ #ifndef _PAIR_H #define _PAIR_H 1 -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /// pair holds two objects of arbitrary type. template struct pair @@ -141,7 +141,9 @@ namespace std // 181. make_pair() unintended behavior template inline pair<_T1, _T2> - make_pair(_T1 __x, _T2 __y) { return pair<_T1, _T2>(__x, __y); } -} // namespace std + make_pair(_T1 __x, _T2 __y) + { return pair<_T1, _T2>(__x, __y); } + +_GLIBCXX_END_NAMESPACE #endif /* _PAIR_H */ diff --git a/contrib/libstdc++/include/bits/stl_queue.h b/contrib/libstdc++/include/bits/stl_queue.h index 3583547..04e3a7b 100644 --- a/contrib/libstdc++/include/bits/stl_queue.h +++ b/contrib/libstdc++/include/bits/stl_queue.h @@ -1,6 +1,7 @@ // Queue implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -64,19 +65,7 @@ #include #include -namespace std -{ - // Forward declarations of operators < and ==, needed for friend declaration. - template > - class queue; - - template - inline bool - operator==(const queue<_Tp,_Seq>&, const queue<_Tp,_Seq>&); - - template - inline bool - operator<(const queue<_Tp,_Seq>&, const queue<_Tp,_Seq>&); +_GLIBCXX_BEGIN_NAMESPACE(std) /** * @brief A standard container giving FIFO behavior. @@ -102,7 +91,7 @@ namespace std * which is a typedef for the second Sequence parameter, and @c push and * @c pop, which are standard %queue/FIFO operations. */ - template + template > class queue { // concept requirements @@ -245,10 +234,9 @@ namespace std * linear in the size of the sequences, and queues are considered equivalent * if their sequences compare equal. */ - template + template inline bool - operator==(const queue<_Tp,_Sequence>& __x, - const queue<_Tp,_Sequence>& __y) + operator==(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) { return __x.c == __y.c; } /** @@ -264,36 +252,33 @@ namespace std * std::lexicographical_compare() is usually used to make the * determination. */ - template + template inline bool - operator<(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y) + operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) { return __x.c < __y.c; } /// Based on operator== - template + template inline bool - operator!=(const queue<_Tp,_Sequence>& __x, - const queue<_Tp,_Sequence>& __y) + operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) { return !(__x == __y); } /// Based on operator< - template + template inline bool - operator>(const queue<_Tp,_Sequence>& __x, const queue<_Tp,_Sequence>& __y) + operator>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) { return __y < __x; } /// Based on operator< - template + template inline bool - operator<=(const queue<_Tp,_Sequence>& __x, - const queue<_Tp,_Sequence>& __y) + operator<=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) { return !(__y < __x); } /// Based on operator< - template + template inline bool - operator>=(const queue<_Tp,_Sequence>& __x, - const queue<_Tp,_Sequence>& __y) + operator>=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) { return !(__x < __y); } /** @@ -304,10 +289,9 @@ namespace std * * This is not a true container, but an @e adaptor. It holds * another container, and provides a wrapper interface to that - * container. The wrapper is what enforces sorting and - * first-in-first-out %queue behavior. Very few of the standard - * container/sequence interface requirements are met (e.g., - * iterators). + * container. The wrapper is what enforces priority-based sorting + * and %queue behavior. Very few of the standard container/sequence + * interface requirements are met (e.g., iterators). * * The second template parameter defines the type of the underlying * sequence/container. It defaults to std::vector, but it can be @@ -321,8 +305,7 @@ namespace std * * Members not found in "normal" containers are @c container_type, * which is a typedef for the second Sequence parameter, and @c - * push, @c pop, and @c top, which are standard %queue/FIFO - * operations. + * push, @c pop, and @c top, which are standard %queue operations. * * @note No equality/comparison operators are provided for * %priority_queue. @@ -344,7 +327,8 @@ namespace std __glibcxx_class_requires(_Sequence, _SequenceConcept) __glibcxx_class_requires(_Sequence, _RandomAccessContainerConcept) __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) - __glibcxx_class_requires4(_Compare, bool, _Tp,_Tp,_BinaryFunctionConcept) + __glibcxx_class_requires4(_Compare, bool, _Tp, _Tp, + _BinaryFunctionConcept) public: typedef typename _Sequence::value_type value_type; @@ -398,11 +382,13 @@ namespace std * Returns true if the %queue is empty. */ bool - empty() const { return c.empty(); } + empty() const + { return c.empty(); } /** Returns the number of elements in the %queue. */ size_type - size() const { return c.size(); } + size() const + { return c.size(); } /** * Returns a read-only (constant) reference to the data at the first @@ -426,16 +412,8 @@ namespace std void push(const value_type& __x) { - try - { - c.push_back(__x); - std::push_heap(c.begin(), c.end(), comp); - } - catch(...) - { - c.clear(); - __throw_exception_again; - } + c.push_back(__x); + std::push_heap(c.begin(), c.end(), comp); } /** @@ -453,20 +431,13 @@ namespace std pop() { __glibcxx_requires_nonempty(); - try - { - std::pop_heap(c.begin(), c.end(), comp); - c.pop_back(); - } - catch(...) - { - c.clear(); - __throw_exception_again; - } + std::pop_heap(c.begin(), c.end(), comp); + c.pop_back(); } }; // No equality/comparison operators are provided for priority_queue. -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif /* _QUEUE_H */ diff --git a/contrib/libstdc++/include/bits/stl_raw_storage_iter.h b/contrib/libstdc++/include/bits/stl_raw_storage_iter.h index 732142e..615da28 100644 --- a/contrib/libstdc++/include/bits/stl_raw_storage_iter.h +++ b/contrib/libstdc++/include/bits/stl_raw_storage_iter.h @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2001, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -61,8 +61,8 @@ #ifndef _STL_RAW_STORAGE_ITERATOR_H #define _STL_RAW_STORAGE_ITERATOR_H 1 -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * This iterator class lets algorithms store their results into * uninitialized memory. @@ -104,10 +104,7 @@ namespace std return __tmp; } }; -} // namespace std -#endif +_GLIBCXX_END_NAMESPACE -// Local Variables: -// mode:C++ -// End: +#endif diff --git a/contrib/libstdc++/include/bits/stl_relops.h b/contrib/libstdc++/include/bits/stl_relops.h index 3e9f060..11fc30d 100644 --- a/contrib/libstdc++/include/bits/stl_relops.h +++ b/contrib/libstdc++/include/bits/stl_relops.h @@ -1,6 +1,6 @@ // std::rel_ops implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -71,8 +71,8 @@ #ifndef _STL_RELOPS_H #define _STL_RELOPS_H 1 -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + namespace rel_ops { /** @namespace std::rel_ops @@ -132,6 +132,7 @@ namespace std { return !(__x < __y); } } // namespace rel_ops -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif /* _STL_RELOPS_H */ diff --git a/contrib/libstdc++/include/bits/stl_set.h b/contrib/libstdc++/include/bits/stl_set.h index bb28bdd..b61106a 100644 --- a/contrib/libstdc++/include/bits/stl_set.h +++ b/contrib/libstdc++/include/bits/stl_set.h @@ -1,6 +1,6 @@ // Set implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004, 2005, 2006 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -63,22 +63,7 @@ #include -namespace _GLIBCXX_STD -{ - // Forward declarations of operators < and ==, needed for friend declaration. - template, - class _Alloc = allocator<_Key> > - class set; - - template - inline bool - operator==(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y); - - template - inline bool - operator<(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y); +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) /** * @brief A standard container made up of unique keys, which can be @@ -103,13 +88,16 @@ namespace _GLIBCXX_STD * called (*_unique versus *_equal, same as the standard). * @endif */ - template + template, + class _Alloc = std::allocator<_Key> > class set { // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; __glibcxx_class_requires(_Key, _SGIAssignableConcept) __glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept) + __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept) public: // typedefs: @@ -119,29 +107,32 @@ namespace _GLIBCXX_STD typedef _Key value_type; typedef _Compare key_compare; typedef _Compare value_compare; + typedef _Alloc allocator_type; //@} private: - typedef _Rb_tree, key_compare, _Alloc> _Rep_type; + typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type; + + typedef _Rb_tree, + key_compare, _Key_alloc_type> _Rep_type; _Rep_type _M_t; // red-black tree representing set + public: //@{ /// Iterator-related typedefs. - typedef typename _Alloc::pointer pointer; - typedef typename _Alloc::const_pointer const_pointer; - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; + typedef typename _Key_alloc_type::pointer pointer; + typedef typename _Key_alloc_type::const_pointer const_pointer; + typedef typename _Key_alloc_type::reference reference; + typedef typename _Key_alloc_type::const_reference const_reference; // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 103. set::iterator is required to be modifiable, // but this allows modification of keys. - typedef typename _Rep_type::const_iterator iterator; - typedef typename _Rep_type::const_iterator const_iterator; - typedef typename _Rep_type::const_reverse_iterator reverse_iterator; - typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; - typedef typename _Rep_type::size_type size_type; - typedef typename _Rep_type::difference_type difference_type; - typedef typename _Rep_type::allocator_type allocator_type; + typedef typename _Rep_type::const_iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::const_reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; //@} // allocation/deallocation @@ -155,8 +146,9 @@ namespace _GLIBCXX_STD * @param comp Comparator to use. * @param a Allocator to use. */ - explicit set(const _Compare& __comp, - const allocator_type& __a = allocator_type()) + explicit + set(const _Compare& __comp, + const allocator_type& __a = allocator_type()) : _M_t(__comp, __a) {} /** @@ -171,7 +163,7 @@ namespace _GLIBCXX_STD template set(_InputIterator __first, _InputIterator __last) : _M_t(_Compare(), allocator_type()) - { _M_t.insert_unique(__first, __last); } + { _M_t._M_insert_unique(__first, __last); } /** * @brief Builds a %set from a range. @@ -189,7 +181,7 @@ namespace _GLIBCXX_STD const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_t(__comp, __a) - { _M_t.insert_unique(__first, __last); } + { _M_t._M_insert_unique(__first, __last); } /** * @brief Set copy constructor. @@ -308,11 +300,12 @@ namespace _GLIBCXX_STD * * Insertion requires logarithmic time. */ - pair + std::pair insert(const value_type& __x) { - pair __p = _M_t.insert_unique(__x); - return pair(__p.first, __p.second); + std::pair __p = + _M_t._M_insert_unique(__x); + return std::pair(__p.first, __p.second); } /** @@ -336,10 +329,7 @@ namespace _GLIBCXX_STD */ iterator insert(iterator __position, const value_type& __x) - { - typedef typename _Rep_type::iterator _Rep_iterator; - return _M_t.insert_unique((_Rep_iterator&)__position, __x); - } + { return _M_t._M_insert_unique(__position, __x); } /** * @brief A template function that attemps to insert a range of elements. @@ -350,9 +340,9 @@ namespace _GLIBCXX_STD * Complexity similar to that of the range constructor. */ template - void - insert(_InputIterator __first, _InputIterator __last) - { _M_t.insert_unique(__first, __last); } + void + insert(_InputIterator __first, _InputIterator __last) + { _M_t._M_insert_unique(__first, __last); } /** * @brief Erases an element from a %set. @@ -365,10 +355,7 @@ namespace _GLIBCXX_STD */ void erase(iterator __position) - { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__position); - } + { _M_t.erase(__position); } /** * @brief Erases elements according to the provided key. @@ -382,7 +369,8 @@ namespace _GLIBCXX_STD * in any way. Managing the pointer is the user's responsibilty. */ size_type - erase(const key_type& __x) { return _M_t.erase(__x); } + erase(const key_type& __x) + { return _M_t.erase(__x); } /** * @brief Erases a [first,last) range of elements from a %set. @@ -397,10 +385,7 @@ namespace _GLIBCXX_STD */ void erase(iterator __first, iterator __last) - { - typedef typename _Rep_type::iterator _Rep_iterator; - _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last); - } + { _M_t.erase(__first, __last); } /** * Erases all elements in a %set. Note that this function only erases @@ -502,22 +487,22 @@ namespace _GLIBCXX_STD * * This function probably only makes sense for multisets. */ - pair + std::pair equal_range(const key_type& __x) { return _M_t.equal_range(__x); } - pair + std::pair equal_range(const key_type& __x) const { return _M_t.equal_range(__x); } //@} template friend bool - operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); + operator== (const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); template friend bool - operator< (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); + operator< (const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); }; @@ -533,8 +518,8 @@ namespace _GLIBCXX_STD */ template inline bool - operator==(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator==(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return __x._M_t == __y._M_t; } /** @@ -550,44 +535,44 @@ namespace _GLIBCXX_STD */ template inline bool - operator<(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator<(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return __x._M_t < __y._M_t; } /// Returns !(x == y). template inline bool - operator!=(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator!=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return !(__x == __y); } /// Returns y < x. template inline bool - operator>(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator>(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return __y < __x; } /// Returns !(y < x) template inline bool - operator<=(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator<=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return !(__y < __x); } /// Returns !(x < y) template inline bool - operator>=(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator>=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return !(__x < __y); } /// See std::set::swap(). template inline void - swap(set<_Key,_Compare,_Alloc>& __x, set<_Key,_Compare,_Alloc>& __y) + swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y) { __x.swap(__y); } -} // namespace std +_GLIBCXX_END_NESTED_NAMESPACE #endif /* _SET_H */ diff --git a/contrib/libstdc++/include/bits/stl_stack.h b/contrib/libstdc++/include/bits/stl_stack.h index ada50ee..f5b41fa 100644 --- a/contrib/libstdc++/include/bits/stl_stack.h +++ b/contrib/libstdc++/include/bits/stl_stack.h @@ -1,6 +1,7 @@ // Stack implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -64,20 +65,7 @@ #include #include -namespace std -{ - // Forward declarations of operators == and <, needed for friend - // declaration. - template > - class stack; - - template - inline bool - operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y); - - template - inline bool - operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y); +_GLIBCXX_BEGIN_NAMESPACE(std) /** * @brief A standard container giving FILO behavior. @@ -106,7 +94,7 @@ namespace std * push, @c pop, and @c top, which are standard %stack/FILO * operations. */ - template + template > class stack { // concept requirements @@ -141,7 +129,7 @@ namespace std */ explicit stack(const _Sequence& __c = _Sequence()) - : c(__c) {} + : c(__c) { } /** * Returns true if the %stack is empty. @@ -267,6 +255,7 @@ namespace std inline bool operator>=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) { return !(__x < __y); } -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif /* _STACK_H */ diff --git a/contrib/libstdc++/include/bits/stl_tempbuf.h b/contrib/libstdc++/include/bits/stl_tempbuf.h index 399cffb..fbe24e7 100644 --- a/contrib/libstdc++/include/bits/stl_tempbuf.h +++ b/contrib/libstdc++/include/bits/stl_tempbuf.h @@ -1,6 +1,7 @@ // Temporary buffer implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -63,8 +64,8 @@ #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @if maint * This class is used in two places: stl_algo.h and ext/memory, @@ -78,7 +79,7 @@ namespace std // concept requirements __glibcxx_class_requires(_ForwardIterator, _ForwardIteratorConcept) - public: + public: typedef _Tp value_type; typedef value_type* pointer; typedef pointer iterator; @@ -93,8 +94,8 @@ namespace std _M_initialize_buffer(const _Tp&, __true_type) { } void - _M_initialize_buffer(const _Tp& val, __false_type) - { std::uninitialized_fill_n(_M_buffer, _M_len, val); } + _M_initialize_buffer(const _Tp& __val, __false_type) + { std::uninitialized_fill_n(_M_buffer, _M_len, __val); } public: /// As per Table mumble. @@ -145,8 +146,7 @@ namespace std _M_len(0), _M_buffer(0) { // Workaround for a __type_traits bug in the pre-7.3 compiler. - typedef typename __type_traits<_Tp>::has_trivial_default_constructor - _Trivial; + typedef typename std::__is_scalar<_Tp>::__type _Trivial; try { @@ -165,7 +165,8 @@ namespace std __throw_exception_again; } } -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif /* _TEMPBUF_H */ diff --git a/contrib/libstdc++/include/bits/stl_tree.h b/contrib/libstdc++/include/bits/stl_tree.h index cea16f1..22e132f 100644 --- a/contrib/libstdc++/include/bits/stl_tree.h +++ b/contrib/libstdc++/include/bits/stl_tree.h @@ -1,6 +1,7 @@ // RB tree implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -69,8 +70,8 @@ #include #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // Red-black tree class, designed for use in implementing STL // associative containers (set, multiset, map, and multimap). The // insertion and deletion algorithms are based on those in Cormen, @@ -164,6 +165,7 @@ namespace std _Rb_tree_iterator() : _M_node() { } + explicit _Rb_tree_iterator(_Link_type __x) : _M_node(__x) { } @@ -235,6 +237,7 @@ namespace std _Rb_tree_const_iterator() : _M_node() { } + explicit _Rb_tree_const_iterator(_Link_type __x) : _M_node(__x) { } @@ -346,10 +349,18 @@ namespace std typedef ptrdiff_t difference_type; typedef _Alloc allocator_type; - allocator_type - get_allocator() const + _Node_allocator& + _M_get_Node_allocator() + { return *static_cast<_Node_allocator*>(&this->_M_impl); } + + const _Node_allocator& + _M_get_Node_allocator() const { return *static_cast(&this->_M_impl); } + allocator_type + get_allocator() const + { return allocator_type(_M_get_Node_allocator()); } + protected: _Rb_tree_node* _M_get_node() @@ -364,7 +375,7 @@ namespace std { _Link_type __tmp = _M_get_node(); try - { std::_Construct(&__tmp->_M_value_field, __x); } + { get_allocator().construct(&__tmp->_M_value_field, __x); } catch(...) { _M_put_node(__tmp); @@ -384,15 +395,15 @@ namespace std } void - destroy_node(_Link_type __p) + _M_destroy_node(_Link_type __p) { - std::_Destroy(&__p->_M_value_field); + get_allocator().destroy(&__p->_M_value_field); _M_put_node(__p); } protected: template::_M_type> + bool _Is_pod_comparator = std::__is_pod<_Key_compare>::__value> struct _Rb_tree_impl : public _Node_allocator { _Key_compare _M_key_compare; @@ -401,7 +412,8 @@ namespace std _Rb_tree_impl(const _Node_allocator& __a = _Node_allocator(), const _Key_compare& __comp = _Key_compare()) - : _Node_allocator(__a), _M_key_compare(__comp), _M_node_count(0) + : _Node_allocator(__a), _M_key_compare(__comp), _M_header(), + _M_node_count(0) { this->_M_header._M_color = _S_red; this->_M_header._M_parent = 0; @@ -421,7 +433,8 @@ namespace std _Rb_tree_impl(const _Node_allocator& __a = _Node_allocator(), const _Key_compare& __comp = _Key_compare()) - : _Node_allocator(__a), _M_key_compare(__comp), _M_node_count(0) + : _Node_allocator(__a), _M_key_compare(__comp), _M_header(), + _M_node_count(0) { this->_M_header._M_color = _S_red; this->_M_header._M_parent = 0; @@ -463,7 +476,10 @@ namespace std _Const_Link_type _M_begin() const - { return static_cast<_Const_Link_type>(this->_M_impl._M_header._M_parent); } + { + return static_cast<_Const_Link_type> + (this->_M_impl._M_header._M_parent); + } _Link_type _M_end() @@ -532,6 +548,15 @@ namespace std iterator _M_insert(_Base_ptr __x, _Base_ptr __y, const value_type& __v); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 233. Insertion hints in associative containers. + iterator + _M_insert_lower(_Base_ptr __x, _Base_ptr __y, const value_type& __v); + + const_iterator + _M_insert(_Const_Base_ptr __x, _Const_Base_ptr __y, + const value_type& __v); + _Link_type _M_copy(_Const_Link_type __x, _Link_type __p); @@ -551,8 +576,8 @@ namespace std : _M_impl(__a, __comp) { } - _Rb_tree(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x) - : _M_impl(__x.get_allocator(), __x._M_impl._M_key_compare) + _Rb_tree(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x) + : _M_impl(__x._M_get_Node_allocator(), __x._M_impl._M_key_compare) { if (__x._M_root() != 0) { @@ -566,8 +591,8 @@ namespace std ~_Rb_tree() { _M_erase(_M_begin()); } - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& - operator=(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x); + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& + operator=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x); // Accessors. _Compare @@ -576,19 +601,28 @@ namespace std iterator begin() - { return static_cast<_Link_type>(this->_M_impl._M_header._M_left); } + { + return iterator(static_cast<_Link_type> + (this->_M_impl._M_header._M_left)); + } const_iterator begin() const - { return static_cast<_Const_Link_type>(this->_M_impl._M_header._M_left); } + { + return const_iterator(static_cast<_Const_Link_type> + (this->_M_impl._M_header._M_left)); + } iterator end() - { return static_cast<_Link_type>(&this->_M_impl._M_header); } + { return iterator(static_cast<_Link_type>(&this->_M_impl._M_header)); } const_iterator end() const - { return static_cast<_Const_Link_type>(&this->_M_impl._M_header); } + { + return const_iterator(static_cast<_Const_Link_type> + (&this->_M_impl._M_header)); + } reverse_iterator rbegin() @@ -616,35 +650,49 @@ namespace std size_type max_size() const - { return size_type(-1); } + { return get_allocator().max_size(); } void - swap(_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __t); + swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __t); // Insert/erase. - pair - insert_unique(const value_type& __x); + pair + _M_insert_unique(const value_type& __x); + + iterator + _M_insert_equal(const value_type& __x); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 233. Insertion hints in associative containers. iterator - insert_equal(const value_type& __x); + _M_insert_equal_lower(const value_type& __x); iterator - insert_unique(iterator __position, const value_type& __x); + _M_insert_unique(iterator __position, const value_type& __x); + + const_iterator + _M_insert_unique(const_iterator __position, const value_type& __x); iterator - insert_equal(iterator __position, const value_type& __x); + _M_insert_equal(iterator __position, const value_type& __x); + + const_iterator + _M_insert_equal(const_iterator __position, const value_type& __x); template - void - insert_unique(_InputIterator __first, _InputIterator __last); + void + _M_insert_unique(_InputIterator __first, _InputIterator __last); template - void - insert_equal(_InputIterator __first, _InputIterator __last); + void + _M_insert_equal(_InputIterator __first, _InputIterator __last); void erase(iterator __position); + void + erase(const_iterator __position); + size_type erase(const key_type& __x); @@ -652,6 +700,9 @@ namespace std erase(iterator __first, iterator __last); void + erase(const_iterator __first, const_iterator __last); + + void erase(const key_type* __first, const key_type* __last); void @@ -700,8 +751,8 @@ namespace std template inline bool - operator==(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __y) + operator==(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, + const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) { return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); @@ -710,8 +761,8 @@ namespace std template inline bool - operator<(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __y) + operator<(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, + const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) { return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); @@ -720,43 +771,43 @@ namespace std template inline bool - operator!=(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __y) + operator!=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, + const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) { return !(__x == __y); } template inline bool - operator>(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __y) + operator>(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, + const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) { return __y < __x; } template inline bool - operator<=(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __y) + operator<=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, + const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) { return !(__y < __x); } template inline bool - operator>=(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x, - const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __y) + operator>=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, + const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) { return !(__x < __y); } template inline void - swap(_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x, - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __y) + swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) { __x.swap(__y); } template - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: - operator=(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x) + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + operator=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x) { if (this != &__x) { @@ -776,16 +827,33 @@ namespace std template - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert(_Base_ptr __x, _Base_ptr __p, const _Val& __v) { + bool __insert_left = (__x != 0 || __p == _M_end() + || _M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key(__p))); + _Link_type __z = _M_create_node(__v); - bool __insert_left; - __insert_left = __x != 0 || __p == _M_end() - || _M_impl._M_key_compare(_KeyOfValue()(__v), - _S_key(__p)); + _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, + this->_M_impl._M_header); + ++_M_impl._M_node_count; + return iterator(__z); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_lower(_Base_ptr __x, _Base_ptr __p, const _Val& __v) + { + bool __insert_left = (__x != 0 || __p == _M_end() + || !_M_impl._M_key_compare(_S_key(__p), + _KeyOfValue()(__v))); + + _Link_type __z = _M_create_node(__v); _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, this->_M_impl._M_header); @@ -795,9 +863,28 @@ namespace std template - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: - insert_equal(const _Val& __v) + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert(_Const_Base_ptr __x, _Const_Base_ptr __p, const _Val& __v) + { + bool __insert_left = (__x != 0 || __p == _M_end() + || _M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key(__p))); + + _Link_type __z = _M_create_node(__v); + + _Rb_tree_insert_and_rebalance(__insert_left, __z, + const_cast<_Base_ptr>(__p), + this->_M_impl._M_header); + ++_M_impl._M_node_count; + return const_iterator(__z); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_equal(const _Val& __v) { _Link_type __x = _M_begin(); _Link_type __y = _M_end(); @@ -812,55 +899,77 @@ namespace std template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_equal_lower(const _Val& __v) + { + _Link_type __x = _M_begin(); + _Link_type __y = _M_end(); + while (__x != 0) + { + __y = __x; + __x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ? + _S_left(__x) : _S_right(__x); + } + return _M_insert_lower(__x, __y, __v); + } + + template void - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: - swap(_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __t) + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __t) { if (_M_root() == 0) - { - if (__t._M_root() != 0) { - _M_root() = __t._M_root(); - _M_leftmost() = __t._M_leftmost(); - _M_rightmost() = __t._M_rightmost(); - _M_root()->_M_parent = _M_end(); - - __t._M_root() = 0; - __t._M_leftmost() = __t._M_end(); - __t._M_rightmost() = __t._M_end(); + if (__t._M_root() != 0) + { + _M_root() = __t._M_root(); + _M_leftmost() = __t._M_leftmost(); + _M_rightmost() = __t._M_rightmost(); + _M_root()->_M_parent = _M_end(); + + __t._M_root() = 0; + __t._M_leftmost() = __t._M_end(); + __t._M_rightmost() = __t._M_end(); + } } - } else if (__t._M_root() == 0) - { - __t._M_root() = _M_root(); - __t._M_leftmost() = _M_leftmost(); - __t._M_rightmost() = _M_rightmost(); - __t._M_root()->_M_parent = __t._M_end(); - - _M_root() = 0; - _M_leftmost() = _M_end(); - _M_rightmost() = _M_end(); - } + { + __t._M_root() = _M_root(); + __t._M_leftmost() = _M_leftmost(); + __t._M_rightmost() = _M_rightmost(); + __t._M_root()->_M_parent = __t._M_end(); + + _M_root() = 0; + _M_leftmost() = _M_end(); + _M_rightmost() = _M_end(); + } else - { - std::swap(_M_root(),__t._M_root()); - std::swap(_M_leftmost(),__t._M_leftmost()); - std::swap(_M_rightmost(),__t._M_rightmost()); - - _M_root()->_M_parent = _M_end(); - __t._M_root()->_M_parent = __t._M_end(); - } + { + std::swap(_M_root(),__t._M_root()); + std::swap(_M_leftmost(),__t._M_leftmost()); + std::swap(_M_rightmost(),__t._M_rightmost()); + + _M_root()->_M_parent = _M_end(); + __t._M_root()->_M_parent = __t._M_end(); + } // No need to swap header's color as it does not change. std::swap(this->_M_impl._M_node_count, __t._M_impl._M_node_count); std::swap(this->_M_impl._M_key_compare, __t._M_impl._M_key_compare); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 431. Swapping containers with unequal allocators. + std::__alloc_swap<_Node_allocator>:: + _S_do_it(_M_get_Node_allocator(), __t._M_get_Node_allocator()); } template - pair::iterator, - bool> - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: - insert_unique(const _Val& __v) + pair::iterator, bool> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_unique(const _Val& __v) { _Link_type __x = _M_begin(); _Link_type __y = _M_end(); @@ -878,99 +987,229 @@ namespace std else --__j; if (_M_impl._M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__v))) - return pair(_M_insert(__x, __y, __v), true); - return pair(__j, false); + return pair(_M_insert(__x, __y, __v), true); + return pair(__j, false); } template typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: - insert_unique(iterator __position, const _Val& __v) + _M_insert_unique(iterator __position, const _Val& __v) { - if (__position._M_node == _M_leftmost()) + // end() + if (__position._M_node == _M_end()) { - // begin() if (size() > 0 - && _M_impl._M_key_compare(_KeyOfValue()(__v), - _S_key(__position._M_node))) - return _M_insert(__position._M_node, __position._M_node, __v); - // First argument just needs to be non-null. + && _M_impl._M_key_compare(_S_key(_M_rightmost()), + _KeyOfValue()(__v))) + return _M_insert(0, _M_rightmost(), __v); else - return insert_unique(__v).first; + return _M_insert_unique(__v).first; } - else if (__position._M_node == _M_end()) + else if (_M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key(__position._M_node))) { - // end() - if (_M_impl._M_key_compare(_S_key(_M_rightmost()), - _KeyOfValue()(__v))) + // First, try before... + iterator __before = __position; + if (__position._M_node == _M_leftmost()) // begin() + return _M_insert(_M_leftmost(), _M_leftmost(), __v); + else if (_M_impl._M_key_compare(_S_key((--__before)._M_node), + _KeyOfValue()(__v))) + { + if (_S_right(__before._M_node) == 0) + return _M_insert(0, __before._M_node, __v); + else + return _M_insert(__position._M_node, + __position._M_node, __v); + } + else + return _M_insert_unique(__v).first; + } + else if (_M_impl._M_key_compare(_S_key(__position._M_node), + _KeyOfValue()(__v))) + { + // ... then try after. + iterator __after = __position; + if (__position._M_node == _M_rightmost()) return _M_insert(0, _M_rightmost(), __v); + else if (_M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key((++__after)._M_node))) + { + if (_S_right(__position._M_node) == 0) + return _M_insert(0, __position._M_node, __v); + else + return _M_insert(__after._M_node, __after._M_node, __v); + } else - return insert_unique(__v).first; + return _M_insert_unique(__v).first; } else + return __position; // Equivalent keys. + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_unique(const_iterator __position, const _Val& __v) + { + // end() + if (__position._M_node == _M_end()) { - iterator __before = __position; - --__before; - if (_M_impl._M_key_compare(_S_key(__before._M_node), - _KeyOfValue()(__v)) - && _M_impl._M_key_compare(_KeyOfValue()(__v), - _S_key(__position._M_node))) + if (size() > 0 + && _M_impl._M_key_compare(_S_key(_M_rightmost()), + _KeyOfValue()(__v))) + return _M_insert(0, _M_rightmost(), __v); + else + return const_iterator(_M_insert_unique(__v).first); + } + else if (_M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key(__position._M_node))) + { + // First, try before... + const_iterator __before = __position; + if (__position._M_node == _M_leftmost()) // begin() + return _M_insert(_M_leftmost(), _M_leftmost(), __v); + else if (_M_impl._M_key_compare(_S_key((--__before)._M_node), + _KeyOfValue()(__v))) { if (_S_right(__before._M_node) == 0) return _M_insert(0, __before._M_node, __v); else - return _M_insert(__position._M_node, __position._M_node, __v); - // First argument just needs to be non-null. + return _M_insert(__position._M_node, + __position._M_node, __v); } else - return insert_unique(__v).first; + return const_iterator(_M_insert_unique(__v).first); } + else if (_M_impl._M_key_compare(_S_key(__position._M_node), + _KeyOfValue()(__v))) + { + // ... then try after. + const_iterator __after = __position; + if (__position._M_node == _M_rightmost()) + return _M_insert(0, _M_rightmost(), __v); + else if (_M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key((++__after)._M_node))) + { + if (_S_right(__position._M_node) == 0) + return _M_insert(0, __position._M_node, __v); + else + return _M_insert(__after._M_node, __after._M_node, __v); + } + else + return const_iterator(_M_insert_unique(__v).first); + } + else + return __position; // Equivalent keys. } template - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: - insert_equal(iterator __position, const _Val& __v) + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_equal(iterator __position, const _Val& __v) { - if (__position._M_node == _M_leftmost()) + // end() + if (__position._M_node == _M_end()) { - // begin() if (size() > 0 - && !_M_impl._M_key_compare(_S_key(__position._M_node), - _KeyOfValue()(__v))) - return _M_insert(__position._M_node, __position._M_node, __v); - // first argument just needs to be non-null + && !_M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key(_M_rightmost()))) + return _M_insert(0, _M_rightmost(), __v); else - return insert_equal(__v); + return _M_insert_equal(__v); } - else if (__position._M_node == _M_end()) + else if (!_M_impl._M_key_compare(_S_key(__position._M_node), + _KeyOfValue()(__v))) { - // end() - if (!_M_impl._M_key_compare(_KeyOfValue()(__v), - _S_key(_M_rightmost()))) - return _M_insert(0, _M_rightmost(), __v); + // First, try before... + iterator __before = __position; + if (__position._M_node == _M_leftmost()) // begin() + return _M_insert(_M_leftmost(), _M_leftmost(), __v); + else if (!_M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key((--__before)._M_node))) + { + if (_S_right(__before._M_node) == 0) + return _M_insert(0, __before._M_node, __v); + else + return _M_insert(__position._M_node, + __position._M_node, __v); + } else - return insert_equal(__v); + return _M_insert_equal(__v); } else { - iterator __before = __position; - --__before; - if (!_M_impl._M_key_compare(_KeyOfValue()(__v), - _S_key(__before._M_node)) - && !_M_impl._M_key_compare(_S_key(__position._M_node), - _KeyOfValue()(__v))) + // ... then try after. + iterator __after = __position; + if (__position._M_node == _M_rightmost()) + return _M_insert(0, _M_rightmost(), __v); + else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node), + _KeyOfValue()(__v))) + { + if (_S_right(__position._M_node) == 0) + return _M_insert(0, __position._M_node, __v); + else + return _M_insert(__after._M_node, __after._M_node, __v); + } + else + return _M_insert_equal_lower(__v); + } + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_equal(const_iterator __position, const _Val& __v) + { + // end() + if (__position._M_node == _M_end()) + { + if (size() > 0 + && !_M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key(_M_rightmost()))) + return _M_insert(0, _M_rightmost(), __v); + else + return const_iterator(_M_insert_equal(__v)); + } + else if (!_M_impl._M_key_compare(_S_key(__position._M_node), + _KeyOfValue()(__v))) + { + // First, try before... + const_iterator __before = __position; + if (__position._M_node == _M_leftmost()) // begin() + return _M_insert(_M_leftmost(), _M_leftmost(), __v); + else if (!_M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key((--__before)._M_node))) { if (_S_right(__before._M_node) == 0) return _M_insert(0, __before._M_node, __v); else - return _M_insert(__position._M_node, __position._M_node, __v); - // First argument just needs to be non-null. + return _M_insert(__position._M_node, + __position._M_node, __v); } else - return insert_equal(__v); + return const_iterator(_M_insert_equal(__v)); + } + else + { + // ... then try after. + const_iterator __after = __position; + if (__position._M_node == _M_rightmost()) + return _M_insert(0, _M_rightmost(), __v); + else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node), + _KeyOfValue()(__v))) + { + if (_S_right(__position._M_node) == 0) + return _M_insert(0, __position._M_node, __v); + else + return _M_insert(__after._M_node, __after._M_node, __v); + } + else + return const_iterator(_M_insert_equal_lower(__v)); } } @@ -978,51 +1217,68 @@ namespace std typename _Cmp, typename _Alloc> template void - _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>:: - insert_equal(_II __first, _II __last) + _Rb_tree<_Key, _Val, _KoV, _Cmp, _Alloc>:: + _M_insert_equal(_II __first, _II __last) { - for ( ; __first != __last; ++__first) - insert_equal(*__first); + for (; __first != __last; ++__first) + _M_insert_equal(end(), *__first); } template template - void - _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>:: - insert_unique(_II __first, _II __last) + void + _Rb_tree<_Key, _Val, _KoV, _Cmp, _Alloc>:: + _M_insert_unique(_II __first, _II __last) + { + for (; __first != __last; ++__first) + _M_insert_unique(end(), *__first); + } + + template + inline void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + erase(iterator __position) { - for ( ; __first != __last; ++__first) - insert_unique(*__first); + _Link_type __y = + static_cast<_Link_type>(_Rb_tree_rebalance_for_erase + (__position._M_node, + this->_M_impl._M_header)); + _M_destroy_node(__y); + --_M_impl._M_node_count; } template inline void - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::erase(iterator __position) + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + erase(const_iterator __position) { _Link_type __y = - static_cast<_Link_type>(_Rb_tree_rebalance_for_erase(__position._M_node, - this->_M_impl._M_header)); - destroy_node(__y); + static_cast<_Link_type>(_Rb_tree_rebalance_for_erase + (const_cast<_Base_ptr>(__position._M_node), + this->_M_impl._M_header)); + _M_destroy_node(__y); --_M_impl._M_node_count; } template - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::size_type - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::erase(const _Key& __x) + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + erase(const _Key& __x) { - pair __p = equal_range(__x); - size_type __n = std::distance(__p.first, __p.second); + pair __p = equal_range(__x); + const size_type __old_size = size(); erase(__p.first, __p.second); - return __n; + return __old_size - size(); } template typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type - _Rb_tree<_Key,_Val,_KoV,_Compare,_Alloc>:: + _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>:: _M_copy(_Const_Link_type __x, _Link_type __p) { // Structural copy. __x and __p must be non-null. @@ -1058,14 +1314,15 @@ namespace std template void - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::_M_erase(_Link_type __x) + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_erase(_Link_type __x) { // Erase without rebalancing. while (__x != 0) { _M_erase(_S_right(__x)); _Link_type __y = _S_left(__x); - destroy_node(__x); + _M_destroy_node(__x); __x = __y; } } @@ -1073,19 +1330,33 @@ namespace std template void - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: erase(iterator __first, iterator __last) { if (__first == begin() && __last == end()) clear(); else - while (__first != __last) erase(__first++); + while (__first != __last) + erase(__first++); } template void - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + erase(const_iterator __first, const_iterator __last) + { + if (__first == begin() && __last == end()) + clear(); + else + while (__first != __last) + erase(__first++); + } + + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: erase(const _Key* __first, const _Key* __last) { while (__first != __last) @@ -1094,8 +1365,9 @@ namespace std template - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::find(const _Key& __k) + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + find(const _Key& __k) { _Link_type __x = _M_begin(); // Current node. _Link_type __y = _M_end(); // Last node which is not less than __k. @@ -1107,14 +1379,15 @@ namespace std __x = _S_right(__x); iterator __j = iterator(__y); - return (__j == end() - || _M_impl._M_key_compare(__k, _S_key(__j._M_node))) ? end() : __j; + return (__j == end() + || _M_impl._M_key_compare(__k, + _S_key(__j._M_node))) ? end() : __j; } template - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::const_iterator - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: find(const _Key& __k) const { _Const_Link_type __x = _M_begin(); // Current node. @@ -1128,14 +1401,15 @@ namespace std __x = _S_right(__x); } const_iterator __j = const_iterator(__y); - return (__j == end() - || _M_impl._M_key_compare(__k, _S_key(__j._M_node))) ? end() : __j; + return (__j == end() + || _M_impl._M_key_compare(__k, + _S_key(__j._M_node))) ? end() : __j; } template - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::size_type - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: count(const _Key& __k) const { pair __p = equal_range(__k); @@ -1145,8 +1419,8 @@ namespace std template - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: lower_bound(const _Key& __k) { _Link_type __x = _M_begin(); // Current node. @@ -1163,8 +1437,8 @@ namespace std template - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::const_iterator - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: lower_bound(const _Key& __k) const { _Const_Link_type __x = _M_begin(); // Current node. @@ -1181,8 +1455,8 @@ namespace std template - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: upper_bound(const _Key& __k) { _Link_type __x = _M_begin(); // Current node. @@ -1199,8 +1473,8 @@ namespace std template - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::const_iterator - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: upper_bound(const _Key& __k) const { _Const_Link_type __x = _M_begin(); // Current node. @@ -1218,10 +1492,10 @@ namespace std template inline - pair::iterator, - typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator> - _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: + pair::iterator, + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: equal_range(const _Key& __k) { return pair(lower_bound(__k), upper_bound(__k)); } @@ -1277,7 +1551,7 @@ namespace std return false; return true; } -} // namespace std -#endif +_GLIBCXX_END_NAMESPACE +#endif diff --git a/contrib/libstdc++/include/bits/stl_uninitialized.h b/contrib/libstdc++/include/bits/stl_uninitialized.h index f4f8d18..2c947f6 100644 --- a/contrib/libstdc++/include/bits/stl_uninitialized.h +++ b/contrib/libstdc++/include/bits/stl_uninitialized.h @@ -1,6 +1,7 @@ // Raw memory manipulators -*- C++ -*- -// Copyright (C) 2001, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -63,8 +64,8 @@ #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // uninitialized_copy template inline _ForwardIterator @@ -82,7 +83,7 @@ namespace std _ForwardIterator __cur = __result; try { - for ( ; __first != __last; ++__first, ++__cur) + for (; __first != __last; ++__first, ++__cur) std::_Construct(&*__cur, *__first); return __cur; } @@ -108,7 +109,7 @@ namespace std _ForwardIterator __result) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; - typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD; + typedef typename std::__is_scalar<_ValueType>::__type _Is_POD; return std::__uninitialized_copy_aux(__first, __last, __result, _Is_POD()); } @@ -145,7 +146,7 @@ namespace std _ForwardIterator __cur = __first; try { - for ( ; __cur != __last; ++__cur) + for (; __cur != __last; ++__cur) std::_Construct(&*__cur, __x); } catch(...) @@ -170,29 +171,28 @@ namespace std const _Tp& __x) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; - typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD; + typedef typename std::__is_scalar<_ValueType>::__type _Is_POD; std::__uninitialized_fill_aux(__first, __last, __x, _Is_POD()); } // Valid if copy construction is equivalent to assignment, and if the // destructor is trivial. template - inline _ForwardIterator + inline void __uninitialized_fill_n_aux(_ForwardIterator __first, _Size __n, const _Tp& __x, __true_type) - { return std::fill_n(__first, __n, __x); } + { std::fill_n(__first, __n, __x); } template - _ForwardIterator + void __uninitialized_fill_n_aux(_ForwardIterator __first, _Size __n, const _Tp& __x, __false_type) { _ForwardIterator __cur = __first; try { - for ( ; __n > 0; --__n, ++__cur) + for (; __n > 0; --__n, ++__cur) std::_Construct(&*__cur, __x); - return __cur; } catch(...) { @@ -206,21 +206,109 @@ namespace std * @param first An input iterator. * @param n The number of copies to make. * @param x The source value. - * @return first+n + * @return Nothing. * * Like fill_n(), but does not require an initialized output range. */ template - inline _ForwardIterator + inline void uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; - typedef typename __type_traits<_ValueType>::is_POD_type _Is_POD; - return std::__uninitialized_fill_n_aux(__first, __n, __x, _Is_POD()); + typedef typename std::__is_scalar<_ValueType>::__type _Is_POD; + std::__uninitialized_fill_n_aux(__first, __n, __x, _Is_POD()); + } + + // Extensions: versions of uninitialized_copy, uninitialized_fill, + // and uninitialized_fill_n that take an allocator parameter. + // We dispatch back to the standard versions when we're given the + // default allocator. For nondefault allocators we do not use + // any of the POD optimizations. + + template + _ForwardIterator + __uninitialized_copy_a(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, + _Allocator __alloc) + { + _ForwardIterator __cur = __result; + try + { + for (; __first != __last; ++__first, ++__cur) + __alloc.construct(&*__cur, *__first); + return __cur; + } + catch(...) + { + std::_Destroy(__result, __cur, __alloc); + __throw_exception_again; + } + } + + template + inline _ForwardIterator + __uninitialized_copy_a(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, + allocator<_Tp>) + { return std::uninitialized_copy(__first, __last, __result); } + + template + void + __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x, _Allocator __alloc) + { + _ForwardIterator __cur = __first; + try + { + for (; __cur != __last; ++__cur) + __alloc.construct(&*__cur, __x); + } + catch(...) + { + std::_Destroy(__first, __cur, __alloc); + __throw_exception_again; + } + } + + template + inline void + __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x, allocator<_Tp2>) + { std::uninitialized_fill(__first, __last, __x); } + + template + void + __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, + const _Tp& __x, + _Allocator __alloc) + { + _ForwardIterator __cur = __first; + try + { + for (; __n > 0; --__n, ++__cur) + __alloc.construct(&*__cur, __x); + } + catch(...) + { + std::_Destroy(__first, __cur, __alloc); + __throw_exception_again; + } } + template + inline void + __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, + const _Tp& __x, + allocator<_Tp2>) + { std::uninitialized_fill_n(__first, __n, __x); } + + // Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill, - // __uninitialized_fill_copy. + // __uninitialized_fill_copy. All of these algorithms take a user- + // supplied allocator, which is used for construction and destruction. // __uninitialized_copy_copy // Copies [first1, last1) into [result, result + (last1 - first1)), and @@ -228,23 +316,25 @@ namespace std // [result, result + (last1 - first1) + (last2 - first2)). template + typename _ForwardIterator, typename _Allocator> inline _ForwardIterator __uninitialized_copy_copy(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, - _ForwardIterator __result) + _ForwardIterator __result, + _Allocator __alloc) { - _ForwardIterator __mid = std::uninitialized_copy(__first1, __last1, - __result); + _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1, + __result, + __alloc); try { - return std::uninitialized_copy(__first2, __last2, __mid); + return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc); } catch(...) { - std::_Destroy(__result, __mid); + std::_Destroy(__result, __mid, __alloc); __throw_exception_again; } } @@ -252,20 +342,22 @@ namespace std // __uninitialized_fill_copy // Fills [result, mid) with x, and copies [first, last) into // [mid, mid + (last - first)). - template + template inline _ForwardIterator __uninitialized_fill_copy(_ForwardIterator __result, _ForwardIterator __mid, const _Tp& __x, _InputIterator __first, - _InputIterator __last) + _InputIterator __last, + _Allocator __alloc) { - std::uninitialized_fill(__result, __mid, __x); + std::__uninitialized_fill_a(__result, __mid, __x, __alloc); try { - return std::uninitialized_copy(__first, __last, __mid); + return std::__uninitialized_copy_a(__first, __last, __mid, __alloc); } catch(...) { - std::_Destroy(__result, __mid); + std::_Destroy(__result, __mid, __alloc); __throw_exception_again; } } @@ -273,25 +365,28 @@ namespace std // __uninitialized_copy_fill // Copies [first1, last1) into [first2, first2 + (last1 - first1)), and // fills [first2 + (last1 - first1), last2) with x. - template + template inline void __uninitialized_copy_fill(_InputIterator __first1, _InputIterator __last1, _ForwardIterator __first2, - _ForwardIterator __last2, const _Tp& __x) + _ForwardIterator __last2, const _Tp& __x, + _Allocator __alloc) { - _ForwardIterator __mid2 = std::uninitialized_copy(__first1, __last1, - __first2); + _ForwardIterator __mid2 = std::__uninitialized_copy_a(__first1, __last1, + __first2, + __alloc); try { - std::uninitialized_fill(__mid2, __last2, __x); + std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc); } catch(...) { - std::_Destroy(__first2, __mid2); + std::_Destroy(__first2, __mid2, __alloc); __throw_exception_again; } } -} // namespace std +_GLIBCXX_END_NAMESPACE #endif /* _STL_UNINITIALIZED_H */ diff --git a/contrib/libstdc++/include/bits/stl_vector.h b/contrib/libstdc++/include/bits/stl_vector.h index fee413d..a81c597 100644 --- a/contrib/libstdc++/include/bits/stl_vector.h +++ b/contrib/libstdc++/include/bits/stl_vector.h @@ -1,6 +1,7 @@ // Vector implementation -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -65,8 +66,8 @@ #include #include -namespace _GLIBCXX_STD -{ +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) + /** * @if maint * See bits/stl_deque.h's _Deque_base for an explanation. @@ -75,27 +76,40 @@ namespace _GLIBCXX_STD template struct _Vector_base { + typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type; + struct _Vector_impl - : public _Alloc { + : public _Tp_alloc_type + { _Tp* _M_start; _Tp* _M_finish; _Tp* _M_end_of_storage; - _Vector_impl (_Alloc const& __a) - : _Alloc(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0) + _Vector_impl(_Tp_alloc_type const& __a) + : _Tp_alloc_type(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0) { } }; public: typedef _Alloc allocator_type; + _Tp_alloc_type& + _M_get_Tp_allocator() + { return *static_cast<_Tp_alloc_type*>(&this->_M_impl); } + + const _Tp_alloc_type& + _M_get_Tp_allocator() const + { return *static_cast(&this->_M_impl); } + allocator_type - get_allocator() const { return *static_cast(&this->_M_impl); } + get_allocator() const + { return allocator_type(_M_get_Tp_allocator()); } - _Vector_base(const allocator_type& __a) : _M_impl(__a) + _Vector_base(const allocator_type& __a) + : _M_impl(__a) { } _Vector_base(size_t __n, const allocator_type& __a) - : _M_impl(__a) + : _M_impl(__a) { this->_M_impl._M_start = this->_M_allocate(__n); this->_M_impl._M_finish = this->_M_impl._M_start; @@ -103,18 +117,22 @@ namespace _GLIBCXX_STD } ~_Vector_base() - { _M_deallocate(this->_M_impl._M_start, - this->_M_impl._M_end_of_storage - this->_M_impl._M_start); } + { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); } public: _Vector_impl _M_impl; _Tp* - _M_allocate(size_t __n) { return _M_impl.allocate(__n); } + _M_allocate(size_t __n) + { return _M_impl.allocate(__n); } void _M_deallocate(_Tp* __p, size_t __n) - { if (__p) _M_impl.deallocate(__p, __n); } + { + if (__p) + _M_impl.deallocate(__p, __n); + } }; @@ -137,21 +155,24 @@ namespace _GLIBCXX_STD * memory and size allocation. Subscripting ( @c [] ) access is * also provided as with C-style arrays. */ - template > + template > class vector : protected _Vector_base<_Tp, _Alloc> { // Concept requirements. + typedef typename _Alloc::value_type _Alloc_value_type; __glibcxx_class_requires(_Tp, _SGIAssignableConcept) - - typedef _Vector_base<_Tp, _Alloc> _Base; - typedef vector<_Tp, _Alloc> vector_type; + __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) + + typedef _Vector_base<_Tp, _Alloc> _Base; + typedef vector<_Tp, _Alloc> vector_type; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; public: typedef _Tp value_type; - typedef typename _Alloc::pointer pointer; - typedef typename _Alloc::const_pointer const_pointer; - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; + typedef typename _Tp_alloc_type::pointer pointer; + typedef typename _Tp_alloc_type::const_pointer const_pointer; + typedef typename _Tp_alloc_type::reference reference; + typedef typename _Tp_alloc_type::const_reference const_reference; typedef __gnu_cxx::__normal_iterator iterator; typedef __gnu_cxx::__normal_iterator const_iterator; @@ -159,17 +180,13 @@ namespace _GLIBCXX_STD typedef std::reverse_iterator reverse_iterator; typedef size_t size_type; typedef ptrdiff_t difference_type; - typedef typename _Base::allocator_type allocator_type; + typedef _Alloc allocator_type; protected: - /** @if maint - * These two functions and three data members are all from the - * base class. They should be pretty self-explanatory, as - * %vector uses a simple contiguous allocation scheme. @endif - */ using _Base::_M_allocate; using _Base::_M_deallocate; using _Base::_M_impl; + using _Base::_M_get_Tp_allocator; public: // [23.2.4.1] construct/copy/destroy @@ -179,7 +196,8 @@ namespace _GLIBCXX_STD */ explicit vector(const allocator_type& __a = allocator_type()) - : _Base(__a) { } + : _Base(__a) + { } /** * @brief Create a %vector with copies of an exemplar element. @@ -188,24 +206,15 @@ namespace _GLIBCXX_STD * * This constructor fills the %vector with @a n copies of @a value. */ - vector(size_type __n, const value_type& __value, + explicit + vector(size_type __n, const value_type& __value = value_type(), const allocator_type& __a = allocator_type()) : _Base(__n, __a) - { this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start, - __n, __value); } - - /** - * @brief Create a %vector with default elements. - * @param n The number of elements to initially create. - * - * This constructor fills the %vector with @a n copies of a - * default-constructed element. - */ - explicit - vector(size_type __n) - : _Base(__n, allocator_type()) - { this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start, - __n, value_type()); } + { + std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = this->_M_impl._M_start + __n; + } /** * @brief %Vector copy constructor. @@ -217,9 +226,11 @@ namespace _GLIBCXX_STD * @a x (for fast expansion) will not be copied. */ vector(const vector& __x) - : _Base(__x.size(), __x.get_allocator()) - { this->_M_impl._M_finish = std::uninitialized_copy(__x.begin(), __x.end(), - this->_M_impl._M_start); + : _Base(__x.size(), __x._M_get_Tp_allocator()) + { this->_M_impl._M_finish = + std::__uninitialized_copy_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); } /** @@ -243,7 +254,7 @@ namespace _GLIBCXX_STD : _Base(__a) { // Check whether it's an integral type. If so, it's not an iterator. - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; + typedef typename std::__is_integer<_InputIterator>::__type _Integral; _M_initialize_dispatch(__first, __last, _Integral()); } @@ -253,7 +264,9 @@ namespace _GLIBCXX_STD * not touched in any way. Managing the pointer is the user's * responsibilty. */ - ~vector() { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); } + ~vector() + { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); } /** * @brief %Vector assignment operator. @@ -297,7 +310,7 @@ namespace _GLIBCXX_STD assign(_InputIterator __first, _InputIterator __last) { // Check whether it's an integral type. If so, it's not an iterator. - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; + typedef typename std::__is_integer<_InputIterator>::__type _Integral; _M_assign_dispatch(__first, __last, _Integral()); } @@ -311,7 +324,8 @@ namespace _GLIBCXX_STD * element order. */ iterator - begin() { return iterator (this->_M_impl._M_start); } + begin() + { return iterator(this->_M_impl._M_start); } /** * Returns a read-only (constant) iterator that points to the @@ -319,7 +333,8 @@ namespace _GLIBCXX_STD * element order. */ const_iterator - begin() const { return const_iterator (this->_M_impl._M_start); } + begin() const + { return const_iterator(this->_M_impl._M_start); } /** * Returns a read/write iterator that points one past the last @@ -327,7 +342,8 @@ namespace _GLIBCXX_STD * element order. */ iterator - end() { return iterator (this->_M_impl._M_finish); } + end() + { return iterator(this->_M_impl._M_finish); } /** * Returns a read-only (constant) iterator that points one past @@ -335,7 +351,8 @@ namespace _GLIBCXX_STD * ordinary element order. */ const_iterator - end() const { return const_iterator (this->_M_impl._M_finish); } + end() const + { return const_iterator(this->_M_impl._M_finish); } /** * Returns a read/write reverse iterator that points to the @@ -343,7 +360,8 @@ namespace _GLIBCXX_STD * element order. */ reverse_iterator - rbegin() { return reverse_iterator(end()); } + rbegin() + { return reverse_iterator(end()); } /** * Returns a read-only (constant) reverse iterator that points @@ -351,7 +369,8 @@ namespace _GLIBCXX_STD * reverse element order. */ const_reverse_iterator - rbegin() const { return const_reverse_iterator(end()); } + rbegin() const + { return const_reverse_iterator(end()); } /** * Returns a read/write reverse iterator that points to one @@ -359,7 +378,8 @@ namespace _GLIBCXX_STD * in reverse element order. */ reverse_iterator - rend() { return reverse_iterator(begin()); } + rend() + { return reverse_iterator(begin()); } /** * Returns a read-only (constant) reverse iterator that points @@ -367,16 +387,19 @@ namespace _GLIBCXX_STD * is done in reverse element order. */ const_reverse_iterator - rend() const { return const_reverse_iterator(begin()); } + rend() const + { return const_reverse_iterator(begin()); } // [23.2.4.2] capacity /** Returns the number of elements in the %vector. */ size_type - size() const { return size_type(end() - begin()); } + size() const + { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); } /** Returns the size() of the largest possible %vector. */ size_type - max_size() const { return size_type(-1) / sizeof(value_type); } + max_size() const + { return _M_get_Tp_allocator().max_size(); } /** * @brief Resizes the %vector to the specified number of elements. @@ -390,41 +413,30 @@ namespace _GLIBCXX_STD * given data. */ void - resize(size_type __new_size, const value_type& __x) + resize(size_type __new_size, value_type __x = value_type()) { if (__new_size < size()) - erase(begin() + __new_size, end()); + _M_erase_at_end(this->_M_impl._M_start + __new_size); else insert(end(), __new_size - size(), __x); } /** - * @brief Resizes the %vector to the specified number of elements. - * @param new_size Number of elements the %vector should contain. - * - * This function will resize the %vector to the specified - * number of elements. If the number is smaller than the - * %vector's current size the %vector is truncated, otherwise - * the %vector is extended and new elements are - * default-constructed. - */ - void - resize(size_type __new_size) { resize(__new_size, value_type()); } - - /** * Returns the total number of elements that the %vector can * hold before needing to allocate more memory. */ size_type capacity() const - { return size_type(const_iterator(this->_M_impl._M_end_of_storage) - begin()); } + { return size_type(this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); } /** * Returns true if the %vector is empty. (Thus begin() would * equal end().) */ bool - empty() const { return begin() == end(); } + empty() const + { return begin() == end(); } /** * @brief Attempt to preallocate enough memory for specified number of @@ -459,7 +471,8 @@ namespace _GLIBCXX_STD * see at().) */ reference - operator[](size_type __n) { return *(begin() + __n); } + operator[](size_type __n) + { return *(this->_M_impl._M_start + __n); } /** * @brief Subscript access to the data contained in the %vector. @@ -473,7 +486,8 @@ namespace _GLIBCXX_STD * see at().) */ const_reference - operator[](size_type __n) const { return *(begin() + __n); } + operator[](size_type __n) const + { return *(this->_M_impl._M_start + __n); } protected: /// @if maint Safety check used only from at(). @endif @@ -497,7 +511,11 @@ namespace _GLIBCXX_STD * function throws out_of_range if the check fails. */ reference - at(size_type __n) { _M_range_check(__n); return (*this)[__n]; } + at(size_type __n) + { + _M_range_check(__n); + return (*this)[__n]; + } /** * @brief Provides access to the data contained in the %vector. @@ -511,35 +529,58 @@ namespace _GLIBCXX_STD * function throws out_of_range if the check fails. */ const_reference - at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; } + at(size_type __n) const + { + _M_range_check(__n); + return (*this)[__n]; + } /** * Returns a read/write reference to the data at the first * element of the %vector. */ reference - front() { return *begin(); } + front() + { return *begin(); } /** * Returns a read-only (constant) reference to the data at the first * element of the %vector. */ const_reference - front() const { return *begin(); } + front() const + { return *begin(); } /** * Returns a read/write reference to the data at the last * element of the %vector. */ reference - back() { return *(end() - 1); } - + back() + { return *(end() - 1); } + /** * Returns a read-only (constant) reference to the data at the * last element of the %vector. */ const_reference - back() const { return *(end() - 1); } + back() const + { return *(end() - 1); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + // data access + /** + * Returns a pointer such that [data(), data() + size()) is a valid + * range. For a non-empty %vector, data() == &front(). + */ + pointer + data() + { return pointer(this->_M_impl._M_start); } + + const_pointer + data() const + { return const_pointer(this->_M_impl._M_start); } // [23.2.4.3] modifiers /** @@ -557,7 +598,7 @@ namespace _GLIBCXX_STD { if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) { - std::_Construct(this->_M_impl._M_finish, __x); + this->_M_impl.construct(this->_M_impl._M_finish, __x); ++this->_M_impl._M_finish; } else @@ -577,7 +618,7 @@ namespace _GLIBCXX_STD pop_back() { --this->_M_impl._M_finish; - std::_Destroy(this->_M_impl._M_finish); + this->_M_impl.destroy(this->_M_impl._M_finish); } /** @@ -631,7 +672,7 @@ namespace _GLIBCXX_STD _InputIterator __last) { // Check whether it's an integral type. If so, it's not an iterator. - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; + typedef typename std::__is_integer<_InputIterator>::__type _Integral; _M_insert_dispatch(__position, __first, __last, _Integral()); } @@ -688,7 +729,13 @@ namespace _GLIBCXX_STD { std::swap(this->_M_impl._M_start, __x._M_impl._M_start); std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); - std::swap(this->_M_impl._M_end_of_storage, __x._M_impl._M_end_of_storage); + std::swap(this->_M_impl._M_end_of_storage, + __x._M_impl._M_end_of_storage); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 431. Swapping containers with unequal allocators. + std::__alloc_swap<_Tp_alloc_type>::_S_do_it(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); } /** @@ -698,7 +745,8 @@ namespace _GLIBCXX_STD * the user's responsibilty. */ void - clear() { erase(begin(), end()); } + clear() + { _M_erase_at_end(this->_M_impl._M_start); } protected: /** @@ -715,7 +763,8 @@ namespace _GLIBCXX_STD pointer __result = this->_M_allocate(__n); try { - std::uninitialized_copy(__first, __last, __result); + std::__uninitialized_copy_a(__first, __last, __result, + _M_get_Tp_allocator()); return __result; } catch(...) @@ -735,8 +784,9 @@ namespace _GLIBCXX_STD { this->_M_impl._M_start = _M_allocate(__n); this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; - this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start, - __n, __value); + std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = this->_M_impl._M_end_of_storage; } // Called by the range constructor to implement [23.1.1]/9 @@ -745,8 +795,8 @@ namespace _GLIBCXX_STD _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, __false_type) { - typedef typename iterator_traits<_InputIterator>::iterator_category - _IterCategory; + typedef typename std::iterator_traits<_InputIterator>:: + iterator_category _IterCategory; _M_range_initialize(__first, __last, _IterCategory()); } @@ -754,9 +804,9 @@ namespace _GLIBCXX_STD template void _M_range_initialize(_InputIterator __first, - _InputIterator __last, input_iterator_tag) + _InputIterator __last, std::input_iterator_tag) { - for ( ; __first != __last; ++__first) + for (; __first != __last; ++__first) push_back(*__first); } @@ -764,13 +814,15 @@ namespace _GLIBCXX_STD template void _M_range_initialize(_ForwardIterator __first, - _ForwardIterator __last, forward_iterator_tag) + _ForwardIterator __last, std::forward_iterator_tag) { - size_type __n = std::distance(__first, __last); + const size_type __n = std::distance(__first, __last); this->_M_impl._M_start = this->_M_allocate(__n); this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; - this->_M_impl._M_finish = std::uninitialized_copy(__first, __last, - this->_M_impl._M_start); + this->_M_impl._M_finish = + std::__uninitialized_copy_a(__first, __last, + this->_M_impl._M_start, + _M_get_Tp_allocator()); } @@ -792,8 +844,8 @@ namespace _GLIBCXX_STD _M_assign_dispatch(_InputIterator __first, _InputIterator __last, __false_type) { - typedef typename iterator_traits<_InputIterator>::iterator_category - _IterCategory; + typedef typename std::iterator_traits<_InputIterator>:: + iterator_category _IterCategory; _M_assign_aux(__first, __last, _IterCategory()); } @@ -801,13 +853,13 @@ namespace _GLIBCXX_STD template void _M_assign_aux(_InputIterator __first, _InputIterator __last, - input_iterator_tag); + std::input_iterator_tag); // Called by the second assign_dispatch above template void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag); + std::forward_iterator_tag); // Called by assign(n,t), and the range assign when it turns out // to be the same thing. @@ -833,8 +885,8 @@ namespace _GLIBCXX_STD _M_insert_dispatch(iterator __pos, _InputIterator __first, _InputIterator __last, __false_type) { - typedef typename iterator_traits<_InputIterator>::iterator_category - _IterCategory; + typedef typename std::iterator_traits<_InputIterator>:: + iterator_category _IterCategory; _M_range_insert(__pos, __first, __last, _IterCategory()); } @@ -842,13 +894,13 @@ namespace _GLIBCXX_STD template void _M_range_insert(iterator __pos, _InputIterator __first, - _InputIterator __last, input_iterator_tag); + _InputIterator __last, std::input_iterator_tag); // Called by the second insert_dispatch above template void _M_range_insert(iterator __pos, _ForwardIterator __first, - _ForwardIterator __last, forward_iterator_tag); + _ForwardIterator __last, std::forward_iterator_tag); // Called by insert(p,n,x), and the range insert when it turns out to be // the same thing. @@ -858,6 +910,17 @@ namespace _GLIBCXX_STD // Called by insert(p,x) void _M_insert_aux(iterator __position, const value_type& __x); + + // Internal erase functions follow. + + // Called by erase(q1,q2), clear(), resize(), _M_fill_assign, + // _M_assign_aux. + void + _M_erase_at_end(pointer __pos) + { + std::_Destroy(__pos, this->_M_impl._M_finish, _M_get_Tp_allocator()); + this->_M_impl._M_finish = __pos; + } }; @@ -873,11 +936,9 @@ namespace _GLIBCXX_STD */ template inline bool - operator==(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y) - { - return __x.size() == __y.size() && - std::equal(__x.begin(), __x.end(), __y.begin()); - } + operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return (__x.size() == __y.size() + && std::equal(__x.begin(), __x.end(), __y.begin())); } /** * @brief Vector ordering relation. @@ -892,41 +953,40 @@ namespace _GLIBCXX_STD */ template inline bool - operator<(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y) - { - return std::lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); - } + operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); } /// Based on operator== template inline bool - operator!=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y) + operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return !(__x == __y); } /// Based on operator< template inline bool - operator>(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y) + operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return __y < __x; } /// Based on operator< template inline bool - operator<=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y) + operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return !(__y < __x); } /// Based on operator< template inline bool - operator>=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y) + operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return !(__x < __y); } /// See std::vector::swap(). template inline void - swap(vector<_Tp,_Alloc>& __x, vector<_Tp,_Alloc>& __y) + swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) { __x.swap(__y); } -} // namespace std + +_GLIBCXX_END_NESTED_NAMESPACE #endif /* _VECTOR_H */ diff --git a/contrib/libstdc++/include/bits/stream_iterator.h b/contrib/libstdc++/include/bits/stream_iterator.h index fa11bd6..ce3e675 100644 --- a/contrib/libstdc++/include/bits/stream_iterator.h +++ b/contrib/libstdc++/include/bits/stream_iterator.h @@ -1,6 +1,6 @@ // Stream iterators -// Copyright (C) 2001, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -39,8 +39,8 @@ #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /// Provides input iterator semantics for streams. template, typename _Dist = ptrdiff_t> @@ -60,7 +60,7 @@ namespace std public: /// Construct end of input stream iterator. istream_iterator() - : _M_stream(0), _M_ok(false) {} + : _M_stream(0), _M_value(), _M_ok(false) {} /// Construct start of input stream iterator. istream_iterator(istream_type& __s) @@ -210,5 +210,7 @@ namespace std operator++(int) { return *this; } }; -} // namespace std + +_GLIBCXX_END_NAMESPACE + #endif diff --git a/contrib/libstdc++/include/bits/streambuf.tcc b/contrib/libstdc++/include/bits/streambuf.tcc index 554d061..c4b8605 100644 --- a/contrib/libstdc++/include/bits/streambuf.tcc +++ b/contrib/libstdc++/include/bits/streambuf.tcc @@ -1,6 +1,6 @@ // Stream buffer classes -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,11 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file streambuf.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + // // ISO C++ 14882: 27.5 Stream buffers // @@ -37,8 +42,8 @@ #pragma GCC system_header -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template streamsize basic_streambuf<_CharT, _Traits>:: @@ -47,11 +52,11 @@ namespace std streamsize __ret = 0; while (__ret < __n) { - const size_t __buf_len = this->egptr() - this->gptr(); + const streamsize __buf_len = this->egptr() - this->gptr(); if (__buf_len) { - const size_t __remaining = __n - __ret; - const size_t __len = std::min(__buf_len, __remaining); + const streamsize __remaining = __n - __ret; + const streamsize __len = std::min(__buf_len, __remaining); traits_type::copy(__s, this->gptr(), __len); __ret += __len; __s += __len; @@ -81,11 +86,11 @@ namespace std streamsize __ret = 0; while (__ret < __n) { - const size_t __buf_len = this->epptr() - this->pptr(); + const streamsize __buf_len = this->epptr() - this->pptr(); if (__buf_len) { - const size_t __remaining = __n - __ret; - const size_t __len = std::min(__buf_len, __remaining); + const streamsize __remaining = __n - __ret; + const streamsize __len = std::min(__buf_len, __remaining); traits_type::copy(this->pptr(), __s, __len); __ret += __len; __s += __len; @@ -109,39 +114,39 @@ namespace std // Conceivably, this could be used to implement buffer-to-buffer // copies, if this was ever desired in an un-ambiguous way by the - // standard. If so, then checks for __ios being zero would be - // necessary. + // standard. template streamsize - __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin, - basic_streambuf<_CharT, _Traits>* __sbout) + __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>* __sbin, + basic_streambuf<_CharT, _Traits>* __sbout, + bool& __ineof) { streamsize __ret = 0; + __ineof = true; typename _Traits::int_type __c = __sbin->sgetc(); while (!_Traits::eq_int_type(__c, _Traits::eof())) { - const size_t __n = __sbin->egptr() - __sbin->gptr(); - if (__n > 1) - { - const size_t __wrote = __sbout->sputn(__sbin->gptr(), __n); - __sbin->gbump(__wrote); - __ret += __wrote; - if (__wrote < __n) - break; - __c = __sbin->underflow(); - } - else + __c = __sbout->sputc(_Traits::to_char_type(__c)); + if (_Traits::eq_int_type(__c, _Traits::eof())) { - __c = __sbout->sputc(_Traits::to_char_type(__c)); - if (_Traits::eq_int_type(__c, _Traits::eof())) - break; - ++__ret; - __c = __sbin->snextc(); + __ineof = false; + break; } + ++__ret; + __c = __sbin->snextc(); } return __ret; } + template + inline streamsize + __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin, + basic_streambuf<_CharT, _Traits>* __sbout) + { + bool __ineof; + return __copy_streambufs_eof(__sbin, __sbout, __ineof); + } + // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. @@ -149,15 +154,26 @@ namespace std extern template class basic_streambuf; extern template streamsize - __copy_streambufs(basic_streambuf*, basic_streambuf*); + __copy_streambufs(basic_streambuf*, + basic_streambuf*); + extern template + streamsize + __copy_streambufs_eof(basic_streambuf*, + basic_streambuf*, bool&); #ifdef _GLIBCXX_USE_WCHAR_T extern template class basic_streambuf; extern template streamsize - __copy_streambufs(basic_streambuf*, basic_streambuf*); + __copy_streambufs(basic_streambuf*, + basic_streambuf*); + extern template + streamsize + __copy_streambufs_eof(basic_streambuf*, + basic_streambuf*, bool&); #endif #endif -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/bits/streambuf_iterator.h b/contrib/libstdc++/include/bits/streambuf_iterator.h index 9709335..a1cf234 100644 --- a/contrib/libstdc++/include/bits/streambuf_iterator.h +++ b/contrib/libstdc++/include/bits/streambuf_iterator.h @@ -1,6 +1,6 @@ // Streambuf iterators -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -41,10 +41,8 @@ #include #include -// NB: Should specialize copy, find algorithms for streambuf iterators. - -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // 24.5.3 Template class istreambuf_iterator /// Provides input iterator semantics for streambufs. template @@ -63,6 +61,24 @@ namespace std typedef basic_istream<_CharT, _Traits> istream_type; //@} + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + ostreambuf_iterator<_CharT2> >::__type + copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, + ostreambuf_iterator<_CharT2>); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + _CharT2*>::__type + __copy_aux(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, + _CharT2*); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + istreambuf_iterator<_CharT2> >::__type + find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, + const _CharT2&); + private: // 24.5.3 istreambuf_iterator // p 1 @@ -72,7 +88,7 @@ namespace std // NB: This implementation assumes the "end of stream" value // is EOF, or -1. mutable streambuf_type* _M_sbuf; - int_type _M_c; + mutable int_type _M_c; public: /// Construct end of input stream iterator. @@ -110,11 +126,11 @@ namespace std __glibcxx_requires_cond(!_M_at_eof(), _M_message(__gnu_debug::__msg_inc_istreambuf) ._M_iterator(*this)); - const int_type __eof = traits_type::eof(); - if (_M_sbuf && traits_type::eq_int_type(_M_sbuf->sbumpc(), __eof)) - _M_sbuf = 0; - else - _M_c = __eof; + if (_M_sbuf) + { + _M_sbuf->sbumpc(); + _M_c = traits_type::eof(); + } return *this; } @@ -126,14 +142,12 @@ namespace std _M_message(__gnu_debug::__msg_inc_istreambuf) ._M_iterator(*this)); - const int_type __eof = traits_type::eof(); istreambuf_iterator __old = *this; - if (_M_sbuf - && traits_type::eq_int_type((__old._M_c = _M_sbuf->sbumpc()), - __eof)) - _M_sbuf = 0; - else - _M_c = __eof; + if (_M_sbuf) + { + __old._M_c = _M_sbuf->sbumpc(); + _M_c = traits_type::eof(); + } return __old; } @@ -159,8 +173,10 @@ namespace std { if (!traits_type::eq_int_type(_M_c, __eof)) __ret = _M_c; - else if (traits_type::eq_int_type((__ret = _M_sbuf->sgetc()), - __eof)) + else if (!traits_type::eq_int_type((__ret = _M_sbuf->sgetc()), + __eof)) + _M_c = __ret; + else _M_sbuf = 0; } return __ret; @@ -201,6 +217,12 @@ namespace std typedef basic_ostream<_CharT, _Traits> ostream_type; //@} + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + ostreambuf_iterator<_CharT2> >::__type + copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, + ostreambuf_iterator<_CharT2>); + private: streambuf_type* _M_sbuf; bool _M_failed; @@ -254,5 +276,125 @@ namespace std return *this; } }; -} // namespace std + + // Overloads for streambuf iterators. + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + copy(istreambuf_iterator<_CharT> __first, + istreambuf_iterator<_CharT> __last, + ostreambuf_iterator<_CharT> __result) + { + if (__first._M_sbuf && !__last._M_sbuf && !__result._M_failed) + { + bool __ineof; + __copy_streambufs_eof(__first._M_sbuf, __result._M_sbuf, __ineof); + if (!__ineof) + __result._M_failed = true; + } + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + __copy_aux(_CharT* __first, _CharT* __last, + ostreambuf_iterator<_CharT> __result) + { + const streamsize __num = __last - __first; + if (__num > 0) + __result._M_put(__first, __num); + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + __copy_aux(const _CharT* __first, const _CharT* __last, + ostreambuf_iterator<_CharT> __result) + { + const streamsize __num = __last - __first; + if (__num > 0) + __result._M_put(__first, __num); + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + _CharT*>::__type + __copy_aux(istreambuf_iterator<_CharT> __first, + istreambuf_iterator<_CharT> __last, _CharT* __result) + { + typedef istreambuf_iterator<_CharT> __is_iterator_type; + typedef typename __is_iterator_type::traits_type traits_type; + typedef typename __is_iterator_type::streambuf_type streambuf_type; + typedef typename traits_type::int_type int_type; + + if (__first._M_sbuf && !__last._M_sbuf) + { + streambuf_type* __sb = __first._M_sbuf; + int_type __c = __sb->sgetc(); + while (!traits_type::eq_int_type(__c, traits_type::eof())) + { + const streamsize __n = __sb->egptr() - __sb->gptr(); + if (__n > 1) + { + traits_type::copy(__result, __sb->gptr(), __n); + __sb->gbump(__n); + __result += __n; + __c = __sb->underflow(); + } + else + { + *__result++ = traits_type::to_char_type(__c); + __c = __sb->snextc(); + } + } + } + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + istreambuf_iterator<_CharT> >::__type + find(istreambuf_iterator<_CharT> __first, + istreambuf_iterator<_CharT> __last, const _CharT& __val) + { + typedef istreambuf_iterator<_CharT> __is_iterator_type; + typedef typename __is_iterator_type::traits_type traits_type; + typedef typename __is_iterator_type::streambuf_type streambuf_type; + typedef typename traits_type::int_type int_type; + + if (__first._M_sbuf && !__last._M_sbuf) + { + const int_type __ival = traits_type::to_int_type(__val); + streambuf_type* __sb = __first._M_sbuf; + int_type __c = __sb->sgetc(); + while (!traits_type::eq_int_type(__c, traits_type::eof()) + && !traits_type::eq_int_type(__c, __ival)) + { + streamsize __n = __sb->egptr() - __sb->gptr(); + if (__n > 1) + { + const _CharT* __p = traits_type::find(__sb->gptr(), + __n, __val); + if (__p) + __n = __p - __sb->gptr(); + __sb->gbump(__n); + __c = __sb->sgetc(); + } + else + __c = __sb->snextc(); + } + + if (!traits_type::eq_int_type(__c, traits_type::eof())) + __first._M_c = __c; + else + __first._M_sbuf = 0; + } + return __first; + } + +_GLIBCXX_END_NAMESPACE + #endif diff --git a/contrib/libstdc++/include/bits/stringfwd.h b/contrib/libstdc++/include/bits/stringfwd.h index 99d3ce3..d27ef14 100644 --- a/contrib/libstdc++/include/bits/stringfwd.h +++ b/contrib/libstdc++/include/bits/stringfwd.h @@ -1,6 +1,6 @@ // String support -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,15 +27,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 21 Strings library -// - /** @file stringfwd.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// +// ISO C++ 14882: 21 Strings library +// + #ifndef _STRINGFWD_H #define _STRINGFWD_H 1 @@ -43,8 +43,8 @@ #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template class allocator; @@ -64,6 +64,7 @@ namespace std typedef basic_string wstring; #endif -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif // _STRINGFWD_H diff --git a/contrib/libstdc++/include/bits/valarray_after.h b/contrib/libstdc++/include/bits/valarray_after.h index b74cab5..723df61 100644 --- a/contrib/libstdc++/include/bits/valarray_after.h +++ b/contrib/libstdc++/include/bits/valarray_after.h @@ -1,6 +1,7 @@ // The template and inlines for the -*- C++ -*- internal _Meta class. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,106 +28,136 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// Written by Gabriel Dos Reis - -/** @file valarray_meta.h +/** @file valarray_after.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// Written by Gabriel Dos Reis + #ifndef _VALARRAY_AFTER_H #define _VALARRAY_AFTER_H 1 #pragma GCC system_header -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) - // - // gslice_array closure. - // - template class _GBase { + // + // gslice_array closure. + // + template + class _GBase + { public: - typedef typename _Dom::value_type value_type; - - _GBase (const _Dom& __e, const valarray& __i) - : _M_expr (__e), _M_index(__i) {} - value_type operator[] (size_t __i) const - { return _M_expr[_M_index[__i]]; } - size_t size () const { return _M_index.size(); } + typedef typename _Dom::value_type value_type; + + _GBase (const _Dom& __e, const valarray& __i) + : _M_expr (__e), _M_index(__i) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_index[__i]]; } + + size_t + size () const + { return _M_index.size(); } private: - const _Dom& _M_expr; - const valarray& _M_index; + const _Dom& _M_expr; + const valarray& _M_index; }; - template class _GBase<_Array<_Tp> > { + template + class _GBase<_Array<_Tp> > + { public: - typedef _Tp value_type; - - _GBase (_Array<_Tp> __a, const valarray& __i) - : _M_array (__a), _M_index(__i) {} - value_type operator[] (size_t __i) const - { return _M_array._M_data[_M_index[__i]]; } - size_t size () const { return _M_index.size(); } + typedef _Tp value_type; + + _GBase (_Array<_Tp> __a, const valarray& __i) + : _M_array (__a), _M_index(__i) {} + + value_type + operator[] (size_t __i) const + { return _M_array._M_data[_M_index[__i]]; } + + size_t + size () const + { return _M_index.size(); } private: - const _Array<_Tp> _M_array; - const valarray& _M_index; + const _Array<_Tp> _M_array; + const valarray& _M_index; }; - template struct _GClos<_Expr,_Dom> : _GBase<_Dom> { - typedef _GBase<_Dom> _Base; - typedef typename _Base::value_type value_type; - - _GClos (const _Dom& __e, const valarray& __i) - : _Base (__e, __i) {} + template + struct _GClos<_Expr, _Dom> + : _GBase<_Dom> + { + typedef _GBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _GClos (const _Dom& __e, const valarray& __i) + : _Base (__e, __i) {} }; - template - struct _GClos<_ValArray,_Tp> : _GBase<_Array<_Tp> > { - typedef _GBase<_Array<_Tp> > _Base; - typedef typename _Base::value_type value_type; - - _GClos (_Array<_Tp> __a, const valarray& __i) - : _Base (__a, __i) {} + template + struct _GClos<_ValArray, _Tp> + : _GBase<_Array<_Tp> > + { + typedef _GBase<_Array<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _GClos (_Array<_Tp> __a, const valarray& __i) + : _Base (__a, __i) {} }; - // - // indirect_array closure - // - template class _IBase { + // + // indirect_array closure + // + template + class _IBase + { public: - typedef typename _Dom::value_type value_type; - - _IBase (const _Dom& __e, const valarray& __i) - : _M_expr (__e), _M_index (__i) {} - value_type operator[] (size_t __i) const - { return _M_expr[_M_index[__i]]; } - size_t size() const { return _M_index.size(); } + typedef typename _Dom::value_type value_type; + + _IBase (const _Dom& __e, const valarray& __i) + : _M_expr (__e), _M_index (__i) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_index[__i]]; } + + size_t + size() const + { return _M_index.size(); } private: - const _Dom& _M_expr; - const valarray& _M_index; + const _Dom& _M_expr; + const valarray& _M_index; }; - template struct _IClos<_Expr,_Dom> : _IBase<_Dom> { - typedef _IBase<_Dom> _Base; - typedef typename _Base::value_type value_type; - - _IClos (const _Dom& __e, const valarray& __i) - : _Base (__e, __i) {} + template + struct _IClos<_Expr, _Dom> + : _IBase<_Dom> + { + typedef _IBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _IClos (const _Dom& __e, const valarray& __i) + : _Base (__e, __i) {} }; - template - struct _IClos<_ValArray,_Tp> : _IBase > { - typedef _IBase > _Base; - typedef _Tp value_type; - - _IClos (const valarray<_Tp>& __a, const valarray& __i) - : _Base (__a, __i) {} + template + struct _IClos<_ValArray, _Tp> + : _IBase > + { + typedef _IBase > _Base; + typedef _Tp value_type; + + _IClos (const valarray<_Tp>& __a, const valarray& __i) + : _Base (__a, __i) {} }; - + // // class _Expr // @@ -146,17 +177,17 @@ namespace std valarray operator[](const valarray&) const; valarray operator[](const valarray&) const; - _Expr<_UnClos<__unary_plus,std::_Expr,_Clos>, value_type> - operator+() const; + _Expr<_UnClos<__unary_plus, std::_Expr, _Clos>, value_type> + operator+() const; - _Expr<_UnClos<__negate,std::_Expr,_Clos>, value_type> - operator-() const; + _Expr<_UnClos<__negate, std::_Expr, _Clos>, value_type> + operator-() const; - _Expr<_UnClos<__bitwise_not,std::_Expr,_Clos>, value_type> - operator~() const; + _Expr<_UnClos<__bitwise_not, std::_Expr, _Clos>, value_type> + operator~() const; - _Expr<_UnClos<__logical_not,std::_Expr,_Clos>, bool> - operator!() const; + _Expr<_UnClos<__logical_not, std::_Expr, _Clos>, bool> + operator!() const; size_t size() const; value_type sum() const; @@ -176,66 +207,91 @@ namespace std template inline - _Expr<_Clos,_Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {} + _Expr<_Clos, _Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {} template inline const _Clos& - _Expr<_Clos,_Tp>::operator()() const + _Expr<_Clos, _Tp>::operator()() const { return _M_closure; } template inline _Tp - _Expr<_Clos,_Tp>::operator[](size_t __i) const + _Expr<_Clos, _Tp>::operator[](size_t __i) const { return _M_closure[__i]; } template inline valarray<_Tp> - _Expr<_Clos,_Tp>::operator[](slice __s) const - { return _M_closure[__s]; } + _Expr<_Clos, _Tp>::operator[](slice __s) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__s]; + return __v; + } template inline valarray<_Tp> - _Expr<_Clos,_Tp>::operator[](const gslice& __gs) const - { return _M_closure[__gs]; } + _Expr<_Clos, _Tp>::operator[](const gslice& __gs) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__gs]; + return __v; + } template inline valarray<_Tp> - _Expr<_Clos,_Tp>::operator[](const valarray& __m) const - { return _M_closure[__m]; } + _Expr<_Clos, _Tp>::operator[](const valarray& __m) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__m]; + return __v; + } template inline valarray<_Tp> - _Expr<_Clos,_Tp>::operator[](const valarray& __i) const - { return _M_closure[__i]; } + _Expr<_Clos, _Tp>::operator[](const valarray& __i) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__i]; + return __v; + } template inline size_t - _Expr<_Clos,_Tp>::size() const { return _M_closure.size (); } + _Expr<_Clos, _Tp>::size() const + { return _M_closure.size(); } template inline valarray<_Tp> _Expr<_Clos, _Tp>::shift(int __n) const - { return valarray<_Tp>(_M_closure).shift(__n); } + { + valarray<_Tp> __v = valarray<_Tp>(*this).shift(__n); + return __v; + } template inline valarray<_Tp> _Expr<_Clos, _Tp>::cshift(int __n) const - { return valarray<_Tp>(_M_closure).cshift(__n); } + { + valarray<_Tp> __v = valarray<_Tp>(*this).cshift(__n); + return __v; + } template inline valarray<_Tp> _Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const - { return valarray<_Tp>(_M_closure).apply(__f); } + { + valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f); + return __v; + } template inline valarray<_Tp> _Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const - { return valarray<_Tp>(_M_closure).apply(__f); } + { + valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f); + return __v; + } // XXX: replace this with a more robust summation algorithm. template inline _Tp - _Expr<_Clos,_Tp>::sum() const + _Expr<_Clos, _Tp>::sum() const { size_t __n = _M_closure.size(); if (__n == 0) @@ -260,20 +316,20 @@ namespace std { return __valarray_max(_M_closure); } template - inline _Expr<_UnClos<__logical_not,_Expr,_Dom>, bool> - _Expr<_Dom,_Tp>::operator!() const + inline _Expr<_UnClos<__logical_not, _Expr, _Dom>, bool> + _Expr<_Dom, _Tp>::operator!() const { - typedef _UnClos<__logical_not,std::_Expr,_Dom> _Closure; - return _Expr<_Closure,_Tp>(_Closure(this->_M_closure)); + typedef _UnClos<__logical_not, std::_Expr, _Dom> _Closure; + return _Expr<_Closure, _Tp>(_Closure(this->_M_closure)); } #define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \ template \ - inline _Expr<_UnClos<_Name,std::_Expr,_Dom>,_Tp> \ - _Expr<_Dom,_Tp>::operator _Op() const \ + inline _Expr<_UnClos<_Name, std::_Expr, _Dom>, _Tp> \ + _Expr<_Dom, _Tp>::operator _Op() const \ { \ - typedef _UnClos<_Name,std::_Expr,_Dom> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(this->_M_closure)); \ + typedef _UnClos<_Name, std::_Expr, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(this->_M_closure)); \ } _DEFINE_EXPR_UNARY_OPERATOR(+, __unary_plus) @@ -282,67 +338,70 @@ namespace std #undef _DEFINE_EXPR_UNARY_OPERATOR - #define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \ template \ - inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, \ - typename __fun<_Name, typename _Dom1::value_type>::result_type>\ - operator _Op(const _Expr<_Dom1,typename _Dom1::value_type>& __v, \ - const _Expr<_Dom2,typename _Dom2::value_type>& __w) \ - { \ - typedef typename _Dom1::value_type _Arg; \ - typedef typename __fun<_Name, _Arg>::result_type _Value; \ - typedef _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \ - return _Expr<_Closure,_Value>(_Closure(__v(), __w())); \ - } \ + inline _Expr<_BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2>, \ + typename __fun<_Name, typename _Dom1::value_type>::result_type> \ + operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v, \ + const _Expr<_Dom2, typename _Dom2::value_type>& __w) \ + { \ + typedef typename _Dom1::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v(), __w())); \ + } \ \ -template \ -inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>,\ - typename __fun<_Name, typename _Dom::value_type>::result_type>\ -operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __v, \ - const typename _Dom::value_type& __t) \ -{ \ - typedef typename _Dom::value_type _Arg; \ - typedef typename __fun<_Name, _Arg>::result_type _Value; \ - typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \ - return _Expr<_Closure,_Value>(_Closure(__v(), __t)); \ -} \ + template \ + inline _Expr<_BinClos<_Name, _Expr, _Constant, _Dom, \ + typename _Dom::value_type>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v, \ + const typename _Dom::value_type& __t) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _Constant, _Dom, _Arg> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v(), __t)); \ + } \ \ -template \ -inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>,\ - typename __fun<_Name, typename _Dom::value_type>::result_type>\ -operator _Op(const typename _Dom::value_type& __t, \ - const _Expr<_Dom,typename _Dom::value_type>& __v) \ -{ \ - typedef typename _Dom::value_type _Arg; \ - typedef typename __fun<_Name, _Arg>::result_type _Value; \ - typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \ - return _Expr<_Closure,_Value>(_Closure(__t, __v())); \ -} \ + template \ + inline _Expr<_BinClos<_Name, _Constant, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const typename _Dom::value_type& __t, \ + const _Expr<_Dom, typename _Dom::value_type>& __v) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Constant, _Expr, _Arg, _Dom> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__t, __v())); \ + } \ \ -template \ -inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>,\ - typename __fun<_Name, typename _Dom::value_type>::result_type>\ -operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e, \ - const valarray& __v) \ -{ \ - typedef typename _Dom::value_type _Arg; \ - typedef typename __fun<_Name, _Arg>::result_type _Value; \ - typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Arg> _Closure; \ - return _Expr<_Closure,_Value>(_Closure(__e(), __v)); \ -} \ + template \ + inline _Expr<_BinClos<_Name, _Expr, _ValArray, \ + _Dom, typename _Dom::value_type>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e, \ + const valarray& __v) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _ValArray, _Dom, _Arg> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__e(), __v)); \ + } \ \ -template \ -inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>,\ - typename __fun<_Name, typename _Dom::value_type>::result_type>\ -operator _Op(const valarray& __v, \ - const _Expr<_Dom,typename _Dom::value_type>& __e) \ -{ \ - typedef typename _Dom::value_type _Tp; \ - typedef typename __fun<_Name, _Tp>::result_type _Value; \ - typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \ - return _Expr<_Closure,_Value> (_Closure (__v, __e ())); \ -} + template \ + inline _Expr<_BinClos<_Name, _ValArray, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const valarray& __v, \ + const _Expr<_Dom, typename _Dom::value_type>& __e) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef typename __fun<_Name, _Tp>::result_type _Value; \ + typedef _BinClos<_Name, _ValArray, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v, __e ())); \ + } _DEFINE_EXPR_BINARY_OPERATOR(+, __plus) _DEFINE_EXPR_BINARY_OPERATOR(-, __minus) @@ -367,20 +426,21 @@ operator _Op(const valarray& __v, \ #define _DEFINE_EXPR_UNARY_FUNCTION(_Name) \ template \ - inline _Expr<_UnClos<__##_Name,_Expr,_Dom>,typename _Dom::value_type>\ - _Name(const _Expr<_Dom,typename _Dom::value_type>& __e) \ + inline _Expr<_UnClos<__##_Name, _Expr, _Dom>, \ + typename _Dom::value_type> \ + _Name(const _Expr<_Dom, typename _Dom::value_type>& __e) \ { \ typedef typename _Dom::value_type _Tp; \ - typedef _UnClos<__##_Name,_Expr,_Dom> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__e())); \ + typedef _UnClos<__##_Name, _Expr, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e())); \ } \ \ template \ - inline _Expr<_UnClos<__##_Name,_ValArray,_Tp>,_Tp> \ + inline _Expr<_UnClos<__##_Name, _ValArray, _Tp>, _Tp> \ _Name(const valarray<_Tp>& __v) \ { \ - typedef _UnClos<__##_Name,_ValArray,_Tp> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__v)); \ + typedef _UnClos<__##_Name, _ValArray, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v)); \ } _DEFINE_EXPR_UNARY_FUNCTION(abs) @@ -402,86 +462,86 @@ operator _Op(const valarray& __v, \ #define _DEFINE_EXPR_BINARY_FUNCTION(_Fun) \ template \ - inline _Expr<_BinClos<__##_Fun,_Expr,_Expr,_Dom1,_Dom2>, \ + inline _Expr<_BinClos<__##_Fun, _Expr, _Expr, _Dom1, _Dom2>, \ typename _Dom1::value_type> \ - _Fun(const _Expr<_Dom1,typename _Dom1::value_type>& __e1, \ - const _Expr<_Dom2,typename _Dom2::value_type>& __e2) \ + _Fun(const _Expr<_Dom1, typename _Dom1::value_type>& __e1, \ + const _Expr<_Dom2, typename _Dom2::value_type>& __e2) \ { \ typedef typename _Dom1::value_type _Tp; \ - typedef _BinClos<__##_Fun,_Expr,_Expr,_Dom1,_Dom2> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__e1(), __e2())); \ + typedef _BinClos<__##_Fun, _Expr, _Expr, _Dom1, _Dom2> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e1(), __e2())); \ } \ \ template \ inline _Expr<_BinClos<__##_Fun, _Expr, _ValArray, _Dom, \ typename _Dom::value_type>, \ typename _Dom::value_type> \ - _Fun(const _Expr<_Dom,typename _Dom::value_type>& __e, \ + _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \ const valarray& __v) \ { \ typedef typename _Dom::value_type _Tp; \ - typedef _BinClos<__##_Fun, _Expr, _ValArray, _Dom, _Tp> _Closure;\ - return _Expr<_Closure,_Tp>(_Closure(__e(), __v)); \ + typedef _BinClos<__##_Fun, _Expr, _ValArray, _Dom, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e(), __v)); \ } \ \ template \ inline _Expr<_BinClos<__##_Fun, _ValArray, _Expr, \ - typename _Dom::value_type,_Dom>, \ + typename _Dom::value_type, _Dom>, \ typename _Dom::value_type> \ _Fun(const valarray& __v, \ - const _Expr<_Dom,typename _Dom::value_type>& __e) \ + const _Expr<_Dom, typename _Dom::value_type>& __e) \ { \ typedef typename _Dom::value_type _Tp; \ - typedef _BinClos<__##_Fun,_ValArray,_Expr,_Tp,_Dom> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__v, __e())); \ + typedef _BinClos<__##_Fun, _ValArray, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v, __e())); \ } \ \ template \ - inline _Expr<_BinClos<__##_Fun,_Expr,_Constant,_Dom, \ + inline _Expr<_BinClos<__##_Fun, _Expr, _Constant, _Dom, \ typename _Dom::value_type>, \ typename _Dom::value_type> \ _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \ const typename _Dom::value_type& __t) \ { \ typedef typename _Dom::value_type _Tp; \ - typedef _BinClos<__##_Fun,_Expr,_Constant,_Dom,_Tp> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__e(), __t)); \ + typedef _BinClos<__##_Fun, _Expr, _Constant, _Dom, _Tp> _Closure;\ + return _Expr<_Closure, _Tp>(_Closure(__e(), __t)); \ } \ \ template \ - inline _Expr<_BinClos<__##_Fun,_Constant,_Expr, \ - typename _Dom::value_type,_Dom>, \ + inline _Expr<_BinClos<__##_Fun, _Constant, _Expr, \ + typename _Dom::value_type, _Dom>, \ typename _Dom::value_type> \ _Fun(const typename _Dom::value_type& __t, \ - const _Expr<_Dom,typename _Dom::value_type>& __e) \ + const _Expr<_Dom, typename _Dom::value_type>& __e) \ { \ typedef typename _Dom::value_type _Tp; \ - typedef _BinClos<__##_Fun, _Constant,_Expr,_Tp,_Dom> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__t, __e())); \ + typedef _BinClos<__##_Fun, _Constant, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__t, __e())); \ } \ \ template \ - inline _Expr<_BinClos<__##_Fun,_ValArray,_ValArray,_Tp,_Tp>, _Tp> \ + inline _Expr<_BinClos<__##_Fun, _ValArray, _ValArray, _Tp, _Tp>, _Tp> \ _Fun(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \ { \ - typedef _BinClos<__##_Fun,_ValArray,_ValArray,_Tp,_Tp> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__v, __w)); \ + typedef _BinClos<__##_Fun, _ValArray, _ValArray, _Tp, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v, __w)); \ } \ \ template \ - inline _Expr<_BinClos<__##_Fun,_ValArray,_Constant,_Tp,_Tp>,_Tp> \ + inline _Expr<_BinClos<__##_Fun, _ValArray, _Constant, _Tp, _Tp>, _Tp> \ _Fun(const valarray<_Tp>& __v, const _Tp& __t) \ { \ - typedef _BinClos<__##_Fun,_ValArray,_Constant,_Tp,_Tp> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__v, __t)); \ + typedef _BinClos<__##_Fun, _ValArray, _Constant, _Tp, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v, __t)); \ } \ \ template \ - inline _Expr<_BinClos<__##_Fun,_Constant,_ValArray,_Tp,_Tp>,_Tp> \ + inline _Expr<_BinClos<__##_Fun, _Constant, _ValArray, _Tp, _Tp>, _Tp> \ _Fun(const _Tp& __t, const valarray<_Tp>& __v) \ { \ - typedef _BinClos<__##_Fun,_Constant,_ValArray,_Tp,_Tp> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__t, __v)); \ + typedef _BinClos<__##_Fun, _Constant, _ValArray, _Tp, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \ } _DEFINE_EXPR_BINARY_FUNCTION(atan2) @@ -489,11 +549,6 @@ _DEFINE_EXPR_BINARY_FUNCTION(pow) #undef _DEFINE_EXPR_BINARY_FUNCTION -} // std:: - +_GLIBCXX_END_NAMESPACE #endif /* _CPP_VALARRAY_AFTER_H */ - -// Local Variables: -// mode:c++ -// End: diff --git a/contrib/libstdc++/include/bits/valarray_array.h b/contrib/libstdc++/include/bits/valarray_array.h index e18e8e8..a40c880 100644 --- a/contrib/libstdc++/include/bits/valarray_array.h +++ b/contrib/libstdc++/include/bits/valarray_array.h @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- internal _Array helper class. -// Copyright (C) 1997, 1998, 1999, 2000, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,13 +28,13 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// Written by Gabriel Dos Reis - /** @file valarray_array.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// Written by Gabriel Dos Reis + #ifndef _VALARRAY_ARRAY_H #define _VALARRAY_ARRAY_H 1 @@ -46,8 +46,8 @@ #include #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // // Helper functions on raw pointers // @@ -58,12 +58,12 @@ namespace std { return operator new(__n); } template - inline _Tp*__restrict__ - __valarray_get_storage(size_t __n) - { - return static_cast<_Tp*__restrict__> - (std::__valarray_get_memory(__n * sizeof(_Tp))); - } + inline _Tp*__restrict__ + __valarray_get_storage(size_t __n) + { + return static_cast<_Tp*__restrict__> + (std::__valarray_get_memory(__n * sizeof(_Tp))); + } // Return memory to the system inline void @@ -73,230 +73,275 @@ namespace std // Turn a raw-memory into an array of _Tp filled with _Tp() // This is required in 'valarray v(n);' template - struct _Array_default_ctor - { - // Please note that this isn't exception safe. But - // valarrays aren't required to be exception safe. - inline static void - _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e) - { while (__b != __e) new(__b++) _Tp(); } - }; - - template - struct _Array_default_ctor<_Tp, true> - { - // For fundamental types, it suffices to say 'memset()' - inline static void - _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e) - { std::memset(__b, 0, (__e - __b)*sizeof(_Tp)); } - }; - - template - inline void - __valarray_default_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e) - { - _Array_default_ctor<_Tp, __is_fundamental<_Tp>::_M_type>:: - _S_do_it(__b, __e); - } + struct _Array_default_ctor + { + // Please note that this isn't exception safe. But + // valarrays aren't required to be exception safe. + inline static void + _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e) + { + while (__b != __e) + new(__b++) _Tp(); + } + }; + + template + struct _Array_default_ctor<_Tp, true> + { + // For fundamental types, it suffices to say 'memset()' + inline static void + _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e) + { std::memset(__b, 0, (__e - __b) * sizeof(_Tp)); } + }; + + template + inline void + __valarray_default_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e) + { + _Array_default_ctor<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__b, __e); + } // Turn a raw-memory into an array of _Tp filled with __t // This is the required in valarray v(n, t). Also // used in valarray<>::resize(). template - struct _Array_init_ctor - { - // Please note that this isn't exception safe. But - // valarrays aren't required to be exception safe. - inline static void - _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t) - { while (__b != __e) new(__b++) _Tp(__t); } - }; - - template - struct _Array_init_ctor<_Tp, true> - { - inline static void - _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t) - { while (__b != __e) *__b++ = __t; } - }; - - template - inline void - __valarray_fill_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e, - const _Tp __t) - { - _Array_init_ctor<_Tp, __is_fundamental<_Tp>::_M_type>:: - _S_do_it(__b, __e, __t); - } + struct _Array_init_ctor + { + // Please note that this isn't exception safe. But + // valarrays aren't required to be exception safe. + inline static void + _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t) + { + while (__b != __e) + new(__b++) _Tp(__t); + } + }; + + template + struct _Array_init_ctor<_Tp, true> + { + inline static void + _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t) + { + while (__b != __e) + *__b++ = __t; + } + }; + + template + inline void + __valarray_fill_construct(_Tp* __restrict__ __b, _Tp* __restrict__ __e, + const _Tp __t) + { + _Array_init_ctor<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__b, __e, __t); + } // // copy-construct raw array [__o, *) from plain array [__b, __e) // We can't just say 'memcpy()' // template - struct _Array_copy_ctor - { - // Please note that this isn't exception safe. But - // valarrays aren't required to be exception safe. - inline static void - _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e, - _Tp* __restrict__ __o) - { while (__b != __e) new(__o++) _Tp(*__b++); } - }; - - template - struct _Array_copy_ctor<_Tp, true> - { - inline static void - _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e, - _Tp* __restrict__ __o) - { std::memcpy(__o, __b, (__e - __b)*sizeof(_Tp)); } - }; - - template - inline void - __valarray_copy_construct(const _Tp* __restrict__ __b, - const _Tp* __restrict__ __e, - _Tp* __restrict__ __o) - { - _Array_copy_ctor<_Tp, __is_fundamental<_Tp>::_M_type>:: - _S_do_it(__b, __e, __o); - } + struct _Array_copy_ctor + { + // Please note that this isn't exception safe. But + // valarrays aren't required to be exception safe. + inline static void + _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e, + _Tp* __restrict__ __o) + { + while (__b != __e) + new(__o++) _Tp(*__b++); + } + }; + + template + struct _Array_copy_ctor<_Tp, true> + { + inline static void + _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e, + _Tp* __restrict__ __o) + { std::memcpy(__o, __b, (__e - __b)*sizeof(_Tp)); } + }; + + template + inline void + __valarray_copy_construct(const _Tp* __restrict__ __b, + const _Tp* __restrict__ __e, + _Tp* __restrict__ __o) + { + _Array_copy_ctor<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__b, __e, __o); + } // copy-construct raw array [__o, *) from strided array __a[<__n : __s>] template - inline void - __valarray_copy_construct (const _Tp* __restrict__ __a, size_t __n, - size_t __s, _Tp* __restrict__ __o) - { - if (__is_fundamental<_Tp>::_M_type) - while (__n--) { *__o++ = *__a; __a += __s; } - else - while (__n--) { new(__o++) _Tp(*__a); __a += __s; } - } + inline void + __valarray_copy_construct (const _Tp* __restrict__ __a, size_t __n, + size_t __s, _Tp* __restrict__ __o) + { + if (__is_pod<_Tp>::__value) + while (__n--) + { + *__o++ = *__a; + __a += __s; + } + else + while (__n--) + { + new(__o++) _Tp(*__a); + __a += __s; + } + } // copy-construct raw array [__o, *) from indexed array __a[__i[<__n>]] template - inline void - __valarray_copy_construct (const _Tp* __restrict__ __a, - const size_t* __restrict__ __i, - _Tp* __restrict__ __o, size_t __n) - { - if (__is_fundamental<_Tp>::_M_type) - while (__n--) *__o++ = __a[*__i++]; - else - while (__n--) new (__o++) _Tp(__a[*__i++]); - } + inline void + __valarray_copy_construct (const _Tp* __restrict__ __a, + const size_t* __restrict__ __i, + _Tp* __restrict__ __o, size_t __n) + { + if (__is_pod<_Tp>::__value) + while (__n--) + *__o++ = __a[*__i++]; + else + while (__n--) + new (__o++) _Tp(__a[*__i++]); + } // Do the necessary cleanup when we're done with arrays. template - inline void - __valarray_destroy_elements(_Tp* __restrict__ __b, _Tp* __restrict__ __e) - { - if (!__is_fundamental<_Tp>::_M_type) - while (__b != __e) { __b->~_Tp(); ++__b; } - } + inline void + __valarray_destroy_elements(_Tp* __restrict__ __b, _Tp* __restrict__ __e) + { + if (!__is_pod<_Tp>::__value) + while (__b != __e) + { + __b->~_Tp(); + ++__b; + } + } // Fill a plain array __a[<__n>] with __t template - inline void - __valarray_fill (_Tp* __restrict__ __a, size_t __n, const _Tp& __t) - { while (__n--) *__a++ = __t; } - + inline void + __valarray_fill(_Tp* __restrict__ __a, size_t __n, const _Tp& __t) + { + while (__n--) + *__a++ = __t; + } + // fill strided array __a[<__n-1 : __s>] with __t template - inline void - __valarray_fill (_Tp* __restrict__ __a, size_t __n, - size_t __s, const _Tp& __t) - { for (size_t __i=0; __i<__n; ++__i, __a+=__s) *__a = __t; } + inline void + __valarray_fill(_Tp* __restrict__ __a, size_t __n, + size_t __s, const _Tp& __t) + { + for (size_t __i = 0; __i < __n; ++__i, __a += __s) + *__a = __t; + } // fill indir ect array __a[__i[<__n>]] with __i template - inline void - __valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i, - size_t __n, const _Tp& __t) - { for (size_t __j=0; __j<__n; ++__j, ++__i) __a[*__i] = __t; } - + inline void + __valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i, + size_t __n, const _Tp& __t) + { + for (size_t __j = 0; __j < __n; ++__j, ++__i) + __a[*__i] = __t; + } + // copy plain array __a[<__n>] in __b[<__n>] // For non-fundamental types, it is wrong to say 'memcpy()' template - struct _Array_copier - { - inline static void - _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) - { while (__n--) *__b++ = *__a++; } - }; - - template - struct _Array_copier<_Tp, true> - { - inline static void - _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) - { std::memcpy (__b, __a, __n * sizeof (_Tp)); } - }; + struct _Array_copier + { + inline static void + _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) + { + while(__n--) + *__b++ = *__a++; + } + }; + + template + struct _Array_copier<_Tp, true> + { + inline static void + _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) + { std::memcpy (__b, __a, __n * sizeof (_Tp)); } + }; // Copy a plain array __a[<__n>] into a play array __b[<>] template - inline void - __valarray_copy(const _Tp* __restrict__ __a, size_t __n, - _Tp* __restrict__ __b) - { - _Array_copier<_Tp, __is_fundamental<_Tp>::_M_type>:: - _S_do_it(__a, __n, __b); - } + inline void + __valarray_copy(const _Tp* __restrict__ __a, size_t __n, + _Tp* __restrict__ __b) + { + _Array_copier<_Tp, __is_pod<_Tp>::__value>::_S_do_it(__a, __n, __b); + } // Copy strided array __a[<__n : __s>] in plain __b[<__n>] template - inline void - __valarray_copy(const _Tp* __restrict__ __a, size_t __n, size_t __s, - _Tp* __restrict__ __b) - { for (size_t __i=0; __i<__n; ++__i, ++__b, __a += __s) *__b = *__a; } + inline void + __valarray_copy(const _Tp* __restrict__ __a, size_t __n, size_t __s, + _Tp* __restrict__ __b) + { + for (size_t __i = 0; __i < __n; ++__i, ++__b, __a += __s) + *__b = *__a; + } // Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>] template - inline void - __valarray_copy(const _Tp* __restrict__ __a, _Tp* __restrict__ __b, - size_t __n, size_t __s) - { for (size_t __i=0; __i<__n; ++__i, ++__a, __b+=__s) *__b = *__a; } + inline void + __valarray_copy(const _Tp* __restrict__ __a, _Tp* __restrict__ __b, + size_t __n, size_t __s) + { + for (size_t __i = 0; __i < __n; ++__i, ++__a, __b += __s) + *__b = *__a; + } // Copy strided array __src[<__n : __s1>] into another // strided array __dst[< : __s2>]. Their sizes must match. template - inline void - __valarray_copy(const _Tp* __restrict__ __src, size_t __n, size_t __s1, - _Tp* __restrict__ __dst, size_t __s2) - { - for (size_t __i = 0; __i < __n; ++__i) - __dst[__i * __s2] = __src [ __i * __s1]; - } - + inline void + __valarray_copy(const _Tp* __restrict__ __src, size_t __n, size_t __s1, + _Tp* __restrict__ __dst, size_t __s2) + { + for (size_t __i = 0; __i < __n; ++__i) + __dst[__i * __s2] = __src[__i * __s1]; + } // Copy an indexed array __a[__i[<__n>]] in plain array __b[<__n>] template - inline void - __valarray_copy (const _Tp* __restrict__ __a, - const size_t* __restrict__ __i, - _Tp* __restrict__ __b, size_t __n) - { for (size_t __j=0; __j<__n; ++__j, ++__b, ++__i) *__b = __a[*__i]; } + inline void + __valarray_copy(const _Tp* __restrict__ __a, + const size_t* __restrict__ __i, + _Tp* __restrict__ __b, size_t __n) + { + for (size_t __j = 0; __j < __n; ++__j, ++__b, ++__i) + *__b = __a[*__i]; + } // Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]] template - inline void - __valarray_copy (const _Tp* __restrict__ __a, size_t __n, - _Tp* __restrict__ __b, const size_t* __restrict__ __i) - { for (size_t __j=0; __j<__n; ++__j, ++__a, ++__i) __b[*__i] = *__a; } + inline void + __valarray_copy(const _Tp* __restrict__ __a, size_t __n, + _Tp* __restrict__ __b, const size_t* __restrict__ __i) + { + for (size_t __j = 0; __j < __n; ++__j, ++__a, ++__i) + __b[*__i] = *__a; + } // Copy the __n first elements of an indexed array __src[<__i>] into // another indexed array __dst[<__j>]. template - inline void - __valarray_copy(const _Tp* __restrict__ __src, size_t __n, - const size_t* __restrict__ __i, - _Tp* __restrict__ __dst, const size_t* __restrict__ __j) - { - for (size_t __k = 0; __k < __n; ++__k) - __dst[*__j++] = __src[*__i++]; - } + inline void + __valarray_copy(const _Tp* __restrict__ __src, size_t __n, + const size_t* __restrict__ __i, + _Tp* __restrict__ __dst, const size_t* __restrict__ __j) + { + for (size_t __k = 0; __k < __n; ++__k) + __dst[*__j++] = __src[*__i++]; + } // // Compute the sum of elements in range [__f, __l) @@ -306,57 +351,59 @@ namespace std // algorithm. // template - inline _Tp - __valarray_sum(const _Tp* __restrict__ __f, const _Tp* __restrict__ __l) - { - _Tp __r = _Tp(); - while (__f != __l) __r += *__f++; - return __r; - } + inline _Tp + __valarray_sum(const _Tp* __restrict__ __f, const _Tp* __restrict__ __l) + { + _Tp __r = _Tp(); + while (__f != __l) + __r += *__f++; + return __r; + } // Compute the product of all elements in range [__f, __l) template - inline _Tp - __valarray_product(const _Tp* __restrict__ __f, - const _Tp* __restrict__ __l) - { - _Tp __r = _Tp(1); - while (__f != __l) __r = __r * *__f++; - return __r; - } + inline _Tp + __valarray_product(const _Tp* __restrict__ __f, + const _Tp* __restrict__ __l) + { + _Tp __r = _Tp(1); + while (__f != __l) + __r = __r * *__f++; + return __r; + } // Compute the min/max of an array-expression template - inline typename _Ta::value_type - __valarray_min(const _Ta& __a) - { - size_t __s = __a.size(); - typedef typename _Ta::value_type _Value_type; - _Value_type __r = __s == 0 ? _Value_type() : __a[0]; - for (size_t __i = 1; __i < __s; ++__i) - { - _Value_type __t = __a[__i]; - if (__t < __r) - __r = __t; - } - return __r; - } + inline typename _Ta::value_type + __valarray_min(const _Ta& __a) + { + size_t __s = __a.size(); + typedef typename _Ta::value_type _Value_type; + _Value_type __r = __s == 0 ? _Value_type() : __a[0]; + for (size_t __i = 1; __i < __s; ++__i) + { + _Value_type __t = __a[__i]; + if (__t < __r) + __r = __t; + } + return __r; + } template - inline typename _Ta::value_type - __valarray_max(const _Ta& __a) - { - size_t __s = __a.size(); - typedef typename _Ta::value_type _Value_type; - _Value_type __r = __s == 0 ? _Value_type() : __a[0]; - for (size_t __i = 1; __i < __s; ++__i) - { - _Value_type __t = __a[__i]; - if (__t > __r) - __r = __t; - } - return __r; - } + inline typename _Ta::value_type + __valarray_max(const _Ta& __a) + { + size_t __s = __a.size(); + typedef typename _Ta::value_type _Value_type; + _Value_type __r = __s == 0 ? _Value_type() : __a[0]; + for (size_t __i = 1; __i < __s; ++__i) + { + _Value_type __t = __a[__i]; + if (__t > __r) + __r = __t; + } + return __r; + } // // Helper class _Array, first layer of valarray abstraction. @@ -365,244 +412,275 @@ namespace std // template - struct _Array - { - explicit _Array (size_t); - explicit _Array (_Tp* const __restrict__); - explicit _Array (const valarray<_Tp>&); - _Array (const _Tp* __restrict__, size_t); + struct _Array + { + explicit _Array(size_t); + explicit _Array(_Tp* const __restrict__); + explicit _Array(const valarray<_Tp>&); + _Array(const _Tp* __restrict__, size_t); + + _Tp* begin() const; + + _Tp* const __restrict__ _M_data; + }; - _Tp* begin () const; - _Tp* const __restrict__ _M_data; - }; + // Copy-construct plain array __b[<__n>] from indexed array __a[__i[<__n>]] + template + inline void + __valarray_copy_construct(_Array<_Tp> __a, _Array __i, + _Array<_Tp> __b, size_t __n) + { std::__valarray_copy_construct(__a._M_data, __i._M_data, + __b._M_data, __n); } + // Copy-construct plain array __b[<__n>] from strided array __a[<__n : __s>] template - inline void - __valarray_fill (_Array<_Tp> __a, size_t __n, const _Tp& __t) - { std::__valarray_fill (__a._M_data, __n, __t); } + inline void + __valarray_copy_construct(_Array<_Tp> __a, size_t __n, size_t __s, + _Array<_Tp> __b) + { std::__valarray_copy_construct(__a._M_data, __n, __s, __b._M_data); } template - inline void - __valarray_fill (_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t) - { std::__valarray_fill (__a._M_data, __n, __s, __t); } + inline void + __valarray_fill (_Array<_Tp> __a, size_t __n, const _Tp& __t) + { std::__valarray_fill(__a._M_data, __n, __t); } template - inline void - __valarray_fill (_Array<_Tp> __a, _Array __i, - size_t __n, const _Tp& __t) - { std::__valarray_fill (__a._M_data, __i._M_data, __n, __t); } + inline void + __valarray_fill(_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t) + { std::__valarray_fill(__a._M_data, __n, __s, __t); } + + template + inline void + __valarray_fill(_Array<_Tp> __a, _Array __i, + size_t __n, const _Tp& __t) + { std::__valarray_fill(__a._M_data, __i._M_data, __n, __t); } // Copy a plain array __a[<__n>] into a play array __b[<>] template - inline void - __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) - { std::__valarray_copy(__a._M_data, __n, __b._M_data); } + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) + { std::__valarray_copy(__a._M_data, __n, __b._M_data); } // Copy strided array __a[<__n : __s>] in plain __b[<__n>] template - inline void - __valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s, _Array<_Tp> __b) - { std::__valarray_copy(__a._M_data, __n, __s, __b._M_data); } + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s, _Array<_Tp> __b) + { std::__valarray_copy(__a._M_data, __n, __s, __b._M_data); } // Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>] template - inline void - __valarray_copy(_Array<_Tp> __a, _Array<_Tp> __b, size_t __n, size_t __s) - { __valarray_copy(__a._M_data, __b._M_data, __n, __s); } + inline void + __valarray_copy(_Array<_Tp> __a, _Array<_Tp> __b, size_t __n, size_t __s) + { __valarray_copy(__a._M_data, __b._M_data, __n, __s); } // Copy strided array __src[<__n : __s1>] into another // strided array __dst[< : __s2>]. Their sizes must match. template - inline void - __valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s1, - _Array<_Tp> __b, size_t __s2) - { std::__valarray_copy(__a._M_data, __n, __s1, __b._M_data, __s2); } - + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s1, + _Array<_Tp> __b, size_t __s2) + { std::__valarray_copy(__a._M_data, __n, __s1, __b._M_data, __s2); } // Copy an indexed array __a[__i[<__n>]] in plain array __b[<__n>] template - inline void - __valarray_copy(_Array<_Tp> __a, _Array __i, - _Array<_Tp> __b, size_t __n) - { std::__valarray_copy(__a._M_data, __i._M_data, __b._M_data, __n); } + inline void + __valarray_copy(_Array<_Tp> __a, _Array __i, + _Array<_Tp> __b, size_t __n) + { std::__valarray_copy(__a._M_data, __i._M_data, __b._M_data, __n); } // Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]] template - inline void - __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, - _Array __i) - { std::__valarray_copy(__a._M_data, __n, __b._M_data, __i._M_data); } + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, + _Array __i) + { std::__valarray_copy(__a._M_data, __n, __b._M_data, __i._M_data); } // Copy the __n first elements of an indexed array __src[<__i>] into // another indexed array __dst[<__j>]. template - inline void - __valarray_copy(_Array<_Tp> __src, size_t __n, _Array __i, - _Array<_Tp> __dst, _Array __j) - { - std::__valarray_copy(__src._M_data, __n, __i._M_data, - __dst._M_data, __j._M_data); - } + inline void + __valarray_copy(_Array<_Tp> __src, size_t __n, _Array __i, + _Array<_Tp> __dst, _Array __j) + { + std::__valarray_copy(__src._M_data, __n, __i._M_data, + __dst._M_data, __j._M_data); + } template - inline - _Array<_Tp>::_Array (size_t __n) - : _M_data(__valarray_get_storage<_Tp>(__n)) - { std::__valarray_default_construct(_M_data, _M_data + __n); } + inline + _Array<_Tp>::_Array(size_t __n) + : _M_data(__valarray_get_storage<_Tp>(__n)) + { std::__valarray_default_construct(_M_data, _M_data + __n); } template - inline - _Array<_Tp>::_Array (_Tp* const __restrict__ __p) : _M_data (__p) {} + inline + _Array<_Tp>::_Array(_Tp* const __restrict__ __p) + : _M_data (__p) {} template - inline _Array<_Tp>::_Array (const valarray<_Tp>& __v) - : _M_data (__v._M_data) {} + inline + _Array<_Tp>::_Array(const valarray<_Tp>& __v) + : _M_data (__v._M_data) {} template - inline - _Array<_Tp>::_Array (const _Tp* __restrict__ __b, size_t __s) - : _M_data(__valarray_get_storage<_Tp>(__s)) - { std::__valarray_copy_construct(__b, __s, _M_data); } + inline + _Array<_Tp>::_Array(const _Tp* __restrict__ __b, size_t __s) + : _M_data(__valarray_get_storage<_Tp>(__s)) + { std::__valarray_copy_construct(__b, __s, _M_data); } template - inline _Tp* - _Array<_Tp>::begin () const - { return _M_data; } + inline _Tp* + _Array<_Tp>::begin () const + { return _M_data; } #define _DEFINE_ARRAY_FUNCTION(_Op, _Name) \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, const _Tp& __t) \ -{ \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p) \ - *__p _Op##= __t; \ -} \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, const _Tp& __t) \ + { \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; ++__p) \ + *__p _Op##= __t; \ + } \ \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \ -{ \ - _Tp* __p = __a._M_data; \ - for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__p, ++__q) \ - *__p _Op##= *__q; \ -} \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \ + { \ + _Tp* __p = __a._M_data; \ + for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; ++__p, ++__q) \ + *__p _Op##= *__q; \ + } \ \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, \ - const _Expr<_Dom,_Tp>& __e, size_t __n) \ -{ \ - _Tp* __p (__a._M_data); \ - for (size_t __i=0; __i<__n; ++__i, ++__p) *__p _Op##= __e[__i]; \ -} \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, ++__p) \ + *__p _Op##= __e[__i]; \ + } \ \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, size_t __s, \ - _Array<_Tp> __b) \ -{ \ - _Tp* __q (__b._M_data); \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__s*__n; __p+=__s, ++__q) \ - *__p _Op##= *__q; \ -} \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, size_t __s, \ + _Array<_Tp> __b) \ + { \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __s * __n; \ + __p += __s, ++__q) \ + *__p _Op##= *__q; \ + } \ \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array<_Tp> __b, \ - size_t __n, size_t __s) \ -{ \ - _Tp* __q (__b._M_data); \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, __q+=__s) \ - *__p _Op##= *__q; \ -} \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array<_Tp> __b, \ + size_t __n, size_t __s) \ + { \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \ + ++__p, __q += __s) \ + *__p _Op##= *__q; \ + } \ \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __s, \ - const _Expr<_Dom,_Tp>& __e, size_t __n) \ -{ \ - _Tp* __p (__a._M_data); \ - for (size_t __i=0; __i<__n; ++__i, __p+=__s) *__p _Op##= __e[__i]; \ -} \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __s, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, __p += __s) \ + *__p _Op##= __e[__i]; \ + } \ \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array __i, \ - _Array<_Tp> __b, size_t __n) \ -{ \ - _Tp* __q (__b._M_data); \ - for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__q) \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __i, \ + _Array<_Tp> __b, size_t __n) \ + { \ + _Tp* __q(__b._M_data); \ + for (size_t* __j = __i._M_data; __j < __i._M_data + __n; \ + ++__j, ++__q) \ __a._M_data[*__j] _Op##= *__q; \ -} \ + } \ \ -template \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \ - _Array<_Tp> __b, _Array __i) \ -{ \ - _Tp* __p (__a._M_data); \ - for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__p) \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \ + _Array<_Tp> __b, _Array __i) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t* __j = __i._M_data; __j<__i._M_data + __n; \ + ++__j, ++__p) \ *__p _Op##= __b._M_data[*__j]; \ -} \ + } \ \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array __i, \ - const _Expr<_Dom, _Tp>& __e, size_t __n) \ -{ \ - size_t* __j (__i._M_data); \ - for (size_t __k=0; __k<__n; ++__k, ++__j) \ - __a._M_data[*__j] _Op##= __e[__k]; \ -} \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __i, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + size_t* __j(__i._M_data); \ + for (size_t __k = 0; __k<__n; ++__k, ++__j) \ + __a._M_data[*__j] _Op##= __e[__k]; \ + } \ \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array __m, \ - _Array<_Tp> __b, size_t __n) \ -{ \ - bool* ok (__m._M_data); \ - _Tp* __p (__a._M_data); \ - for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++ok, ++__p) { \ - while (! *ok) { \ - ++ok; \ - ++__p; \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __m, \ + _Array<_Tp> __b, size_t __n) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __p(__a._M_data); \ + for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; \ + ++__q, ++__ok, ++__p) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__p; \ + } \ + *__p _Op##= *__q; \ } \ - *__p _Op##= *__q; \ } \ -} \ \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \ - _Array<_Tp> __b, _Array __m) \ -{ \ - bool* ok (__m._M_data); \ - _Tp* __q (__b._M_data); \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, ++ok, ++__q) { \ - while (! *ok) { \ - ++ok; \ - ++__q; \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \ + _Array<_Tp> __b, _Array __m) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \ + ++__p, ++__ok, ++__q) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__q; \ + } \ + *__p _Op##= *__q; \ } \ - *__p _Op##= *__q; \ } \ -} \ \ -template \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array __m, \ - const _Expr<_Dom, _Tp>& __e, size_t __n) \ -{ \ - bool* ok(__m._M_data); \ - _Tp* __p (__a._M_data); \ - for (size_t __i=0; __i<__n; ++__i, ++ok, ++__p) { \ - while (! *ok) { \ - ++ok; \ - ++__p; \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __m, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__p; \ + } \ + *__p _Op##= __e[__i]; \ } \ - *__p _Op##= __e[__i]; \ - } \ -} + } _DEFINE_ARRAY_FUNCTION(+, __plus) _DEFINE_ARRAY_FUNCTION(-, __minus) @@ -615,8 +693,9 @@ _Array_augmented_##_Name (_Array<_Tp> __a, _Array __m, \ _DEFINE_ARRAY_FUNCTION(<<, __shift_left) _DEFINE_ARRAY_FUNCTION(>>, __shift_right) -#undef _DEFINE_VALARRAY_FUNCTION -} // namespace std +#undef _DEFINE_ARRAY_FUNCTION + +_GLIBCXX_END_NAMESPACE #ifndef _GLIBCXX_EXPORT_TEMPLATE # include diff --git a/contrib/libstdc++/include/bits/valarray_array.tcc b/contrib/libstdc++/include/bits/valarray_array.tcc index fac5de6..f00ffb4 100644 --- a/contrib/libstdc++/include/bits/valarray_array.tcc +++ b/contrib/libstdc++/include/bits/valarray_array.tcc @@ -1,6 +1,6 @@ // The template and inlines for the -*- C++ -*- internal _Array helper class. -// Copyright (C) 1997, 1998, 1999, 2003 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2003, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,13 +27,18 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file valarray_array.tcc + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + // Written by Gabriel Dos Reis #ifndef _VALARRAY_ARRAY_TCC #define _VALARRAY_ARRAY_TCC 1 -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template void __valarray_fill(_Array<_Tp> __a, size_t __n, _Array __m, @@ -235,6 +240,7 @@ namespace std new (__q) _Tp(*__p); } } -} // namespace std + +_GLIBCXX_END_NAMESPACE #endif /* _VALARRAY_ARRAY_TCC */ diff --git a/contrib/libstdc++/include/bits/valarray_before.h b/contrib/libstdc++/include/bits/valarray_before.h index 263ac2f..4e3b937 100644 --- a/contrib/libstdc++/include/bits/valarray_before.h +++ b/contrib/libstdc++/include/bits/valarray_before.h @@ -1,6 +1,7 @@ // The template and inlines for the -*- C++ -*- internal _Meta class. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,13 +28,13 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// Written by Gabriel Dos Reis - -/** @file valarray_meta.h +/** @file valarray_before.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ +// Written by Gabriel Dos Reis + #ifndef _VALARRAY_BEFORE_H #define _VALARRAY_BEFORE_H 1 @@ -41,8 +42,8 @@ #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // // Implementing a loosened valarray return value is tricky. // First we need to meet 26.3.1/3: we should not add more than @@ -66,85 +67,99 @@ namespace std struct __abs { template - _Tp operator()(const _Tp& __t) const { return abs(__t); } + _Tp operator()(const _Tp& __t) const + { return abs(__t); } }; struct __cos { template - _Tp operator()(const _Tp& __t) const { return cos(__t); } + _Tp operator()(const _Tp& __t) const + { return cos(__t); } }; struct __acos { template - _Tp operator()(const _Tp& __t) const { return acos(__t); } + _Tp operator()(const _Tp& __t) const + { return acos(__t); } }; struct __cosh { template - _Tp operator()(const _Tp& __t) const { return cosh(__t); } + _Tp operator()(const _Tp& __t) const + { return cosh(__t); } }; struct __sin { template - _Tp operator()(const _Tp& __t) const { return sin(__t); } + _Tp operator()(const _Tp& __t) const + { return sin(__t); } }; struct __asin { template - _Tp operator()(const _Tp& __t) const { return asin(__t); } + _Tp operator()(const _Tp& __t) const + { return asin(__t); } }; struct __sinh { template - _Tp operator()(const _Tp& __t) const { return sinh(__t); } + _Tp operator()(const _Tp& __t) const + { return sinh(__t); } }; struct __tan { template - _Tp operator()(const _Tp& __t) const { return tan(__t); } + _Tp operator()(const _Tp& __t) const + { return tan(__t); } }; struct __atan { template - _Tp operator()(const _Tp& __t) const { return atan(__t); } + _Tp operator()(const _Tp& __t) const + { return atan(__t); } }; struct __tanh { template - _Tp operator()(const _Tp& __t) const { return tanh(__t); } + _Tp operator()(const _Tp& __t) const + { return tanh(__t); } }; struct __exp { template - _Tp operator()(const _Tp& __t) const { return exp(__t); } + _Tp operator()(const _Tp& __t) const + { return exp(__t); } }; struct __log { template - _Tp operator()(const _Tp& __t) const { return log(__t); } + _Tp operator()(const _Tp& __t) const + { return log(__t); } }; struct __log10 { template - _Tp operator()(const _Tp& __t) const { return log10(__t); } + _Tp operator()(const _Tp& __t) const + { return log10(__t); } }; struct __sqrt { template - _Tp operator()(const _Tp& __t) const { return sqrt(__t); } + _Tp operator()(const _Tp& __t) const + { return sqrt(__t); } }; // In the past, we used to tailor operator applications semantics @@ -154,19 +169,22 @@ namespace std struct __unary_plus { template - _Tp operator()(const _Tp& __t) const { return +__t; } + _Tp operator()(const _Tp& __t) const + { return +__t; } }; struct __negate { template - _Tp operator()(const _Tp& __t) const { return -__t; } + _Tp operator()(const _Tp& __t) const + { return -__t; } }; struct __bitwise_not { template - _Tp operator()(const _Tp& __t) const { return ~__t; } + _Tp operator()(const _Tp& __t) const + { return ~__t; } }; struct __plus @@ -381,9 +399,9 @@ namespace std typedef bool result_type; }; - // - // Apply function taking a value/const reference closure - // + // + // Apply function taking a value/const reference closure + // template class _FunBase @@ -392,7 +410,7 @@ namespace std typedef typename _Dom::value_type value_type; _FunBase(const _Dom& __e, value_type __f(_Arg)) - : _M_expr(__e), _M_func(__f) {} + : _M_expr(__e), _M_func(__f) {} value_type operator[](size_t __i) const { return _M_func (_M_expr[__i]); } @@ -400,8 +418,8 @@ namespace std size_t size() const { return _M_expr.size ();} private: - const _Dom& _M_expr; - value_type (*_M_func)(_Arg); + const _Dom& _M_expr; + value_type (*_M_func)(_Arg); }; template @@ -424,25 +442,26 @@ namespace std }; template - struct _RefFunClos<_Expr,_Dom> : - _FunBase<_Dom, const typename _Dom::value_type&> + struct _RefFunClos<_Expr, _Dom> + : _FunBase<_Dom, const typename _Dom::value_type&> { typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base; typedef typename _Base::value_type value_type; typedef value_type _Tp; _RefFunClos(const _Dom& __e, _Tp __f(const _Tp&)) - : _Base(__e, __f) {} + : _Base(__e, __f) {} }; template - struct _RefFunClos<_ValArray,_Tp> : _FunBase, const _Tp&> + struct _RefFunClos<_ValArray, _Tp> + : _FunBase, const _Tp&> { typedef _FunBase, const _Tp&> _Base; typedef _Tp value_type; _RefFunClos(const valarray<_Tp>& __v, _Tp __f(const _Tp&)) - : _Base(__v, __f) {} + : _Base(__v, __f) {} }; // @@ -462,13 +481,14 @@ namespace std { return _Oper()(_M_expr[__i]); } size_t size() const { return _M_expr.size(); } - + private: const _Arg& _M_expr; }; template - struct _UnClos<_Oper, _Expr, _Dom> : _UnBase<_Oper, _Dom> + struct _UnClos<_Oper, _Expr, _Dom> + : _UnBase<_Oper, _Dom> { typedef _Dom _Arg; typedef _UnBase<_Oper, _Dom> _Base; @@ -478,7 +498,8 @@ namespace std }; template - struct _UnClos<_Oper, _ValArray, _Tp> : _UnBase<_Oper, valarray<_Tp> > + struct _UnClos<_Oper, _ValArray, _Tp> + : _UnBase<_Oper, valarray<_Tp> > { typedef valarray<_Tp> _Arg; typedef _UnBase<_Oper, valarray<_Tp> > _Base; @@ -496,11 +517,11 @@ namespace std class _BinBase { public: - typedef typename _FirstArg::value_type _Vt; - typedef typename __fun<_Oper, _Vt>::result_type value_type; + typedef typename _FirstArg::value_type _Vt; + typedef typename __fun<_Oper, _Vt>::result_type value_type; _BinBase(const _FirstArg& __e1, const _SecondArg& __e2) - : _M_expr1(__e1), _M_expr2(__e2) {} + : _M_expr1(__e1), _M_expr2(__e2) {} value_type operator[](size_t __i) const { return _Oper()(_M_expr1[__i], _M_expr2[__i]); } @@ -521,7 +542,7 @@ namespace std typedef typename __fun<_Oper, _Vt>::result_type value_type; _BinBase2(const _Clos& __e, const _Vt& __t) - : _M_expr1(__e), _M_expr2(__t) {} + : _M_expr1(__e), _M_expr2(__t) {} value_type operator[](size_t __i) const { return _Oper()(_M_expr1[__i], _M_expr2); } @@ -541,7 +562,7 @@ namespace std typedef typename __fun<_Oper, _Vt>::result_type value_type; _BinBase1(const _Vt& __t, const _Clos& __e) - : _M_expr1(__t), _M_expr2(__e) {} + : _M_expr1(__t), _M_expr2(__e) {} value_type operator[](size_t __i) const { return _Oper()(_M_expr1, _M_expr2[__i]); } @@ -555,52 +576,52 @@ namespace std template struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2> - : _BinBase<_Oper,_Dom1,_Dom2> + : _BinBase<_Oper, _Dom1, _Dom2> { - typedef _BinBase<_Oper,_Dom1,_Dom2> _Base; + typedef _BinBase<_Oper, _Dom1, _Dom2> _Base; typedef typename _Base::value_type value_type; _BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {} }; template - struct _BinClos<_Oper,_ValArray,_ValArray,_Tp,_Tp> - : _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > + struct _BinClos<_Oper,_ValArray, _ValArray, _Tp, _Tp> + : _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > { - typedef _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > _Base; - typedef _Tp value_type; + typedef _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > _Base; + typedef typename _Base::value_type value_type; _BinClos(const valarray<_Tp>& __v, const valarray<_Tp>& __w) - : _Base(__v, __w) {} + : _Base(__v, __w) {} }; template - struct _BinClos<_Oper,_Expr,_ValArray,_Dom,typename _Dom::value_type> - : _BinBase<_Oper,_Dom,valarray > + struct _BinClos<_Oper, _Expr, _ValArray, _Dom, typename _Dom::value_type> + : _BinBase<_Oper, _Dom, valarray > { typedef typename _Dom::value_type _Tp; typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base; typedef typename _Base::value_type value_type; _BinClos(const _Dom& __e1, const valarray<_Tp>& __e2) - : _Base(__e1, __e2) {} + : _Base(__e1, __e2) {} }; template - struct _BinClos<_Oper,_ValArray,_Expr,typename _Dom::value_type,_Dom> - : _BinBase<_Oper,valarray,_Dom> + struct _BinClos<_Oper, _ValArray, _Expr, typename _Dom::value_type, _Dom> + : _BinBase<_Oper, valarray,_Dom> { typedef typename _Dom::value_type _Tp; - typedef _BinBase<_Oper,valarray<_Tp>,_Dom> _Base; + typedef _BinBase<_Oper, valarray<_Tp>, _Dom> _Base; typedef typename _Base::value_type value_type; _BinClos(const valarray<_Tp>& __e1, const _Dom& __e2) - : _Base(__e1, __e2) {} + : _Base(__e1, __e2) {} }; template - struct _BinClos<_Oper,_Expr,_Constant,_Dom,typename _Dom::value_type> - : _BinBase2<_Oper,_Dom> + struct _BinClos<_Oper, _Expr, _Constant, _Dom, typename _Dom::value_type> + : _BinBase2<_Oper, _Dom> { typedef typename _Dom::value_type _Tp; typedef _BinBase2<_Oper,_Dom> _Base; @@ -610,19 +631,19 @@ namespace std }; template - struct _BinClos<_Oper,_Constant,_Expr,typename _Dom::value_type,_Dom> - : _BinBase1<_Oper,_Dom> + struct _BinClos<_Oper, _Constant, _Expr, typename _Dom::value_type, _Dom> + : _BinBase1<_Oper, _Dom> { typedef typename _Dom::value_type _Tp; - typedef _BinBase1<_Oper,_Dom> _Base; + typedef _BinBase1<_Oper, _Dom> _Base; typedef typename _Base::value_type value_type; _BinClos(const _Tp& __e1, const _Dom& __e2) : _Base(__e1, __e2) {} }; template - struct _BinClos<_Oper,_ValArray,_Constant,_Tp,_Tp> - : _BinBase2<_Oper,valarray<_Tp> > + struct _BinClos<_Oper, _ValArray, _Constant, _Tp, _Tp> + : _BinBase2<_Oper, valarray<_Tp> > { typedef _BinBase2<_Oper,valarray<_Tp> > _Base; typedef typename _Base::value_type value_type; @@ -631,71 +652,84 @@ namespace std }; template - struct _BinClos<_Oper,_Constant,_ValArray,_Tp,_Tp> - : _BinBase1<_Oper,valarray<_Tp> > + struct _BinClos<_Oper, _Constant, _ValArray, _Tp, _Tp> + : _BinBase1<_Oper, valarray<_Tp> > { - typedef _BinBase1<_Oper,valarray<_Tp> > _Base; + typedef _BinBase1<_Oper, valarray<_Tp> > _Base; typedef typename _Base::value_type value_type; _BinClos(const _Tp& __t, const valarray<_Tp>& __v) : _Base(__t, __v) {} }; - // // slice_array closure. // - template class _SBase { + template + class _SBase + { public: - typedef typename _Dom::value_type value_type; - - _SBase (const _Dom& __e, const slice& __s) - : _M_expr (__e), _M_slice (__s) {} - value_type operator[] (size_t __i) const - { return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; } - size_t size() const { return _M_slice.size (); } + typedef typename _Dom::value_type value_type; + + _SBase (const _Dom& __e, const slice& __s) + : _M_expr (__e), _M_slice (__s) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; } + + size_t + size() const + { return _M_slice.size (); } private: - const _Dom& _M_expr; - const slice& _M_slice; + const _Dom& _M_expr; + const slice& _M_slice; }; - template class _SBase<_Array<_Tp> > { + template + class _SBase<_Array<_Tp> > + { public: - typedef _Tp value_type; - - _SBase (_Array<_Tp> __a, const slice& __s) - : _M_array (__a._M_data+__s.start()), _M_size (__s.size()), - _M_stride (__s.stride()) {} - value_type operator[] (size_t __i) const - { return _M_array._M_data[__i * _M_stride]; } - size_t size() const { return _M_size; } + typedef _Tp value_type; + + _SBase (_Array<_Tp> __a, const slice& __s) + : _M_array (__a._M_data+__s.start()), _M_size (__s.size()), + _M_stride (__s.stride()) {} + + value_type + operator[] (size_t __i) const + { return _M_array._M_data[__i * _M_stride]; } + + size_t + size() const + { return _M_size; } private: - const _Array<_Tp> _M_array; - const size_t _M_size; - const size_t _M_stride; + const _Array<_Tp> _M_array; + const size_t _M_size; + const size_t _M_stride; }; - template struct _SClos<_Expr,_Dom> : _SBase<_Dom> { - typedef _SBase<_Dom> _Base; - typedef typename _Base::value_type value_type; - - _SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {} + template + struct _SClos<_Expr, _Dom> + : _SBase<_Dom> + { + typedef _SBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {} }; - template - struct _SClos<_ValArray,_Tp> : _SBase<_Array<_Tp> > { - typedef _SBase<_Array<_Tp> > _Base; - typedef _Tp value_type; - - _SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {} + template + struct _SClos<_ValArray, _Tp> + : _SBase<_Array<_Tp> > + { + typedef _SBase<_Array<_Tp> > _Base; + typedef _Tp value_type; + + _SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {} }; -} // std:: - +_GLIBCXX_END_NAMESPACE #endif /* _CPP_VALARRAY_BEFORE_H */ - -// Local Variables: -// mode:c++ -// End: diff --git a/contrib/libstdc++/include/bits/vector.tcc b/contrib/libstdc++/include/bits/vector.tcc index 786afab..f476c46 100644 --- a/contrib/libstdc++/include/bits/vector.tcc +++ b/contrib/libstdc++/include/bits/vector.tcc @@ -1,6 +1,6 @@ // Vector implementation (out of line) -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -61,11 +61,11 @@ #ifndef _VECTOR_TCC #define _VECTOR_TCC 1 -namespace _GLIBCXX_STD -{ +_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) + template void - vector<_Tp,_Alloc>:: + vector<_Tp, _Alloc>:: reserve(size_type __n) { if (__n > this->max_size()) @@ -73,12 +73,13 @@ namespace _GLIBCXX_STD if (this->capacity() < __n) { const size_type __old_size = size(); - pointer __tmp = _M_allocate_and_copy(__n, - this->_M_impl._M_start, + pointer __tmp = _M_allocate_and_copy(__n, this->_M_impl._M_start, this->_M_impl._M_finish); - std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); _M_deallocate(this->_M_impl._M_start, - this->_M_impl._M_end_of_storage - this->_M_impl._M_start); + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); this->_M_impl._M_start = __tmp; this->_M_impl._M_finish = __tmp + __old_size; this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; @@ -86,329 +87,410 @@ namespace _GLIBCXX_STD } template - typename vector<_Tp,_Alloc>::iterator - vector<_Tp,_Alloc>:: + typename vector<_Tp, _Alloc>::iterator + vector<_Tp, _Alloc>:: insert(iterator __position, const value_type& __x) { - size_type __n = __position - begin(); - if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage && __position == end()) - { - std::_Construct(this->_M_impl._M_finish, __x); - ++this->_M_impl._M_finish; - } + const size_type __n = __position - begin(); + if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage + && __position == end()) + { + this->_M_impl.construct(this->_M_impl._M_finish, __x); + ++this->_M_impl._M_finish; + } else _M_insert_aux(__position, __x); - return begin() + __n; + return iterator(this->_M_impl._M_start + __n); } template - typename vector<_Tp,_Alloc>::iterator - vector<_Tp,_Alloc>:: + typename vector<_Tp, _Alloc>::iterator + vector<_Tp, _Alloc>:: erase(iterator __position) { if (__position + 1 != end()) std::copy(__position + 1, end(), __position); --this->_M_impl._M_finish; - std::_Destroy(this->_M_impl._M_finish); + this->_M_impl.destroy(this->_M_impl._M_finish); return __position; } template - typename vector<_Tp,_Alloc>::iterator - vector<_Tp,_Alloc>:: + typename vector<_Tp, _Alloc>::iterator + vector<_Tp, _Alloc>:: erase(iterator __first, iterator __last) { - iterator __i(std::copy(__last, end(), __first)); - std::_Destroy(__i, end()); - this->_M_impl._M_finish = this->_M_impl._M_finish - (__last - __first); + if (__last != end()) + std::copy(__last, end(), __first); + _M_erase_at_end(__first.base() + (end() - __last)); return __first; } template - vector<_Tp,_Alloc>& - vector<_Tp,_Alloc>:: - operator=(const vector<_Tp,_Alloc>& __x) + vector<_Tp, _Alloc>& + vector<_Tp, _Alloc>:: + operator=(const vector<_Tp, _Alloc>& __x) { if (&__x != this) - { - const size_type __xlen = __x.size(); - if (__xlen > capacity()) - { - pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end()); - std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); - _M_deallocate(this->_M_impl._M_start, - this->_M_impl._M_end_of_storage - this->_M_impl._M_start); - this->_M_impl._M_start = __tmp; - this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen; - } - else if (size() >= __xlen) - { - iterator __i(std::copy(__x.begin(), __x.end(), begin())); - std::_Destroy(__i, end()); - } - else - { - std::copy(__x.begin(), __x.begin() + size(), this->_M_impl._M_start); - std::uninitialized_copy(__x.begin() + size(), __x.end(), this->_M_impl._M_finish); - } - this->_M_impl._M_finish = this->_M_impl._M_start + __xlen; - } + { + const size_type __xlen = __x.size(); + if (__xlen > capacity()) + { + pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), + __x.end()); + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __tmp; + this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen; + } + else if (size() >= __xlen) + { + std::_Destroy(std::copy(__x.begin(), __x.end(), begin()), + end(), _M_get_Tp_allocator()); + } + else + { + std::copy(__x._M_impl._M_start, __x._M_impl._M_start + size(), + this->_M_impl._M_start); + std::__uninitialized_copy_a(__x._M_impl._M_start + size(), + __x._M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + } + this->_M_impl._M_finish = this->_M_impl._M_start + __xlen; + } return *this; } template void - vector<_Tp,_Alloc>:: + vector<_Tp, _Alloc>:: _M_fill_assign(size_t __n, const value_type& __val) { if (__n > capacity()) - { - vector __tmp(__n, __val, get_allocator()); - __tmp.swap(*this); - } + { + vector __tmp(__n, __val, _M_get_Tp_allocator()); + __tmp.swap(*this); + } else if (__n > size()) - { - std::fill(begin(), end(), __val); - this->_M_impl._M_finish - = std::uninitialized_fill_n(this->_M_impl._M_finish, __n - size(), __val); - } - else - erase(fill_n(begin(), __n, __val), end()); - } - - template template - void - vector<_Tp,_Alloc>:: - _M_assign_aux(_InputIterator __first, _InputIterator __last, input_iterator_tag) - { - iterator __cur(begin()); - for ( ; __first != __last && __cur != end(); ++__cur, ++__first) - *__cur = *__first; - if (__first == __last) - erase(__cur, end()); + { + std::fill(begin(), end(), __val); + std::__uninitialized_fill_n_a(this->_M_impl._M_finish, + __n - size(), __val, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __n - size(); + } else - insert(end(), __first, __last); + _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val)); } - template template - void - vector<_Tp,_Alloc>:: - _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, - forward_iterator_tag) - { - size_type __len = std::distance(__first, __last); - - if (__len > capacity()) - { - pointer __tmp(_M_allocate_and_copy(__len, __first, __last)); - std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); - _M_deallocate(this->_M_impl._M_start, - this->_M_impl._M_end_of_storage - this->_M_impl._M_start); - this->_M_impl._M_start = __tmp; - this->_M_impl._M_end_of_storage = this->_M_impl._M_finish = this->_M_impl._M_start + __len; - } - else if (size() >= __len) + template + template + void + vector<_Tp, _Alloc>:: + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) { - iterator __new_finish(std::copy(__first, __last, this->_M_impl._M_start)); - std::_Destroy(__new_finish, end()); - this->_M_impl._M_finish = __new_finish.base(); + pointer __cur(this->_M_impl._M_start); + for (; __first != __last && __cur != this->_M_impl._M_finish; + ++__cur, ++__first) + *__cur = *__first; + if (__first == __last) + _M_erase_at_end(__cur); + else + insert(end(), __first, __last); } - else + + template + template + void + vector<_Tp, _Alloc>:: + _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) { - _ForwardIterator __mid = __first; - std::advance(__mid, size()); - std::copy(__first, __mid, this->_M_impl._M_start); - this->_M_impl._M_finish = std::uninitialized_copy(__mid, __last, this->_M_impl._M_finish); + const size_type __len = std::distance(__first, __last); + + if (__len > capacity()) + { + pointer __tmp(_M_allocate_and_copy(__len, __first, __last)); + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __tmp; + this->_M_impl._M_finish = this->_M_impl._M_start + __len; + this->_M_impl._M_end_of_storage = this->_M_impl._M_finish; + } + else if (size() >= __len) + _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start)); + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, size()); + std::copy(__first, __mid, this->_M_impl._M_start); + this->_M_impl._M_finish = + std::__uninitialized_copy_a(__mid, __last, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + } } - } template void - vector<_Tp,_Alloc>:: + vector<_Tp, _Alloc>:: _M_insert_aux(iterator __position, const _Tp& __x) { if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) - { - std::_Construct(this->_M_impl._M_finish, *(this->_M_impl._M_finish - 1)); - ++this->_M_impl._M_finish; - _Tp __x_copy = __x; - std::copy_backward(__position, - iterator(this->_M_impl._M_finish-2), - iterator(this->_M_impl._M_finish-1)); - *__position = __x_copy; - } + { + this->_M_impl.construct(this->_M_impl._M_finish, + *(this->_M_impl._M_finish - 1)); + ++this->_M_impl._M_finish; + _Tp __x_copy = __x; + std::copy_backward(__position.base(), + this->_M_impl._M_finish - 2, + this->_M_impl._M_finish - 1); + *__position = __x_copy; + } else - { - const size_type __old_size = size(); - const size_type __len = __old_size != 0 ? 2 * __old_size : 1; - iterator __new_start(this->_M_allocate(__len)); - iterator __new_finish(__new_start); - try - { - __new_finish = std::uninitialized_copy(iterator(this->_M_impl._M_start), - __position, - __new_start); - std::_Construct(__new_finish.base(), __x); - ++__new_finish; - __new_finish = std::uninitialized_copy(__position, - iterator(this->_M_impl._M_finish), - __new_finish); - } - catch(...) - { - std::_Destroy(__new_start,__new_finish); - _M_deallocate(__new_start.base(),__len); - __throw_exception_again; - } - std::_Destroy(begin(), end()); - _M_deallocate(this->_M_impl._M_start, - this->_M_impl._M_end_of_storage - this->_M_impl._M_start); - this->_M_impl._M_start = __new_start.base(); - this->_M_impl._M_finish = __new_finish.base(); - this->_M_impl._M_end_of_storage = __new_start.base() + __len; - } + { + const size_type __old_size = size(); + if (__old_size == this->max_size()) + __throw_length_error(__N("vector::_M_insert_aux")); + + // When sizeof(value_type) == 1 and __old_size > size_type(-1)/2 + // __len overflows: if we don't notice and _M_allocate doesn't + // throw we crash badly later. + size_type __len = __old_size != 0 ? 2 * __old_size : 1; + if (__len < __old_size) + __len = this->max_size(); + + pointer __new_start(this->_M_allocate(__len)); + pointer __new_finish(__new_start); + try + { + __new_finish = + std::__uninitialized_copy_a(this->_M_impl._M_start, + __position.base(), __new_start, + _M_get_Tp_allocator()); + this->_M_impl.construct(__new_finish, __x); + ++__new_finish; + __new_finish = + std::__uninitialized_copy_a(__position.base(), + this->_M_impl._M_finish, + __new_finish, + _M_get_Tp_allocator()); + } + catch(...) + { + std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator()); + _M_deallocate(__new_start, __len); + __throw_exception_again; + } + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __new_start; + this->_M_impl._M_finish = __new_finish; + this->_M_impl._M_end_of_storage = __new_start + __len; + } } template void - vector<_Tp,_Alloc>:: + vector<_Tp, _Alloc>:: _M_fill_insert(iterator __position, size_type __n, const value_type& __x) { if (__n != 0) - { - if (size_type(this->_M_impl._M_end_of_storage - this->_M_impl._M_finish) >= __n) - { - value_type __x_copy = __x; - const size_type __elems_after = end() - __position; - iterator __old_finish(this->_M_impl._M_finish); - if (__elems_after > __n) - { - std::uninitialized_copy(this->_M_impl._M_finish - __n, - this->_M_impl._M_finish, - this->_M_impl._M_finish); - this->_M_impl._M_finish += __n; - std::copy_backward(__position, __old_finish - __n, __old_finish); - std::fill(__position, __position + __n, __x_copy); - } - else - { - std::uninitialized_fill_n(this->_M_impl._M_finish, - __n - __elems_after, - __x_copy); - this->_M_impl._M_finish += __n - __elems_after; - std::uninitialized_copy(__position, __old_finish, this->_M_impl._M_finish); - this->_M_impl._M_finish += __elems_after; - std::fill(__position, __old_finish, __x_copy); - } - } - else - { - const size_type __old_size = size(); - const size_type __len = __old_size + std::max(__old_size, __n); - iterator __new_start(this->_M_allocate(__len)); - iterator __new_finish(__new_start); - try - { - __new_finish = std::uninitialized_copy(begin(), __position, - __new_start); - __new_finish = std::uninitialized_fill_n(__new_finish, __n, __x); - __new_finish = std::uninitialized_copy(__position, end(), - __new_finish); - } - catch(...) - { - std::_Destroy(__new_start,__new_finish); - _M_deallocate(__new_start.base(),__len); - __throw_exception_again; - } - std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); - _M_deallocate(this->_M_impl._M_start, - this->_M_impl._M_end_of_storage - this->_M_impl._M_start); - this->_M_impl._M_start = __new_start.base(); - this->_M_impl._M_finish = __new_finish.base(); - this->_M_impl._M_end_of_storage = __new_start.base() + __len; - } - } + { + if (size_type(this->_M_impl._M_end_of_storage + - this->_M_impl._M_finish) >= __n) + { + value_type __x_copy = __x; + const size_type __elems_after = end() - __position; + pointer __old_finish(this->_M_impl._M_finish); + if (__elems_after > __n) + { + std::__uninitialized_copy_a(this->_M_impl._M_finish - __n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __n; + std::copy_backward(__position.base(), __old_finish - __n, + __old_finish); + std::fill(__position.base(), __position.base() + __n, + __x_copy); + } + else + { + std::__uninitialized_fill_n_a(this->_M_impl._M_finish, + __n - __elems_after, + __x_copy, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __n - __elems_after; + std::__uninitialized_copy_a(__position.base(), __old_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __elems_after; + std::fill(__position.base(), __old_finish, __x_copy); + } + } + else + { + const size_type __old_size = size(); + if (this->max_size() - __old_size < __n) + __throw_length_error(__N("vector::_M_fill_insert")); + + // See _M_insert_aux above. + size_type __len = __old_size + std::max(__old_size, __n); + if (__len < __old_size) + __len = this->max_size(); + + pointer __new_start(this->_M_allocate(__len)); + pointer __new_finish(__new_start); + try + { + __new_finish = + std::__uninitialized_copy_a(this->_M_impl._M_start, + __position.base(), + __new_start, + _M_get_Tp_allocator()); + std::__uninitialized_fill_n_a(__new_finish, __n, __x, + _M_get_Tp_allocator()); + __new_finish += __n; + __new_finish = + std::__uninitialized_copy_a(__position.base(), + this->_M_impl._M_finish, + __new_finish, + _M_get_Tp_allocator()); + } + catch(...) + { + std::_Destroy(__new_start, __new_finish, + _M_get_Tp_allocator()); + _M_deallocate(__new_start, __len); + __throw_exception_again; + } + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __new_start; + this->_M_impl._M_finish = __new_finish; + this->_M_impl._M_end_of_storage = __new_start + __len; + } + } } template template void - vector<_Tp,_Alloc>:: - _M_range_insert(iterator __pos, - _InputIterator __first, _InputIterator __last, - input_iterator_tag) + vector<_Tp, _Alloc>:: + _M_range_insert(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag) { - for ( ; __first != __last; ++__first) - { - __pos = insert(__pos, *__first); - ++__pos; - } + for (; __first != __last; ++__first) + { + __pos = insert(__pos, *__first); + ++__pos; + } } - template template - void - vector<_Tp,_Alloc>:: - _M_range_insert(iterator __position,_ForwardIterator __first, - _ForwardIterator __last, forward_iterator_tag) - { - if (__first != __last) + template + template + void + vector<_Tp, _Alloc>:: + _M_range_insert(iterator __position, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag) { - size_type __n = std::distance(__first, __last); - if (size_type(this->_M_impl._M_end_of_storage - this->_M_impl._M_finish) >= __n) - { - const size_type __elems_after = end() - __position; - iterator __old_finish(this->_M_impl._M_finish); - if (__elems_after > __n) - { - std::uninitialized_copy(this->_M_impl._M_finish - __n, - this->_M_impl._M_finish, - this->_M_impl._M_finish); - this->_M_impl._M_finish += __n; - std::copy_backward(__position, __old_finish - __n, __old_finish); - std::copy(__first, __last, __position); - } - else - { - _ForwardIterator __mid = __first; - std::advance(__mid, __elems_after); - std::uninitialized_copy(__mid, __last, this->_M_impl._M_finish); - this->_M_impl._M_finish += __n - __elems_after; - std::uninitialized_copy(__position, __old_finish, this->_M_impl._M_finish); - this->_M_impl._M_finish += __elems_after; - std::copy(__first, __mid, __position); - } - } - else - { - const size_type __old_size = size(); - const size_type __len = __old_size + std::max(__old_size, __n); - iterator __new_start(this->_M_allocate(__len)); - iterator __new_finish(__new_start); - try - { - __new_finish = std::uninitialized_copy(iterator(this->_M_impl._M_start), - __position, __new_start); - __new_finish = std::uninitialized_copy(__first, __last, - __new_finish); - __new_finish = std::uninitialized_copy(__position, - iterator(this->_M_impl._M_finish), - __new_finish); - } - catch(...) - { - std::_Destroy(__new_start,__new_finish); - _M_deallocate(__new_start.base(), __len); - __throw_exception_again; - } - std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); - _M_deallocate(this->_M_impl._M_start, - this->_M_impl._M_end_of_storage - this->_M_impl._M_start); - this->_M_impl._M_start = __new_start.base(); - this->_M_impl._M_finish = __new_finish.base(); - this->_M_impl._M_end_of_storage = __new_start.base() + __len; - } + if (__first != __last) + { + const size_type __n = std::distance(__first, __last); + if (size_type(this->_M_impl._M_end_of_storage + - this->_M_impl._M_finish) >= __n) + { + const size_type __elems_after = end() - __position; + pointer __old_finish(this->_M_impl._M_finish); + if (__elems_after > __n) + { + std::__uninitialized_copy_a(this->_M_impl._M_finish - __n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __n; + std::copy_backward(__position.base(), __old_finish - __n, + __old_finish); + std::copy(__first, __last, __position); + } + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, __elems_after); + std::__uninitialized_copy_a(__mid, __last, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __n - __elems_after; + std::__uninitialized_copy_a(__position.base(), + __old_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __elems_after; + std::copy(__first, __mid, __position); + } + } + else + { + const size_type __old_size = size(); + if (this->max_size() - __old_size < __n) + __throw_length_error(__N("vector::_M_range_insert")); + + // See _M_insert_aux above. + size_type __len = __old_size + std::max(__old_size, __n); + if (__len < __old_size) + __len = this->max_size(); + + pointer __new_start(this->_M_allocate(__len)); + pointer __new_finish(__new_start); + try + { + __new_finish = + std::__uninitialized_copy_a(this->_M_impl._M_start, + __position.base(), + __new_start, + _M_get_Tp_allocator()); + __new_finish = + std::__uninitialized_copy_a(__first, __last, __new_finish, + _M_get_Tp_allocator()); + __new_finish = + std::__uninitialized_copy_a(__position.base(), + this->_M_impl._M_finish, + __new_finish, + _M_get_Tp_allocator()); + } + catch(...) + { + std::_Destroy(__new_start, __new_finish, + _M_get_Tp_allocator()); + _M_deallocate(__new_start, __len); + __throw_exception_again; + } + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __new_start; + this->_M_impl._M_finish = __new_finish; + this->_M_impl._M_end_of_storage = __new_start + __len; + } + } } - } -} // namespace std + +_GLIBCXX_END_NESTED_NAMESPACE #endif /* _VECTOR_TCC */ diff --git a/contrib/libstdc++/include/c/std_cassert.h b/contrib/libstdc++/include/c/std_cassert.h index 9b2bb72..873eeef 100644 --- a/contrib/libstdc++/include/c/std_cassert.h +++ b/contrib/libstdc++/include/c/std_cassert.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_cctype.h b/contrib/libstdc++/include/c/std_cctype.h index 3231f48..103dd37 100644 --- a/contrib/libstdc++/include/c/std_cctype.h +++ b/contrib/libstdc++/include/c/std_cctype.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_cerrno.h b/contrib/libstdc++/include/c/std_cerrno.h index 84e0e53..e27c361 100644 --- a/contrib/libstdc++/include/c/std_cerrno.h +++ b/contrib/libstdc++/include/c/std_cerrno.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,10 +27,6 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 19.3 Error numbers -// - /** @file cerrno * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. @@ -40,6 +36,10 @@ * contained in the namespace @c std. */ +// +// ISO C++ 14882: 19.3 Error numbers +// + #ifndef _GLIBCXX_CERRNO #define _GLIBCXX_CERRNO 1 diff --git a/contrib/libstdc++/include/c/std_cfloat.h b/contrib/libstdc++/include/c/std_cfloat.h index e9319d3..3cf6b9b 100644 --- a/contrib/libstdc++/include/c/std_cfloat.h +++ b/contrib/libstdc++/include/c/std_cfloat.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_ciso646.h b/contrib/libstdc++/include/c/std_ciso646.h index 0993a0a..4ffd3bb 100644 --- a/contrib/libstdc++/include/c/std_ciso646.h +++ b/contrib/libstdc++/include/c/std_ciso646.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_climits.h b/contrib/libstdc++/include/c/std_climits.h index e1986f2..ca9db69 100644 --- a/contrib/libstdc++/include/c/std_climits.h +++ b/contrib/libstdc++/include/c/std_climits.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_clocale.h b/contrib/libstdc++/include/c/std_clocale.h index 6aa937b..7642222 100644 --- a/contrib/libstdc++/include/c/std_clocale.h +++ b/contrib/libstdc++/include/c/std_clocale.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_cmath.h b/contrib/libstdc++/include/c/std_cmath.h index fcaa759..18c1fb2 100644 --- a/contrib/libstdc++/include/c/std_cmath.h +++ b/contrib/libstdc++/include/c/std_cmath.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_csetjmp.h b/contrib/libstdc++/include/c/std_csetjmp.h index 022753f..1926bcc 100644 --- a/contrib/libstdc++/include/c/std_csetjmp.h +++ b/contrib/libstdc++/include/c/std_csetjmp.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_csignal.h b/contrib/libstdc++/include/c/std_csignal.h index 6fa9607..37bacae 100644 --- a/contrib/libstdc++/include/c/std_csignal.h +++ b/contrib/libstdc++/include/c/std_csignal.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_cstdarg.h b/contrib/libstdc++/include/c/std_cstdarg.h index 0c23634..00aa001 100644 --- a/contrib/libstdc++/include/c/std_cstdarg.h +++ b/contrib/libstdc++/include/c/std_cstdarg.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_cstddef.h b/contrib/libstdc++/include/c/std_cstddef.h index 4178ecf..33269af 100644 --- a/contrib/libstdc++/include/c/std_cstddef.h +++ b/contrib/libstdc++/include/c/std_cstddef.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_cstdio.h b/contrib/libstdc++/include/c/std_cstdio.h index fa04bc4..5cb8bcf 100644 --- a/contrib/libstdc++/include/c/std_cstdio.h +++ b/contrib/libstdc++/include/c/std_cstdio.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_cstdlib.h b/contrib/libstdc++/include/c/std_cstdlib.h index 90b2f10..85f5bf7 100644 --- a/contrib/libstdc++/include/c/std_cstdlib.h +++ b/contrib/libstdc++/include/c/std_cstdlib.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_cstring.h b/contrib/libstdc++/include/c/std_cstring.h index 72ee44f..ed7719c 100644 --- a/contrib/libstdc++/include/c/std_cstring.h +++ b/contrib/libstdc++/include/c/std_cstring.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_ctime.h b/contrib/libstdc++/include/c/std_ctime.h index 197a1f8..1d2bd3f 100644 --- a/contrib/libstdc++/include/c/std_ctime.h +++ b/contrib/libstdc++/include/c/std_ctime.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_cwchar.h b/contrib/libstdc++/include/c/std_cwchar.h index 0d2f6be..69576b5 100644 --- a/contrib/libstdc++/include/c/std_cwchar.h +++ b/contrib/libstdc++/include/c/std_cwchar.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c/std_cwctype.h b/contrib/libstdc++/include/c/std_cwctype.h index 9302864..a916760 100644 --- a/contrib/libstdc++/include/c/std_cwctype.h +++ b/contrib/libstdc++/include/c/std_cwctype.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/assert.h b/contrib/libstdc++/include/c_compatibility/assert.h index cb5313f..fc14c0f 100644 --- a/contrib/libstdc++/include/c_compatibility/assert.h +++ b/contrib/libstdc++/include/c_compatibility/assert.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/ctype.h b/contrib/libstdc++/include/c_compatibility/ctype.h index 3a610d1..1bd379d 100644 --- a/contrib/libstdc++/include/c_compatibility/ctype.h +++ b/contrib/libstdc++/include/c_compatibility/ctype.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/errno.h b/contrib/libstdc++/include/c_compatibility/errno.h index f6b2b76..d7cc829 100644 --- a/contrib/libstdc++/include/c_compatibility/errno.h +++ b/contrib/libstdc++/include/c_compatibility/errno.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/float.h b/contrib/libstdc++/include/c_compatibility/float.h index 5eaaba6..adeb73f 100644 --- a/contrib/libstdc++/include/c_compatibility/float.h +++ b/contrib/libstdc++/include/c_compatibility/float.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/iso646.h b/contrib/libstdc++/include/c_compatibility/iso646.h index 83c5364..d5097ca 100644 --- a/contrib/libstdc++/include/c_compatibility/iso646.h +++ b/contrib/libstdc++/include/c_compatibility/iso646.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/limits.h b/contrib/libstdc++/include/c_compatibility/limits.h index d9a753c..e7abd01 100644 --- a/contrib/libstdc++/include/c_compatibility/limits.h +++ b/contrib/libstdc++/include/c_compatibility/limits.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/locale.h b/contrib/libstdc++/include/c_compatibility/locale.h index 549bd7d..8baf041 100644 --- a/contrib/libstdc++/include/c_compatibility/locale.h +++ b/contrib/libstdc++/include/c_compatibility/locale.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/math.h b/contrib/libstdc++/include/c_compatibility/math.h index 1cd48cf..38636e6 100644 --- a/contrib/libstdc++/include/c_compatibility/math.h +++ b/contrib/libstdc++/include/c_compatibility/math.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/setjmp.h b/contrib/libstdc++/include/c_compatibility/setjmp.h index 0bcad03..f2d481a 100644 --- a/contrib/libstdc++/include/c_compatibility/setjmp.h +++ b/contrib/libstdc++/include/c_compatibility/setjmp.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/signal.h b/contrib/libstdc++/include/c_compatibility/signal.h index b43deb5..ae1d23d 100644 --- a/contrib/libstdc++/include/c_compatibility/signal.h +++ b/contrib/libstdc++/include/c_compatibility/signal.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/stdarg.h b/contrib/libstdc++/include/c_compatibility/stdarg.h index 76d6c74..9b92a93 100644 --- a/contrib/libstdc++/include/c_compatibility/stdarg.h +++ b/contrib/libstdc++/include/c_compatibility/stdarg.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/stddef.h b/contrib/libstdc++/include/c_compatibility/stddef.h index 4dac7db..457cd00 100644 --- a/contrib/libstdc++/include/c_compatibility/stddef.h +++ b/contrib/libstdc++/include/c_compatibility/stddef.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/stdio.h b/contrib/libstdc++/include/c_compatibility/stdio.h index 2686a72..270852f 100644 --- a/contrib/libstdc++/include/c_compatibility/stdio.h +++ b/contrib/libstdc++/include/c_compatibility/stdio.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/stdlib.h b/contrib/libstdc++/include/c_compatibility/stdlib.h index 2b05c1a..dbf99b4 100644 --- a/contrib/libstdc++/include/c_compatibility/stdlib.h +++ b/contrib/libstdc++/include/c_compatibility/stdlib.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/string.h b/contrib/libstdc++/include/c_compatibility/string.h index a399f60..09e59cf 100644 --- a/contrib/libstdc++/include/c_compatibility/string.h +++ b/contrib/libstdc++/include/c_compatibility/string.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/time.h b/contrib/libstdc++/include/c_compatibility/time.h index 0e7e2ad..d5684ad 100644 --- a/contrib/libstdc++/include/c_compatibility/time.h +++ b/contrib/libstdc++/include/c_compatibility/time.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/wchar.h b/contrib/libstdc++/include/c_compatibility/wchar.h index a962ff2f..2071ae4 100644 --- a/contrib/libstdc++/include/c_compatibility/wchar.h +++ b/contrib/libstdc++/include/c_compatibility/wchar.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_compatibility/wctype.h b/contrib/libstdc++/include/c_compatibility/wctype.h index 6086f3d..c7ddc90 100644 --- a/contrib/libstdc++/include/c_compatibility/wctype.h +++ b/contrib/libstdc++/include/c_compatibility/wctype.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software diff --git a/contrib/libstdc++/include/c_std/cmath.tcc b/contrib/libstdc++/include/c_std/cmath.tcc index d771467..472324a 100644 --- a/contrib/libstdc++/include/c_std/cmath.tcc +++ b/contrib/libstdc++/include/c_std/cmath.tcc @@ -1,6 +1,6 @@ // -*- C++ -*- C math library. -// Copyright (C) 2000, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2000, 2003, 2004, 2006 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -29,11 +29,15 @@ // This file was written by Gabriel Dos Reis +/** @file cmath.tcc + * This is a Standard C++ Library file. + */ + #ifndef _GLIBCXX_CMATH_TCC #define _GLIBCXX_CMATH_TCC 1 -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template inline _Tp __cmath_power(_Tp __x, unsigned int __n) @@ -49,6 +53,7 @@ namespace std return __y; } -} + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/c_std/std_cassert.h b/contrib/libstdc++/include/c_std/std_cassert.h index 9fc1079..0e5c77a 100644 --- a/contrib/libstdc++/include/c_std/std_cassert.h +++ b/contrib/libstdc++/include/c_std/std_cassert.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,19 +28,20 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 19.2 Assertions -// - /** @file cassert * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c assert.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 19.2 Assertions +// + // No include guards on this header... #pragma GCC system_header diff --git a/contrib/libstdc++/include/c_std/std_cctype.h b/contrib/libstdc++/include/c_std/std_cctype.h index 65a4214..61a55cb 100644 --- a/contrib/libstdc++/include/c_std/std_cctype.h +++ b/contrib/libstdc++/include/c_std/std_cctype.h @@ -1,6 +1,7 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,19 +28,20 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: -// - -/** @file cctype +/** @file include/cctype * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c ctype.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: +// + #ifndef _GLIBCXX_CCTYPE #define _GLIBCXX_CCTYPE 1 @@ -63,8 +65,8 @@ #undef tolower #undef toupper -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::isalnum; using ::isalpha; using ::iscntrl; @@ -78,6 +80,7 @@ namespace std using ::isxdigit; using ::tolower; using ::toupper; -} + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/c_std/std_cerrno.h b/contrib/libstdc++/include/c_std/std_cerrno.h index 7915e14..e597b8f 100644 --- a/contrib/libstdc++/include/c_std/std_cerrno.h +++ b/contrib/libstdc++/include/c_std/std_cerrno.h @@ -1,6 +1,7 @@ // The -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,19 +28,20 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 19.3 Error numbers -// - /** @file cerrno * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c errno.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 19.3 Error numbers +// + #ifndef _GLIBCXX_CERRNO #define _GLIBCXX_CERRNO 1 diff --git a/contrib/libstdc++/include/c_std/std_cfloat.h b/contrib/libstdc++/include/c_std/std_cfloat.h index 4c5bb00..2b51449 100644 --- a/contrib/libstdc++/include/c_std/std_cfloat.h +++ b/contrib/libstdc++/include/c_std/std_cfloat.h @@ -1,6 +1,7 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,19 +28,20 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 18.2.2 Implementation properties: C library -// - -/** @file cfloat +/** @file include/cfloat * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c float.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 18.2.2 Implementation properties: C library +// + #ifndef _GLIBCXX_CFLOAT #define _GLIBCXX_CFLOAT 1 diff --git a/contrib/libstdc++/include/c_std/std_ciso646.h b/contrib/libstdc++/include/c_std/std_ciso646.h index 0993a0a..3e391b4 100644 --- a/contrib/libstdc++/include/c_std/std_ciso646.h +++ b/contrib/libstdc++/include/c_std/std_ciso646.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -33,5 +33,6 @@ * * This is the C++ version of the Standard C Library header @c iso646.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ diff --git a/contrib/libstdc++/include/c_std/std_climits.h b/contrib/libstdc++/include/c_std/std_climits.h index f4e1d8f..e85869f 100644 --- a/contrib/libstdc++/include/c_std/std_climits.h +++ b/contrib/libstdc++/include/c_std/std_climits.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,19 +28,20 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 18.2.2 Implementation properties: C library -// - -/** @file climits +/** @file include/climits * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c limits.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 18.2.2 Implementation properties: C library +// + #ifndef _GLIBCXX_CLIMITS #define _GLIBCXX_CLIMITS 1 diff --git a/contrib/libstdc++/include/c_std/std_clocale.h b/contrib/libstdc++/include/c_std/std_clocale.h index 988b849..51e6440 100644 --- a/contrib/libstdc++/include/c_std/std_clocale.h +++ b/contrib/libstdc++/include/c_std/std_clocale.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,35 +28,38 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 18.2.2 Implementation properties: C library -// - /** @file clocale * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c locale.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 18.2.2 Implementation properties: C library +// + #ifndef _GLIBCXX_CLOCALE #define _GLIBCXX_CLOCALE 1 #pragma GCC system_header +#include #include // Get rid of those macros defined in in lieu of real functions. #undef setlocale #undef localeconv -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::lconv; using ::setlocale; using ::localeconv; -} + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/c_std/std_cmath.h b/contrib/libstdc++/include/c_std/std_cmath.h index 729f510..897290a 100644 --- a/contrib/libstdc++/include/c_std/std_cmath.h +++ b/contrib/libstdc++/include/c_std/std_cmath.h @@ -1,6 +1,6 @@ // -*- C++ -*- C forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,19 +28,20 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 26.5 C library -// - -/** @file cmath +/** @file include/cmath * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c math.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 26.5 C library +// + #ifndef _GLIBCXX_CMATH #define _GLIBCXX_CMATH 1 @@ -48,6 +49,7 @@ #include #include +#include #include @@ -77,9 +79,8 @@ #undef tan #undef tanh +_GLIBCXX_BEGIN_NAMESPACE(std) -namespace std -{ // Forward declaration of a helper function. This really should be // an `exported' forward declaration. template _Tp __cmath_power(_Tp, unsigned int); @@ -107,11 +108,10 @@ namespace std { return __builtin_acosl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type acos(_Tp __x) - { - return __builtin_acos(__x); - } + { return __builtin_acos(__x); } using ::asin; @@ -124,7 +124,8 @@ namespace std { return __builtin_asinl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type asin(_Tp __x) { return __builtin_asin(__x); } @@ -139,7 +140,8 @@ namespace std { return __builtin_atanl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type atan(_Tp __x) { return __builtin_atan(__x); } @@ -154,8 +156,9 @@ namespace std { return __builtin_atan2l(__y, __x); } template - inline typename __enable_if::_M_type - && __is_integer<_Up>::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value + && __is_integer<_Up>::__value, + double>::__type atan2(_Tp __y, _Up __x) { return __builtin_atan2(__y, __x); } @@ -170,7 +173,8 @@ namespace std { return __builtin_ceill(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type ceil(_Tp __x) { return __builtin_ceil(__x); } @@ -185,7 +189,8 @@ namespace std { return __builtin_cosl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type cos(_Tp __x) { return __builtin_cos(__x); } @@ -200,7 +205,8 @@ namespace std { return __builtin_coshl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type cosh(_Tp __x) { return __builtin_cosh(__x); } @@ -215,7 +221,8 @@ namespace std { return __builtin_expl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type exp(_Tp __x) { return __builtin_exp(__x); } @@ -230,7 +237,8 @@ namespace std { return __builtin_fabsl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type fabs(_Tp __x) { return __builtin_fabs(__x); } @@ -245,7 +253,8 @@ namespace std { return __builtin_floorl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type floor(_Tp __x) { return __builtin_floor(__x); } @@ -270,7 +279,8 @@ namespace std { return __builtin_frexpl(__x, __exp); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type frexp(_Tp __x, int* __exp) { return __builtin_frexp(__x, __exp); } @@ -285,7 +295,8 @@ namespace std { return __builtin_ldexpl(__x, __exp); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type ldexp(_Tp __x, int __exp) { return __builtin_ldexp(__x, __exp); } @@ -300,7 +311,8 @@ namespace std { return __builtin_logl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type log(_Tp __x) { return __builtin_log(__x); } @@ -315,7 +327,8 @@ namespace std { return __builtin_log10l(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type log10(_Tp __x) { return __builtin_log10(__x); } @@ -350,15 +363,15 @@ namespace std inline double pow(double __x, int __i) - { return __pow_helper(__x, __i); } + { return __builtin_powi(__x, __i); } inline float pow(float __x, int __n) - { return __pow_helper(__x, __n); } + { return __builtin_powif(__x, __n); } inline long double pow(long double __x, int __n) - { return __pow_helper(__x, __n); } + { return __builtin_powil(__x, __n); } using ::sin; @@ -371,7 +384,8 @@ namespace std { return __builtin_sinl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type sin(_Tp __x) { return __builtin_sin(__x); } @@ -386,7 +400,8 @@ namespace std { return __builtin_sinhl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type sinh(_Tp __x) { return __builtin_sinh(__x); } @@ -401,7 +416,8 @@ namespace std { return __builtin_sqrtl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type sqrt(_Tp __x) { return __builtin_sqrt(__x); } @@ -416,7 +432,8 @@ namespace std { return __builtin_tanl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type tan(_Tp __x) { return __builtin_tan(__x); } @@ -431,18 +448,21 @@ namespace std { return __builtin_tanhl(__x); } template - inline typename __enable_if::_M_type>::_M_type + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type tanh(_Tp __x) { return __builtin_tanh(__x); } -} + +_GLIBCXX_END_NAMESPACE #if _GLIBCXX_USE_C99_MATH #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC // These are possible macros imported from C99-land. For strict // conformance, remove possible C99-injected names from the global // namespace, and sequester them in the __gnu_cxx extension namespace. -namespace __gnu_cxx -{ + +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + template inline int __capture_fpclassify(_Tp __f) { return fpclassify(__f); } @@ -495,7 +515,8 @@ namespace __gnu_cxx inline int __capture_isunordered(_Tp __f1, _Tp __f2) { return isunordered(__f1, __f2); } -} + +_GLIBCXX_END_NAMESPACE // Only undefine the C99 FP macros, if actually captured for namespace movement #undef fpclassify @@ -510,81 +531,65 @@ namespace __gnu_cxx #undef islessequal #undef islessgreater #undef isunordered -#endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */ -#endif -#if _GLIBCXX_USE_C99_MATH -#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + template inline int - fpclassify(_Tp __f) { return __capture_fpclassify(__f); } + fpclassify(_Tp __f) { return ::__gnu_cxx::__capture_fpclassify(__f); } template inline int - isfinite(_Tp __f) { return __capture_isfinite(__f); } + isfinite(_Tp __f) { return ::__gnu_cxx::__capture_isfinite(__f); } template inline int - isinf(_Tp __f) { return __capture_isinf(__f); } + isinf(_Tp __f) { return ::__gnu_cxx::__capture_isinf(__f); } template inline int - isnan(_Tp __f) { return __capture_isnan(__f); } + isnan(_Tp __f) { return ::__gnu_cxx::__capture_isnan(__f); } template inline int - isnormal(_Tp __f) { return __capture_isnormal(__f); } + isnormal(_Tp __f) { return ::__gnu_cxx::__capture_isnormal(__f); } template inline int - signbit(_Tp __f) { return __capture_signbit(__f); } + signbit(_Tp __f) { return ::__gnu_cxx::__capture_signbit(__f); } template inline int - isgreater(_Tp __f1, _Tp __f2) { return __capture_isgreater(__f1, __f2); } + isgreater(_Tp __f1, _Tp __f2) + { return ::__gnu_cxx::__capture_isgreater(__f1, __f2); } template inline int isgreaterequal(_Tp __f1, _Tp __f2) - { return __capture_isgreaterequal(__f1, __f2); } + { return ::__gnu_cxx::__capture_isgreaterequal(__f1, __f2); } template inline int - isless(_Tp __f1, _Tp __f2) { return __capture_isless(__f1, __f2); } + isless(_Tp __f1, _Tp __f2) + { return ::__gnu_cxx::__capture_isless(__f1, __f2); } template inline int islessequal(_Tp __f1, _Tp __f2) - { return __capture_islessequal(__f1, __f2); } + { return ::__gnu_cxx::__capture_islessequal(__f1, __f2); } template inline int islessgreater(_Tp __f1, _Tp __f2) - { return __capture_islessgreater(__f1, __f2); } + { return ::__gnu_cxx::__capture_islessgreater(__f1, __f2); } template inline int isunordered(_Tp __f1, _Tp __f2) - { return __capture_isunordered(__f1, __f2); } -} - -namespace std -{ - using __gnu_cxx::fpclassify; - using __gnu_cxx::isfinite; - using __gnu_cxx::isinf; - using __gnu_cxx::isnan; - using __gnu_cxx::isnormal; - using __gnu_cxx::signbit; - using __gnu_cxx::isgreater; - using __gnu_cxx::isgreaterequal; - using __gnu_cxx::isless; - using __gnu_cxx::islessequal; - using __gnu_cxx::islessgreater; - using __gnu_cxx::isunordered; -} + { return ::__gnu_cxx::__capture_isunordered(__f1, __f2); } + +_GLIBCXX_END_NAMESPACE + #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */ #endif diff --git a/contrib/libstdc++/include/c_std/std_csetjmp.h b/contrib/libstdc++/include/c_std/std_csetjmp.h index d5fe073..946e7e3 100644 --- a/contrib/libstdc++/include/c_std/std_csetjmp.h +++ b/contrib/libstdc++/include/c_std/std_csetjmp.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,24 +28,26 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 20.4.6 C library -// - /** @file csetjmp * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c setjmp.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 20.4.6 C library +// + #ifndef _GLIBCXX_CSETJMP #define _GLIBCXX_CSETJMP 1 #pragma GCC system_header +#include #include // Get rid of those macros defined in in lieu of real functions. @@ -56,10 +58,11 @@ #define setjmp(env) setjmp (env) #endif -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::jmp_buf; using ::longjmp; -} + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/c_std/std_csignal.h b/contrib/libstdc++/include/c_std/std_csignal.h index 5734cf6..0ce5e2f 100644 --- a/contrib/libstdc++/include/c_std/std_csignal.h +++ b/contrib/libstdc++/include/c_std/std_csignal.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,34 +28,37 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 20.4.6 C library -// - /** @file csignal * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c signal.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 20.4.6 C library +// + #ifndef _GLIBCXX_CSIGNAL #define _GLIBCXX_CSIGNAL 1 #pragma GCC system_header +#include #include // Get rid of those macros defined in in lieu of real functions. #undef raise -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::sig_atomic_t; using ::signal; using ::raise; -} + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/c_std/std_cstdarg.h b/contrib/libstdc++/include/c_std/std_cstdarg.h index ca362e4..53c29c8 100644 --- a/contrib/libstdc++/include/c_std/std_cstdarg.h +++ b/contrib/libstdc++/include/c_std/std_cstdarg.h @@ -1,6 +1,7 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,24 +28,26 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 20.4.6 C library -// - -/** @file cstdarg +/** @file include/cstdarg * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c stdarg.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 20.4.6 C library +// + #ifndef _GLIBCXX_CSTDARG #define _GLIBCXX_CSTDARG 1 #pragma GCC system_header +#include #include // Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 @@ -52,9 +55,10 @@ #define va_end(ap) va_end (ap) #endif -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::va_list; -} + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/c_std/std_cstddef.h b/contrib/libstdc++/include/c_std/std_cstddef.h index 4fa82c6..bfa8388 100644 --- a/contrib/libstdc++/include/c_std/std_cstddef.h +++ b/contrib/libstdc++/include/c_std/std_cstddef.h @@ -1,6 +1,7 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,30 +28,33 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 18.1 Types -// - /** @file cstddef * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c stddef.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 18.1 Types +// + #ifndef _GLIBCXX_CSTDDEF #define _GLIBCXX_CSTDDEF 1 #pragma GCC system_header +#include #include -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::ptrdiff_t; using ::size_t; -} + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/c_std/std_cstdio.h b/contrib/libstdc++/include/c_std/std_cstdio.h index f31e58e..3935ef4 100644 --- a/contrib/libstdc++/include/c_std/std_cstdio.h +++ b/contrib/libstdc++/include/c_std/std_cstdio.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,19 +28,20 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 27.8.2 C Library files -// - -/** @file cstdio +/** @file include/cstdio * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c stdio.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 27.8.2 C Library files +// + #ifndef _GLIBCXX_CSTDIO #define _GLIBCXX_CSTDIO 1 @@ -94,8 +95,8 @@ #undef vprintf #undef vsprintf -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::FILE; using ::fpos_t; @@ -140,7 +141,8 @@ namespace std using ::vfprintf; using ::vprintf; using ::vsprintf; -} + +_GLIBCXX_END_NAMESPACE #if _GLIBCXX_USE_C99 @@ -150,19 +152,20 @@ namespace std #undef vsnprintf #undef vsscanf -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC extern "C" int - (snprintf)(char * restrict, size_t, const char * restrict, ...); + (snprintf)(char * restrict, size_t, const char * restrict, ...); extern "C" int - (vfscanf)(FILE * restrict, const char * restrict, __gnuc_va_list); + (vfscanf)(FILE * restrict, const char * restrict, __gnuc_va_list); extern "C" int (vscanf)(const char * restrict, __gnuc_va_list); extern "C" int - (vsnprintf)(char * restrict, size_t, const char * restrict, __gnuc_va_list); + (vsnprintf)(char * restrict, size_t, const char * restrict, __gnuc_va_list); extern "C" int - (vsscanf)(const char * restrict, const char * restrict, __gnuc_va_list); + (vsscanf)(const char * restrict, const char * restrict, __gnuc_va_list); #endif + #if !_GLIBCXX_USE_C99_DYNAMIC using ::snprintf; using ::vfscanf; @@ -170,16 +173,19 @@ namespace __gnu_cxx using ::vsnprintf; using ::vsscanf; #endif -} - -namespace std -{ - using __gnu_cxx::snprintf; - using __gnu_cxx::vfscanf; - using __gnu_cxx::vscanf; - using __gnu_cxx::vsnprintf; - using __gnu_cxx::vsscanf; -} + +_GLIBCXX_END_NAMESPACE + +_GLIBCXX_BEGIN_NAMESPACE(std) + + using ::__gnu_cxx::snprintf; + using ::__gnu_cxx::vfscanf; + using ::__gnu_cxx::vscanf; + using ::__gnu_cxx::vsnprintf; + using ::__gnu_cxx::vsscanf; + +_GLIBCXX_END_NAMESPACE + #endif #endif diff --git a/contrib/libstdc++/include/c_std/std_cstdlib.h b/contrib/libstdc++/include/c_std/std_cstdlib.h index d2d6e37..5c3d586 100644 --- a/contrib/libstdc++/include/c_std/std_cstdlib.h +++ b/contrib/libstdc++/include/c_std/std_cstdlib.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,19 +28,20 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 20.4.6 C library -// - -/** @file cstdlib +/** @file include/cstdlib * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c stdlib.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 20.4.6 C library +// + #ifndef _GLIBCXX_CSTDLIB #define _GLIBCXX_CSTDLIB 1 @@ -49,6 +50,25 @@ #include #include +#if !_GLIBCXX_HOSTED +// The C standard does not require a freestanding implementation to +// provide . However, the C++ standard does still require +// -- but only the functionality mentioned in +// [lib.support.start.term]. + +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 + +_GLIBCXX_BEGIN_NAMESPACE(std) + + extern "C" void abort(void); + extern "C" int atexit(void (*)()); + extern "C" void exit(int); + +_GLIBCXX_END_NAMESPACE + +#else + #include // Get rid of those macros defined in in lieu of real functions. @@ -81,8 +101,8 @@ #undef wcstombs #undef wctomb -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::div_t; using ::ldiv_t; @@ -124,7 +144,8 @@ namespace std inline ldiv_t div(long __i, long __j) { return ldiv(__i, __j); } -} + +_GLIBCXX_END_NAMESPACE #if _GLIBCXX_USE_C99 @@ -137,8 +158,8 @@ namespace std #undef strtof #undef strtold -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC using ::lldiv_t; #endif @@ -152,17 +173,14 @@ namespace __gnu_cxx inline long long abs(long long __x) { return __x >= 0 ? __x : -__x; } - inline long long - llabs(long long __x) { return __x >= 0 ? __x : -__x; } - #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::llabs; + inline lldiv_t div(long long __n, long long __d) { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } - inline lldiv_t - lldiv(long long __n, long long __d) - { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } + using ::lldiv; #endif #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC @@ -179,26 +197,31 @@ namespace __gnu_cxx #endif using ::strtof; using ::strtold; -} -namespace std -{ +_GLIBCXX_END_NAMESPACE + +_GLIBCXX_BEGIN_NAMESPACE(std) + #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC - using __gnu_cxx::lldiv_t; + using ::__gnu_cxx::lldiv_t; #endif - using __gnu_cxx::_Exit; - using __gnu_cxx::abs; - using __gnu_cxx::llabs; + using ::__gnu_cxx::_Exit; + using ::__gnu_cxx::abs; #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC - using __gnu_cxx::div; - using __gnu_cxx::lldiv; -#endif - using __gnu_cxx::atoll; - using __gnu_cxx::strtof; - using __gnu_cxx::strtoll; - using __gnu_cxx::strtoull; - using __gnu_cxx::strtold; -} + using ::__gnu_cxx::llabs; + using ::__gnu_cxx::div; + using ::__gnu_cxx::lldiv; #endif + using ::__gnu_cxx::atoll; + using ::__gnu_cxx::strtof; + using ::__gnu_cxx::strtoll; + using ::__gnu_cxx::strtoull; + using ::__gnu_cxx::strtold; + +_GLIBCXX_END_NAMESPACE + +#endif // _GLIBCXX_USE_C99 + +#endif // !_GLIBCXX_HOSTED #endif diff --git a/contrib/libstdc++/include/c_std/std_cstring.h b/contrib/libstdc++/include/c_std/std_cstring.h index dad40c2..5fef6b0 100644 --- a/contrib/libstdc++/include/c_std/std_cstring.h +++ b/contrib/libstdc++/include/c_std/std_cstring.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,26 +28,27 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 20.4.6 C library -// - /** @file cstring * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c string.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 20.4.6 C library +// + #ifndef _GLIBCXX_CSTRING #define _GLIBCXX_CSTRING 1 #pragma GCC system_header +#include #include - #include // Get rid of those macros defined in in lieu of real functions. @@ -74,8 +75,8 @@ #undef strerror #undef strlen -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::memcpy; using ::memmove; using ::strcpy; @@ -123,6 +124,7 @@ namespace std inline char* strstr(char* __s1, const char* __s2) { return __builtin_strstr(const_cast(__s1), __s2); } -} + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/c_std/std_ctime.h b/contrib/libstdc++/include/c_std/std_ctime.h index fe890df..9f7f15c 100644 --- a/contrib/libstdc++/include/c_std/std_ctime.h +++ b/contrib/libstdc++/include/c_std/std_ctime.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,26 +28,26 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 20.5 Date and time -// - -/** @file ctime +/** @file include/ctime * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c time.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 20.5 Date and time +// + #ifndef _GLIBCXX_CTIME #define _GLIBCXX_CTIME 1 #pragma GCC system_header #include - #include // Get rid of those macros defined in in lieu of real functions. @@ -61,8 +61,8 @@ #undef localtime #undef strftime -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::clock_t; using ::time_t; using ::tm; @@ -76,6 +76,7 @@ namespace std using ::gmtime; using ::localtime; using ::strftime; -} + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/c_std/std_cwchar.h b/contrib/libstdc++/include/c_std/std_cwchar.h index d9e11e9..20cb804 100644 --- a/contrib/libstdc++/include/c_std/std_cwchar.h +++ b/contrib/libstdc++/include/c_std/std_cwchar.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,19 +28,20 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: 21.4 -// - -/** @file cwchar +/** @file include/cwchar * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c wchar.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: 21.4 +// + #ifndef _GLIBCXX_CWCHAR #define _GLIBCXX_CWCHAR 1 @@ -66,10 +67,11 @@ extern "C" } #endif -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::mbstate_t; -} + +_GLIBCXX_END_NAMESPACE // Get rid of those macros defined in in lieu of real functions. #undef btowc @@ -138,8 +140,9 @@ namespace std #undef wscanf #if _GLIBCXX_USE_WCHAR_T -namespace std -{ + +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::wint_t; using ::btowc; @@ -211,7 +214,7 @@ namespace std using ::wcspbrk; inline wchar_t* - wcspbrk(wchar_t* __s1, wchar_t* __s2) + wcspbrk(wchar_t* __s1, const wchar_t* __s2) { return wcspbrk(const_cast(__s1), __s2); } using ::wcsrchr; @@ -231,7 +234,8 @@ namespace std inline wchar_t* wmemchr(wchar_t* __p, wchar_t __c, size_t __n) { return wmemchr(const_cast(__p), __c, __n); } -} + +_GLIBCXX_END_NAMESPACE #if _GLIBCXX_USE_C99 @@ -239,8 +243,8 @@ namespace std #undef wcstoll #undef wcstoull -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC extern "C" long double (wcstold)(const wchar_t * restrict, wchar_t ** restrict); @@ -258,14 +262,17 @@ namespace __gnu_cxx using ::wcstoll; using ::wcstoull; #endif -} -namespace std -{ - using __gnu_cxx::wcstold; - using __gnu_cxx::wcstoll; - using __gnu_cxx::wcstoull; -} +_GLIBCXX_END_NAMESPACE + +_GLIBCXX_BEGIN_NAMESPACE(std) + + using ::__gnu_cxx::wcstold; + using ::__gnu_cxx::wcstoll; + using ::__gnu_cxx::wcstoull; + +_GLIBCXX_END_NAMESPACE + #endif #endif //_GLIBCXX_USE_WCHAR_T diff --git a/contrib/libstdc++/include/c_std/std_cwctype.h b/contrib/libstdc++/include/c_std/std_cwctype.h index 970c53a..dd0032f 100644 --- a/contrib/libstdc++/include/c_std/std_cwctype.h +++ b/contrib/libstdc++/include/c_std/std_cwctype.h @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,19 +28,20 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -// -// ISO C++ 14882: -// - -/** @file cwctype +/** @file include/cwctype * This is a Standard C++ Library file. You should @c #include this file * in your programs, rather than any of the "*.h" implementation files. * * This is the C++ version of the Standard C Library header @c wctype.h, * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. + * contained in the namespace @c std (except for names which are defined + * as macros in C). */ +// +// ISO C++ 14882: +// + #ifndef _GLIBCXX_CWCTYPE #define _GLIBCXX_CWCTYPE 1 @@ -59,25 +60,25 @@ # undef iswblank #endif #undef iswcntrl +#undef iswctype #undef iswdigit #undef iswgraph #undef iswlower #undef iswprint -#undef iswprint #undef iswpunct #undef iswspace #undef iswupper #undef iswxdigit -#undef iswctype +#undef towctrans #undef towlower #undef towupper -#undef towctrans #undef wctrans #undef wctype #if _GLIBCXX_USE_WCHAR_T -namespace std -{ + +_GLIBCXX_BEGIN_NAMESPACE(std) + using ::wint_t; // cwchar using ::wctype_t; @@ -89,22 +90,23 @@ namespace std using ::iswblank; #endif using ::iswcntrl; + using ::iswctype; using ::iswdigit; using ::iswgraph; using ::iswlower; using ::iswprint; - using ::iswprint; using ::iswpunct; using ::iswspace; using ::iswupper; using ::iswxdigit; - using ::iswctype; + using ::towctrans; using ::towlower; using ::towupper; - using ::towctrans; using ::wctrans; using ::wctype; -} + +_GLIBCXX_END_NAMESPACE + #endif //_GLIBCXX_USE_WCHAR_T #endif diff --git a/contrib/libstdc++/include/debug/bitset b/contrib/libstdc++/include/debug/bitset index 2e2364f..58d4e6b 100644 --- a/contrib/libstdc++/include/debug/bitset +++ b/contrib/libstdc++/include/debug/bitset @@ -1,6 +1,6 @@ // Debugging bitset implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/bitset + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_BITSET #define _GLIBCXX_DEBUG_BITSET @@ -35,7 +39,9 @@ #include #include -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template class bitset @@ -68,7 +74,7 @@ namespace __gnu_debug_def operator=(bool __x) { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_write) + _M_message(__gnu_debug::__msg_bad_bitset_write) ._M_iterator(*this)); *static_cast<_Base_ref*>(this) = __x; return *this; @@ -78,10 +84,10 @@ namespace __gnu_debug_def operator=(const reference& __x) { _GLIBCXX_DEBUG_VERIFY(! __x._M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_read) + _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(__x)); _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_write) + _M_message(__gnu_debug::__msg_bad_bitset_write) ._M_iterator(*this)); *static_cast<_Base_ref*>(this) = __x; return *this; @@ -91,7 +97,7 @@ namespace __gnu_debug_def operator~() const { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_read) + _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(*this)); return ~(*static_cast(this)); } @@ -99,7 +105,7 @@ namespace __gnu_debug_def operator bool() const { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_read) + _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(*this)); return *static_cast(this); } @@ -108,7 +114,7 @@ namespace __gnu_debug_def flip() { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), - _M_message(::__gnu_debug::__msg_bad_bitset_flip) + _M_message(__gnu_debug::__msg_bad_bitset_flip) ._M_iterator(*this)); _Base_ref::flip(); return *this; @@ -239,6 +245,28 @@ namespace __gnu_debug_def to_string() const { return _M_base().template to_string<_CharT, _Traits, _Allocator>(); } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 434. bitset::to_string() hard to use. + template + std::basic_string<_CharT, _Traits, std::allocator<_CharT> > + to_string() const + { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); } + + template + std::basic_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> > + to_string() const + { + return to_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> >(); + } + + std::basic_string, std::allocator > + to_string() const + { + return to_string,std::allocator >(); + } + using _Base::count; using _Base::size; @@ -294,6 +322,7 @@ namespace __gnu_debug_def operator<<(std::basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x) { return __os << __x._M_base(); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/debug.h b/contrib/libstdc++/include/debug/debug.h index 87bbcfa..b914a2c 100644 --- a/contrib/libstdc++/include/debug/debug.h +++ b/contrib/libstdc++/include/debug/debug.h @@ -1,6 +1,6 @@ // Debugging support implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,504 +28,118 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#ifndef _GLIBCXX_DEBUG_DEBUG_H -#define _GLIBCXX_DEBUG_DEBUG_H 1 - -/** - * Macros used by the implementation to verify certain - * properties. These macros may only be used directly by the debug - * wrappers. Note that these are macros (instead of the more obviously - * "correct" choice of making them functions) because we need line and - * file information at the call site, to minimize the distance between - * the user error and where the error is reported. - * +/** @file debug/debug.h + * This file is a GNU debug extension to the Standard C++ Library. */ -#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \ - do { \ - if (! (_Condition)) \ - ::__gnu_debug::_Error_formatter::_M_at(__FILE__, __LINE__) \ - ._ErrorMessage._M_error(); \ - } while (false) - -// Verify that [_First, _Last) forms a valid iterator range. -#define __glibcxx_check_valid_range(_First,_Last) \ -_GLIBCXX_DEBUG_VERIFY(::__gnu_debug::__valid_range(_First, _Last), \ - _M_message(::__gnu_debug::__msg_valid_range) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last)) -/** Verify that we can insert into *this with the iterator _Position. - * Insertion into a container at a specific position requires that - * the iterator be nonsingular (i.e., either dereferenceable or - * past-the-end) and that it reference the sequence we are inserting - * into. Note that this macro is only valid when the container is a - * _Safe_sequence and the iterator is a _Safe_iterator. -*/ -#define __glibcxx_check_insert(_Position) \ -_GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ - _M_message(::__gnu_debug::__msg_insert_singular) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)); \ -_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ - _M_message(::__gnu_debug::__msg_insert_different) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)) - -/** Verify that we can insert the values in the iterator range - * [_First, _Last) into *this with the iterator _Position. Insertion - * into a container at a specific position requires that the iterator - * be nonsingular (i.e., either dereferenceable or past-the-end), - * that it reference the sequence we are inserting into, and that the - * iterator range [_First, Last) is a valid (possibly empty) - * range. Note that this macro is only valid when the container is a - * _Safe_sequence and the iterator is a _Safe_iterator. - * - * @tbd We would like to be able to check for noninterference of - * _Position and the range [_First, _Last), but that can't (in - * general) be done. -*/ -#define __glibcxx_check_insert_range(_Position,_First,_Last) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ - _M_message(::__gnu_debug::__msg_insert_singular) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)); \ -_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ - _M_message(::__gnu_debug::__msg_insert_different) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)) +#ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H +#define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1 -/** Verify that we can erase the element referenced by the iterator - * _Position. We can erase the element if the _Position iterator is - * dereferenceable and references this sequence. +/** Macros and namespaces used by the implementation outside of debug + * wrappers to verify certain properties. The __glibcxx_requires_xxx + * macros are merely wrappers around the __glibcxx_check_xxx wrappers + * when we are compiling with debug mode, but disappear when we are + * in release mode so that there is no checking performed in, e.g., + * the standard library algorithms. */ -#define __glibcxx_check_erase(_Position) \ -_GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \ - _M_message(::__gnu_debug::__msg_erase_bad) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)); \ -_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ - _M_message(::__gnu_debug::__msg_erase_different) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_Position, #_Position)) - -/** Verify that we can erase the elements in the iterator range - * [_First, _Last). We can erase the elements if [_First, _Last) is a - * valid iterator range within this sequence. -*/ -#define __glibcxx_check_erase_range(_First,_Last) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \ - _M_message(::__gnu_debug::__msg_erase_different) \ - ._M_sequence(*this, "this") \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last)) - -// Verify that the subscript _N is less than the container's size. -#define __glibcxx_check_subscript(_N) \ -_GLIBCXX_DEBUG_VERIFY(_N < this->size(), \ - _M_message(::__gnu_debug::__msg_subscript_oob) \ - ._M_sequence(*this, "this") \ - ._M_integer(_N, #_N) \ - ._M_integer(this->size(), "size")) - -// Verify that the container is nonempty -#define __glibcxx_check_nonempty() \ -_GLIBCXX_DEBUG_VERIFY(! this->empty(), \ - _M_message(::__gnu_debug::__msg_empty) \ - ._M_sequence(*this, "this")) - -// Verify that the < operator for elements in the sequence is a -// StrictWeakOrdering by checking that it is irreflexive. -#define __glibcxx_check_strict_weak_ordering(_First,_Last) \ -_GLIBCXX_DEBUG_ASSERT(_First == _Last || !(*_First < *_First)) -// Verify that the predicate is StrictWeakOrdering by checking that it -// is irreflexive. -#define __glibcxx_check_strict_weak_ordering_pred(_First,_Last,_Pred) \ -_GLIBCXX_DEBUG_ASSERT(_First == _Last || !_Pred(*_First, *_First)) +// Debug mode namespaces. +namespace std +{ + namespace __debug { } +} +namespace __gnu_cxx +{ + namespace __debug { }; +} -// Verify that the iterator range [_First, _Last) is sorted -#define __glibcxx_check_sorted(_First,_Last) \ -__glibcxx_check_valid_range(_First,_Last); \ -__glibcxx_check_strict_weak_ordering(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(::__gnu_debug::__check_sorted(_First, _Last), \ - _M_message(::__gnu_debug::__msg_unsorted) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last)) - -/** Verify that the iterator range [_First, _Last) is sorted by the - predicate _Pred. */ -#define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \ -__glibcxx_check_valid_range(_First,_Last); \ -__glibcxx_check_strict_weak_ordering_pred(_First,_Last,_Pred); \ -_GLIBCXX_DEBUG_VERIFY(::__gnu_debug::__check_sorted(_First, _Last, _Pred), \ - _M_message(::__gnu_debug::__msg_unsorted_pred) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last) \ - ._M_string(#_Pred)) - -/** Verify that the iterator range [_First, _Last) is partitioned - w.r.t. the value _Value. */ -#define __glibcxx_check_partitioned(_First,_Last,_Value) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(::__gnu_debug::__check_partitioned(_First, _Last, \ - _Value), \ - _M_message(::__gnu_debug::__msg_unpartitioned) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last) \ - ._M_string(#_Value)) +namespace __gnu_debug +{ + using namespace std::__debug; + using namespace __gnu_cxx::__debug; +} + +#ifndef _GLIBCXX_DEBUG + +# define _GLIBCXX_DEBUG_ASSERT(_Condition) +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) +# define _GLIBCXX_DEBUG_ONLY(_Statement) ; +# define __glibcxx_requires_cond(_Cond,_Msg) +# define __glibcxx_requires_valid_range(_First,_Last) +# define __glibcxx_requires_sorted(_First,_Last) +# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) +# define __glibcxx_requires_partitioned(_First,_Last,_Value) +# define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred) +# define __glibcxx_requires_heap(_First,_Last) +# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) +# define __glibcxx_requires_nonempty() +# define __glibcxx_requires_string(_String) +# define __glibcxx_requires_string_len(_String,_Len) +# define __glibcxx_requires_subscript(_N) -/** Verify that the iterator range [_First, _Last) is partitioned - w.r.t. the value _Value and predicate _Pred. */ -#define __glibcxx_check_partitioned_pred(_First,_Last,_Value,_Pred) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(::__gnu_debug::__check_partitioned(_First, _Last, \ - _Value, _Pred), \ - _M_message(::__gnu_debug::__msg_unpartitioned_pred) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last) \ - ._M_string(#_Pred) \ - ._M_string(#_Value)) +#else -// Verify that the iterator range [_First, _Last) is a heap -#define __glibcxx_check_heap(_First,_Last) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(::std::__is_heap(_First, _Last), \ - _M_message(::__gnu_debug::__msg_not_heap) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last)) +# include +# include +# include -/** Verify that the iterator range [_First, _Last) is a heap - w.r.t. the predicate _Pred. */ -#define __glibcxx_check_heap_pred(_First,_Last,_Pred) \ -__glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(::std::__is_heap(_First, _Last, _Pred), \ - _M_message(::__gnu_debug::__msg_not_heap_pred) \ - ._M_iterator(_First, #_First) \ - ._M_iterator(_Last, #_Last) \ - ._M_string(#_Pred)) +namespace std +{ + namespace __debug + { + // Avoid the use of assert, because we're trying to keep the + // include out of the mix. + inline void + __replacement_assert(const char* __file, int __line, + const char* __function, const char* __condition) + { + printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line, + __function, __condition); + abort(); + } + } // namespace __debug +} // namespace std + +#define _GLIBCXX_DEBUG_ASSERT(_Condition) \ + do \ + { \ + if (! (_Condition)) \ + std::__debug::__replacement_assert(__FILE__, __LINE__, \ + __PRETTY_FUNCTION__, #_Condition); \ + } while (false) #ifdef _GLIBCXX_DEBUG_PEDANTIC -# define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0) -# define __glibcxx_check_string_len(_String,_Len) \ - _GLIBCXX_DEBUG_ASSERT(_String != 0 || _Len == 0) +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition) #else -# define __glibcxx_check_string(_String) -# define __glibcxx_check_string_len(_String,_Len) +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) #endif +# define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement -/** Macros used by the implementation outside of debug wrappers to - * verify certain properties. The __glibcxx_requires_xxx macros are - * merely wrappers around the __glibcxx_check_xxx wrappers when we - * are compiling with debug mode, but disappear when we are in - * release mode so that there is no checking performed in, e.g., the - * standard library algorithms. -*/ -#ifdef _GLIBCXX_DEBUG -# define _GLIBCXX_DEBUG_ASSERT(_Condition) assert(_Condition) - -# ifdef _GLIBXX_DEBUG_PEDANTIC -# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) assert(_Condition) -# else -# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) -# endif - -# define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) -# define __glibcxx_requires_valid_range(_First,_Last) \ +# define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) +# define __glibcxx_requires_valid_range(_First,_Last) \ __glibcxx_check_valid_range(_First,_Last) -# define __glibcxx_requires_sorted(_First,_Last) \ +# define __glibcxx_requires_sorted(_First,_Last) \ __glibcxx_check_sorted(_First,_Last) -# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \ +# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \ __glibcxx_check_sorted_pred(_First,_Last,_Pred) -# define __glibcxx_requires_partitioned(_First,_Last,_Value) \ +# define __glibcxx_requires_partitioned(_First,_Last,_Value) \ __glibcxx_check_partitioned(_First,_Last,_Value) -# define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred) \ +# define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred) \ __glibcxx_check_partitioned_pred(_First,_Last,_Value,_Pred) -# define __glibcxx_requires_heap(_First,_Last) \ +# define __glibcxx_requires_heap(_First,_Last) \ __glibcxx_check_heap(_First,_Last) -# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \ +# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \ __glibcxx_check_heap_pred(_First,_Last,_Pred) -# define __glibcxx_requires_nonempty() __glibcxx_check_nonempty() -# define __glibcxx_requires_string(_String) __glibcxx_check_string(_String) -# define __glibcxx_requires_string_len(_String,_Len) \ +# define __glibcxx_requires_nonempty() __glibcxx_check_nonempty() +# define __glibcxx_requires_string(_String) __glibcxx_check_string(_String) +# define __glibcxx_requires_string_len(_String,_Len) \ __glibcxx_check_string_len(_String,_Len) -# define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N) -#else -# define _GLIBCXX_DEBUG_ASSERT(_Condition) -# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) -# define __glibcxx_requires_cond(_Cond,_Msg) -# define __glibcxx_requires_valid_range(_First,_Last) -# define __glibcxx_requires_sorted(_First,_Last) -# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) -# define __glibcxx_requires_partitioned(_First,_Last,_Value) -# define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred) -# define __glibcxx_requires_heap(_First,_Last) -# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) -# define __glibcxx_requires_nonempty() -# define __glibcxx_requires_string(_String) -# define __glibcxx_requires_string_len(_String,_Len) -# define __glibcxx_requires_subscript(_N) -#endif - -#include // TBD: temporary - -#include // for ptrdiff_t -#include // for iterator_traits, categories -#include // for _Is_integer - -namespace __gnu_debug -{ - template - class _Safe_iterator; - - // An arbitrary iterator pointer is not singular. - inline bool - __check_singular_aux(const void*) { return false; } - - // We may have an iterator that derives from _Safe_iterator_base but isn't - // a _Safe_iterator. - template - inline bool - __check_singular(_Iterator& __x) - { return __gnu_debug::__check_singular_aux(&__x); } - - /** Non-NULL pointers are nonsingular. */ - template - inline bool - __check_singular(const _Tp* __ptr) - { return __ptr == 0; } - - /** Safe iterators know if they are singular. */ - template - inline bool - __check_singular(const _Safe_iterator<_Iterator, _Sequence>& __x) - { return __x._M_singular(); } - - /** Assume that some arbitrary iterator is dereferenceable, because we - can't prove that it isn't. */ - template - inline bool - __check_dereferenceable(_Iterator&) - { return true; } - - /** Non-NULL pointers are dereferenceable. */ - template - inline bool - __check_dereferenceable(const _Tp* __ptr) - { return __ptr; } - - /** Safe iterators know if they are singular. */ - template - inline bool - __check_dereferenceable(const _Safe_iterator<_Iterator, _Sequence>& __x) - { return __x._M_dereferenceable(); } - - /** If the distance between two random access iterators is - * nonnegative, assume the range is valid. - */ - template - inline bool - __valid_range_aux2(const _RandomAccessIterator& __first, - const _RandomAccessIterator& __last, - std::random_access_iterator_tag) - { return __last - __first >= 0; } - - /** Can't test for a valid range with input iterators, because - * iteration may be destructive. So we just assume that the range - * is valid. - */ - template - inline bool - __valid_range_aux2(const _InputIterator&, const _InputIterator&, - std::input_iterator_tag) - { return true; } - - /** We say that integral types for a valid range, and defer to other - * routines to realize what to do with integral types instead of - * iterators. - */ - template - inline bool - __valid_range_aux(const _Integral&, const _Integral&, __true_type) - { return true; } - - /** We have iterators, so figure out what kind of iterators that are - * to see if we can check the range ahead of time. - */ - template - inline bool - __valid_range_aux(const _InputIterator& __first, - const _InputIterator& __last, __false_type) - { - typedef typename std::iterator_traits<_InputIterator>::iterator_category - _Category; - return __gnu_debug::__valid_range_aux2(__first, __last, _Category()); - } +# define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N) - /** Don't know what these iterators are, or if they are even - * iterators (we may get an integral type for InputIterator), so - * see if they are integral and pass them on to the next phase - * otherwise. - */ - template - inline bool - __valid_range(const _InputIterator& __first, const _InputIterator& __last) - { - typedef typename _Is_integer<_InputIterator>::_Integral _Integral; - return __gnu_debug::__valid_range_aux(__first, __last, _Integral()); - } - - /** Safe iterators know how to check if they form a valid range. */ - template - inline bool - __valid_range(const _Safe_iterator<_Iterator, _Sequence>& __first, - const _Safe_iterator<_Iterator, _Sequence>& __last) - { return __first._M_valid_range(__last); } - - /* Checks that [first, last) is a valid range, and then returns - * __first. This routine is useful when we can't use a separate - * assertion statement because, e.g., we are in a constructor. - */ - template - inline _InputIterator - __check_valid_range(const _InputIterator& __first, - const _InputIterator& __last) - { - _GLIBCXX_DEBUG_ASSERT(__gnu_debug::__valid_range(__first, __last)); - return __first; - } +# include +# include - /** Checks that __s is non-NULL or __n == 0, and then returns __s. */ - template - inline const _CharT* - __check_string(const _CharT* __s, const _Integer& __n) - { -#ifdef _GLIBCXX_DEBUG_PEDANTIC - _GLIBCXX_DEBUG_ASSERT(__s != 0 || __n == 0); #endif - return __s; - } - - /** Checks that __s is non-NULL and then returns __s. */ - template - inline const _CharT* - __check_string(const _CharT* __s) - { -#ifdef _GLIBCXX_DEBUG_PEDANTIC - _GLIBCXX_DEBUG_ASSERT(__s != 0); -#endif - return __s; - } - - // Can't check if an input iterator sequence is sorted, because we - // can't step through the sequence. - template - inline bool - __check_sorted_aux(const _InputIterator&, const _InputIterator&, - std::input_iterator_tag) - { return true; } - - // Can verify if a forward iterator sequence is in fact sorted using - // std::__is_sorted - template - inline bool - __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last, - std::forward_iterator_tag) - { - if (__first == __last) - return true; - - _ForwardIterator __next = __first; - for (++__next; __next != __last; __first = __next, ++__next) { - if (*__next < *__first) - return false; - } - - return true; - } - - // Can't check if an input iterator sequence is sorted, because we can't step - // through the sequence. - template - inline bool - __check_sorted_aux(const _InputIterator&, const _InputIterator&, - _Predicate, std::input_iterator_tag) - { return true; } - // Can verify if a forward iterator sequence is in fact sorted using - // std::__is_sorted - template - inline bool - __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last, - _Predicate __pred, std::forward_iterator_tag) - { - if (__first == __last) - return true; - - _ForwardIterator __next = __first; - for (++__next; __next != __last; __first = __next, ++__next) { - if (__pred(*__next, *__first)) - return false; - } - - return true; - } - - // Determine if a sequence is sorted. - template - inline bool - __check_sorted(const _InputIterator& __first, const _InputIterator& __last) - { - typedef typename std::iterator_traits<_InputIterator>::iterator_category - _Category; - return __gnu_debug::__check_sorted_aux(__first, __last, _Category()); - } - - template - inline bool - __check_sorted(const _InputIterator& __first, const _InputIterator& __last, - _Predicate __pred) - { - typedef typename std::iterator_traits<_InputIterator>::iterator_category - _Category; - return __gnu_debug::__check_sorted_aux(__first, __last, __pred, - _Category()); - } - - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 270. Binary search requirements overly strict - // Determine if a sequence is partitioned w.r.t. this element. - template - inline bool - __check_partitioned(_ForwardIterator __first, _ForwardIterator __last, - const _Tp& __value) - { - while (__first != __last && *__first < __value) - ++__first; - while (__first != __last && !(*__first < __value)) - ++__first; - return __first == __last; - } - - // Determine if a sequence is partitioned w.r.t. this element. - template - inline bool - __check_partitioned(_ForwardIterator __first, _ForwardIterator __last, - const _Tp& __value, _Pred __pred) - { - while (__first != __last && __pred(*__first, __value)) - ++__first; - while (__first != __last && !__pred(*__first, __value)) - ++__first; - return __first == __last; - } -} // namespace __gnu_debug - -#ifdef _GLIBCXX_DEBUG -// We need the error formatter -# include -#endif - -#endif +#endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H diff --git a/contrib/libstdc++/include/debug/deque b/contrib/libstdc++/include/debug/deque index c39a49c..79142d9 100644 --- a/contrib/libstdc++/include/debug/deque +++ b/contrib/libstdc++/include/debug/deque @@ -1,6 +1,6 @@ // Debugging deque implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/deque + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_DEQUE #define _GLIBCXX_DEBUG_DEQUE 1 @@ -35,7 +39,9 @@ #include #include -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template > class deque @@ -46,8 +52,8 @@ namespace __gnu_debug_def typedef __gnu_debug::_Safe_sequence _Safe_base; public: - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator iterator; @@ -59,8 +65,8 @@ namespace __gnu_debug_def typedef _Tp value_type; typedef _Allocator allocator_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; @@ -381,6 +387,7 @@ namespace __gnu_debug_def inline void swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/formatter.h b/contrib/libstdc++/include/debug/formatter.h index db555b0..8975285 100644 --- a/contrib/libstdc++/include/debug/formatter.h +++ b/contrib/libstdc++/include/debug/formatter.h @@ -1,7 +1,6 @@ // Debug-mode error formatting implementation -*- C++ -*- -// Copyright (C) 2003, 2004 -// Free Software Foundation, Inc. +// Copyright (C) 2003, 2004, 2005, 2006 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 @@ -16,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +27,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/formatter.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_FORMATTER_H #define _GLIBCXX_DEBUG_FORMATTER_H 1 @@ -310,7 +313,7 @@ namespace __gnu_debug const _Error_formatter& _M_iterator(const _Iterator& __it, const char* __name = 0) const { - if (_M_num_parameters < __max_parameters) + if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__it, __name, _Is_iterator()); return *this; @@ -319,7 +322,7 @@ namespace __gnu_debug const _Error_formatter& _M_integer(long __value, const char* __name = 0) const { - if (_M_num_parameters < __max_parameters) + if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__value, __name); return *this; } @@ -327,7 +330,7 @@ namespace __gnu_debug const _Error_formatter& _M_string(const char* __value, const char* __name = 0) const { - if (_M_num_parameters < __max_parameters) + if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__value, __name); return *this; } @@ -336,7 +339,7 @@ namespace __gnu_debug const _Error_formatter& _M_sequence(const _Sequence& __seq, const char* __name = 0) const { - if (_M_num_parameters < __max_parameters) + if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__seq, __name, _Is_sequence()); return *this; diff --git a/contrib/libstdc++/include/debug/functions.h b/contrib/libstdc++/include/debug/functions.h new file mode 100644 index 0000000..a61c0b9 --- /dev/null +++ b/contrib/libstdc++/include/debug/functions.h @@ -0,0 +1,293 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003, 2005, 2006 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file debug/functions.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_FUNCTIONS_H +#define _GLIBCXX_DEBUG_FUNCTIONS_H 1 + +#include +#include // for ptrdiff_t +#include // for iterator_traits, categories +#include // for __is_integer + +namespace __gnu_debug +{ + template + class _Safe_iterator; + + // An arbitrary iterator pointer is not singular. + inline bool + __check_singular_aux(const void*) { return false; } + + // We may have an iterator that derives from _Safe_iterator_base but isn't + // a _Safe_iterator. + template + inline bool + __check_singular(_Iterator& __x) + { return __check_singular_aux(&__x); } + + /** Non-NULL pointers are nonsingular. */ + template + inline bool + __check_singular(const _Tp* __ptr) + { return __ptr == 0; } + + /** Safe iterators know if they are singular. */ + template + inline bool + __check_singular(const _Safe_iterator<_Iterator, _Sequence>& __x) + { return __x._M_singular(); } + + /** Assume that some arbitrary iterator is dereferenceable, because we + can't prove that it isn't. */ + template + inline bool + __check_dereferenceable(_Iterator&) + { return true; } + + /** Non-NULL pointers are dereferenceable. */ + template + inline bool + __check_dereferenceable(const _Tp* __ptr) + { return __ptr; } + + /** Safe iterators know if they are singular. */ + template + inline bool + __check_dereferenceable(const _Safe_iterator<_Iterator, _Sequence>& __x) + { return __x._M_dereferenceable(); } + + /** If the distance between two random access iterators is + * nonnegative, assume the range is valid. + */ + template + inline bool + __valid_range_aux2(const _RandomAccessIterator& __first, + const _RandomAccessIterator& __last, + std::random_access_iterator_tag) + { return __last - __first >= 0; } + + /** Can't test for a valid range with input iterators, because + * iteration may be destructive. So we just assume that the range + * is valid. + */ + template + inline bool + __valid_range_aux2(const _InputIterator&, const _InputIterator&, + std::input_iterator_tag) + { return true; } + + /** We say that integral types for a valid range, and defer to other + * routines to realize what to do with integral types instead of + * iterators. + */ + template + inline bool + __valid_range_aux(const _Integral&, const _Integral&, std::__true_type) + { return true; } + + /** We have iterators, so figure out what kind of iterators that are + * to see if we can check the range ahead of time. + */ + template + inline bool + __valid_range_aux(const _InputIterator& __first, + const _InputIterator& __last, std::__false_type) + { + typedef typename std::iterator_traits<_InputIterator>::iterator_category + _Category; + return __valid_range_aux2(__first, __last, _Category()); + } + + /** Don't know what these iterators are, or if they are even + * iterators (we may get an integral type for InputIterator), so + * see if they are integral and pass them on to the next phase + * otherwise. + */ + template + inline bool + __valid_range(const _InputIterator& __first, const _InputIterator& __last) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + return __valid_range_aux(__first, __last, _Integral()); + } + + /** Safe iterators know how to check if they form a valid range. */ + template + inline bool + __valid_range(const _Safe_iterator<_Iterator, _Sequence>& __first, + const _Safe_iterator<_Iterator, _Sequence>& __last) + { return __first._M_valid_range(__last); } + + /* Checks that [first, last) is a valid range, and then returns + * __first. This routine is useful when we can't use a separate + * assertion statement because, e.g., we are in a constructor. + */ + template + inline _InputIterator + __check_valid_range(const _InputIterator& __first, + const _InputIterator& __last + __attribute__((__unused__))) + { + _GLIBCXX_DEBUG_ASSERT(__valid_range(__first, __last)); + return __first; + } + + /** Checks that __s is non-NULL or __n == 0, and then returns __s. */ + template + inline const _CharT* + __check_string(const _CharT* __s, + const _Integer& __n __attribute__((__unused__))) + { +#ifdef _GLIBCXX_DEBUG_PEDANTIC + _GLIBCXX_DEBUG_ASSERT(__s != 0 || __n == 0); +#endif + return __s; + } + + /** Checks that __s is non-NULL and then returns __s. */ + template + inline const _CharT* + __check_string(const _CharT* __s) + { +#ifdef _GLIBCXX_DEBUG_PEDANTIC + _GLIBCXX_DEBUG_ASSERT(__s != 0); +#endif + return __s; + } + + // Can't check if an input iterator sequence is sorted, because we + // can't step through the sequence. + template + inline bool + __check_sorted_aux(const _InputIterator&, const _InputIterator&, + std::input_iterator_tag) + { return true; } + + // Can verify if a forward iterator sequence is in fact sorted using + // std::__is_sorted + template + inline bool + __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + if (__first == __last) + return true; + + _ForwardIterator __next = __first; + for (++__next; __next != __last; __first = __next, ++__next) { + if (*__next < *__first) + return false; + } + + return true; + } + + // Can't check if an input iterator sequence is sorted, because we can't step + // through the sequence. + template + inline bool + __check_sorted_aux(const _InputIterator&, const _InputIterator&, + _Predicate, std::input_iterator_tag) + { return true; } + + // Can verify if a forward iterator sequence is in fact sorted using + // std::__is_sorted + template + inline bool + __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred, std::forward_iterator_tag) + { + if (__first == __last) + return true; + + _ForwardIterator __next = __first; + for (++__next; __next != __last; __first = __next, ++__next) { + if (__pred(*__next, *__first)) + return false; + } + + return true; + } + + // Determine if a sequence is sorted. + template + inline bool + __check_sorted(const _InputIterator& __first, const _InputIterator& __last) + { + typedef typename std::iterator_traits<_InputIterator>::iterator_category + _Category; + return __check_sorted_aux(__first, __last, _Category()); + } + + template + inline bool + __check_sorted(const _InputIterator& __first, const _InputIterator& __last, + _Predicate __pred) + { + typedef typename std::iterator_traits<_InputIterator>::iterator_category + _Category; + return __check_sorted_aux(__first, __last, __pred, + _Category()); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 270. Binary search requirements overly strict + // Determine if a sequence is partitioned w.r.t. this element. + template + inline bool + __check_partitioned(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value) + { + while (__first != __last && *__first < __value) + ++__first; + while (__first != __last && !(*__first < __value)) + ++__first; + return __first == __last; + } + + // Determine if a sequence is partitioned w.r.t. this element. + template + inline bool + __check_partitioned(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value, _Pred __pred) + { + while (__first != __last && __pred(*__first, __value)) + ++__first; + while (__first != __last && !__pred(*__first, __value)) + ++__first; + return __first == __last; + } +} // namespace __gnu_debug + +#endif diff --git a/contrib/libstdc++/include/debug/hash_map b/contrib/libstdc++/include/debug/hash_map index 570a9af..f44586b 100644 --- a/contrib/libstdc++/include/debug/hash_map +++ b/contrib/libstdc++/include/debug/hash_map @@ -1,6 +1,6 @@ // Debugging hash_map/hash_multimap implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,11 +28,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_map + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_MAP #define _GLIBCXX_DEBUG_HASH_MAP 1 -#include -#include -#include +#include +#include +#include #endif diff --git a/contrib/libstdc++/include/debug/hash_map.h b/contrib/libstdc++/include/debug/hash_map.h index c2cd7b8..1eb6acb 100644 --- a/contrib/libstdc++/include/debug/hash_map.h +++ b/contrib/libstdc++/include/debug/hash_map.h @@ -1,6 +1,6 @@ // Debugging hash_map implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,24 +28,30 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_map.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_MAP_H #define _GLIBCXX_DEBUG_HASH_MAP_H 1 #include #include -namespace __gnu_debug_def +namespace __gnu_cxx +{ +namespace __debug { template, typename _EqualKey = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value> > class hash_map - : public __gnu_cxx::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>, + : public _GLIBCXX_EXT::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>, public __gnu_debug::_Safe_sequence > { - typedef __gnu_cxx::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc> + typedef _GLIBCXX_EXT::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc> _Base; typedef __gnu_debug::_Safe_sequence _Safe_base; @@ -139,7 +145,14 @@ namespace __gnu_debug_def return std::make_pair(iterator(__res.first, this), __res.second); } - template + void + insert(const value_type* __first, const value_type* __last) + { + __glibcxx_check_valid_range(__first, __last); + _Base::insert(__first, __last); + } + + template void insert(_InputIterator __first, _InputIterator __last) { @@ -265,6 +278,7 @@ namespace __gnu_debug_def swap(hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x, hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y) { __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace __gnu_cxx #endif diff --git a/contrib/libstdc++/include/debug/hash_multimap.h b/contrib/libstdc++/include/debug/hash_multimap.h index 83b4425..e3c689a 100644 --- a/contrib/libstdc++/include/debug/hash_multimap.h +++ b/contrib/libstdc++/include/debug/hash_multimap.h @@ -1,6 +1,6 @@ // Debugging hash_multimap implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,24 +28,30 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_multimap.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_MULTIMAP_H #define _GLIBCXX_DEBUG_HASH_MULTIMAP_H 1 #include #include -namespace __gnu_debug_def +namespace __gnu_cxx +{ +namespace __debug { template, typename _EqualKey = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value> > class hash_multimap - : public __gnu_cxx::hash_multimap<_Value,_Tp,_HashFcn, _EqualKey,_Alloc>, + : public _GLIBCXX_EXT::hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc>, public __gnu_debug::_Safe_sequence > { - typedef __gnu_cxx::hash_multimap<_Value,_Tp,_HashFcn, _EqualKey,_Alloc> + typedef _GLIBCXX_EXT::hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc> _Base; typedef __gnu_debug::_Safe_sequence _Safe_base; @@ -179,7 +185,7 @@ namespace __gnu_debug_def erase(const key_type& __key) { std::pair __victims = this->equal_range(__key); - size_t __num_victims = 0; + std::size_t __num_victims = 0; while (__victims.first != __victims.second) { this->erase(__victims.first++); @@ -256,6 +262,7 @@ namespace __gnu_debug_def swap(hash_multimap<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x, hash_multimap<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y) { __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace __gnu_cxx #endif diff --git a/contrib/libstdc++/include/debug/hash_multiset.h b/contrib/libstdc++/include/debug/hash_multiset.h index 705d8da..9346496 100644 --- a/contrib/libstdc++/include/debug/hash_multiset.h +++ b/contrib/libstdc++/include/debug/hash_multiset.h @@ -1,6 +1,6 @@ // Debugging hash_multiset implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,24 +28,30 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_multiset.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_MULTISET_H #define _GLIBCXX_DEBUG_HASH_MULTISET_H 1 #include #include -namespace __gnu_debug_def +namespace __gnu_cxx +{ +namespace __debug { template, typename _EqualKey = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value> > class hash_multiset - : public __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>, + : public _GLIBCXX_EXT::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>, public __gnu_debug::_Safe_sequence > { - typedef __gnu_cxx:: hash_multiset<_Value,_HashFcn, _EqualKey,_Alloc> + typedef _GLIBCXX_EXT:: hash_multiset<_Value,_HashFcn, _EqualKey,_Alloc> _Base; typedef __gnu_debug::_Safe_sequence _Safe_base; @@ -231,6 +237,7 @@ template& __x, hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __y) { __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace __gnu_cxx #endif diff --git a/contrib/libstdc++/include/debug/hash_set b/contrib/libstdc++/include/debug/hash_set index 282cba2..4b98fef 100644 --- a/contrib/libstdc++/include/debug/hash_set +++ b/contrib/libstdc++/include/debug/hash_set @@ -1,6 +1,6 @@ // Debugging hash_set/hash_multiset implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,11 +28,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_set + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_SET #define _GLIBCXX_DEBUG_HASH_SET 1 -#include -#include -#include +#include +#include +#include #endif diff --git a/contrib/libstdc++/include/debug/hash_set.h b/contrib/libstdc++/include/debug/hash_set.h index 0f56d88..2d3e0b3 100644 --- a/contrib/libstdc++/include/debug/hash_set.h +++ b/contrib/libstdc++/include/debug/hash_set.h @@ -1,6 +1,6 @@ // Debugging hash_set implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,24 +28,30 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/hash_set.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_HASH_SET_H #define _GLIBCXX_DEBUG_HASH_SET_H 1 #include #include -namespace __gnu_debug_def +namespace __gnu_cxx +{ +namespace __debug { template, typename _EqualKey = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value> > class hash_set - : public __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc>, + : public _GLIBCXX_EXT::hash_set<_Value, _HashFcn, _EqualKey,_Alloc>, public __gnu_debug::_Safe_sequence > { - typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Base; + typedef _GLIBCXX_EXT::hash_set<_Value, _HashFcn, _EqualKey,_Alloc> _Base; typedef __gnu_debug::_Safe_sequence _Safe_base; public: @@ -129,7 +135,14 @@ namespace __gnu_debug_def return std::make_pair(iterator(__res.first, this), __res.second); } - template + void + insert(const value_type* __first, const value_type* __last) + { + __glibcxx_check_valid_range(__first, __last); + _Base::insert(__first, __last); + } + + template void insert(_InputIterator __first, _InputIterator __last) { @@ -240,6 +253,7 @@ namespace __gnu_debug_def swap(hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __x, hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __y) { __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace __gnu_cxx #endif diff --git a/contrib/libstdc++/include/debug/list b/contrib/libstdc++/include/debug/list index 556c9d9..939fe4d 100644 --- a/contrib/libstdc++/include/debug/list +++ b/contrib/libstdc++/include/debug/list @@ -1,6 +1,6 @@ // Debugging list implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,37 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file debug/list + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_LIST #define _GLIBCXX_DEBUG_LIST 1 @@ -36,7 +67,9 @@ #include #include -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template > class list @@ -47,8 +80,8 @@ namespace __gnu_debug_def typedef __gnu_debug::_Safe_sequence _Safe_base; public: - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator iterator; @@ -60,8 +93,8 @@ namespace __gnu_debug_def typedef _Tp value_type; typedef _Allocator allocator_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; @@ -296,7 +329,7 @@ namespace __gnu_debug_def splice(iterator __position, list& __x) { _GLIBCXX_DEBUG_VERIFY(&__x != this, - _M_message(::__gnu_debug::__msg_self_splice) + _M_message(__gnu_debug::__msg_self_splice) ._M_sequence(*this, "this")); this->splice(__position, __x, __x.begin(), __x.end()); } @@ -305,14 +338,15 @@ namespace __gnu_debug_def splice(iterator __position, list& __x, iterator __i) { __glibcxx_check_insert(__position); - _GLIBCXX_DEBUG_VERIFY(__x.get_allocator() == this->get_allocator(), - _M_message(::__gnu_debug::__msg_splice_alloc) - ._M_sequence(*this)._M_sequence(__x, "__x")); + + // We used to perform the splice_alloc check: not anymore, redundant + // after implementing the relevant bits of N1599. + _GLIBCXX_DEBUG_VERIFY(__i._M_dereferenceable(), - _M_message(::__gnu_debug::__msg_splice_bad) + _M_message(__gnu_debug::__msg_splice_bad) ._M_iterator(__i, "__i")); _GLIBCXX_DEBUG_VERIFY(__i._M_attached_to(&__x), - _M_message(::__gnu_debug::__msg_splice_other) + _M_message(__gnu_debug::__msg_splice_other) ._M_iterator(__i, "__i")._M_sequence(__x, "__x")); // _GLIBCXX_RESOLVE_LIB_DEFECTS @@ -327,17 +361,17 @@ namespace __gnu_debug_def __glibcxx_check_insert(__position); __glibcxx_check_valid_range(__first, __last); _GLIBCXX_DEBUG_VERIFY(__first._M_attached_to(&__x), - _M_message(::__gnu_debug::__msg_splice_other) + _M_message(__gnu_debug::__msg_splice_other) ._M_sequence(__x, "x") ._M_iterator(__first, "first")); - _GLIBCXX_DEBUG_VERIFY(__x.get_allocator() == this->get_allocator(), - _M_message(::__gnu_debug::__msg_splice_alloc) - ._M_sequence(*this)._M_sequence(__x)); + + // We used to perform the splice_alloc check: not anymore, redundant + // after implementing the relevant bits of N1599. for (iterator __tmp = __first; __tmp != __last; ) { _GLIBCXX_DEBUG_VERIFY(&__x != this || __tmp != __position, - _M_message(::__gnu_debug::__msg_splice_overlap) + _M_message(__gnu_debug::__msg_splice_overlap) ._M_iterator(__tmp, "position") ._M_iterator(__first, "first") ._M_iterator(__last, "last")); @@ -500,6 +534,7 @@ namespace __gnu_debug_def inline void swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/macros.h b/contrib/libstdc++/include/debug/macros.h new file mode 100644 index 0000000..ce40919 --- /dev/null +++ b/contrib/libstdc++/include/debug/macros.h @@ -0,0 +1,224 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003, 2005, 2006 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file debug/macros.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_MACROS_H +#define _GLIBCXX_DEBUG_MACROS_H 1 + +/** + * Macros used by the implementation to verify certain + * properties. These macros may only be used directly by the debug + * wrappers. Note that these are macros (instead of the more obviously + * "correct" choice of making them functions) because we need line and + * file information at the call site, to minimize the distance between + * the user error and where the error is reported. + * + */ +#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \ + do \ + { \ + if (! (_Condition)) \ + __gnu_debug::_Error_formatter::_M_at(__FILE__, __LINE__) \ + ._ErrorMessage._M_error(); \ + } while (false) + +// Verify that [_First, _Last) forms a valid iterator range. +#define __glibcxx_check_valid_range(_First,_Last) \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \ + _M_message(__gnu_debug::__msg_valid_range) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +/** Verify that we can insert into *this with the iterator _Position. + * Insertion into a container at a specific position requires that + * the iterator be nonsingular (i.e., either dereferenceable or + * past-the-end) and that it reference the sequence we are inserting + * into. Note that this macro is only valid when the container is a + * _Safe_sequence and the iterator is a _Safe_iterator. +*/ +#define __glibcxx_check_insert(_Position) \ +_GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ + _M_message(__gnu_debug::__msg_insert_singular) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)); \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_insert_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)) + +/** Verify that we can insert the values in the iterator range + * [_First, _Last) into *this with the iterator _Position. Insertion + * into a container at a specific position requires that the iterator + * be nonsingular (i.e., either dereferenceable or past-the-end), + * that it reference the sequence we are inserting into, and that the + * iterator range [_First, Last) is a valid (possibly empty) + * range. Note that this macro is only valid when the container is a + * _Safe_sequence and the iterator is a _Safe_iterator. + * + * @tbd We would like to be able to check for noninterference of + * _Position and the range [_First, _Last), but that can't (in + * general) be done. +*/ +#define __glibcxx_check_insert_range(_Position,_First,_Last) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ + _M_message(__gnu_debug::__msg_insert_singular) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)); \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_insert_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)) + +/** Verify that we can erase the element referenced by the iterator + * _Position. We can erase the element if the _Position iterator is + * dereferenceable and references this sequence. +*/ +#define __glibcxx_check_erase(_Position) \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \ + _M_message(__gnu_debug::__msg_erase_bad) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)); \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_erase_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)) + +/** Verify that we can erase the elements in the iterator range + * [_First, _Last). We can erase the elements if [_First, _Last) is a + * valid iterator range within this sequence. +*/ +#define __glibcxx_check_erase_range(_First,_Last) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_erase_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +// Verify that the subscript _N is less than the container's size. +#define __glibcxx_check_subscript(_N) \ +_GLIBCXX_DEBUG_VERIFY(_N < this->size(), \ + _M_message(__gnu_debug::__msg_subscript_oob) \ + ._M_sequence(*this, "this") \ + ._M_integer(_N, #_N) \ + ._M_integer(this->size(), "size")) + +// Verify that the container is nonempty +#define __glibcxx_check_nonempty() \ +_GLIBCXX_DEBUG_VERIFY(! this->empty(), \ + _M_message(__gnu_debug::__msg_empty) \ + ._M_sequence(*this, "this")) + +// Verify that the < operator for elements in the sequence is a +// StrictWeakOrdering by checking that it is irreflexive. +#define __glibcxx_check_strict_weak_ordering(_First,_Last) \ +_GLIBCXX_DEBUG_ASSERT(_First == _Last || !(*_First < *_First)) + +// Verify that the predicate is StrictWeakOrdering by checking that it +// is irreflexive. +#define __glibcxx_check_strict_weak_ordering_pred(_First,_Last,_Pred) \ +_GLIBCXX_DEBUG_ASSERT(_First == _Last || !_Pred(*_First, *_First)) + + +// Verify that the iterator range [_First, _Last) is sorted +#define __glibcxx_check_sorted(_First,_Last) \ +__glibcxx_check_valid_range(_First,_Last); \ +__glibcxx_check_strict_weak_ordering(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last), \ + _M_message(__gnu_debug::__msg_unsorted) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +/** Verify that the iterator range [_First, _Last) is sorted by the + predicate _Pred. */ +#define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \ +__glibcxx_check_valid_range(_First,_Last); \ +__glibcxx_check_strict_weak_ordering_pred(_First,_Last,_Pred); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \ + _M_message(__gnu_debug::__msg_unsorted_pred) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Pred)) + +/** Verify that the iterator range [_First, _Last) is partitioned + w.r.t. the value _Value. */ +#define __glibcxx_check_partitioned(_First,_Last,_Value) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned(_First, _Last, \ + _Value), \ + _M_message(__gnu_debug::__msg_unpartitioned) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Value)) + +/** Verify that the iterator range [_First, _Last) is partitioned + w.r.t. the value _Value and predicate _Pred. */ +#define __glibcxx_check_partitioned_pred(_First,_Last,_Value,_Pred) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned(_First, _Last, \ + _Value, _Pred), \ + _M_message(__gnu_debug::__msg_unpartitioned_pred) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Pred) \ + ._M_string(#_Value)) + +// Verify that the iterator range [_First, _Last) is a heap +#define __glibcxx_check_heap(_First,_Last) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last), \ + _M_message(__gnu_debug::__msg_not_heap) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +/** Verify that the iterator range [_First, _Last) is a heap + w.r.t. the predicate _Pred. */ +#define __glibcxx_check_heap_pred(_First,_Last,_Pred) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last, _Pred), \ + _M_message(__gnu_debug::__msg_not_heap_pred) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Pred)) + +#ifdef _GLIBCXX_DEBUG_PEDANTIC +# define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0) +# define __glibcxx_check_string_len(_String,_Len) \ + _GLIBCXX_DEBUG_ASSERT(_String != 0 || _Len == 0) +#else +# define __glibcxx_check_string(_String) +# define __glibcxx_check_string_len(_String,_Len) +#endif + +#endif diff --git a/contrib/libstdc++/include/debug/map b/contrib/libstdc++/include/debug/map index 2c38404..2435154 100644 --- a/contrib/libstdc++/include/debug/map +++ b/contrib/libstdc++/include/debug/map @@ -1,6 +1,6 @@ // Debugging map/multimap implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/map + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_MAP #define _GLIBCXX_DEBUG_MAP 1 diff --git a/contrib/libstdc++/include/debug/map.h b/contrib/libstdc++/include/debug/map.h index 0171584..96591ca 100644 --- a/contrib/libstdc++/include/debug/map.h +++ b/contrib/libstdc++/include/debug/map.h @@ -1,6 +1,6 @@ // Debugging map implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/map.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_MAP_H #define _GLIBCXX_DEBUG_MAP_H 1 @@ -35,7 +39,9 @@ #include #include -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template, typename _Allocator = std::allocator > > @@ -53,8 +59,8 @@ namespace __gnu_debug_def typedef std::pair value_type; typedef _Compare key_compare; typedef _Allocator allocator_type; - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator iterator; @@ -63,8 +69,8 @@ namespace __gnu_debug_def typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; @@ -142,6 +148,10 @@ namespace __gnu_debug_def // 23.3.1.2 element access: using _Base::operator[]; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + using _Base::at; + // modifiers: std::pair insert(const value_type& __x) @@ -318,6 +328,7 @@ namespace __gnu_debug_def swap(map<_Key,_Tp,_Compare,_Allocator>& __lhs, map<_Key,_Tp,_Compare,_Allocator>& __rhs) { __lhs.swap(__rhs); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/multimap.h b/contrib/libstdc++/include/debug/multimap.h index 4de1e3b..cbd6704 100644 --- a/contrib/libstdc++/include/debug/multimap.h +++ b/contrib/libstdc++/include/debug/multimap.h @@ -1,6 +1,6 @@ // Debugging multimap implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/multimap.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_MULTIMAP_H #define _GLIBCXX_DEBUG_MULTIMAP_H 1 @@ -35,7 +39,9 @@ #include #include -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template, typename _Allocator = std::allocator > > @@ -53,8 +59,8 @@ namespace __gnu_debug_def typedef std::pair value_type; typedef _Compare key_compare; typedef _Allocator allocator_type; - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator iterator; @@ -63,8 +69,8 @@ namespace __gnu_debug_def typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; @@ -309,6 +315,7 @@ namespace __gnu_debug_def swap(multimap<_Key,_Tp,_Compare,_Allocator>& __lhs, multimap<_Key,_Tp,_Compare,_Allocator>& __rhs) { __lhs.swap(__rhs); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/multiset.h b/contrib/libstdc++/include/debug/multiset.h index 92042fe..a37099e 100644 --- a/contrib/libstdc++/include/debug/multiset.h +++ b/contrib/libstdc++/include/debug/multiset.h @@ -1,6 +1,6 @@ // Debugging multiset implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/multiset.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_MULTISET_H #define _GLIBCXX_DEBUG_MULTISET_H 1 @@ -35,7 +39,9 @@ #include #include -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template, typename _Allocator = std::allocator<_Key> > @@ -53,8 +59,8 @@ namespace __gnu_debug_def typedef _Compare key_compare; typedef _Compare value_compare; typedef _Allocator allocator_type; - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator iterator; @@ -63,8 +69,8 @@ namespace __gnu_debug_def typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; @@ -315,6 +321,7 @@ namespace __gnu_debug_def swap(multiset<_Key,_Compare,_Allocator>& __x, multiset<_Key,_Compare,_Allocator>& __y) { return __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/safe_base.h b/contrib/libstdc++/include/debug/safe_base.h index a1af33a..2d26f57 100644 --- a/contrib/libstdc++/include/debug/safe_base.h +++ b/contrib/libstdc++/include/debug/safe_base.h @@ -1,6 +1,6 @@ // Safe sequence/iterator base implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,9 +28,15 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/safe_base.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_SAFE_BASE_H #define _GLIBCXX_DEBUG_SAFE_BASE_H 1 +#include + namespace __gnu_debug { class _Safe_sequence_base; @@ -103,6 +109,9 @@ namespace __gnu_debug ~_Safe_iterator_base() { this->_M_detach(); } + /** For use in _Safe_iterator. */ + __gnu_cxx::__mutex& _M_get_mutex(); + public: /** Attaches this iterator to the given sequence, detaching it * from whatever sequence it was attached to originally. If the @@ -111,11 +120,17 @@ namespace __gnu_debug */ void _M_attach(_Safe_sequence_base* __seq, bool __constant); + /** Likewise, but not thread-safe. */ + void _M_attach_single(_Safe_sequence_base* __seq, bool __constant); + /** Detach the iterator for whatever sequence it is attached to, * if any. */ void _M_detach(); + /** Likewise, but not thread-safe. */ + void _M_detach_single(); + /** Determines if we are attached to the given sequence. */ bool _M_attached_to(const _Safe_sequence_base* __seq) const { return _M_sequence == __seq; } @@ -196,6 +211,9 @@ namespace __gnu_debug void _M_swap(_Safe_sequence_base& __x); + /** For use in _Safe_sequence. */ + __gnu_cxx::__mutex& _M_get_mutex(); + public: /** Invalidates all iterators. */ void diff --git a/contrib/libstdc++/include/debug/safe_iterator.h b/contrib/libstdc++/include/debug/safe_iterator.h index 8a4123a..3d8ba59 100644 --- a/contrib/libstdc++/include/debug/safe_iterator.h +++ b/contrib/libstdc++/include/debug/safe_iterator.h @@ -1,6 +1,6 @@ // Safe iterator implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,25 +28,29 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/safe_iterator.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_H #define _GLIBCXX_DEBUG_SAFE_ITERATOR_H 1 -#include #include +#include +#include #include #include -#include +#include +#include namespace __gnu_debug { - using std::iterator_traits; - using std::pair; - /** Iterators that derive from _Safe_iterator_base but that aren't * _Safe_iterators can be determined singular or non-singular via * _Safe_iterator_base. */ - inline bool __check_singular_aux(const _Safe_iterator_base* __x) + inline bool + __check_singular_aux(const _Safe_iterator_base* __x) { return __x->_M_singular(); } /** \brief Safe iterator wrapper. @@ -86,7 +90,7 @@ namespace __gnu_debug return __is_same::value; } - typedef iterator_traits<_Iterator> _Traits; + typedef std::iterator_traits<_Iterator> _Traits; public: typedef _Iterator _Base_iterator; @@ -136,11 +140,9 @@ namespace __gnu_debug template _Safe_iterator( const _Safe_iterator<_MutableIterator, - typename std::__enable_if< - _Sequence, - (std::__are_same<_MutableIterator, - typename _Sequence::iterator::_Base_iterator>::_M_type) - >::_M_type>& __x) + typename __gnu_cxx::__enable_if<(std::__are_same<_MutableIterator, + typename _Sequence::iterator::_Base_iterator>::__value), + _Sequence>::__type>& __x) : _Safe_iterator_base(__x, _M_constant()), _M_current(__x.base()) { _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(), @@ -323,10 +325,22 @@ namespace __gnu_debug _M_constant()); } + /** Likewise, but not thread-safe. */ + void + _M_attach_single(const _Sequence* __seq) + { + _Safe_iterator_base::_M_attach_single(const_cast<_Sequence*>(__seq), + _M_constant()); + } + /** Invalidate the iterator, making it singular. */ void _M_invalidate(); + /** Likewise, but not thread-safe. */ + void + _M_invalidate_single(); + /// Is the iterator dereferenceable? bool _M_dereferenceable() const @@ -358,16 +372,16 @@ namespace __gnu_debug * precision. */ template - static pair + static std::pair _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs) { - typedef typename iterator_traits<_Iterator1>::iterator_category + typedef typename std::iterator_traits<_Iterator1>::iterator_category _Category; return _M_get_distance(__lhs, __rhs, _Category()); } template - static pair + static std::pair _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs, std::random_access_iterator_tag) { @@ -375,7 +389,7 @@ namespace __gnu_debug } template - static pair + static std::pair _M_get_distance(const _Iterator1& __lhs, const _Iterator2& __rhs, std::forward_iterator_tag) { @@ -604,6 +618,22 @@ namespace __gnu_debug return __lhs.base() - __rhs.base(); } + template + inline typename _Safe_iterator<_Iterator, _Sequence>::difference_type + operator-(const _Safe_iterator<_Iterator, _Sequence>& __lhs, + const _Safe_iterator<_Iterator, _Sequence>& __rhs) + { + _GLIBCXX_DEBUG_VERIFY(! __lhs._M_singular() && ! __rhs._M_singular(), + _M_message(__msg_distance_bad) + ._M_iterator(__lhs, "lhs") + ._M_iterator(__rhs, "rhs")); + _GLIBCXX_DEBUG_VERIFY(__lhs._M_can_compare(__rhs), + _M_message(__msg_distance_different) + ._M_iterator(__lhs, "lhs") + ._M_iterator(__rhs, "rhs")); + return __lhs.base() - __rhs.base(); + } + template inline _Safe_iterator<_Iterator, _Sequence> operator+(typename _Safe_iterator<_Iterator,_Sequence>::difference_type __n, diff --git a/contrib/libstdc++/include/debug/safe_iterator.tcc b/contrib/libstdc++/include/debug/safe_iterator.tcc index cede969..d23e90f 100644 --- a/contrib/libstdc++/include/debug/safe_iterator.tcc +++ b/contrib/libstdc++/include/debug/safe_iterator.tcc @@ -1,6 +1,6 @@ // Debugging iterator implementation (out of line) -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,9 +28,8 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -/** @file safe_iterator.tcc - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. +/** @file debug/safe_iterator.tcc + * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_TCC @@ -53,7 +52,7 @@ namespace __gnu_debug { const_iterator __begin = static_cast(_M_sequence)->begin(); - pair __dist = + std::pair __dist = this->_M_get_distance(__begin, *this); bool __ok = (__dist.second == __dp_exact && __dist.first >= -__n || __dist.second != __dp_exact && __dist.first > 0); @@ -63,7 +62,7 @@ namespace __gnu_debug { const_iterator __end = static_cast(_M_sequence)->end(); - pair __dist = + std::pair __dist = this->_M_get_distance(*this, __end); bool __ok = (__dist.second == __dp_exact && __dist.first >= __n || __dist.second != __dp_exact && __dist.first > 0); @@ -82,7 +81,7 @@ namespace __gnu_debug /* Determine if we can order the iterators without the help of the container */ - pair __dist = + std::pair __dist = this->_M_get_distance(*this, __rhs); switch (__dist.second) { case __dp_equality: @@ -111,24 +110,33 @@ namespace __gnu_debug _Safe_iterator<_Iterator, _Sequence>:: _M_invalidate() { + __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); + _M_invalidate_single(); + } + + template + void + _Safe_iterator<_Iterator, _Sequence>:: + _M_invalidate_single() + { typedef typename _Sequence::iterator iterator; typedef typename _Sequence::const_iterator const_iterator; if (!this->_M_singular()) { - for (_Safe_iterator_base* iter = _M_sequence->_M_iterators; iter; ) + for (_Safe_iterator_base* __iter = _M_sequence->_M_iterators; + __iter; __iter = __iter->_M_next) { - iterator* __victim = static_cast(iter); - iter = iter->_M_next; + iterator* __victim = static_cast(__iter); if (this->base() == __victim->base()) __victim->_M_version = 0; } - for (_Safe_iterator_base* iter2 = _M_sequence->_M_const_iterators; - iter2; /* increment in loop */) + + for (_Safe_iterator_base* __iter2 = _M_sequence->_M_const_iterators; + __iter2; __iter2 = __iter2->_M_next) { - const_iterator* __victim = static_cast(iter2); - iter2 = iter2->_M_next; - if (this->base() == __victim->base()) + const_iterator* __victim = static_cast(__iter2); + if (__victim->base() == this->base()) __victim->_M_version = 0; } _M_version = 0; diff --git a/contrib/libstdc++/include/debug/safe_sequence.h b/contrib/libstdc++/include/debug/safe_sequence.h index f050530..b5d6cce 100644 --- a/contrib/libstdc++/include/debug/safe_sequence.h +++ b/contrib/libstdc++/include/debug/safe_sequence.h @@ -1,6 +1,6 @@ // Safe sequence implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,10 +28,16 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/safe_sequence.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_SAFE_SEQUENCE_H #define _GLIBCXX_DEBUG_SAFE_SEQUENCE_H 1 #include +#include +#include #include namespace __gnu_debug @@ -122,27 +128,28 @@ namespace __gnu_debug typedef typename _Sequence::iterator iterator; typedef typename _Sequence::const_iterator const_iterator; - for (_Safe_iterator_base* __iter = _M_iterators; __iter; ) - { - iterator* __victim = static_cast(__iter); - __iter = __iter->_M_next; - if (!__victim->_M_singular()) - { - if (__pred(__victim->base())) - __victim->_M_invalidate(); - } - } - - for (_Safe_iterator_base* __iter2 = _M_const_iterators; __iter2; ) - { - const_iterator* __victim = static_cast(__iter2); - __iter2 = __iter2->_M_next; - if (!__victim->_M_singular()) - { - if (__pred(__victim->base())) - __victim->_M_invalidate(); - } - } + __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); + for (_Safe_iterator_base* __iter = _M_iterators; __iter;) + { + iterator* __victim = static_cast(__iter); + __iter = __iter->_M_next; + if (!__victim->_M_singular()) + { + if (__pred(__victim->base())) + __victim->_M_invalidate_single(); + } + } + + for (_Safe_iterator_base* __iter2 = _M_const_iterators; __iter2;) + { + const_iterator* __victim = static_cast(__iter2); + __iter2 = __iter2->_M_next; + if (!__victim->_M_singular()) + { + if (__pred(__victim->base())) + __victim->_M_invalidate_single(); + } + } } template @@ -158,22 +165,23 @@ namespace __gnu_debug typedef typename _Sequence::iterator iterator; typedef typename _Sequence::const_iterator const_iterator; - for (_Safe_iterator_base* __iter = __from->_M_iterators; __iter; ) - { - iterator* __victim = static_cast(__iter); - __iter = __iter->_M_next; - if (!__victim->_M_singular() && __victim->base() == __x.base()) - __victim->_M_attach(static_cast<_Sequence*>(this)); - } + __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); + for (_Safe_iterator_base* __iter = __from->_M_iterators; __iter;) + { + iterator* __victim = static_cast(__iter); + __iter = __iter->_M_next; + if (!__victim->_M_singular() && __victim->base() == __x.base()) + __victim->_M_attach_single(static_cast<_Sequence*>(this)); + } for (_Safe_iterator_base* __iter2 = __from->_M_const_iterators; __iter2;) - { - const_iterator* __victim = static_cast(__iter2); - __iter2 = __iter2->_M_next; - if (!__victim->_M_singular() && __victim->base() == __x.base()) - __victim->_M_attach(static_cast<_Sequence*>(this)); - } + { + const_iterator* __victim = static_cast(__iter2); + __iter2 = __iter2->_M_next; + if (!__victim->_M_singular() && __victim->base() == __x.base()) + __victim->_M_attach_single(static_cast<_Sequence*>(this)); + } } } // namespace __gnu_debug diff --git a/contrib/libstdc++/include/debug/set b/contrib/libstdc++/include/debug/set index a1a69ef..e5f4e37 100644 --- a/contrib/libstdc++/include/debug/set +++ b/contrib/libstdc++/include/debug/set @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/set + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_SET #define _GLIBCXX_DEBUG_SET 1 diff --git a/contrib/libstdc++/include/debug/set.h b/contrib/libstdc++/include/debug/set.h index 8656cb0..6c2ce9f 100644 --- a/contrib/libstdc++/include/debug/set.h +++ b/contrib/libstdc++/include/debug/set.h @@ -1,6 +1,6 @@ // Debugging set implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/set.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_SET_H #define _GLIBCXX_DEBUG_SET_H 1 @@ -35,7 +39,9 @@ #include #include -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template, typename _Allocator = std::allocator<_Key> > @@ -53,8 +59,8 @@ namespace __gnu_debug_def typedef _Compare key_compare; typedef _Compare value_compare; typedef _Allocator allocator_type; - typedef typename _Allocator::reference reference; - typedef typename _Allocator::const_reference const_reference; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator iterator; @@ -63,8 +69,8 @@ namespace __gnu_debug_def typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; @@ -320,6 +326,7 @@ namespace __gnu_debug_def swap(set<_Key,_Compare,_Allocator>& __x, set<_Key,_Compare,_Allocator>& __y) { return __x.swap(__y); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/debug/string b/contrib/libstdc++/include/debug/string index a91c004e9..070ca1f 100644 --- a/contrib/libstdc++/include/debug/string +++ b/contrib/libstdc++/include/debug/string @@ -1,6 +1,6 @@ // Debugging string implementation -*- C++ -*- -// Copyright (C) 2003 +// Copyright (C) 2003, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,6 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/string + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_STRING #define _GLIBCXX_DEBUG_STRING 1 @@ -37,7 +41,8 @@ namespace __gnu_debug { - template + template, + typename _Allocator = std::allocator<_CharT> > class basic_string : public std::basic_string<_CharT, _Traits, _Allocator>, public __gnu_debug::_Safe_sequence iterator; @@ -203,7 +208,7 @@ namespace __gnu_debug operator[](size_type __pos) const { _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(), - _M_message(::__gnu_debug::__msg_subscript_oob) + _M_message(__gnu_debug::__msg_subscript_oob) ._M_sequence(*this, "this") ._M_integer(__pos, "__pos") ._M_integer(this->size(), "size")); @@ -213,7 +218,16 @@ namespace __gnu_debug reference operator[](size_type __pos) { +#ifdef _GLIBCXX_DEBUG_PEDANTIC __glibcxx_check_subscript(__pos); +#else + // as an extension v3 allows s[s.size()] when s is non-const. + _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(), + _M_message(__gnu_debug::__msg_subscript_oob) + ._M_sequence(*this, "this") + ._M_integer(__pos, "__pos") + ._M_integer(this->size(), "size")); +#endif return _M_base()[__pos]; } @@ -652,7 +666,8 @@ namespace __gnu_debug { return _Base::find_first_of(__c, __pos); } size_type - find_last_of(const basic_string& __str, size_type __pos = _Base::npos) const + find_last_of(const basic_string& __str, + size_type __pos = _Base::npos) const { return _Base::find_last_of(__str, __pos); } size_type @@ -996,6 +1011,13 @@ namespace __gnu_debug __str._M_invalidate_all(); return __res; } + + typedef basic_string string; + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef basic_string wstring; +#endif + } // namespace __gnu_debug #endif diff --git a/contrib/libstdc++/include/debug/vector b/contrib/libstdc++/include/debug/vector index 0cc2997..33b8b63 100644 --- a/contrib/libstdc++/include/debug/vector +++ b/contrib/libstdc++/include/debug/vector @@ -1,6 +1,6 @@ // Debugging vector implementation -*- C++ -*- -// Copyright (C) 2003, 2004 +// Copyright (C) 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,15 +28,21 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file debug/vector + * This file is a GNU debug extension to the Standard C++ Library. + */ + #ifndef _GLIBCXX_DEBUG_VECTOR #define _GLIBCXX_DEBUG_VECTOR 1 #include +#include #include #include -#include -namespace __gnu_debug_def +namespace std +{ +namespace __debug { template > @@ -64,8 +70,8 @@ namespace __gnu_debug_def typedef _Tp value_type; typedef _Allocator allocator_type; - typedef typename _Allocator::pointer pointer; - typedef typename _Allocator::const_pointer const_pointer; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; @@ -230,6 +236,10 @@ namespace __gnu_debug_def return _Base::back(); } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + using _Base::data; + // 23.2.4.3 modifiers: void push_back(const _Tp& __x) @@ -407,6 +417,7 @@ namespace __gnu_debug_def inline void swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } -} // namespace __gnu_debug_def +} // namespace __debug +} // namespace std #endif diff --git a/contrib/libstdc++/include/ext/algorithm b/contrib/libstdc++/include/ext/algorithm index 07ac4cb..712a4ed 100644 --- a/contrib/libstdc++/include/ext/algorithm +++ b/contrib/libstdc++/include/ext/algorithm @@ -1,6 +1,6 @@ // Algorithm extensions -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -55,8 +55,7 @@ /** @file ext/algorithm * This file is a GNU extension to the Standard C++ Library (possibly - * containing extensions from the HP/SGI STL subset). You should only - * include this header if you are using GCC 3 or later. + * containing extensions from the HP/SGI STL subset). */ #ifndef _EXT_ALGORITHM @@ -66,8 +65,8 @@ #include -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + using std::ptrdiff_t; using std::min; using std::pair; @@ -84,11 +83,12 @@ namespace __gnu_cxx _OutputIterator __result, input_iterator_tag) { - for ( ; __count > 0; --__count) { - *__result = *__first; - ++__first; - ++__result; - } + for ( ; __count > 0; --__count) + { + *__result = *__first; + ++__first; + ++__result; + } return pair<_InputIterator, _OutputIterator>(__first, __result); } @@ -99,8 +99,9 @@ namespace __gnu_cxx random_access_iterator_tag) { _RAIterator __last = __first + __count; - return pair<_RAIterator, _OutputIterator>(__last, - std::copy(__first, __last, __result)); + return pair<_RAIterator, _OutputIterator>(__last, std::copy(__first, + __last, + __result)); } /** @@ -132,23 +133,24 @@ namespace __gnu_cxx template int - __lexicographical_compare_3way(_InputIterator1 __first1, _InputIterator1 __last1, - _InputIterator2 __first2, _InputIterator2 __last2) + __lexicographical_compare_3way(_InputIterator1 __first1, + _InputIterator1 __last1, + _InputIterator2 __first2, + _InputIterator2 __last2) { - while (__first1 != __last1 && __first2 != __last2) { - if (*__first1 < *__first2) - return -1; - if (*__first2 < *__first1) - return 1; - ++__first1; - ++__first2; - } - if (__first2 == __last2) { + while (__first1 != __last1 && __first2 != __last2) + { + if (*__first1 < *__first2) + return -1; + if (*__first2 < *__first1) + return 1; + ++__first1; + ++__first2; + } + if (__first2 == __last2) return !(__first1 == __last1); - } - else { + else return -1; - } } inline int @@ -169,11 +171,10 @@ namespace __gnu_cxx const char* __first2, const char* __last2) { #if CHAR_MAX == SCHAR_MAX - return __lexicographical_compare_3way( - (const signed char*) __first1, - (const signed char*) __last1, - (const signed char*) __first2, - (const signed char*) __last2); + return __lexicographical_compare_3way((const signed char*) __first1, + (const signed char*) __last1, + (const signed char*) __first2, + (const signed char*) __last2); #else return __lexicographical_compare_3way((const unsigned char*) __first1, (const unsigned char*) __last1, @@ -198,8 +199,10 @@ namespace __gnu_cxx */ template int - lexicographical_compare_3way(_InputIterator1 __first1, _InputIterator1 __last1, - _InputIterator2 __first2, _InputIterator2 __last2) + lexicographical_compare_3way(_InputIterator1 __first1, + _InputIterator1 __last1, + _InputIterator2 __first2, + _InputIterator2 __last2) { // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) @@ -211,12 +214,12 @@ namespace __gnu_cxx __glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first2, __last2); - return __lexicographical_compare_3way(__first1, __last1, __first2, __last2); + return __lexicographical_compare_3way(__first1, __last1, __first2, + __last2); } // count and count_if: this version, whose return type is void, was present // in the HP STL, and is retained as an extension for backward compatibility. - template void count(_InputIterator __first, _InputIterator __last, @@ -259,7 +262,8 @@ namespace __gnu_cxx * @ingroup SGIextensions * @doctodo */ - template + template _OutputIterator random_sample_n(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __out, const _Distance __n) @@ -273,16 +277,17 @@ namespace __gnu_cxx _Distance __remaining = std::distance(__first, __last); _Distance __m = min(__n, __remaining); - while (__m > 0) { - if ((std::rand() % __remaining) < __m) { + while (__m > 0) + { + if ((std::rand() % __remaining) < __m) + { *__out = *__first; ++__out; --__m; + } + --__remaining; + ++__first; } - - --__remaining; - ++__first; - } return __out; } @@ -291,8 +296,8 @@ namespace __gnu_cxx * @ingroup SGIextensions * @doctodo */ - template + template _OutputIterator random_sample_n(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __out, const _Distance __n, @@ -309,20 +314,22 @@ namespace __gnu_cxx _Distance __remaining = std::distance(__first, __last); _Distance __m = min(__n, __remaining); - while (__m > 0) { - if (__rand(__remaining) < __m) { + while (__m > 0) + { + if (__rand(__remaining) < __m) + { *__out = *__first; ++__out; --__m; + } + --__remaining; + ++__first; } - - --__remaining; - ++__first; - } return __out; } - template + template _RandomAccessIterator __random_sample(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __out, @@ -333,14 +340,14 @@ namespace __gnu_cxx for ( ; __first != __last && __m < __n; ++__m, ++__first) __out[__m] = *__first; - while (__first != __last) { - ++__t; - _Distance __M = std::rand() % (__t); - if (__M < __n) - __out[__M] = *__first; - ++__first; - } - + while (__first != __last) + { + ++__t; + _Distance __M = std::rand() % (__t); + if (__M < __n) + __out[__M] = *__first; + ++__first; + } return __out + __m; } @@ -361,14 +368,14 @@ namespace __gnu_cxx for ( ; __first != __last && __m < __n; ++__m, ++__first) __out[__m] = *__first; - while (__first != __last) { - ++__t; - _Distance __M = __rand(__t); - if (__M < __n) - __out[__M] = *__first; - ++__first; - } - + while (__first != __last) + { + ++__t; + _Distance __M = __rand(__t); + if (__M < __n) + __out[__M] = *__first; + ++__first; + } return __out + __m; } @@ -380,7 +387,8 @@ namespace __gnu_cxx template inline _RandomAccessIterator random_sample(_InputIterator __first, _InputIterator __last, - _RandomAccessIterator __out_first, _RandomAccessIterator __out_last) + _RandomAccessIterator __out_first, + _RandomAccessIterator __out_last) { // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) @@ -402,7 +410,8 @@ namespace __gnu_cxx typename _RandomNumberGenerator> inline _RandomAccessIterator random_sample(_InputIterator __first, _InputIterator __last, - _RandomAccessIterator __out_first, _RandomAccessIterator __out_last, + _RandomAccessIterator __out_first, + _RandomAccessIterator __out_last, _RandomNumberGenerator& __rand) { // concept requirements @@ -427,7 +436,8 @@ namespace __gnu_cxx is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { // concept requirements - __glibcxx_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>) + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) __glibcxx_function_requires(_LessThanComparableConcept< typename iterator_traits<_RandomAccessIterator>::value_type>) __glibcxx_requires_valid_range(__first, __last); @@ -446,7 +456,8 @@ namespace __gnu_cxx _StrictWeakOrdering __comp) { // concept requirements - __glibcxx_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>) + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) __glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering, typename iterator_traits<_RandomAccessIterator>::value_type, typename iterator_traits<_RandomAccessIterator>::value_type>) @@ -478,11 +489,9 @@ namespace __gnu_cxx return true; _ForwardIterator __next = __first; - for (++__next; __next != __last; __first = __next, ++__next) { + for (++__next; __next != __last; __first = __next, ++__next) if (*__next < *__first) return false; - } - return true; } @@ -493,7 +502,8 @@ namespace __gnu_cxx */ template bool - is_sorted(_ForwardIterator __first, _ForwardIterator __last, _StrictWeakOrdering __comp) + is_sorted(_ForwardIterator __first, _ForwardIterator __last, + _StrictWeakOrdering __comp) { // concept requirements __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) @@ -506,13 +516,12 @@ namespace __gnu_cxx return true; _ForwardIterator __next = __first; - for (++__next; __next != __last; __first = __next, ++__next) { + for (++__next; __next != __last; __first = __next, ++__next) if (__comp(*__next, *__first)) return false; - } - return true; } -} // namespace __gnu_cxx + +_GLIBCXX_END_NAMESPACE #endif /* _EXT_ALGORITHM */ diff --git a/contrib/libstdc++/include/ext/array_allocator.h b/contrib/libstdc++/include/ext/array_allocator.h new file mode 100644 index 0000000..0bbd97a --- /dev/null +++ b/contrib/libstdc++/include/ext/array_allocator.h @@ -0,0 +1,149 @@ +// array allocator -*- C++ -*- + +// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file ext/array_allocator.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _ARRAY_ALLOCATOR_H +#define _ARRAY_ALLOCATOR_H 1 + +#include +#include +#include +#include + +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + using std::size_t; + using std::ptrdiff_t; + + /// @brief Base class. + template + class array_allocator_base + { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef _Tp value_type; + + pointer + address(reference __x) const { return &__x; } + + const_pointer + address(const_reference __x) const { return &__x; } + + void + deallocate(pointer, size_type) + { + // Does nothing. + } + + size_type + max_size() const throw() + { return size_t(-1) / sizeof(_Tp); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 402. wrong new expression in [some_] allocator::construct + void + construct(pointer __p, const _Tp& __val) + { ::new(__p) value_type(__val); } + + void + destroy(pointer __p) { __p->~_Tp(); } + }; + + /** + * @brief An allocator that uses previously allocated memory. + * This memory can be externally, globally, or otherwise allocated. + */ + template > + class array_allocator : public array_allocator_base<_Tp> + { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef _Tp value_type; + typedef _Array array_type; + + private: + array_type* _M_array; + size_type _M_used; + + public: + template + struct rebind + { typedef array_allocator<_Tp1, _Array1> other; }; + + array_allocator(array_type* __array = NULL) throw() + : _M_array(__array), _M_used(size_type()) { } + + array_allocator(const array_allocator& __o) throw() + : _M_array(__o._M_array), _M_used(__o._M_used) { } + + template + array_allocator(const array_allocator<_Tp1, _Array1>&) throw() + : _M_array(NULL), _M_used(size_type()) { } + + ~array_allocator() throw() { } + + pointer + allocate(size_type __n, const void* = 0) + { + if (_M_array == 0 || _M_used + __n > _M_array->size()) + std::__throw_bad_alloc(); + pointer __ret = _M_array->begin() + _M_used; + _M_used += __n; + return __ret; + } + }; + + template + inline bool + operator==(const array_allocator<_Tp, _Array>&, + const array_allocator<_Tp, _Array>&) + { return true; } + + template + inline bool + operator!=(const array_allocator<_Tp, _Array>&, + const array_allocator<_Tp, _Array>&) + { return false; } + +_GLIBCXX_END_NAMESPACE + +#endif diff --git a/contrib/libstdc++/include/ext/atomicity.h b/contrib/libstdc++/include/ext/atomicity.h new file mode 100644 index 0000000..975121e --- /dev/null +++ b/contrib/libstdc++/include/ext/atomicity.h @@ -0,0 +1,118 @@ +// Support for atomic operations -*- C++ -*- + +// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file atomicity.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +#ifndef _GLIBCXX_ATOMICITY_H +#define _GLIBCXX_ATOMICITY_H 1 + +#include +#include +#include + +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + // Functions for portable atomic access. + // To abstract locking primatives across all thread policies, use: + // __exchange_and_add_dispatch + // __atomic_add_dispatch +#ifdef _GLIBCXX_ATOMIC_BUILTINS + static inline _Atomic_word + __exchange_and_add(volatile _Atomic_word* __mem, int __val) + { return __sync_fetch_and_add(__mem, __val); } + + static inline void + __atomic_add(volatile _Atomic_word* __mem, int __val) + { __sync_fetch_and_add(__mem, __val); } +#else + _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add(volatile _Atomic_word*, int); + + void + __attribute__ ((__unused__)) + __atomic_add(volatile _Atomic_word*, int); +#endif + + static inline _Atomic_word + __exchange_and_add_single(_Atomic_word* __mem, int __val) + { + _Atomic_word __result = *__mem; + *__mem += __val; + return __result; + } + + static inline void + __atomic_add_single(_Atomic_word* __mem, int __val) + { *__mem += __val; } + + static inline _Atomic_word + __attribute__ ((__unused__)) + __exchange_and_add_dispatch(_Atomic_word* __mem, int __val) + { +#ifdef __GTHREADS + if (__gthread_active_p()) + return __exchange_and_add(__mem, __val); + else + return __exchange_and_add_single(__mem, __val); +#else + return __exchange_and_add_single(__mem, __val); +#endif + } + + static inline void + __attribute__ ((__unused__)) + __atomic_add_dispatch(_Atomic_word* __mem, int __val) + { +#ifdef __GTHREADS + if (__gthread_active_p()) + __atomic_add(__mem, __val); + else + __atomic_add_single(__mem, __val); +#else + __atomic_add_single(__mem, __val); +#endif + } + +_GLIBCXX_END_NAMESPACE + +// Even if the CPU doesn't need a memory barrier, we need to ensure +// that the compiler doesn't reorder memory accesses across the +// barriers. +#ifndef _GLIBCXX_READ_MEM_BARRIER +#define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory") +#endif +#ifndef _GLIBCXX_WRITE_MEM_BARRIER +#define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory") +#endif + +#endif diff --git a/contrib/libstdc++/include/ext/bitmap_allocator.h b/contrib/libstdc++/include/ext/bitmap_allocator.h index 9a0d162..93fa8e6 100644 --- a/contrib/libstdc++/include/ext/bitmap_allocator.h +++ b/contrib/libstdc++/include/ext/bitmap_allocator.h @@ -1,6 +1,6 @@ -// Bitmapped Allocator. -*- C++ -*- +// Bitmap Allocator. -*- C++ -*- -// Copyright (C) 2004 Free Software Foundation, Inc. +// Copyright (C) 2004, 2005, 2006 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,833 +27,1112 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file ext/bitmap_allocator.h + * This file is a GNU extension to the Standard C++ Library. + */ - -#if !defined _BITMAP_ALLOCATOR_H +#ifndef _BITMAP_ALLOCATOR_H #define _BITMAP_ALLOCATOR_H 1 -#include -//For std::size_t, and ptrdiff_t. -#include -//For std::pair. -#include -//std::find_if, and std::lower_bound. -#include -//For the free list of exponentially growing memory blocks. At max, -//size of the vector should be not more than the number of bits in an -//integer or an unsigned integer. -#include -//For greater_equal, and less_equal. -#include -//For operator new. -#include -//For __gthread_mutex_t, __gthread_mutex_lock and __gthread_mutex_unlock. -#include -//For __gnu_cxx::new_allocator for std::vector. - -#include -#define NDEBUG - -//#define CHECK_FOR_ERRORS -//#define __CPU_HAS_BACKWARD_BRANCH_PREDICTION - -namespace __gnu_cxx -{ - namespace { -#if defined __GTHREADS - bool const __threads_enabled = __gthread_active_p(); -#endif +#include // For std::size_t, and ptrdiff_t. +#include // For __throw_bad_alloc(). +#include // For std::pair. +#include // For greater_equal, and less_equal. +#include // For operator new. +#include // _GLIBCXX_DEBUG_ASSERT +#include - } -#if defined __GTHREADS - class _Mutex { - __gthread_mutex_t _M_mut; - //Prevent Copying and assignment. - _Mutex (_Mutex const&); - _Mutex& operator= (_Mutex const&); - public: - _Mutex () - { - if (__threads_enabled) - { -#if !defined __GTHREAD_MUTEX_INIT - __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mut); -#else - __gthread_mutex_t __mtemp = __GTHREAD_MUTEX_INIT; - _M_mut = __mtemp; -#endif - } - } - ~_Mutex () - { - //Gthreads does not define a Mutex Destruction Function. - } - __gthread_mutex_t *_M_get() { return &_M_mut; } - }; +/** @brief The constant in the expression below is the alignment + * required in bytes. + */ +#define _BALLOC_ALIGN_BYTES 8 - class _Lock { - _Mutex* _M_pmt; - bool _M_locked; - //Prevent Copying and assignment. - _Lock (_Lock const&); - _Lock& operator= (_Lock const&); - public: - _Lock(_Mutex* __mptr) - : _M_pmt(__mptr), _M_locked(false) - { this->_M_lock(); } - void _M_lock() - { - if (__threads_enabled) - { - _M_locked = true; - __gthread_mutex_lock(_M_pmt->_M_get()); - } - } - void _M_unlock() - { - if (__threads_enabled) +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + using std::size_t; + using std::ptrdiff_t; + + namespace __detail + { + /** @class __mini_vector bitmap_allocator.h bitmap_allocator.h + * + * @brief __mini_vector<> is a stripped down version of the + * full-fledged std::vector<>. + * + * It is to be used only for built-in types or PODs. Notable + * differences are: + * + * @detail + * 1. Not all accessor functions are present. + * 2. Used ONLY for PODs. + * 3. No Allocator template argument. Uses ::operator new() to get + * memory, and ::operator delete() to free it. + * Caveat: The dtor does NOT free the memory allocated, so this a + * memory-leaking vector! + */ + template + class __mini_vector + { + __mini_vector(const __mini_vector&); + __mini_vector& operator=(const __mini_vector&); + + public: + typedef _Tp value_type; + typedef _Tp* pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef pointer iterator; + + private: + pointer _M_start; + pointer _M_finish; + pointer _M_end_of_storage; + + size_type + _M_space_left() const throw() + { return _M_end_of_storage - _M_finish; } + + pointer + allocate(size_type __n) + { return static_cast(::operator new(__n * sizeof(_Tp))); } + + void + deallocate(pointer __p, size_type) + { ::operator delete(__p); } + + public: + // Members used: size(), push_back(), pop_back(), + // insert(iterator, const_reference), erase(iterator), + // begin(), end(), back(), operator[]. + + __mini_vector() : _M_start(0), _M_finish(0), + _M_end_of_storage(0) + { } + +#if 0 + ~__mini_vector() { - if (__builtin_expect(_M_locked, true)) + if (this->_M_start) { - __gthread_mutex_unlock(_M_pmt->_M_get()); - _M_locked = false; + this->deallocate(this->_M_start, this->_M_end_of_storage + - this->_M_start); } } - } - ~_Lock() { this->_M_unlock(); } - }; #endif + size_type + size() const throw() + { return _M_finish - _M_start; } + iterator + begin() const throw() + { return this->_M_start; } - namespace __aux_balloc { - static const unsigned int _Bits_Per_Byte = 8; - static const unsigned int _Bits_Per_Block = sizeof(unsigned int) * _Bits_Per_Byte; + iterator + end() const throw() + { return this->_M_finish; } - template - inline size_t __balloc_num_blocks (_Addr_Pair_t __ap) - { - return (__ap.second - __ap.first) + 1; - } + reference + back() const throw() + { return *(this->end() - 1); } - template - inline size_t __balloc_num_bit_maps (_Addr_Pair_t __ap) - { - return __balloc_num_blocks(__ap) / _Bits_Per_Block; - } + reference + operator[](const size_type __pos) const throw() + { return this->_M_start[__pos]; } - //T should be a pointer type. - template - class _Inclusive_between : public std::unary_function, bool> { - typedef _Tp pointer; - pointer _M_ptr_value; - typedef typename std::pair<_Tp, _Tp> _Block_pair; - - public: - _Inclusive_between (pointer __ptr) : _M_ptr_value(__ptr) { } - bool operator () (_Block_pair __bp) const throw () - { - if (std::less_equal ()(_M_ptr_value, __bp.second) && - std::greater_equal ()(_M_ptr_value, __bp.first)) - return true; - else - return false; - } - }; - - //Used to pass a Functor to functions by reference. - template - class _Functor_Ref : - public std::unary_function { - _Functor& _M_fref; - - public: - typedef typename _Functor::argument_type argument_type; - typedef typename _Functor::result_type result_type; - - _Functor_Ref (_Functor& __fref) : _M_fref(__fref) { } - result_type operator() (argument_type __arg) { return _M_fref (__arg); } - }; + void + insert(iterator __pos, const_reference __x); + void + push_back(const_reference __x) + { + if (this->_M_space_left()) + { + *this->end() = __x; + ++this->_M_finish; + } + else + this->insert(this->end(), __x); + } - //T should be a pointer type, and A is the Allocator for the vector. - template - class _Ffit_finder - : public std::unary_function, bool> { - typedef typename std::vector, _Alloc> _BPVector; - typedef typename _BPVector::difference_type _Counter_type; - typedef typename std::pair<_Tp, _Tp> _Block_pair; + void + pop_back() throw() + { --this->_M_finish; } - unsigned int *_M_pbitmap; - unsigned int _M_data_offset; + void + erase(iterator __pos) throw(); - public: - _Ffit_finder () - : _M_pbitmap (0), _M_data_offset (0) - { } + void + clear() throw() + { this->_M_finish = this->_M_start; } + }; - bool operator() (_Block_pair __bp) throw() + // Out of line function definitions. + template + void __mini_vector<_Tp>:: + insert(iterator __pos, const_reference __x) { - //Set the _rover to the last unsigned integer, which is the - //bitmap to the first free block. Thus, the bitmaps are in exact - //reverse order of the actual memory layout. So, we count down - //the bimaps, which is the same as moving up the memory. - - //If the used count stored at the start of the Bit Map headers - //is equal to the number of Objects that the current Block can - //store, then there is definitely no space for another single - //object, so just return false. - _Counter_type __diff = __gnu_cxx::__aux_balloc::__balloc_num_bit_maps (__bp); - - assert (*(reinterpret_cast(__bp.first) - (__diff + 1)) <= - __gnu_cxx::__aux_balloc::__balloc_num_blocks (__bp)); - - if (*(reinterpret_cast(__bp.first) - (__diff + 1)) == - __gnu_cxx::__aux_balloc::__balloc_num_blocks (__bp)) - return false; + if (this->_M_space_left()) + { + size_type __to_move = this->_M_finish - __pos; + iterator __dest = this->end(); + iterator __src = this->end() - 1; - unsigned int *__rover = reinterpret_cast(__bp.first) - 1; - for (_Counter_type __i = 0; __i < __diff; ++__i) + ++this->_M_finish; + while (__to_move) + { + *__dest = *__src; + --__dest; --__src; --__to_move; + } + *__pos = __x; + } + else { - _M_data_offset = __i; - if (*__rover) + size_type __new_size = this->size() ? this->size() * 2 : 1; + iterator __new_start = this->allocate(__new_size); + iterator __first = this->begin(); + iterator __start = __new_start; + while (__first != __pos) + { + *__start = *__first; + ++__start; ++__first; + } + *__start = __x; + ++__start; + while (__first != this->end()) { - _M_pbitmap = __rover; - return true; + *__start = *__first; + ++__start; ++__first; } - --__rover; + if (this->_M_start) + this->deallocate(this->_M_start, this->size()); + + this->_M_start = __new_start; + this->_M_finish = __start; + this->_M_end_of_storage = this->_M_start + __new_size; } - return false; - } - - unsigned int *_M_get () { return _M_pbitmap; } - unsigned int _M_offset () { return _M_data_offset * _Bits_Per_Block; } - }; - - //T should be a pointer type. - template - class _Bit_map_counter { - - typedef typename std::vector, _Alloc> _BPVector; - typedef typename _BPVector::size_type _Index_type; - typedef _Tp pointer; - - _BPVector& _M_vbp; - unsigned int *_M_curr_bmap; - unsigned int *_M_last_bmap_in_block; - _Index_type _M_curr_index; - - public: - //Use the 2nd parameter with care. Make sure that such an entry - //exists in the vector before passing that particular index to - //this ctor. - _Bit_map_counter (_BPVector& Rvbp, int __index = -1) - : _M_vbp(Rvbp) - { - this->_M_reset(__index); } - - void _M_reset (int __index = -1) throw() + + template + void __mini_vector<_Tp>:: + erase(iterator __pos) throw() { - if (__index == -1) + while (__pos + 1 != this->end()) { - _M_curr_bmap = 0; - _M_curr_index = (_Index_type)-1; - return; + *__pos = __pos[1]; + ++__pos; } + --this->_M_finish; + } - _M_curr_index = __index; - _M_curr_bmap = reinterpret_cast(_M_vbp[_M_curr_index].first) - 1; - assert (__index <= (int)_M_vbp.size() - 1); - - _M_last_bmap_in_block = _M_curr_bmap - - ((_M_vbp[_M_curr_index].second - _M_vbp[_M_curr_index].first + 1) / _Bits_Per_Block - 1); - } - - //Dangerous Function! Use with extreme care. Pass to this - //function ONLY those values that are known to be correct, - //otherwise this will mess up big time. - void _M_set_internal_bit_map (unsigned int *__new_internal_marker) throw() + template + struct __mv_iter_traits { - _M_curr_bmap = __new_internal_marker; - } - - bool _M_finished () const throw() + typedef typename _Tp::value_type value_type; + typedef typename _Tp::difference_type difference_type; + }; + + template + struct __mv_iter_traits<_Tp*> { - return (_M_curr_bmap == 0); - } - - _Bit_map_counter& operator++ () throw() + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + }; + + enum + { + bits_per_byte = 8, + bits_per_block = sizeof(size_t) * size_t(bits_per_byte) + }; + + template + _ForwardIterator + __lower_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) { - if (_M_curr_bmap == _M_last_bmap_in_block) + typedef typename __mv_iter_traits<_ForwardIterator>::value_type + _ValueType; + typedef typename __mv_iter_traits<_ForwardIterator>::difference_type + _DistanceType; + + _DistanceType __len = __last - __first; + _DistanceType __half; + _ForwardIterator __middle; + + while (__len > 0) { - if (++_M_curr_index == _M_vbp.size()) + __half = __len >> 1; + __middle = __first; + __middle += __half; + if (__comp(*__middle, __val)) { - _M_curr_bmap = 0; + __first = __middle; + ++__first; + __len = __len - __half - 1; } else - { - this->_M_reset (_M_curr_index); - } + __len = __half; } - else - { - --_M_curr_bmap; - } - return *this; + return __first; } - - unsigned int *_M_get () + + template + inline _InputIterator + __find_if(_InputIterator __first, _InputIterator __last, _Predicate __p) { - return _M_curr_bmap; + while (__first != __last && !__p(*__first)) + ++__first; + return __first; } + + /** @brief The number of Blocks pointed to by the address pair + * passed to the function. + */ + template + inline size_t + __num_blocks(_AddrPair __ap) + { return (__ap.second - __ap.first) + 1; } + + /** @brief The number of Bit-maps pointed to by the address pair + * passed to the function. + */ + template + inline size_t + __num_bitmaps(_AddrPair __ap) + { return __num_blocks(__ap) / size_t(bits_per_block); } + + // _Tp should be a pointer type. + template + class _Inclusive_between + : public std::unary_function, bool> + { + typedef _Tp pointer; + pointer _M_ptr_value; + typedef typename std::pair<_Tp, _Tp> _Block_pair; + + public: + _Inclusive_between(pointer __ptr) : _M_ptr_value(__ptr) + { } + + bool + operator()(_Block_pair __bp) const throw() + { + if (std::less_equal()(_M_ptr_value, __bp.second) + && std::greater_equal()(_M_ptr_value, __bp.first)) + return true; + else + return false; + } + }; + + // Used to pass a Functor to functions by reference. + template + class _Functor_Ref + : public std::unary_function + { + _Functor& _M_fref; + + public: + typedef typename _Functor::argument_type argument_type; + typedef typename _Functor::result_type result_type; + + _Functor_Ref(_Functor& __fref) : _M_fref(__fref) + { } + + result_type + operator()(argument_type __arg) + { return _M_fref(__arg); } + }; + + /** @class _Ffit_finder bitmap_allocator.h bitmap_allocator.h + * + * @brief The class which acts as a predicate for applying the + * first-fit memory allocation policy for the bitmap allocator. + */ + // _Tp should be a pointer type, and _Alloc is the Allocator for + // the vector. + template + class _Ffit_finder + : public std::unary_function, bool> + { + typedef typename std::pair<_Tp, _Tp> _Block_pair; + typedef typename __detail::__mini_vector<_Block_pair> _BPVector; + typedef typename _BPVector::difference_type _Counter_type; + + size_t* _M_pbitmap; + _Counter_type _M_data_offset; + + public: + _Ffit_finder() : _M_pbitmap(0), _M_data_offset(0) + { } + + bool + operator()(_Block_pair __bp) throw() + { + // Set the _rover to the last physical location bitmap, + // which is the bitmap which belongs to the first free + // block. Thus, the bitmaps are in exact reverse order of + // the actual memory layout. So, we count down the bimaps, + // which is the same as moving up the memory. + + // If the used count stored at the start of the Bit Map headers + // is equal to the number of Objects that the current Block can + // store, then there is definitely no space for another single + // object, so just return false. + _Counter_type __diff = + __gnu_cxx::__detail::__num_bitmaps(__bp); + + if (*(reinterpret_cast + (__bp.first) - (__diff + 1)) + == __gnu_cxx::__detail::__num_blocks(__bp)) + return false; + + size_t* __rover = reinterpret_cast(__bp.first) - 1; + + for (_Counter_type __i = 0; __i < __diff; ++__i) + { + _M_data_offset = __i; + if (*__rover) + { + _M_pbitmap = __rover; + return true; + } + --__rover; + } + return false; + } + - pointer _M_base () { return _M_vbp[_M_curr_index].first; } - unsigned int _M_offset () + size_t* + _M_get() const throw() + { return _M_pbitmap; } + + _Counter_type + _M_offset() const throw() + { return _M_data_offset * size_t(bits_per_block); } + }; + + + /** @class _Bitmap_counter bitmap_allocator.h bitmap_allocator.h + * + * @brief The bitmap counter which acts as the bitmap + * manipulator, and manages the bit-manipulation functions and + * the searching and identification functions on the bit-map. + */ + // _Tp should be a pointer type. + template + class _Bitmap_counter { - return _Bits_Per_Block * ((reinterpret_cast(this->_M_base()) - _M_curr_bmap) - 1); - } + typedef typename __detail::__mini_vector > + _BPVector; + typedef typename _BPVector::size_type _Index_type; + typedef _Tp pointer; - unsigned int _M_where () { return _M_curr_index; } - }; - } + _BPVector& _M_vbp; + size_t* _M_curr_bmap; + size_t* _M_last_bmap_in_block; + _Index_type _M_curr_index; + + public: + // Use the 2nd parameter with care. Make sure that such an + // entry exists in the vector before passing that particular + // index to this ctor. + _Bitmap_counter(_BPVector& Rvbp, long __index = -1) : _M_vbp(Rvbp) + { this->_M_reset(__index); } + + void + _M_reset(long __index = -1) throw() + { + if (__index == -1) + { + _M_curr_bmap = 0; + _M_curr_index = static_cast<_Index_type>(-1); + return; + } - //Generic Version of the bsf instruction. - typedef unsigned int _Bit_map_type; - static inline unsigned int _Bit_scan_forward (register _Bit_map_type __num) - { - return static_cast(__builtin_ctz(__num)); - } - - struct _OOM_handler { - static std::new_handler _S_old_handler; - static bool _S_handled_oom; - typedef void (*_FL_clear_proc)(void); - static _FL_clear_proc _S_oom_fcp; + _M_curr_index = __index; + _M_curr_bmap = reinterpret_cast + (_M_vbp[_M_curr_index].first) - 1; + + _GLIBCXX_DEBUG_ASSERT(__index <= (long)_M_vbp.size() - 1); + + _M_last_bmap_in_block = _M_curr_bmap + - ((_M_vbp[_M_curr_index].second + - _M_vbp[_M_curr_index].first + 1) + / size_t(bits_per_block) - 1); + } - _OOM_handler (_FL_clear_proc __fcp) - { - _S_oom_fcp = __fcp; - _S_old_handler = std::set_new_handler (_S_handle_oom_proc); - _S_handled_oom = false; - } + // Dangerous Function! Use with extreme care. Pass to this + // function ONLY those values that are known to be correct, + // otherwise this will mess up big time. + void + _M_set_internal_bitmap(size_t* __new_internal_marker) throw() + { _M_curr_bmap = __new_internal_marker; } + + bool + _M_finished() const throw() + { return(_M_curr_bmap == 0); } + + _Bitmap_counter& + operator++() throw() + { + if (_M_curr_bmap == _M_last_bmap_in_block) + { + if (++_M_curr_index == _M_vbp.size()) + _M_curr_bmap = 0; + else + this->_M_reset(_M_curr_index); + } + else + --_M_curr_bmap; + return *this; + } + + size_t* + _M_get() const throw() + { return _M_curr_bmap; } + + pointer + _M_base() const throw() + { return _M_vbp[_M_curr_index].first; } - static void _S_handle_oom_proc() + _Index_type + _M_offset() const throw() + { + return size_t(bits_per_block) + * ((reinterpret_cast(this->_M_base()) + - _M_curr_bmap) - 1); + } + + _Index_type + _M_where() const throw() + { return _M_curr_index; } + }; + + /** @brief Mark a memory address as allocated by re-setting the + * corresponding bit in the bit-map. + */ + inline void + __bit_allocate(size_t* __pbmap, size_t __pos) throw() { - _S_oom_fcp(); - std::set_new_handler (_S_old_handler); - _S_handled_oom = true; + size_t __mask = 1 << __pos; + __mask = ~__mask; + *__pbmap &= __mask; } - - ~_OOM_handler () + + /** @brief Mark a memory address as free by setting the + * corresponding bit in the bit-map. + */ + inline void + __bit_free(size_t* __pbmap, size_t __pos) throw() { - if (!_S_handled_oom) - std::set_new_handler (_S_old_handler); + size_t __mask = 1 << __pos; + *__pbmap |= __mask; } - }; - - std::new_handler _OOM_handler::_S_old_handler; - bool _OOM_handler::_S_handled_oom = false; - _OOM_handler::_FL_clear_proc _OOM_handler::_S_oom_fcp = 0; - + } // namespace __detail + + /** @brief Generic Version of the bsf instruction. + */ + inline size_t + _Bit_scan_forward(size_t __num) + { return static_cast(__builtin_ctzl(__num)); } + + /** @class free_list bitmap_allocator.h bitmap_allocator.h + * + * @brief The free list class for managing chunks of memory to be + * given to and returned by the bitmap_allocator. + */ + class free_list + { + typedef size_t* value_type; + typedef __detail::__mini_vector vector_type; + typedef vector_type::iterator iterator; + typedef __mutex __mutex_type; - class _BA_free_list_store { - struct _LT_pointer_compare { - template - bool operator() (_Tp* __pt, _Tp const& __crt) const throw() - { - return *__pt < __crt; - } + struct _LT_pointer_compare + { + bool + operator()(const size_t* __pui, + const size_t __cui) const throw() + { return *__pui < __cui; } }; #if defined __GTHREADS - static _Mutex _S_bfl_mutex; + __mutex_type& + _M_get_mutex() + { + static __mutex_type _S_mutex; + return _S_mutex; + } #endif - static std::vector _S_free_list; - typedef std::vector::iterator _FLIter; - static void _S_validate_free_list(unsigned int *__addr) throw() + vector_type& + _M_get_free_list() + { + static vector_type _S_free_list; + return _S_free_list; + } + + /** @brief Performs validation of memory based on their size. + * + * @param __addr The pointer to the memory block to be + * validated. + * + * @detail Validates the memory block passed to this function and + * appropriately performs the action of managing the free list of + * blocks by adding this block to the free list or deleting this + * or larger blocks from the free list. + */ + void + _M_validate(size_t* __addr) throw() { - const unsigned int __max_size = 64; - if (_S_free_list.size() >= __max_size) + vector_type& __free_list = _M_get_free_list(); + const vector_type::size_type __max_size = 64; + if (__free_list.size() >= __max_size) { - //Ok, the threshold value has been reached. - //We determine which block to remove from the list of free - //blocks. - if (*__addr >= *_S_free_list.back()) + // Ok, the threshold value has been reached. We determine + // which block to remove from the list of free blocks. + if (*__addr >= *__free_list.back()) { - //Ok, the new block is greater than or equal to the last - //block in the list of free blocks. We just free the new - //block. - operator delete((void*)__addr); + // Ok, the new block is greater than or equal to the + // last block in the list of free blocks. We just free + // the new block. + ::operator delete(static_cast(__addr)); return; } else { - //Deallocate the last block in the list of free lists, and - //insert the new one in it's correct position. - operator delete((void*)_S_free_list.back()); - _S_free_list.pop_back(); + // Deallocate the last block in the list of free lists, + // and insert the new one in it's correct position. + ::operator delete(static_cast(__free_list.back())); + __free_list.pop_back(); } } - //Just add the block to the list of free lists - //unconditionally. - _FLIter __temp = std::lower_bound(_S_free_list.begin(), _S_free_list.end(), - *__addr, _LT_pointer_compare ()); - //We may insert the new free list before _temp; - _S_free_list.insert(__temp, __addr); + // Just add the block to the list of free lists unconditionally. + iterator __temp = __gnu_cxx::__detail::__lower_bound + (__free_list.begin(), __free_list.end(), + *__addr, _LT_pointer_compare()); + + // We may insert the new free list before _temp; + __free_list.insert(__temp, __addr); } - static bool _S_should_i_give(unsigned int __block_size, unsigned int __required_size) throw() + /** @brief Decides whether the wastage of memory is acceptable for + * the current memory request and returns accordingly. + * + * @param __block_size The size of the block available in the free + * list. + * + * @param __required_size The required size of the memory block. + * + * @return true if the wastage incurred is acceptable, else returns + * false. + */ + bool + _M_should_i_give(size_t __block_size, + size_t __required_size) throw() { - const unsigned int __max_wastage_percentage = 36; + const size_t __max_wastage_percentage = 36; if (__block_size >= __required_size && - (((__block_size - __required_size) * 100 / __block_size) < __max_wastage_percentage)) + (((__block_size - __required_size) * 100 / __block_size) + < __max_wastage_percentage)) return true; else return false; } public: - typedef _BA_free_list_store _BFL_type; - - static inline void _S_insert_free_list(unsigned int *__addr) throw() + /** @brief This function returns the block of memory to the + * internal free list. + * + * @param __addr The pointer to the memory block that was given + * by a call to the _M_get function. + */ + inline void + _M_insert(size_t* __addr) throw() { #if defined __GTHREADS - _Lock __bfl_lock(&_S_bfl_mutex); + __gnu_cxx::__scoped_lock __bfl_lock(_M_get_mutex()); #endif - //Call _S_validate_free_list to decide what should be done with this - //particular free list. - _S_validate_free_list(--__addr); + // Call _M_validate to decide what should be done with + // this particular free list. + this->_M_validate(reinterpret_cast(__addr) - 1); + // See discussion as to why this is 1! } - static unsigned int *_S_get_free_list(unsigned int __sz) throw (std::bad_alloc) - { -#if defined __GTHREADS - _Lock __bfl_lock(&_S_bfl_mutex); -#endif - _FLIter __temp = std::lower_bound(_S_free_list.begin(), _S_free_list.end(), - __sz, _LT_pointer_compare()); - if (__temp == _S_free_list.end() || !_S_should_i_give (**__temp, __sz)) - { - //We hold the lock because the OOM_Handler is a stateless - //entity. - _OOM_handler __set_handler(_BFL_type::_S_clear); - unsigned int *__ret_val = reinterpret_cast - (operator new (__sz + sizeof(unsigned int))); - *__ret_val = __sz; - return ++__ret_val; - } - else - { - unsigned int* __ret_val = *__temp; - _S_free_list.erase (__temp); - return ++__ret_val; - } - } - - //This function just clears the internal Free List, and gives back - //all the memory to the OS. - static void _S_clear() - { -#if defined __GTHREADS - _Lock __bfl_lock(&_S_bfl_mutex); -#endif - _FLIter __iter = _S_free_list.begin(); - while (__iter != _S_free_list.end()) - { - operator delete((void*)*__iter); - ++__iter; - } - _S_free_list.clear(); - } - + /** @brief This function gets a block of memory of the specified + * size from the free list. + * + * @param __sz The size in bytes of the memory required. + * + * @return A pointer to the new memory block of size at least + * equal to that requested. + */ + size_t* + _M_get(size_t __sz) throw(std::bad_alloc); + + /** @brief This function just clears the internal Free List, and + * gives back all the memory to the OS. + */ + void + _M_clear(); }; -#if defined __GTHREADS - _Mutex _BA_free_list_store::_S_bfl_mutex; -#endif - std::vector _BA_free_list_store::_S_free_list; - template class bitmap_allocator; - // specialize for void: - template <> class bitmap_allocator { - public: - typedef void* pointer; - typedef const void* const_pointer; - // reference-to-void members are impossible. - typedef void value_type; - template struct rebind { typedef bitmap_allocator<_Tp1> other; }; - }; + // Forward declare the class. + template + class bitmap_allocator; - template class bitmap_allocator : private _BA_free_list_store { - public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Tp* pointer; - typedef const _Tp* const_pointer; - typedef _Tp& reference; - typedef const _Tp& const_reference; - typedef _Tp value_type; - template struct rebind { typedef bitmap_allocator<_Tp1> other; }; - - private: - static const unsigned int _Bits_Per_Byte = 8; - static const unsigned int _Bits_Per_Block = sizeof(unsigned int) * _Bits_Per_Byte; - - static inline void _S_bit_allocate(unsigned int *__pbmap, unsigned int __pos) throw() + // Specialize for void: + template<> + class bitmap_allocator { - unsigned int __mask = 1 << __pos; - __mask = ~__mask; - *__pbmap &= __mask; - } - - static inline void _S_bit_free(unsigned int *__pbmap, unsigned int __pos) throw() - { - unsigned int __mask = 1 << __pos; - *__pbmap |= __mask; - } + public: + typedef void* pointer; + typedef const void* const_pointer; - static inline void *_S_memory_get(size_t __sz) throw (std::bad_alloc) - { - return operator new(__sz); - } + // Reference-to-void members are impossible. + typedef void value_type; + template + struct rebind + { + typedef bitmap_allocator<_Tp1> other; + }; + }; - static inline void _S_memory_put(void *__vptr) throw () + template + class bitmap_allocator : private free_list { - operator delete(__vptr); - } + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef _Tp value_type; + typedef free_list::__mutex_type __mutex_type; + + template + struct rebind + { + typedef bitmap_allocator<_Tp1> other; + }; - typedef typename std::pair _Block_pair; - typedef typename __gnu_cxx::new_allocator<_Block_pair> _BPVec_allocator_type; - typedef typename std::vector<_Block_pair, _BPVec_allocator_type> _BPVector; + private: + template + struct aligned_size + { + enum + { + modulus = _BSize % _AlignSize, + value = _BSize + (modulus ? _AlignSize - (modulus) : 0) + }; + }; + + struct _Alloc_block + { + char __M_unused[aligned_size::value]; + }; -#if defined CHECK_FOR_ERRORS - //Complexity: O(lg(N)). Where, N is the number of block of size - //sizeof(value_type). - static void _S_check_for_free_blocks() throw() - { - typedef typename __gnu_cxx::__aux_balloc::_Ffit_finder _FFF; - _FFF __fff; - typedef typename _BPVector::iterator _BPiter; - _BPiter __bpi = std::find_if(_S_mem_blocks.begin(), _S_mem_blocks.end(), - __gnu_cxx::__aux_balloc::_Functor_Ref<_FFF>(__fff)); - assert(__bpi == _S_mem_blocks.end()); - } -#endif + typedef typename std::pair<_Alloc_block*, _Alloc_block*> _Block_pair; + typedef typename + __detail::__mini_vector<_Block_pair> _BPVector; - //Complexity: O(1), but internally depends upon the complexity of - //the function _BA_free_list_store::_S_get_free_list. The part - //where the bitmap headers are written is of worst case complexity: - //O(X),where X is the number of blocks of size sizeof(value_type) - //within the newly acquired block. Having a tight bound. - static void _S_refill_pool() throw (std::bad_alloc) - { -#if defined CHECK_FOR_ERRORS - _S_check_for_free_blocks(); +#if defined _GLIBCXX_DEBUG + // Complexity: O(lg(N)). Where, N is the number of block of size + // sizeof(value_type). + void + _S_check_for_free_blocks() throw() + { + typedef typename + __gnu_cxx::__detail::_Ffit_finder<_Alloc_block*> _FFF; + _FFF __fff; + typedef typename _BPVector::iterator _BPiter; + _BPiter __bpi = + __gnu_cxx::__detail::__find_if + (_S_mem_blocks.begin(), _S_mem_blocks.end(), + __gnu_cxx::__detail::_Functor_Ref<_FFF>(__fff)); + + _GLIBCXX_DEBUG_ASSERT(__bpi == _S_mem_blocks.end()); + } #endif - const unsigned int __num_bit_maps = _S_block_size / _Bits_Per_Block; - const unsigned int __size_to_allocate = sizeof(unsigned int) + - _S_block_size * sizeof(value_type) + __num_bit_maps*sizeof(unsigned int); + /** @brief Responsible for exponentially growing the internal + * memory pool. + * + * @throw std::bad_alloc. If memory can not be allocated. + * + * @detail Complexity: O(1), but internally depends upon the + * complexity of the function free_list::_M_get. The part where + * the bitmap headers are written has complexity: O(X),where X + * is the number of blocks of size sizeof(value_type) within + * the newly acquired block. Having a tight bound. + */ + void + _S_refill_pool() throw(std::bad_alloc) + { +#if defined _GLIBCXX_DEBUG + _S_check_for_free_blocks(); +#endif - unsigned int *__temp = - reinterpret_cast(_BA_free_list_store::_S_get_free_list(__size_to_allocate)); - *__temp = 0; - ++__temp; + const size_t __num_bitmaps = (_S_block_size + / size_t(__detail::bits_per_block)); + const size_t __size_to_allocate = sizeof(size_t) + + _S_block_size * sizeof(_Alloc_block) + + __num_bitmaps * sizeof(size_t); + + size_t* __temp = + reinterpret_cast + (this->_M_get(__size_to_allocate)); + *__temp = 0; + ++__temp; + + // The Header information goes at the Beginning of the Block. + _Block_pair __bp = + std::make_pair(reinterpret_cast<_Alloc_block*> + (__temp + __num_bitmaps), + reinterpret_cast<_Alloc_block*> + (__temp + __num_bitmaps) + + _S_block_size - 1); + + // Fill the Vector with this information. + _S_mem_blocks.push_back(__bp); - //The Header information goes at the Beginning of the Block. - _Block_pair __bp = std::make_pair(reinterpret_cast(__temp + __num_bit_maps), - reinterpret_cast(__temp + __num_bit_maps) - + _S_block_size - 1); + size_t __bit_mask = 0; // 0 Indicates all Allocated. + __bit_mask = ~__bit_mask; // 1 Indicates all Free. - //Fill the Vector with this information. - _S_mem_blocks.push_back(__bp); + for (size_t __i = 0; __i < __num_bitmaps; ++__i) + __temp[__i] = __bit_mask; - unsigned int __bit_mask = 0; //0 Indicates all Allocated. - __bit_mask = ~__bit_mask; //1 Indicates all Free. + _S_block_size *= 2; + } - for (unsigned int __i = 0; __i < __num_bit_maps; ++__i) - __temp[__i] = __bit_mask; - //On some implementations, operator new might throw bad_alloc, or - //malloc might fail if the size passed is too large, therefore, we - //limit the size passed to malloc or operator new. - _S_block_size *= 2; - } - - static _BPVector _S_mem_blocks; - static unsigned int _S_block_size; - static __gnu_cxx::__aux_balloc::_Bit_map_counter _S_last_request; - static typename _BPVector::size_type _S_last_dealloc_index; + static _BPVector _S_mem_blocks; + static size_t _S_block_size; + static __gnu_cxx::__detail:: + _Bitmap_counter<_Alloc_block*> _S_last_request; + static typename _BPVector::size_type _S_last_dealloc_index; #if defined __GTHREADS - static _Mutex _S_mut; + static __mutex_type _S_mut; #endif - //Complexity: Worst case complexity is O(N), but that is hardly ever - //hit. if and when this particular case is encountered, the next few - //cases are guaranteed to have a worst case complexity of O(1)! - //That's why this function performs very well on the average. you - //can consider this function to be having a complexity refrred to - //commonly as: Amortized Constant time. - static pointer _S_allocate_single_object() - { + public: + + /** @brief Allocates memory for a single object of size + * sizeof(_Tp). + * + * @throw std::bad_alloc. If memory can not be allocated. + * + * @detail Complexity: Worst case complexity is O(N), but that + * is hardly ever hit. If and when this particular case is + * encountered, the next few cases are guaranteed to have a + * worst case complexity of O(1)! That's why this function + * performs very well on average. You can consider this + * function to have a complexity referred to commonly as: + * Amortized Constant time. + */ + pointer + _M_allocate_single_object() throw(std::bad_alloc) + { #if defined __GTHREADS - _Lock __bit_lock(&_S_mut); + __gnu_cxx::__scoped_lock __bit_lock(_S_mut); #endif - //The algorithm is something like this: The last_requst variable - //points to the last accessed Bit Map. When such a condition - //occurs, we try to find a free block in the current bitmap, or - //succeeding bitmaps until the last bitmap is reached. If no free - //block turns up, we resort to First Fit method. - - //WARNING: Do not re-order the condition in the while statement - //below, because it relies on C++'s short-circuit - //evaluation. The return from _S_last_request->_M_get() will NOT - //be dereferenceable if _S_last_request->_M_finished() returns - //true. This would inevitibly lead to a NULL pointer dereference - //if tinkered with. - while (_S_last_request._M_finished() == false && (*(_S_last_request._M_get()) == 0)) - { - _S_last_request.operator++(); - } + // The algorithm is something like this: The last_request + // variable points to the last accessed Bit Map. When such a + // condition occurs, we try to find a free block in the + // current bitmap, or succeeding bitmaps until the last bitmap + // is reached. If no free block turns up, we resort to First + // Fit method. + + // WARNING: Do not re-order the condition in the while + // statement below, because it relies on C++'s short-circuit + // evaluation. The return from _S_last_request->_M_get() will + // NOT be dereference able if _S_last_request->_M_finished() + // returns true. This would inevitably lead to a NULL pointer + // dereference if tinkered with. + while (_S_last_request._M_finished() == false + && (*(_S_last_request._M_get()) == 0)) + { + _S_last_request.operator++(); + } - if (__builtin_expect(_S_last_request._M_finished() == true, false)) - { - //Fall Back to First Fit algorithm. - typedef typename __gnu_cxx::__aux_balloc::_Ffit_finder _FFF; - _FFF __fff; - typedef typename _BPVector::iterator _BPiter; - _BPiter __bpi = std::find_if(_S_mem_blocks.begin(), _S_mem_blocks.end(), - __gnu_cxx::__aux_balloc::_Functor_Ref<_FFF>(__fff)); - - if (__bpi != _S_mem_blocks.end()) - { - //Search was successful. Ok, now mark the first bit from - //the right as 0, meaning Allocated. This bit is obtained - //by calling _M_get() on __fff. - unsigned int __nz_bit = _Bit_scan_forward(*__fff._M_get()); - _S_bit_allocate(__fff._M_get(), __nz_bit); - - _S_last_request._M_reset(__bpi - _S_mem_blocks.begin()); - - //Now, get the address of the bit we marked as allocated. - pointer __ret_val = __bpi->first + __fff._M_offset() + __nz_bit; - unsigned int *__puse_count = reinterpret_cast(__bpi->first) - - (__gnu_cxx::__aux_balloc::__balloc_num_bit_maps(*__bpi) + 1); - ++(*__puse_count); - return __ret_val; - } - else - { - //Search was unsuccessful. We Add more memory to the pool - //by calling _S_refill_pool(). - _S_refill_pool(); + if (__builtin_expect(_S_last_request._M_finished() == true, false)) + { + // Fall Back to First Fit algorithm. + typedef typename + __gnu_cxx::__detail::_Ffit_finder<_Alloc_block*> _FFF; + _FFF __fff; + typedef typename _BPVector::iterator _BPiter; + _BPiter __bpi = + __gnu_cxx::__detail::__find_if + (_S_mem_blocks.begin(), _S_mem_blocks.end(), + __gnu_cxx::__detail::_Functor_Ref<_FFF>(__fff)); + + if (__bpi != _S_mem_blocks.end()) + { + // Search was successful. Ok, now mark the first bit from + // the right as 0, meaning Allocated. This bit is obtained + // by calling _M_get() on __fff. + size_t __nz_bit = _Bit_scan_forward(*__fff._M_get()); + __detail::__bit_allocate(__fff._M_get(), __nz_bit); + + _S_last_request._M_reset(__bpi - _S_mem_blocks.begin()); + + // Now, get the address of the bit we marked as allocated. + pointer __ret = reinterpret_cast + (__bpi->first + __fff._M_offset() + __nz_bit); + size_t* __puse_count = + reinterpret_cast + (__bpi->first) + - (__gnu_cxx::__detail::__num_bitmaps(*__bpi) + 1); + + ++(*__puse_count); + return __ret; + } + else + { + // Search was unsuccessful. We Add more memory to the + // pool by calling _S_refill_pool(). + _S_refill_pool(); - //_M_Reset the _S_last_request structure to the first free - //block's bit map. - _S_last_request._M_reset(_S_mem_blocks.size() - 1); + // _M_Reset the _S_last_request structure to the first + // free block's bit map. + _S_last_request._M_reset(_S_mem_blocks.size() - 1); - //Now, mark that bit as allocated. - } - } - //_S_last_request holds a pointer to a valid bit map, that points - //to a free block in memory. - unsigned int __nz_bit = _Bit_scan_forward(*_S_last_request._M_get()); - _S_bit_allocate(_S_last_request._M_get(), __nz_bit); - - pointer __ret_val = _S_last_request._M_base() + _S_last_request._M_offset() + __nz_bit; - - unsigned int *__puse_count = reinterpret_cast - (_S_mem_blocks[_S_last_request._M_where()].first) - - (__gnu_cxx::__aux_balloc::__balloc_num_bit_maps(_S_mem_blocks[_S_last_request._M_where()]) + 1); - ++(*__puse_count); - return __ret_val; - } + // Now, mark that bit as allocated. + } + } - //Complexity: O(lg(N)), but the worst case is hit quite often! I - //need to do something about this. I'll be able to work on it, only - //when I have some solid figures from a few real apps. - static void _S_deallocate_single_object(pointer __p) throw() - { -#if defined __GTHREADS - _Lock __bit_lock(&_S_mut); -#endif + // _S_last_request holds a pointer to a valid bit map, that + // points to a free block in memory. + size_t __nz_bit = _Bit_scan_forward(*_S_last_request._M_get()); + __detail::__bit_allocate(_S_last_request._M_get(), __nz_bit); - typedef typename _BPVector::iterator _Iterator; - typedef typename _BPVector::difference_type _Difference_type; + pointer __ret = reinterpret_cast + (_S_last_request._M_base() + _S_last_request._M_offset() + __nz_bit); - _Difference_type __diff; - int __displacement; + size_t* __puse_count = reinterpret_cast + (_S_mem_blocks[_S_last_request._M_where()].first) + - (__gnu_cxx::__detail:: + __num_bitmaps(_S_mem_blocks[_S_last_request._M_where()]) + 1); - assert(_S_last_dealloc_index >= 0); + ++(*__puse_count); + return __ret; + } - if (__gnu_cxx::__aux_balloc::_Inclusive_between(__p)(_S_mem_blocks[_S_last_dealloc_index])) - { - assert(_S_last_dealloc_index <= _S_mem_blocks.size() - 1); + /** @brief Deallocates memory that belongs to a single object of + * size sizeof(_Tp). + * + * @detail Complexity: O(lg(N)), but the worst case is not hit + * often! This is because containers usually deallocate memory + * close to each other and this case is handled in O(1) time by + * the deallocate function. + */ + void + _M_deallocate_single_object(pointer __p) throw() + { +#if defined __GTHREADS + __gnu_cxx::__scoped_lock __bit_lock(_S_mut); +#endif + _Alloc_block* __real_p = reinterpret_cast<_Alloc_block*>(__p); - //Initial Assumption was correct! - __diff = _S_last_dealloc_index; - __displacement = __p - _S_mem_blocks[__diff].first; - } - else - { - _Iterator _iter = (std::find_if(_S_mem_blocks.begin(), _S_mem_blocks.end(), - __gnu_cxx::__aux_balloc::_Inclusive_between(__p))); - assert(_iter != _S_mem_blocks.end()); + typedef typename _BPVector::iterator _Iterator; + typedef typename _BPVector::difference_type _Difference_type; - __diff = _iter - _S_mem_blocks.begin(); - __displacement = __p - _S_mem_blocks[__diff].first; - _S_last_dealloc_index = __diff; - } + _Difference_type __diff; + long __displacement; - //Get the position of the iterator that has been found. - const unsigned int __rotate = __displacement % _Bits_Per_Block; - unsigned int *__bit_mapC = reinterpret_cast(_S_mem_blocks[__diff].first) - 1; - __bit_mapC -= (__displacement / _Bits_Per_Block); - - _S_bit_free(__bit_mapC, __rotate); - unsigned int *__puse_count = reinterpret_cast - (_S_mem_blocks[__diff].first) - - (__gnu_cxx::__aux_balloc::__balloc_num_bit_maps(_S_mem_blocks[__diff]) + 1); + _GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index >= 0); - assert(*__puse_count != 0); + + if (__gnu_cxx::__detail::_Inclusive_between<_Alloc_block*> + (__real_p) (_S_mem_blocks[_S_last_dealloc_index])) + { + _GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index + <= _S_mem_blocks.size() - 1); - --(*__puse_count); + // Initial Assumption was correct! + __diff = _S_last_dealloc_index; + __displacement = __real_p - _S_mem_blocks[__diff].first; + } + else + { + _Iterator _iter = __gnu_cxx::__detail:: + __find_if(_S_mem_blocks.begin(), + _S_mem_blocks.end(), + __gnu_cxx::__detail:: + _Inclusive_between<_Alloc_block*>(__real_p)); - if (__builtin_expect(*__puse_count == 0, false)) - { - _S_block_size /= 2; - - //We may safely remove this block. - _Block_pair __bp = _S_mem_blocks[__diff]; - _S_insert_free_list(__puse_count); - _S_mem_blocks.erase(_S_mem_blocks.begin() + __diff); - - //We reset the _S_last_request variable to reflect the erased - //block. We do this to protect future requests after the last - //block has been removed from a particular memory Chunk, - //which in turn has been returned to the free list, and - //hence had been erased from the vector, so the size of the - //vector gets reduced by 1. - if ((_Difference_type)_S_last_request._M_where() >= __diff--) - { - _S_last_request._M_reset(__diff); - // assert(__diff >= 0); - } + _GLIBCXX_DEBUG_ASSERT(_iter != _S_mem_blocks.end()); - //If the Index into the vector of the region of memory that - //might hold the next address that will be passed to - //deallocated may have been invalidated due to the above - //erase procedure being called on the vector, hence we try - //to restore this invariant too. - if (_S_last_dealloc_index >= _S_mem_blocks.size()) - { - _S_last_dealloc_index =(__diff != -1 ? __diff : 0); - assert(_S_last_dealloc_index >= 0); - } - } - } + __diff = _iter - _S_mem_blocks.begin(); + __displacement = __real_p - _S_mem_blocks[__diff].first; + _S_last_dealloc_index = __diff; + } - public: - bitmap_allocator() throw() - { } + // Get the position of the iterator that has been found. + const size_t __rotate = (__displacement + % size_t(__detail::bits_per_block)); + size_t* __bitmapC = + reinterpret_cast + (_S_mem_blocks[__diff].first) - 1; + __bitmapC -= (__displacement / size_t(__detail::bits_per_block)); + + __detail::__bit_free(__bitmapC, __rotate); + size_t* __puse_count = reinterpret_cast + (_S_mem_blocks[__diff].first) + - (__gnu_cxx::__detail::__num_bitmaps(_S_mem_blocks[__diff]) + 1); + + _GLIBCXX_DEBUG_ASSERT(*__puse_count != 0); + + --(*__puse_count); - bitmap_allocator(const bitmap_allocator&) { } + if (__builtin_expect(*__puse_count == 0, false)) + { + _S_block_size /= 2; + + // We can safely remove this block. + // _Block_pair __bp = _S_mem_blocks[__diff]; + this->_M_insert(__puse_count); + _S_mem_blocks.erase(_S_mem_blocks.begin() + __diff); + + // Reset the _S_last_request variable to reflect the + // erased block. We do this to protect future requests + // after the last block has been removed from a particular + // memory Chunk, which in turn has been returned to the + // free list, and hence had been erased from the vector, + // so the size of the vector gets reduced by 1. + if ((_Difference_type)_S_last_request._M_where() >= __diff--) + _S_last_request._M_reset(__diff); + + // If the Index into the vector of the region of memory + // that might hold the next address that will be passed to + // deallocated may have been invalidated due to the above + // erase procedure being called on the vector, hence we + // try to restore this invariant too. + if (_S_last_dealloc_index >= _S_mem_blocks.size()) + { + _S_last_dealloc_index =(__diff != -1 ? __diff : 0); + _GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index >= 0); + } + } + } - template bitmap_allocator(const bitmap_allocator<_Tp1>&) throw() - { } + public: + bitmap_allocator() throw() + { } - ~bitmap_allocator() throw() - { } + bitmap_allocator(const bitmap_allocator&) + { } - //Complexity: O(1), but internally the complexity depends upon the - //complexity of the function(s) _S_allocate_single_object and - //_S_memory_get. - pointer allocate(size_type __n) - { - if (__builtin_expect(__n == 1, true)) - return _S_allocate_single_object(); - else - return reinterpret_cast(_S_memory_get(__n * sizeof(value_type))); - } + template + bitmap_allocator(const bitmap_allocator<_Tp1>&) throw() + { } - //Complexity: Worst case complexity is O(N) where N is the number of - //blocks of size sizeof(value_type) within the free lists that the - //allocator holds. However, this worst case is hit only when the - //user supplies a bogus argument to hint. If the hint argument is - //sensible, then the complexity drops to O(lg(N)), and in extreme - //cases, even drops to as low as O(1). So, if the user supplied - //argument is good, then this function performs very well. - pointer allocate(size_type __n, typename bitmap_allocator::const_pointer) - { - return allocate(__n); - } + ~bitmap_allocator() throw() + { } - void deallocate(pointer __p, size_type __n) throw() - { - if (__builtin_expect(__n == 1, true)) - _S_deallocate_single_object(__p); - else - _S_memory_put(__p); - } + pointer + allocate(size_type __n) + { + if (__builtin_expect(__n > this->max_size(), false)) + std::__throw_bad_alloc(); - pointer address(reference r) const { return &r; } - const_pointer address(const_reference r) const { return &r; } + if (__builtin_expect(__n == 1, true)) + return this->_M_allocate_single_object(); + else + { + const size_type __b = __n * sizeof(value_type); + return reinterpret_cast(::operator new(__b)); + } + } - size_type max_size(void) const throw() { return (size_type()-1)/sizeof(value_type); } + pointer + allocate(size_type __n, typename bitmap_allocator::const_pointer) + { return allocate(__n); } - void construct (pointer p, const_reference __data) - { - ::new(p) value_type(__data); - } + void + deallocate(pointer __p, size_type __n) throw() + { + if (__builtin_expect(__p != 0, true)) + { + if (__builtin_expect(__n == 1, true)) + this->_M_deallocate_single_object(__p); + else + ::operator delete(__p); + } + } - void destroy (pointer p) - { - p->~value_type(); - } + pointer + address(reference __r) const + { return &__r; } - }; + const_pointer + address(const_reference __r) const + { return &__r; } - template - typename bitmap_allocator<_Tp>::_BPVector bitmap_allocator<_Tp>::_S_mem_blocks; + size_type + max_size() const throw() + { return size_type(-1) / sizeof(value_type); } - template - unsigned int bitmap_allocator<_Tp>::_S_block_size = bitmap_allocator<_Tp>::_Bits_Per_Block; + void + construct(pointer __p, const_reference __data) + { ::new(__p) value_type(__data); } - template - typename __gnu_cxx::bitmap_allocator<_Tp>::_BPVector::size_type - bitmap_allocator<_Tp>::_S_last_dealloc_index = 0; + void + destroy(pointer __p) + { __p->~value_type(); } + }; - template - __gnu_cxx::__aux_balloc::_Bit_map_counter - ::pointer, typename bitmap_allocator<_Tp>::_BPVec_allocator_type> - bitmap_allocator<_Tp>::_S_last_request(_S_mem_blocks); + template + bool + operator==(const bitmap_allocator<_Tp1>&, + const bitmap_allocator<_Tp2>&) throw() + { return true; } + + template + bool + operator!=(const bitmap_allocator<_Tp1>&, + const bitmap_allocator<_Tp2>&) throw() + { return false; } + + // Static member definitions. + template + typename bitmap_allocator<_Tp>::_BPVector + bitmap_allocator<_Tp>::_S_mem_blocks; + + template + size_t bitmap_allocator<_Tp>::_S_block_size = + 2 * size_t(__detail::bits_per_block); + + template + typename __gnu_cxx::bitmap_allocator<_Tp>::_BPVector::size_type + bitmap_allocator<_Tp>::_S_last_dealloc_index = 0; + + template + __gnu_cxx::__detail::_Bitmap_counter + ::_Alloc_block*> + bitmap_allocator<_Tp>::_S_last_request(_S_mem_blocks); #if defined __GTHREADS - template - __gnu_cxx::_Mutex - bitmap_allocator<_Tp>::_S_mut; + template + typename bitmap_allocator<_Tp>::__mutex_type + bitmap_allocator<_Tp>::_S_mut; #endif - template - bool operator== (const bitmap_allocator<_Tp1>&, const bitmap_allocator<_Tp2>&) throw() - { - return true; - } - - template - bool operator!= (const bitmap_allocator<_Tp1>&, const bitmap_allocator<_Tp2>&) throw() - { - return false; - } -} +_GLIBCXX_END_NAMESPACE +#endif -#endif //_BITMAP_ALLOCATOR_H diff --git a/contrib/libstdc++/include/ext/codecvt_specializations.h b/contrib/libstdc++/include/ext/codecvt_specializations.h new file mode 100644 index 0000000..f0a6bbe --- /dev/null +++ b/contrib/libstdc++/include/ext/codecvt_specializations.h @@ -0,0 +1,521 @@ +// Locale support (codecvt) -*- C++ -*- + +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 22.2.1.5 Template class codecvt +// + +// Written by Benjamin Kosnik + +/** @file ext/codecvt_specializations.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _EXT_CODECVT_SPECIALIZATIONS_H +#define _EXT_CODECVT_SPECIALIZATIONS_H 1 + +#include + +#ifdef _GLIBCXX_USE_ICONV + +#include +#include + + // XXX + // Define this here so codecvt.cc can have _S_max_size definition. +#define _GLIBCXX_USE_ENCODING_STATE 1 + +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + /// @brief Extension to use icov for dealing with character encodings. + // This includes conversions and comparisons between various character + // sets. This object encapsulates data that may need to be shared between + // char_traits, codecvt and ctype. + class encoding_state + { + public: + // Types: + // NB: A conversion descriptor subsumes and enhances the + // functionality of a simple state type such as mbstate_t. + typedef iconv_t descriptor_type; + + protected: + // Name of internal character set encoding. + std::string _M_int_enc; + + // Name of external character set encoding. + std::string _M_ext_enc; + + // Conversion descriptor between external encoding to internal encoding. + descriptor_type _M_in_desc; + + // Conversion descriptor between internal encoding to external encoding. + descriptor_type _M_out_desc; + + // The byte-order marker for the external encoding, if necessary. + int _M_ext_bom; + + // The byte-order marker for the internal encoding, if necessary. + int _M_int_bom; + + // Number of external bytes needed to construct one complete + // character in the internal encoding. + // NB: -1 indicates variable, or stateful, encodings. + int _M_bytes; + + public: + explicit + encoding_state() + : _M_in_desc(0), _M_out_desc(0), _M_ext_bom(0), _M_int_bom(0), _M_bytes(0) + { } + + explicit + encoding_state(const char* __int, const char* __ext, + int __ibom = 0, int __ebom = 0, int __bytes = 1) + : _M_int_enc(__int), _M_ext_enc(__ext), _M_in_desc(0), _M_out_desc(0), + _M_ext_bom(__ebom), _M_int_bom(__ibom), _M_bytes(__bytes) + { init(); } + + // 21.1.2 traits typedefs + // p4 + // typedef STATE_T state_type + // requires: state_type shall meet the requirements of + // CopyConstructible types (20.1.3) + // NB: This does not preseve the actual state of the conversion + // descriptor member, but it does duplicate the encoding + // information. + encoding_state(const encoding_state& __obj) : _M_in_desc(0), _M_out_desc(0) + { construct(__obj); } + + // Need assignment operator as well. + encoding_state& + operator=(const encoding_state& __obj) + { + construct(__obj); + return *this; + } + + ~encoding_state() + { destroy(); } + + bool + good() const throw() + { + const descriptor_type __err = reinterpret_cast(-1); + bool __test = _M_in_desc && _M_in_desc != __err; + __test &= _M_out_desc && _M_out_desc != __err; + return __test; + } + + int + character_ratio() const + { return _M_bytes; } + + const std::string + internal_encoding() const + { return _M_int_enc; } + + int + internal_bom() const + { return _M_int_bom; } + + const std::string + external_encoding() const + { return _M_ext_enc; } + + int + external_bom() const + { return _M_ext_bom; } + + const descriptor_type& + in_descriptor() const + { return _M_in_desc; } + + const descriptor_type& + out_descriptor() const + { return _M_out_desc; } + + protected: + void + init() + { + const descriptor_type __err = reinterpret_cast(-1); + const bool __have_encodings = _M_int_enc.size() && _M_ext_enc.size(); + if (!_M_in_desc && __have_encodings) + { + _M_in_desc = iconv_open(_M_int_enc.c_str(), _M_ext_enc.c_str()); + if (_M_in_desc == __err) + std::__throw_runtime_error(__N("encoding_state::_M_init " + "creating iconv input descriptor failed")); + } + if (!_M_out_desc && __have_encodings) + { + _M_out_desc = iconv_open(_M_ext_enc.c_str(), _M_int_enc.c_str()); + if (_M_out_desc == __err) + std::__throw_runtime_error(__N("encoding_state::_M_init " + "creating iconv output descriptor failed")); + } + } + + void + construct(const encoding_state& __obj) + { + destroy(); + _M_int_enc = __obj._M_int_enc; + _M_ext_enc = __obj._M_ext_enc; + _M_ext_bom = __obj._M_ext_bom; + _M_int_bom = __obj._M_int_bom; + _M_bytes = __obj._M_bytes; + init(); + } + + void + destroy() throw() + { + const descriptor_type __err = reinterpret_cast(-1); + if (_M_in_desc && _M_in_desc != __err) + { + iconv_close(_M_in_desc); + _M_in_desc = 0; + } + if (_M_out_desc && _M_out_desc != __err) + { + iconv_close(_M_out_desc); + _M_out_desc = 0; + } + } + }; + + /// @brief encoding_char_traits. + // Custom traits type with encoding_state for the state type, and the + // associated fpos for the position type, all other + // bits equivalent to the required char_traits instantiations. + template + struct encoding_char_traits : public std::char_traits<_CharT> + { + typedef encoding_state state_type; + typedef typename std::fpos pos_type; + }; + +_GLIBCXX_END_NAMESPACE + + +_GLIBCXX_BEGIN_NAMESPACE(std) + + using __gnu_cxx::encoding_state; + + /// @brief codecvt specialization. + // This partial specialization takes advantage of iconv to provide + // code conversions between a large number of character encodings. + template + class codecvt<_InternT, _ExternT, encoding_state> + : public __codecvt_abstract_base<_InternT, _ExternT, encoding_state> + { + public: + // Types: + typedef codecvt_base::result result; + typedef _InternT intern_type; + typedef _ExternT extern_type; + typedef __gnu_cxx::encoding_state state_type; + typedef state_type::descriptor_type descriptor_type; + + // Data Members: + static locale::id id; + + explicit + codecvt(size_t __refs = 0) + : __codecvt_abstract_base(__refs) + { } + + explicit + codecvt(state_type& __enc, size_t __refs = 0) + : __codecvt_abstract_base(__refs) + { } + + protected: + virtual + ~codecvt() { } + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, extern_type* __to, + extern_type* __to_end, extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, const extern_type* __from, + const extern_type* __from_end, const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual int + do_encoding() const throw(); + + virtual bool + do_always_noconv() const throw(); + + virtual int + do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; + + template + locale::id + codecvt<_InternT, _ExternT, encoding_state>::id; + + // This adaptor works around the signature problems of the second + // argument to iconv(): SUSv2 and others use 'const char**', but glibc 2.2 + // uses 'char**', which matches the POSIX 1003.1-2001 standard. + // Using this adaptor, g++ will do the work for us. + template + inline size_t + __iconv_adaptor(size_t(*__func)(iconv_t, _Tp, size_t*, char**, size_t*), + iconv_t __cd, char** __inbuf, size_t* __inbytes, + char** __outbuf, size_t* __outbytes) + { return __func(__cd, (_Tp)__inbuf, __inbytes, __outbuf, __outbytes); } + + template + codecvt_base::result + codecvt<_InternT, _ExternT, encoding_state>:: + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const + { + result __ret = codecvt_base::error; + if (__state.good()) + { + const descriptor_type& __desc = __state.out_descriptor(); + const size_t __fmultiple = sizeof(intern_type); + size_t __fbytes = __fmultiple * (__from_end - __from); + const size_t __tmultiple = sizeof(extern_type); + size_t __tbytes = __tmultiple * (__to_end - __to); + + // Argument list for iconv specifies a byte sequence. Thus, + // all to/from arrays must be brutally casted to char*. + char* __cto = reinterpret_cast(__to); + char* __cfrom; + size_t __conv; + + // Some encodings need a byte order marker as the first item + // in the byte stream, to designate endian-ness. The default + // value for the byte order marker is NULL, so if this is + // the case, it's not necessary and we can just go on our + // merry way. + int __int_bom = __state.internal_bom(); + if (__int_bom) + { + size_t __size = __from_end - __from; + intern_type* __cfixed = static_cast + (__builtin_alloca(sizeof(intern_type) * (__size + 1))); + __cfixed[0] = static_cast(__int_bom); + char_traits::copy(__cfixed + 1, __from, __size); + __cfrom = reinterpret_cast(__cfixed); + __conv = __iconv_adaptor(iconv, __desc, &__cfrom, + &__fbytes, &__cto, &__tbytes); + } + else + { + intern_type* __cfixed = const_cast(__from); + __cfrom = reinterpret_cast(__cfixed); + __conv = __iconv_adaptor(iconv, __desc, &__cfrom, &__fbytes, + &__cto, &__tbytes); + } + + if (__conv != size_t(-1)) + { + __from_next = reinterpret_cast(__cfrom); + __to_next = reinterpret_cast(__cto); + __ret = codecvt_base::ok; + } + else + { + if (__fbytes < __fmultiple * (__from_end - __from)) + { + __from_next = reinterpret_cast(__cfrom); + __to_next = reinterpret_cast(__cto); + __ret = codecvt_base::partial; + } + else + __ret = codecvt_base::error; + } + } + return __ret; + } + + template + codecvt_base::result + codecvt<_InternT, _ExternT, encoding_state>:: + do_unshift(state_type& __state, extern_type* __to, + extern_type* __to_end, extern_type*& __to_next) const + { + result __ret = codecvt_base::error; + if (__state.good()) + { + const descriptor_type& __desc = __state.in_descriptor(); + const size_t __tmultiple = sizeof(intern_type); + size_t __tlen = __tmultiple * (__to_end - __to); + + // Argument list for iconv specifies a byte sequence. Thus, + // all to/from arrays must be brutally casted to char*. + char* __cto = reinterpret_cast(__to); + size_t __conv = __iconv_adaptor(iconv,__desc, NULL, NULL, + &__cto, &__tlen); + + if (__conv != size_t(-1)) + { + __to_next = reinterpret_cast(__cto); + if (__tlen == __tmultiple * (__to_end - __to)) + __ret = codecvt_base::noconv; + else if (__tlen == 0) + __ret = codecvt_base::ok; + else + __ret = codecvt_base::partial; + } + else + __ret = codecvt_base::error; + } + return __ret; + } + + template + codecvt_base::result + codecvt<_InternT, _ExternT, encoding_state>:: + do_in(state_type& __state, const extern_type* __from, + const extern_type* __from_end, const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const + { + result __ret = codecvt_base::error; + if (__state.good()) + { + const descriptor_type& __desc = __state.in_descriptor(); + const size_t __fmultiple = sizeof(extern_type); + size_t __flen = __fmultiple * (__from_end - __from); + const size_t __tmultiple = sizeof(intern_type); + size_t __tlen = __tmultiple * (__to_end - __to); + + // Argument list for iconv specifies a byte sequence. Thus, + // all to/from arrays must be brutally casted to char*. + char* __cto = reinterpret_cast(__to); + char* __cfrom; + size_t __conv; + + // Some encodings need a byte order marker as the first item + // in the byte stream, to designate endian-ness. The default + // value for the byte order marker is NULL, so if this is + // the case, it's not necessary and we can just go on our + // merry way. + int __ext_bom = __state.external_bom(); + if (__ext_bom) + { + size_t __size = __from_end - __from; + extern_type* __cfixed = static_cast + (__builtin_alloca(sizeof(extern_type) * (__size + 1))); + __cfixed[0] = static_cast(__ext_bom); + char_traits::copy(__cfixed + 1, __from, __size); + __cfrom = reinterpret_cast(__cfixed); + __conv = __iconv_adaptor(iconv, __desc, &__cfrom, + &__flen, &__cto, &__tlen); + } + else + { + extern_type* __cfixed = const_cast(__from); + __cfrom = reinterpret_cast(__cfixed); + __conv = __iconv_adaptor(iconv, __desc, &__cfrom, + &__flen, &__cto, &__tlen); + } + + + if (__conv != size_t(-1)) + { + __from_next = reinterpret_cast(__cfrom); + __to_next = reinterpret_cast(__cto); + __ret = codecvt_base::ok; + } + else + { + if (__flen < static_cast(__from_end - __from)) + { + __from_next = reinterpret_cast(__cfrom); + __to_next = reinterpret_cast(__cto); + __ret = codecvt_base::partial; + } + else + __ret = codecvt_base::error; + } + } + return __ret; + } + + template + int + codecvt<_InternT, _ExternT, encoding_state>:: + do_encoding() const throw() + { + int __ret = 0; + if (sizeof(_ExternT) <= sizeof(_InternT)) + __ret = sizeof(_InternT) / sizeof(_ExternT); + return __ret; + } + + template + bool + codecvt<_InternT, _ExternT, encoding_state>:: + do_always_noconv() const throw() + { return false; } + + template + int + codecvt<_InternT, _ExternT, encoding_state>:: + do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const + { return std::min(__max, static_cast(__end - __from)); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 74. Garbled text for codecvt::do_max_length + template + int + codecvt<_InternT, _ExternT, encoding_state>:: + do_max_length() const throw() + { return 1; } + +_GLIBCXX_END_NAMESPACE + +#endif + +#endif diff --git a/contrib/libstdc++/include/ext/concurrence.h b/contrib/libstdc++/include/ext/concurrence.h new file mode 100644 index 0000000..56e07de --- /dev/null +++ b/contrib/libstdc++/include/ext/concurrence.h @@ -0,0 +1,225 @@ +// Support for concurrent programing -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file concurrence.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. + */ + +#ifndef _CONCURRENCE_H +#define _CONCURRENCE_H 1 + +#include +#include +#include +#include + +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + // Available locking policies: + // _S_single single-threaded code that doesn't need to be locked. + // _S_mutex multi-threaded code that requires additional support + // from gthr.h or abstraction layers in concurrance.h. + // _S_atomic multi-threaded code using atomic operations. + enum _Lock_policy { _S_single, _S_mutex, _S_atomic }; + + // Compile time constant that indicates prefered locking policy in + // the current configuration. + static const _Lock_policy __default_lock_policy = +#ifdef __GTHREADS + // NB: This macro doesn't actually exist yet in the compiler, but is + // set somewhat haphazardly at configure time. +#ifdef _GLIBCXX_ATOMIC_BUILTINS + _S_atomic; +#else + _S_mutex; +#endif +#else + _S_single; +#endif + + // NB: As this is used in libsupc++, need to only depend on + // exception. No stdexception classes, no use of std::string. + class __concurrence_lock_error : public std::exception + { + public: + virtual char const* + what() const throw() + { return "__gnu_cxx::__concurrence_lock_error"; } + }; + + class __concurrence_unlock_error : public std::exception + { + public: + virtual char const* + what() const throw() + { return "__gnu_cxx::__concurrence_unlock_error"; } + }; + + // Substitute for concurrence_error object in the case of -fno-exceptions. + inline void + __throw_concurrence_lock_error() + { +#if __EXCEPTIONS + throw __concurrence_lock_error(); +#else + std::abort(); +#endif + } + + inline void + __throw_concurrence_unlock_error() + { +#if __EXCEPTIONS + throw __concurrence_unlock_error(); +#else + std::abort(); +#endif + } + + class __mutex + { + private: + __gthread_mutex_t _M_mutex; + + __mutex(const __mutex&); + __mutex& operator=(const __mutex&); + + public: + __mutex() + { +#if __GTHREADS + if (__gthread_active_p()) + { +#if defined __GTHREAD_MUTEX_INIT + __gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT; + _M_mutex = __tmp; +#else + __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex); +#endif + } +#endif + } + + void lock() + { +#if __GTHREADS + if (__gthread_active_p()) + { + if (__gthread_mutex_lock(&_M_mutex) != 0) + __throw_concurrence_lock_error(); + } +#endif + } + + void unlock() + { +#if __GTHREADS + if (__gthread_active_p()) + { + if (__gthread_mutex_unlock(&_M_mutex) != 0) + __throw_concurrence_unlock_error(); + } +#endif + } + }; + + class __recursive_mutex + { + private: + __gthread_recursive_mutex_t _M_mutex; + + __recursive_mutex(const __recursive_mutex&); + __recursive_mutex& operator=(const __recursive_mutex&); + + public: + __recursive_mutex() + { +#if __GTHREADS + if (__gthread_active_p()) + { +#if defined __GTHREAD_RECURSIVE_MUTEX_INIT + __gthread_recursive_mutex_t __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT; + _M_mutex = __tmp; +#else + __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex); +#endif + } +#endif + } + + void lock() + { +#if __GTHREADS + if (__gthread_active_p()) + { + if (__gthread_recursive_mutex_lock(&_M_mutex) != 0) + __throw_concurrence_lock_error(); + } +#endif + } + + void unlock() + { +#if __GTHREADS + if (__gthread_active_p()) + { + if (__gthread_recursive_mutex_unlock(&_M_mutex) != 0) + __throw_concurrence_unlock_error(); + } +#endif + } + }; + + /// @brief Scoped lock idiom. + // Acquire the mutex here with a constructor call, then release with + // the destructor call in accordance with RAII style. + class __scoped_lock + { + public: + typedef __mutex __mutex_type; + + private: + __mutex_type& _M_device; + + __scoped_lock(const __scoped_lock&); + __scoped_lock& operator=(const __scoped_lock&); + + public: + explicit __scoped_lock(__mutex_type& __name) : _M_device(__name) + { _M_device.lock(); } + + ~__scoped_lock() throw() + { _M_device.unlock(); } + }; + +_GLIBCXX_END_NAMESPACE + +#endif diff --git a/contrib/libstdc++/include/ext/debug_allocator.h b/contrib/libstdc++/include/ext/debug_allocator.h index 7ea6fb4..43a9a87 100644 --- a/contrib/libstdc++/include/ext/debug_allocator.h +++ b/contrib/libstdc++/include/ext/debug_allocator.h @@ -1,6 +1,6 @@ // Allocators -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -48,18 +48,18 @@ #ifndef _DEBUG_ALLOCATOR_H #define _DEBUG_ALLOCATOR_H 1 -#include +#include + +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + using std::size_t; -namespace __gnu_cxx -{ /** * @brief A meta-allocator with debugging bits, as per [20.4]. * * This is precisely the allocator defined in the C++ Standard. * - all allocation calls operator new * - all deallocation calls operator delete - * - * (See @link Allocators allocators info @endlink for more.) */ template class debug_allocator @@ -108,14 +108,21 @@ namespace __gnu_cxx void deallocate(pointer __p, size_type __n) { - if (!__p) - abort(); - pointer __real_p = __p - _M_extra; - if (*reinterpret_cast(__real_p) != __n) - abort(); - _M_allocator.deallocate(__real_p, __n + _M_extra); + if (__p) + { + pointer __real_p = __p - _M_extra; + if (*reinterpret_cast(__real_p) != __n) + { + throw std::runtime_error("debug_allocator::deallocate" + " wrong size"); + } + _M_allocator.deallocate(__real_p, __n + _M_extra); + } + else + throw std::runtime_error("debug_allocator::deallocate null pointer"); } }; -} // namespace __gnu_cxx + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/ext/functional b/contrib/libstdc++/include/ext/functional index 1a37817..f159e11 100644 --- a/contrib/libstdc++/include/ext/functional +++ b/contrib/libstdc++/include/ext/functional @@ -1,6 +1,6 @@ // Functional extensions -*- C++ -*- -// Copyright (C) 2002 Free Software Foundation, Inc. +// Copyright (C) 2002, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -55,8 +55,7 @@ /** @file ext/functional * This file is a GNU extension to the Standard C++ Library (possibly - * containing extensions from the HP/SGI STL subset). You should only - * include this header if you are using GCC 3 or later. + * containing extensions from the HP/SGI STL subset). */ #ifndef _EXT_FUNCTIONAL @@ -66,330 +65,364 @@ #include -namespace __gnu_cxx -{ -using std::unary_function; -using std::binary_function; -using std::mem_fun1_t; -using std::const_mem_fun1_t; -using std::mem_fun1_ref_t; -using std::const_mem_fun1_ref_t; - -/** The @c identity_element functions are not part of the C++ standard; SGI - * provided them as an extension. Its argument is an operation, and its - * return value is the identity element for that operation. It is overloaded - * for addition and multiplication, and you can overload it for your own - * nefarious operations. - * - * @addtogroup SGIextensions - * @{ -*/ -/// An \link SGIextensions SGI extension \endlink. -template inline _Tp identity_element(std::plus<_Tp>) { - return _Tp(0); -} -/// An \link SGIextensions SGI extension \endlink. -template inline _Tp identity_element(std::multiplies<_Tp>) { - return _Tp(1); -} -/** @} */ - -/** As an extension to the binders, SGI provided composition functors and - * wrapper functions to aid in their creation. The @c unary_compose - * functor is constructed from two functions/functors, @c f and @c g. - * Calling @c operator() with a single argument @c x returns @c f(g(x)). - * The function @c compose1 takes the two functions and constructs a - * @c unary_compose variable for you. - * - * @c binary_compose is constructed from three functors, @c f, @c g1, - * and @c g2. Its @c operator() returns @c f(g1(x),g2(x)). The function - * @compose2 takes f, g1, and g2, and constructs the @c binary_compose - * instance for you. For example, if @c f returns an int, then - * \code - * int answer = (compose2(f,g1,g2))(x); - * \endcode - * is equivalent to - * \code - * int temp1 = g1(x); - * int temp2 = g2(x); - * int answer = f(temp1,temp2); - * \endcode - * But the first form is more compact, and can be passed around as a - * functor to other algorithms. - * - * @addtogroup SGIextensions - * @{ -*/ -/// An \link SGIextensions SGI extension \endlink. -template -class unary_compose - : public unary_function -{ -protected: - _Operation1 _M_fn1; - _Operation2 _M_fn2; -public: - unary_compose(const _Operation1& __x, const _Operation2& __y) - : _M_fn1(__x), _M_fn2(__y) {} - typename _Operation1::result_type - operator()(const typename _Operation2::argument_type& __x) const { - return _M_fn1(_M_fn2(__x)); - } -}; - -/// An \link SGIextensions SGI extension \endlink. -template -inline unary_compose<_Operation1,_Operation2> -compose1(const _Operation1& __fn1, const _Operation2& __fn2) -{ - return unary_compose<_Operation1,_Operation2>(__fn1, __fn2); -} - -/// An \link SGIextensions SGI extension \endlink. -template -class binary_compose - : public unary_function { -protected: - _Operation1 _M_fn1; - _Operation2 _M_fn2; - _Operation3 _M_fn3; -public: - binary_compose(const _Operation1& __x, const _Operation2& __y, - const _Operation3& __z) - : _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { } - typename _Operation1::result_type - operator()(const typename _Operation2::argument_type& __x) const { - return _M_fn1(_M_fn2(__x), _M_fn3(__x)); - } -}; - -/// An \link SGIextensions SGI extension \endlink. -template -inline binary_compose<_Operation1, _Operation2, _Operation3> -compose2(const _Operation1& __fn1, const _Operation2& __fn2, - const _Operation3& __fn3) -{ - return binary_compose<_Operation1,_Operation2,_Operation3> - (__fn1, __fn2, __fn3); -} -/** @} */ - -/** As an extension, SGI provided a functor called @c identity. When a - * functor is required but no operations are desired, this can be used as a - * pass-through. Its @c operator() returns its argument unchanged. - * - * @addtogroup SGIextensions -*/ -template struct identity : public std::_Identity<_Tp> {}; - -/** @c select1st and @c select2nd are extensions provided by SGI. Their - * @c operator()s - * take a @c std::pair as an argument, and return either the first member - * or the second member, respectively. They can be used (especially with - * the composition functors) to "strip" data from a sequence before - * performing the remainder of an algorithm. - * - * @addtogroup SGIextensions - * @{ -*/ -/// An \link SGIextensions SGI extension \endlink. -template struct select1st : public std::_Select1st<_Pair> {}; -/// An \link SGIextensions SGI extension \endlink. -template struct select2nd : public std::_Select2nd<_Pair> {}; -/** @} */ - -// extension documented next -template -struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> { - _Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; } -}; - -template -struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> { - _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; } -}; - -/** The @c operator() of the @c project1st functor takes two arbitrary - * arguments and returns the first one, while @c project2nd returns the - * second one. They are extensions provided by SGI. - * - * @addtogroup SGIextensions - * @{ -*/ - -/// An \link SGIextensions SGI extension \endlink. -template -struct project1st : public _Project1st<_Arg1, _Arg2> {}; - -/// An \link SGIextensions SGI extension \endlink. -template -struct project2nd : public _Project2nd<_Arg1, _Arg2> {}; -/** @} */ - -// extension documented next -template -struct _Constant_void_fun { - typedef _Result result_type; - result_type _M_val; - - _Constant_void_fun(const result_type& __v) : _M_val(__v) {} - const result_type& operator()() const { return _M_val; } -}; - -template -struct _Constant_unary_fun { - typedef _Argument argument_type; - typedef _Result result_type; - result_type _M_val; - - _Constant_unary_fun(const result_type& __v) : _M_val(__v) {} - const result_type& operator()(const _Argument&) const { return _M_val; } -}; - -template -struct _Constant_binary_fun { - typedef _Arg1 first_argument_type; - typedef _Arg2 second_argument_type; - typedef _Result result_type; - _Result _M_val; - - _Constant_binary_fun(const _Result& __v) : _M_val(__v) {} - const result_type& operator()(const _Arg1&, const _Arg2&) const { - return _M_val; - } -}; - -/** These three functors are each constructed from a single arbitrary - * variable/value. Later, their @c operator()s completely ignore any - * arguments passed, and return the stored value. - * - @c constant_void_fun's @c operator() takes no arguments - * - @c constant_unary_fun's @c operator() takes one argument (ignored) - * - @c constant_binary_fun's @c operator() takes two arguments (ignored) - * - * The helper creator functions @c constant0, @c constant1, and - * @c constant2 each take a "result" argument and construct variables of - * the appropriate functor type. - * - * @addtogroup SGIextensions - * @{ -*/ -/// An \link SGIextensions SGI extension \endlink. -template -struct constant_void_fun : public _Constant_void_fun<_Result> { - constant_void_fun(const _Result& __v) : _Constant_void_fun<_Result>(__v) {} -}; - -/// An \link SGIextensions SGI extension \endlink. -template -struct constant_unary_fun : public _Constant_unary_fun<_Result, _Argument> -{ - constant_unary_fun(const _Result& __v) - : _Constant_unary_fun<_Result, _Argument>(__v) {} -}; - -/// An \link SGIextensions SGI extension \endlink. -template -struct constant_binary_fun - : public _Constant_binary_fun<_Result, _Arg1, _Arg2> -{ - constant_binary_fun(const _Result& __v) - : _Constant_binary_fun<_Result, _Arg1, _Arg2>(__v) {} -}; - -/// An \link SGIextensions SGI extension \endlink. -template -inline constant_void_fun<_Result> constant0(const _Result& __val) -{ - return constant_void_fun<_Result>(__val); -} - -/// An \link SGIextensions SGI extension \endlink. -template -inline constant_unary_fun<_Result,_Result> constant1(const _Result& __val) -{ - return constant_unary_fun<_Result,_Result>(__val); -} - -/// An \link SGIextensions SGI extension \endlink. -template -inline constant_binary_fun<_Result,_Result,_Result> -constant2(const _Result& __val) -{ - return constant_binary_fun<_Result,_Result,_Result>(__val); -} -/** @} */ - -/** The @c subtractive_rng class is documented on - * SGI's site. - * Note that this code assumes that @c int is 32 bits. - * - * @ingroup SGIextensions -*/ -class subtractive_rng : public unary_function { -private: - unsigned int _M_table[55]; - size_t _M_index1; - size_t _M_index2; -public: - /// Returns a number less than the argument. - unsigned int operator()(unsigned int __limit) { - _M_index1 = (_M_index1 + 1) % 55; - _M_index2 = (_M_index2 + 1) % 55; - _M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2]; - return _M_table[_M_index1] % __limit; - } - - void _M_initialize(unsigned int __seed) +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + using std::size_t; + using std::unary_function; + using std::binary_function; + using std::mem_fun1_t; + using std::const_mem_fun1_t; + using std::mem_fun1_ref_t; + using std::const_mem_fun1_ref_t; + + /** The @c identity_element functions are not part of the C++ + * standard; SGI provided them as an extension. Its argument is an + * operation, and its return value is the identity element for that + * operation. It is overloaded for addition and multiplication, + * and you can overload it for your own nefarious operations. + * + * @addtogroup SGIextensions + * @{ + */ + /// An \link SGIextensions SGI extension \endlink. + template + inline _Tp + identity_element(std::plus<_Tp>) + { return _Tp(0); } + + /// An \link SGIextensions SGI extension \endlink. + template + inline _Tp + identity_element(std::multiplies<_Tp>) + { return _Tp(1); } + /** @} */ + + /** As an extension to the binders, SGI provided composition functors and + * wrapper functions to aid in their creation. The @c unary_compose + * functor is constructed from two functions/functors, @c f and @c g. + * Calling @c operator() with a single argument @c x returns @c f(g(x)). + * The function @c compose1 takes the two functions and constructs a + * @c unary_compose variable for you. + * + * @c binary_compose is constructed from three functors, @c f, @c g1, + * and @c g2. Its @c operator() returns @c f(g1(x),g2(x)). The function + * @compose2 takes f, g1, and g2, and constructs the @c binary_compose + * instance for you. For example, if @c f returns an int, then + * \code + * int answer = (compose2(f,g1,g2))(x); + * \endcode + * is equivalent to + * \code + * int temp1 = g1(x); + * int temp2 = g2(x); + * int answer = f(temp1,temp2); + * \endcode + * But the first form is more compact, and can be passed around as a + * functor to other algorithms. + * + * @addtogroup SGIextensions + * @{ + */ + /// An \link SGIextensions SGI extension \endlink. + template + class unary_compose + : public unary_function + { + protected: + _Operation1 _M_fn1; + _Operation2 _M_fn2; + + public: + unary_compose(const _Operation1& __x, const _Operation2& __y) + : _M_fn1(__x), _M_fn2(__y) {} + + typename _Operation1::result_type + operator()(const typename _Operation2::argument_type& __x) const + { return _M_fn1(_M_fn2(__x)); } + }; + + /// An \link SGIextensions SGI extension \endlink. + template + inline unary_compose<_Operation1, _Operation2> + compose1(const _Operation1& __fn1, const _Operation2& __fn2) + { return unary_compose<_Operation1,_Operation2>(__fn1, __fn2); } + + /// An \link SGIextensions SGI extension \endlink. + template + class binary_compose + : public unary_function + { + protected: + _Operation1 _M_fn1; + _Operation2 _M_fn2; + _Operation3 _M_fn3; + + public: + binary_compose(const _Operation1& __x, const _Operation2& __y, + const _Operation3& __z) + : _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { } + + typename _Operation1::result_type + operator()(const typename _Operation2::argument_type& __x) const + { return _M_fn1(_M_fn2(__x), _M_fn3(__x)); } + }; + + /// An \link SGIextensions SGI extension \endlink. + template + inline binary_compose<_Operation1, _Operation2, _Operation3> + compose2(const _Operation1& __fn1, const _Operation2& __fn2, + const _Operation3& __fn3) + { return binary_compose<_Operation1, _Operation2, _Operation3> + (__fn1, __fn2, __fn3); } + /** @} */ + + /** As an extension, SGI provided a functor called @c identity. When a + * functor is required but no operations are desired, this can be used as a + * pass-through. Its @c operator() returns its argument unchanged. + * + * @addtogroup SGIextensions + */ + template + struct identity : public std::_Identity<_Tp> {}; + + /** @c select1st and @c select2nd are extensions provided by SGI. Their + * @c operator()s + * take a @c std::pair as an argument, and return either the first member + * or the second member, respectively. They can be used (especially with + * the composition functors) to "strip" data from a sequence before + * performing the remainder of an algorithm. + * + * @addtogroup SGIextensions + * @{ + */ + /// An \link SGIextensions SGI extension \endlink. + template + struct select1st : public std::_Select1st<_Pair> {}; + + /// An \link SGIextensions SGI extension \endlink. + template + struct select2nd : public std::_Select2nd<_Pair> {}; + /** @} */ + + // extension documented next + template + struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> + { + _Arg1 + operator()(const _Arg1& __x, const _Arg2&) const + { return __x; } + }; + + template + struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> + { + _Arg2 + operator()(const _Arg1&, const _Arg2& __y) const + { return __y; } + }; + + /** The @c operator() of the @c project1st functor takes two arbitrary + * arguments and returns the first one, while @c project2nd returns the + * second one. They are extensions provided by SGI. + * + * @addtogroup SGIextensions + * @{ + */ + + /// An \link SGIextensions SGI extension \endlink. + template + struct project1st : public _Project1st<_Arg1, _Arg2> {}; + + /// An \link SGIextensions SGI extension \endlink. + template + struct project2nd : public _Project2nd<_Arg1, _Arg2> {}; + /** @} */ + + // extension documented next + template + struct _Constant_void_fun + { + typedef _Result result_type; + result_type _M_val; + + _Constant_void_fun(const result_type& __v) : _M_val(__v) {} + + const result_type& + operator()() const + { return _M_val; } + }; + + template + struct _Constant_unary_fun + { + typedef _Argument argument_type; + typedef _Result result_type; + result_type _M_val; + + _Constant_unary_fun(const result_type& __v) : _M_val(__v) {} + + const result_type& + operator()(const _Argument&) const + { return _M_val; } + }; + + template + struct _Constant_binary_fun + { + typedef _Arg1 first_argument_type; + typedef _Arg2 second_argument_type; + typedef _Result result_type; + _Result _M_val; + + _Constant_binary_fun(const _Result& __v) : _M_val(__v) {} + + const result_type& + operator()(const _Arg1&, const _Arg2&) const + { return _M_val; } + }; + + /** These three functors are each constructed from a single arbitrary + * variable/value. Later, their @c operator()s completely ignore any + * arguments passed, and return the stored value. + * - @c constant_void_fun's @c operator() takes no arguments + * - @c constant_unary_fun's @c operator() takes one argument (ignored) + * - @c constant_binary_fun's @c operator() takes two arguments (ignored) + * + * The helper creator functions @c constant0, @c constant1, and + * @c constant2 each take a "result" argument and construct variables of + * the appropriate functor type. + * + * @addtogroup SGIextensions + * @{ + */ + /// An \link SGIextensions SGI extension \endlink. + template + struct constant_void_fun + : public _Constant_void_fun<_Result> + { + constant_void_fun(const _Result& __v) + : _Constant_void_fun<_Result>(__v) {} + }; + + /// An \link SGIextensions SGI extension \endlink. + template + struct constant_unary_fun : public _Constant_unary_fun<_Result, _Argument> + { + constant_unary_fun(const _Result& __v) + : _Constant_unary_fun<_Result, _Argument>(__v) {} + }; + + /// An \link SGIextensions SGI extension \endlink. + template + struct constant_binary_fun + : public _Constant_binary_fun<_Result, _Arg1, _Arg2> + { + constant_binary_fun(const _Result& __v) + : _Constant_binary_fun<_Result, _Arg1, _Arg2>(__v) {} + }; + + /// An \link SGIextensions SGI extension \endlink. + template + inline constant_void_fun<_Result> + constant0(const _Result& __val) + { return constant_void_fun<_Result>(__val); } + + /// An \link SGIextensions SGI extension \endlink. + template + inline constant_unary_fun<_Result, _Result> + constant1(const _Result& __val) + { return constant_unary_fun<_Result, _Result>(__val); } + + /// An \link SGIextensions SGI extension \endlink. + template + inline constant_binary_fun<_Result,_Result,_Result> + constant2(const _Result& __val) + { return constant_binary_fun<_Result, _Result, _Result>(__val); } + /** @} */ + + /** The @c subtractive_rng class is documented on + * SGI's site. + * Note that this code assumes that @c int is 32 bits. + * + * @ingroup SGIextensions + */ + class subtractive_rng + : public unary_function { - unsigned int __k = 1; - _M_table[54] = __seed; - size_t __i; - for (__i = 0; __i < 54; __i++) { - size_t __ii = (21 * (__i + 1) % 55) - 1; - _M_table[__ii] = __k; - __k = __seed - __k; - __seed = _M_table[__ii]; + private: + unsigned int _M_table[55]; + size_t _M_index1; + size_t _M_index2; + + public: + /// Returns a number less than the argument. + unsigned int + operator()(unsigned int __limit) + { + _M_index1 = (_M_index1 + 1) % 55; + _M_index2 = (_M_index2 + 1) % 55; + _M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2]; + return _M_table[_M_index1] % __limit; } - for (int __loop = 0; __loop < 4; __loop++) { - for (__i = 0; __i < 55; __i++) + + void + _M_initialize(unsigned int __seed) + { + unsigned int __k = 1; + _M_table[54] = __seed; + size_t __i; + for (__i = 0; __i < 54; __i++) + { + size_t __ii = (21 * (__i + 1) % 55) - 1; + _M_table[__ii] = __k; + __k = __seed - __k; + __seed = _M_table[__ii]; + } + for (int __loop = 0; __loop < 4; __loop++) + { + for (__i = 0; __i < 55; __i++) _M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55]; + } + _M_index1 = 0; + _M_index2 = 31; } - _M_index1 = 0; - _M_index2 = 31; - } - - /// Ctor allowing you to initialize the seed. - subtractive_rng(unsigned int __seed) { _M_initialize(__seed); } - /// Default ctor; initializes its state with some number you don't see. - subtractive_rng() { _M_initialize(161803398u); } -}; - -// Mem_fun adaptor helper functions mem_fun1 and mem_fun1_ref, -// provided for backward compatibility, they are no longer part of -// the C++ standard. - -template -inline mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg)) - { return mem_fun1_t<_Ret,_Tp,_Arg>(__f); } - -template -inline const_mem_fun1_t<_Ret,_Tp,_Arg> mem_fun1(_Ret (_Tp::*__f)(_Arg) const) - { return const_mem_fun1_t<_Ret,_Tp,_Arg>(__f); } - -template -inline mem_fun1_ref_t<_Ret,_Tp,_Arg> mem_fun1_ref(_Ret (_Tp::*__f)(_Arg)) - { return mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); } - -template -inline const_mem_fun1_ref_t<_Ret,_Tp,_Arg> -mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const) - { return const_mem_fun1_ref_t<_Ret,_Tp,_Arg>(__f); } -} // namespace __gnu_cxx + + /// Ctor allowing you to initialize the seed. + subtractive_rng(unsigned int __seed) + { _M_initialize(__seed); } + + /// Default ctor; initializes its state with some number you don't see. + subtractive_rng() + { _M_initialize(161803398u); } + }; + + // Mem_fun adaptor helper functions mem_fun1 and mem_fun1_ref, + // provided for backward compatibility, they are no longer part of + // the C++ standard. + + template + inline mem_fun1_t<_Ret, _Tp, _Arg> + mem_fun1(_Ret (_Tp::*__f)(_Arg)) + { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); } + + template + inline const_mem_fun1_t<_Ret, _Tp, _Arg> + mem_fun1(_Ret (_Tp::*__f)(_Arg) const) + { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); } + + template + inline mem_fun1_ref_t<_Ret, _Tp, _Arg> + mem_fun1_ref(_Ret (_Tp::*__f)(_Arg)) + { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } + + template + inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg> + mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const) + { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/ext/hash_fun.h b/contrib/libstdc++/include/ext/hash_fun.h index 27453a6..16c0458 100644 --- a/contrib/libstdc++/include/ext/hash_fun.h +++ b/contrib/libstdc++/include/ext/hash_fun.h @@ -1,6 +1,6 @@ // 'struct hash' from SGI -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -55,8 +55,7 @@ /** @file ext/hash_fun.h * This file is a GNU extension to the Standard C++ Library (possibly - * containing extensions from the HP/SGI STL subset). You should only - * include this header if you are using GCC 3 or later. + * containing extensions from the HP/SGI STL subset). */ #ifndef _HASH_FUN_H @@ -64,59 +63,110 @@ #include -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + using std::size_t; - template struct hash { }; + template + struct hash { }; inline size_t __stl_hash_string(const char* __s) { unsigned long __h = 0; for ( ; *__s; ++__s) - __h = 5*__h + *__s; + __h = 5 * __h + *__s; return size_t(__h); } - template<> struct hash - { - size_t operator()(const char* __s) const - { return __stl_hash_string(__s); } - }; - - template<> struct hash - { - size_t operator()(const char* __s) const - { return __stl_hash_string(__s); } - }; - - template<> struct hash - { size_t operator()(char __x) const { return __x; } }; - - template<> struct hash - { size_t operator()(unsigned char __x) const { return __x; } }; - - template<> struct hash - { size_t operator()(unsigned char __x) const { return __x; } }; - - template<> struct hash - { size_t operator()(short __x) const { return __x; } }; - - template<> struct hash - { size_t operator()(unsigned short __x) const { return __x; } }; - - template<> struct hash - { size_t operator()(int __x) const { return __x; } }; - - template<> struct hash - { size_t operator()(unsigned int __x) const { return __x; } }; - - template<> struct hash - { size_t operator()(long __x) const { return __x; } }; - - template<> struct hash - { size_t operator()(unsigned long __x) const { return __x; } }; -} // namespace __gnu_cxx + template<> + struct hash + { + size_t + operator()(const char* __s) const + { return __stl_hash_string(__s); } + }; + + template<> + struct hash + { + size_t + operator()(const char* __s) const + { return __stl_hash_string(__s); } + }; + + template<> + struct hash + { + size_t + operator()(char __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(unsigned char __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(unsigned char __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(short __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(unsigned short __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(int __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(unsigned int __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(long __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(unsigned long __x) const + { return __x; } + }; + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/ext/hash_map b/contrib/libstdc++/include/ext/hash_map index 5032c7b..b6855eb 100644 --- a/contrib/libstdc++/include/ext/hash_map +++ b/contrib/libstdc++/include/ext/hash_map @@ -1,6 +1,6 @@ // Hashing map implementation -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004, 2005, 2006 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -55,393 +55,551 @@ /** @file ext/hash_map * This file is a GNU extension to the Standard C++ Library (possibly - * containing extensions from the HP/SGI STL subset). You should only - * include this header if you are using GCC 3 or later. + * containing extensions from the HP/SGI STL subset). */ #ifndef _HASH_MAP #define _HASH_MAP 1 +#include #include #include -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NESTED_NAMESPACE(__gnu_cxx, _GLIBCXX_EXT) + using std::equal_to; using std::allocator; using std::pair; using std::_Select1st; - // Forward declaration of equality operator; needed for friend - // declaration. - template, - class _EqualKey = equal_to<_Key>, class _Alloc = allocator<_Tp> > - class hash_map; - - template - inline bool operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&, - const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&); -/** - * This is an SGI extension. - * @ingroup SGIextensions - * @doctodo -*/ -template -class hash_map -{ -private: - typedef hashtable,_Key,_HashFcn, - _Select1st >,_EqualKey,_Alloc> _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_map(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_map(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - - template - hash_map(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_map(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_map(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_map(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_map& __hs) { _M_ht.swap(__hs._M_ht); } - - template - friend bool operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&, - const hash_map<_K1, _T1, _HF, _EqK, _Al>&); - - iterator begin() { return _M_ht.begin(); } - iterator end() { return _M_ht.end(); } - const_iterator begin() const { return _M_ht.begin(); } - const_iterator end() const { return _M_ht.end(); } - -public: - pair insert(const value_type& __obj) - { return _M_ht.insert_unique(__obj); } - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_unique(__f,__l); } - pair insert_noresize(const value_type& __obj) - { return _M_ht.insert_unique_noresize(__obj); } - - iterator find(const key_type& __key) { return _M_ht.find(__key); } - const_iterator find(const key_type& __key) const - { return _M_ht.find(__key); } - - _Tp& operator[](const key_type& __key) { - return _M_ht.find_or_insert(value_type(__key, _Tp())).second; - } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) - { return _M_ht.equal_range(__key); } - pair - equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, - const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) -{ - return __hm1._M_ht == __hm2._M_ht; -} - -template -inline bool -operator!=(const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, - const hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) { - return !(__hm1 == __hm2); -} - -template -inline void -swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, - hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) -{ - __hm1.swap(__hm2); -} - -// Forward declaration of equality operator; needed for friend declaration. - -template , - class _EqualKey = equal_to<_Key>, - class _Alloc = allocator<_Tp> > -class hash_multimap; - -template -inline bool -operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, - const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2); - -/** - * This is an SGI extension. - * @ingroup SGIextensions - * @doctodo -*/ -template -class hash_multimap -{ - // concept requirements - __glibcxx_class_requires(_Key, _SGIAssignableConcept) - __glibcxx_class_requires(_Tp, _SGIAssignableConcept) - __glibcxx_class_requires3(_HashFcn, size_t, _Key, _UnaryFunctionConcept) - __glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept) - -private: - typedef hashtable, _Key, _HashFcn, - _Select1st >, _EqualKey, _Alloc> + /** + * This is an SGI extension. + * @ingroup SGIextensions + * @doctodo + */ + template, + class _EqualKey = equal_to<_Key>, class _Alloc = allocator<_Tp> > + class hash_map + { + private: + typedef hashtable,_Key, _HashFn, + _Select1st >, + _EqualKey, _Alloc> _Ht; + + _Ht _M_ht; + + public: + typedef typename _Ht::key_type key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher + hash_funct() const + { return _M_ht.hash_funct(); } + + key_equal + key_eq() const + { return _M_ht.key_eq(); } + + allocator_type + get_allocator() const + { return _M_ht.get_allocator(); } + + public: + hash_map() + : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + + explicit + hash_map(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + + hash_map(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + + hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + + template + hash_map(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_map(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_map(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_map(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + + public: + size_type + size() const + { return _M_ht.size(); } + + size_type + max_size() const + { return _M_ht.max_size(); } + + bool + empty() const + { return _M_ht.empty(); } + + void + swap(hash_map& __hs) + { _M_ht.swap(__hs._M_ht); } + + template + friend bool + operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&, + const hash_map<_K1, _T1, _HF, _EqK, _Al>&); + + iterator + begin() + { return _M_ht.begin(); } + + iterator + end() + { return _M_ht.end(); } + + const_iterator + begin() const + { return _M_ht.begin(); } + + const_iterator + end() const + { return _M_ht.end(); } + + public: + pair + insert(const value_type& __obj) + { return _M_ht.insert_unique(__obj); } + + template + void + insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_unique(__f, __l); } + + pair + insert_noresize(const value_type& __obj) + { return _M_ht.insert_unique_noresize(__obj); } + + iterator + find(const key_type& __key) + { return _M_ht.find(__key); } + + const_iterator + find(const key_type& __key) const + { return _M_ht.find(__key); } + + _Tp& + operator[](const key_type& __key) + { return _M_ht.find_or_insert(value_type(__key, _Tp())).second; } + + size_type + count(const key_type& __key) const + { return _M_ht.count(__key); } + + pair + equal_range(const key_type& __key) + { return _M_ht.equal_range(__key); } + + pair + equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type + erase(const key_type& __key) + {return _M_ht.erase(__key); } + + void + erase(iterator __it) + { _M_ht.erase(__it); } + + void + erase(iterator __f, iterator __l) + { _M_ht.erase(__f, __l); } + + void + clear() + { _M_ht.clear(); } + + void + resize(size_type __hint) + { _M_ht.resize(__hint); } + + size_type + bucket_count() const + { return _M_ht.bucket_count(); } + + size_type + max_bucket_count() const + { return _M_ht.max_bucket_count(); } + + size_type + elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } + }; + + template + inline bool + operator==(const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, + const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) + { return __hm1._M_ht == __hm2._M_ht; } + + template + inline bool + operator!=(const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, + const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) + { return !(__hm1 == __hm2); } + + template + inline void + swap(hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, + hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) + { __hm1.swap(__hm2); } + + + /** + * This is an SGI extension. + * @ingroup SGIextensions + * @doctodo + */ + template, + class _EqualKey = equal_to<_Key>, + class _Alloc = allocator<_Tp> > + class hash_multimap + { + // concept requirements + __glibcxx_class_requires(_Key, _SGIAssignableConcept) + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) + __glibcxx_class_requires3(_HashFn, size_t, _Key, _UnaryFunctionConcept) + __glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept) + + private: + typedef hashtable, _Key, _HashFn, + _Select1st >, _EqualKey, _Alloc> _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_multimap(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_multimap(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - - template - hash_multimap(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); } - - template - friend bool operator== (const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&, - const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&); - - iterator begin() { return _M_ht.begin(); } - iterator end() { return _M_ht.end(); } - const_iterator begin() const { return _M_ht.begin(); } - const_iterator end() const { return _M_ht.end(); } - -public: - iterator insert(const value_type& __obj) - { return _M_ht.insert_equal(__obj); } - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_equal(__f,__l); } - iterator insert_noresize(const value_type& __obj) - { return _M_ht.insert_equal_noresize(__obj); } - - iterator find(const key_type& __key) { return _M_ht.find(__key); } - const_iterator find(const key_type& __key) const - { return _M_ht.find(__key); } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) - { return _M_ht.equal_range(__key); } - pair - equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - -public: - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, - const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) -{ - return __hm1._M_ht == __hm2._M_ht; -} - -template -inline bool -operator!=(const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm1, - const hash_multimap<_Key,_Tp,_HF,_EqKey,_Alloc>& __hm2) { - return !(__hm1 == __hm2); -} - -template -inline void -swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, - hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm2) -{ - __hm1.swap(__hm2); -} - -} // namespace __gnu_cxx - -namespace std -{ -// Specialization of insert_iterator so that it will work for hash_map -// and hash_multimap. - -template -class insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > { -protected: - typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; - _Container* container; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x) : container(&__x) {} - insert_iterator(_Container& __x, typename _Container::iterator) - : container(&__x) {} - insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->insert(__value); - return *this; - } - insert_iterator<_Container>& operator*() { return *this; } - insert_iterator<_Container>& operator++() { return *this; } - insert_iterator<_Container>& operator++(int) { return *this; } -}; - -template -class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > { -protected: - typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; - _Container* container; - typename _Container::iterator iter; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x) : container(&__x) {} - insert_iterator(_Container& __x, typename _Container::iterator) - : container(&__x) {} - insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->insert(__value); - return *this; - } - insert_iterator<_Container>& operator*() { return *this; } - insert_iterator<_Container>& operator++() { return *this; } - insert_iterator<_Container>& operator++(int) { return *this; } -}; -} // namespace std + + _Ht _M_ht; + + public: + typedef typename _Ht::key_type key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher + hash_funct() const + { return _M_ht.hash_funct(); } + + key_equal + key_eq() const + { return _M_ht.key_eq(); } + + allocator_type + get_allocator() const + { return _M_ht.get_allocator(); } + + public: + hash_multimap() + : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + + explicit + hash_multimap(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + + hash_multimap(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + + hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + + template + hash_multimap(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + + public: + size_type + size() const + { return _M_ht.size(); } + + size_type + max_size() const + { return _M_ht.max_size(); } + + bool + empty() const + { return _M_ht.empty(); } + + void + swap(hash_multimap& __hs) + { _M_ht.swap(__hs._M_ht); } + + template + friend bool + operator==(const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&, + const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&); + + iterator + begin() + { return _M_ht.begin(); } + + iterator + end() + { return _M_ht.end(); } + + const_iterator + begin() const + { return _M_ht.begin(); } + + const_iterator + end() const + { return _M_ht.end(); } + + public: + iterator + insert(const value_type& __obj) + { return _M_ht.insert_equal(__obj); } + + template + void + insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_equal(__f,__l); } + + iterator + insert_noresize(const value_type& __obj) + { return _M_ht.insert_equal_noresize(__obj); } + + iterator + find(const key_type& __key) + { return _M_ht.find(__key); } + + const_iterator + find(const key_type& __key) const + { return _M_ht.find(__key); } + + size_type + count(const key_type& __key) const + { return _M_ht.count(__key); } + + pair + equal_range(const key_type& __key) + { return _M_ht.equal_range(__key); } + + pair + equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type + erase(const key_type& __key) + { return _M_ht.erase(__key); } + + void + erase(iterator __it) + { _M_ht.erase(__it); } + + void + erase(iterator __f, iterator __l) + { _M_ht.erase(__f, __l); } + + void + clear() + { _M_ht.clear(); } + + public: + void + resize(size_type __hint) + { _M_ht.resize(__hint); } + + size_type + bucket_count() const + { return _M_ht.bucket_count(); } + + size_type + max_bucket_count() const + { return _M_ht.max_bucket_count(); } + + size_type + elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } + }; + + template + inline bool + operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, + const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) + { return __hm1._M_ht == __hm2._M_ht; } + + template + inline bool + operator!=(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, + const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) + { return !(__hm1 == __hm2); } + + template + inline void + swap(hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, + hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) + { __hm1.swap(__hm2); } + +_GLIBCXX_END_NESTED_NAMESPACE + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // Specialization of insert_iterator so that it will work for hash_map + // and hash_multimap. + template + class insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn, + _EqKey, _Alloc> > + { + protected: + typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> + _Container; + _Container* container; + + public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) + : container(&__x) {} + + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __value) + { + container->insert(__value); + return *this; + } + + insert_iterator<_Container>& + operator*() + { return *this; } + + insert_iterator<_Container>& + operator++() { return *this; } + + insert_iterator<_Container>& + operator++(int) + { return *this; } + }; + + template + class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, + _EqKey, _Alloc> > + { + protected: + typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> + _Container; + _Container* container; + typename _Container::iterator iter; + + public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) + : container(&__x) {} + + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __value) + { + container->insert(__value); + return *this; + } + + insert_iterator<_Container>& + operator*() + { return *this; } + + insert_iterator<_Container>& + operator++() + { return *this; } + + insert_iterator<_Container>& + operator++(int) + { return *this; } + }; + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/ext/hash_set b/contrib/libstdc++/include/ext/hash_set index fee64fc..668fe13 100644 --- a/contrib/libstdc++/include/ext/hash_set +++ b/contrib/libstdc++/include/ext/hash_set @@ -1,6 +1,6 @@ // Hashing set implementation -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004, 2005, 2006 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -55,385 +55,520 @@ /** @file ext/hash_set * This file is a GNU extension to the Standard C++ Library (possibly - * containing extensions from the HP/SGI STL subset). You should only - * include this header if you are using GCC 3 or later. + * containing extensions from the HP/SGI STL subset). */ #ifndef _HASH_SET #define _HASH_SET 1 +#include #include #include -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NESTED_NAMESPACE(__gnu_cxx, _GLIBCXX_EXT) + using std::equal_to; using std::allocator; using std::pair; using std::_Identity; - // Forward declaration of equality operator; needed for friend - // declaration. - template , - class _EqualKey = equal_to<_Value>, - class _Alloc = allocator<_Value> > - class hash_set; + /** + * This is an SGI extension. + * @ingroup SGIextensions + * @doctodo + */ + template, + class _EqualKey = equal_to<_Value>, + class _Alloc = allocator<_Value> > + class hash_set + { + // concept requirements + __glibcxx_class_requires(_Value, _SGIAssignableConcept) + __glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept) + __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept) + + private: + typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, + _EqualKey, _Alloc> _Ht; + _Ht _M_ht; + + public: + typedef typename _Ht::key_type key_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Alloc::pointer pointer; + typedef typename _Alloc::const_pointer const_pointer; + typedef typename _Alloc::reference reference; + typedef typename _Alloc::const_reference const_reference; + + typedef typename _Ht::const_iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher + hash_funct() const + { return _M_ht.hash_funct(); } + + key_equal + key_eq() const + { return _M_ht.key_eq(); } + + allocator_type + get_allocator() const + { return _M_ht.get_allocator(); } + + public: + hash_set() + : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + + explicit + hash_set(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + + hash_set(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + + hash_set(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + + template + hash_set(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_set(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_set(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_set(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + + public: + size_type + size() const + { return _M_ht.size(); } + + size_type + max_size() const + { return _M_ht.max_size(); } + + bool + empty() const + { return _M_ht.empty(); } + + void + swap(hash_set& __hs) + { _M_ht.swap(__hs._M_ht); } + + template + friend bool + operator==(const hash_set<_Val, _HF, _EqK, _Al>&, + const hash_set<_Val, _HF, _EqK, _Al>&); + + iterator + begin() const + { return _M_ht.begin(); } + + iterator + end() const + { return _M_ht.end(); } + + public: + pair + insert(const value_type& __obj) + { + pair __p = _M_ht.insert_unique(__obj); + return pair(__p.first, __p.second); + } + + template + void + insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_unique(__f, __l); } + + pair + insert_noresize(const value_type& __obj) + { + pair __p + = _M_ht.insert_unique_noresize(__obj); + return pair(__p.first, __p.second); + } + + iterator + find(const key_type& __key) const + { return _M_ht.find(__key); } + + size_type + count(const key_type& __key) const + { return _M_ht.count(__key); } + + pair + equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type + erase(const key_type& __key) + {return _M_ht.erase(__key); } + + void + erase(iterator __it) + { _M_ht.erase(__it); } + + void + erase(iterator __f, iterator __l) + { _M_ht.erase(__f, __l); } + + void + clear() + { _M_ht.clear(); } + + public: + void + resize(size_type __hint) + { _M_ht.resize(__hint); } + + size_type + bucket_count() const + { return _M_ht.bucket_count(); } + + size_type + max_bucket_count() const + { return _M_ht.max_bucket_count(); } + + size_type + elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } + }; + + template + inline bool + operator==(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1, + const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2) + { return __hs1._M_ht == __hs2._M_ht; } + + template + inline bool + operator!=(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1, + const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2) + { return !(__hs1 == __hs2); } + + template + inline void + swap(hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1, + hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2) + { __hs1.swap(__hs2); } + + + /** + * This is an SGI extension. + * @ingroup SGIextensions + * @doctodo + */ + template, + class _EqualKey = equal_to<_Value>, + class _Alloc = allocator<_Value> > + class hash_multiset + { + // concept requirements + __glibcxx_class_requires(_Value, _SGIAssignableConcept) + __glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept) + __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept) + + private: + typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, + _EqualKey, _Alloc> _Ht; + _Ht _M_ht; + + public: + typedef typename _Ht::key_type key_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Alloc::pointer pointer; + typedef typename _Alloc::const_pointer const_pointer; + typedef typename _Alloc::reference reference; + typedef typename _Alloc::const_reference const_reference; + + typedef typename _Ht::const_iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher + hash_funct() const + { return _M_ht.hash_funct(); } + + key_equal + key_eq() const + { return _M_ht.key_eq(); } + + allocator_type + get_allocator() const + { return _M_ht.get_allocator(); } + + public: + hash_multiset() + : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + + explicit + hash_multiset(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + + hash_multiset(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + + hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + + template + hash_multiset(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + + public: + size_type + size() const + { return _M_ht.size(); } + + size_type + max_size() const + { return _M_ht.max_size(); } + + bool + empty() const + { return _M_ht.empty(); } + + void + swap(hash_multiset& hs) + { _M_ht.swap(hs._M_ht); } + + template + friend bool + operator==(const hash_multiset<_Val, _HF, _EqK, _Al>&, + const hash_multiset<_Val, _HF, _EqK, _Al>&); + + iterator + begin() const + { return _M_ht.begin(); } + + iterator + end() const + { return _M_ht.end(); } + + public: + iterator + insert(const value_type& __obj) + { return _M_ht.insert_equal(__obj); } + + template + void + insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_equal(__f,__l); } + + iterator + insert_noresize(const value_type& __obj) + { return _M_ht.insert_equal_noresize(__obj); } + + iterator + find(const key_type& __key) const + { return _M_ht.find(__key); } + + size_type + count(const key_type& __key) const + { return _M_ht.count(__key); } + + pair + equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type + erase(const key_type& __key) + { return _M_ht.erase(__key); } + + void + erase(iterator __it) + { _M_ht.erase(__it); } + + void + erase(iterator __f, iterator __l) + { _M_ht.erase(__f, __l); } + + void + clear() + { _M_ht.clear(); } + + public: + void + resize(size_type __hint) + { _M_ht.resize(__hint); } + + size_type + bucket_count() const + { return _M_ht.bucket_count(); } + + size_type + max_bucket_count() const + { return _M_ht.max_bucket_count(); } + + size_type + elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } + }; + + template + inline bool + operator==(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1, + const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2) + { return __hs1._M_ht == __hs2._M_ht; } - template + template inline bool - operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2); - -/** - * This is an SGI extension. - * @ingroup SGIextensions - * @doctodo -*/ -template -class hash_set -{ - // concept requirements - __glibcxx_class_requires(_Value, _SGIAssignableConcept) - __glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept) - __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept) - -private: - typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, - _EqualKey, _Alloc> _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Alloc::pointer pointer; - typedef typename _Alloc::const_pointer const_pointer; - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; - - typedef typename _Ht::const_iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_set() - : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_set(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_set(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_set(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - - template - hash_set(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_set(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_set(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_unique(__f, __l); } - template - hash_set(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_unique(__f, __l); } - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_set& __hs) { _M_ht.swap(__hs._M_ht); } - - template - friend bool operator== (const hash_set<_Val, _HF, _EqK, _Al>&, - const hash_set<_Val, _HF, _EqK, _Al>&); - - iterator begin() const { return _M_ht.begin(); } - iterator end() const { return _M_ht.end(); } - -public: - pair insert(const value_type& __obj) + operator!=(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1, + const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2) + { return !(__hs1 == __hs2); } + + template + inline void + swap(hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1, + hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2) + { __hs1.swap(__hs2); } + +_GLIBCXX_END_NESTED_NAMESPACE + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // Specialization of insert_iterator so that it will work for hash_set + // and hash_multiset. + template + class insert_iterator<__gnu_cxx::hash_set<_Value, _HashFcn, + _EqualKey, _Alloc> > + { + protected: + typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc> + _Container; + _Container* container; + + public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) + : container(&__x) {} + + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __value) + { + container->insert(__value); + return *this; + } + + insert_iterator<_Container>& + operator*() + { return *this; } + + insert_iterator<_Container>& + operator++() + { return *this; } + + insert_iterator<_Container>& + operator++(int) + { return *this; } + }; + + template + class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn, + _EqualKey, _Alloc> > { - pair __p = _M_ht.insert_unique(__obj); - return pair(__p.first, __p.second); - } - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_unique(__f,__l); } - pair insert_noresize(const value_type& __obj) - { - pair __p = - _M_ht.insert_unique_noresize(__obj); - return pair(__p.first, __p.second); - } - - iterator find(const key_type& __key) const { return _M_ht.find(__key); } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - -public: - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) -{ - return __hs1._M_ht == __hs2._M_ht; -} - -template -inline bool -operator!=(const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_set<_Value,_HashFcn,_EqualKey,_Alloc>& __hs2) { - return !(__hs1 == __hs2); -} - -template -inline void -swap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) -{ - __hs1.swap(__hs2); -} - - -template , - class _EqualKey = equal_to<_Value>, - class _Alloc = allocator<_Value> > -class hash_multiset; - -template -inline bool -operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2); - - -/** - * This is an SGI extension. - * @ingroup SGIextensions - * @doctodo -*/ -template -class hash_multiset -{ - // concept requirements - __glibcxx_class_requires(_Value, _SGIAssignableConcept) - __glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept) - __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept) - -private: - typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, - _EqualKey, _Alloc> _Ht; - _Ht _M_ht; - -public: - typedef typename _Ht::key_type key_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Alloc::pointer pointer; - typedef typename _Alloc::const_pointer const_pointer; - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; - - typedef typename _Ht::const_iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; - - hasher hash_funct() const { return _M_ht.hash_funct(); } - key_equal key_eq() const { return _M_ht.key_eq(); } - allocator_type get_allocator() const { return _M_ht.get_allocator(); } - -public: - hash_multiset() - : _M_ht(100, hasher(), key_equal(), allocator_type()) {} - explicit hash_multiset(size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_multiset(size_type __n, const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) {} - - template - hash_multiset(_InputIterator __f, _InputIterator __l) - : _M_ht(100, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n) - : _M_ht(__n, hasher(), key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _M_ht(__n, __hf, key_equal(), allocator_type()) - { _M_ht.insert_equal(__f, __l); } - template - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _M_ht(__n, __hf, __eql, __a) - { _M_ht.insert_equal(__f, __l); } - -public: - size_type size() const { return _M_ht.size(); } - size_type max_size() const { return _M_ht.max_size(); } - bool empty() const { return _M_ht.empty(); } - void swap(hash_multiset& hs) { _M_ht.swap(hs._M_ht); } - - template - friend bool operator== (const hash_multiset<_Val, _HF, _EqK, _Al>&, - const hash_multiset<_Val, _HF, _EqK, _Al>&); - - iterator begin() const { return _M_ht.begin(); } - iterator end() const { return _M_ht.end(); } - -public: - iterator insert(const value_type& __obj) - { return _M_ht.insert_equal(__obj); } - template - void insert(_InputIterator __f, _InputIterator __l) - { _M_ht.insert_equal(__f,__l); } - iterator insert_noresize(const value_type& __obj) - { return _M_ht.insert_equal_noresize(__obj); } - - iterator find(const key_type& __key) const { return _M_ht.find(__key); } - - size_type count(const key_type& __key) const { return _M_ht.count(__key); } - - pair equal_range(const key_type& __key) const - { return _M_ht.equal_range(__key); } - - size_type erase(const key_type& __key) {return _M_ht.erase(__key); } - void erase(iterator __it) { _M_ht.erase(__it); } - void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } - void clear() { _M_ht.clear(); } - -public: - void resize(size_type __hint) { _M_ht.resize(__hint); } - size_type bucket_count() const { return _M_ht.bucket_count(); } - size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } - size_type elems_in_bucket(size_type __n) const - { return _M_ht.elems_in_bucket(__n); } -}; - -template -inline bool -operator==(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) -{ - return __hs1._M_ht == __hs2._M_ht; -} - -template -inline bool -operator!=(const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - const hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) { - return !(__hs1 == __hs2); -} - -template -inline void -swap(hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, - hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs2) { - __hs1.swap(__hs2); -} - -} // namespace __gnu_cxx - -namespace std -{ -// Specialization of insert_iterator so that it will work for hash_set -// and hash_multiset. - -template -class insert_iterator<__gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc> > { -protected: - typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Container; - _Container* container; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x) : container(&__x) {} - insert_iterator(_Container& __x, typename _Container::iterator) - : container(&__x) {} - insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->insert(__value); - return *this; - } - insert_iterator<_Container>& operator*() { return *this; } - insert_iterator<_Container>& operator++() { return *this; } - insert_iterator<_Container>& operator++(int) { return *this; } -}; - -template -class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > { -protected: - typedef __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container; - _Container* container; - typename _Container::iterator iter; -public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; - - insert_iterator(_Container& __x) : container(&__x) {} - insert_iterator(_Container& __x, typename _Container::iterator) - : container(&__x) {} - insert_iterator<_Container>& - operator=(const typename _Container::value_type& __value) { - container->insert(__value); - return *this; - } - insert_iterator<_Container>& operator*() { return *this; } - insert_iterator<_Container>& operator++() { return *this; } - insert_iterator<_Container>& operator++(int) { return *this; } -}; -} // namespace std + protected: + typedef __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> + _Container; + _Container* container; + typename _Container::iterator iter; + + public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) + : container(&__x) {} + + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __value) + { + container->insert(__value); + return *this; + } + + insert_iterator<_Container>& + operator*() + { return *this; } + + insert_iterator<_Container>& + operator++() + { return *this; } + + insert_iterator<_Container>& + operator++(int) { return *this; } + }; + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/ext/hashtable.h b/contrib/libstdc++/include/ext/hashtable.h index 9f2fb1e..233806f 100644 --- a/contrib/libstdc++/include/ext/hashtable.h +++ b/contrib/libstdc++/include/ext/hashtable.h @@ -1,6 +1,7 @@ // Hashtable implementation used by containers -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -15,7 +16,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -55,8 +56,7 @@ /** @file ext/hashtable.h * This file is a GNU extension to the Standard C++ Library (possibly - * containing extensions from the HP/SGI STL subset). You should only - * include this header if you are using GCC 3 or later. + * containing extensions from the HP/SGI STL subset). */ #ifndef _HASHTABLE_H @@ -71,924 +71,1060 @@ #include #include -namespace __gnu_cxx -{ -using std::size_t; -using std::ptrdiff_t; -using std::forward_iterator_tag; -using std::input_iterator_tag; -using std::_Construct; -using std::_Destroy; -using std::distance; -using std::vector; -using std::pair; -using std::__iterator_category; - -template -struct _Hashtable_node -{ - _Hashtable_node* _M_next; - _Val _M_val; -}; - -template > -class hashtable; - -template -struct _Hashtable_iterator; - -template -struct _Hashtable_const_iterator; - -template -struct _Hashtable_iterator { - typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> - _Hashtable; - typedef _Hashtable_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - const_iterator; - typedef _Hashtable_node<_Val> _Node; - - typedef forward_iterator_tag iterator_category; - typedef _Val value_type; - typedef ptrdiff_t difference_type; - typedef size_t size_type; - typedef _Val& reference; - typedef _Val* pointer; - - _Node* _M_cur; - _Hashtable* _M_ht; - - _Hashtable_iterator(_Node* __n, _Hashtable* __tab) - : _M_cur(__n), _M_ht(__tab) {} - _Hashtable_iterator() {} - reference operator*() const { return _M_cur->_M_val; } - pointer operator->() const { return &(operator*()); } - iterator& operator++(); - iterator operator++(int); - bool operator==(const iterator& __it) const - { return _M_cur == __it._M_cur; } - bool operator!=(const iterator& __it) const - { return _M_cur != __it._M_cur; } -}; - - -template -struct _Hashtable_const_iterator { - typedef hashtable<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> - _Hashtable; - typedef _Hashtable_iterator<_Val,_Key,_HashFcn, - _ExtractKey,_EqualKey,_Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - const_iterator; - typedef _Hashtable_node<_Val> _Node; - - typedef forward_iterator_tag iterator_category; - typedef _Val value_type; - typedef ptrdiff_t difference_type; - typedef size_t size_type; - typedef const _Val& reference; - typedef const _Val* pointer; - - const _Node* _M_cur; - const _Hashtable* _M_ht; - - _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab) - : _M_cur(__n), _M_ht(__tab) {} - _Hashtable_const_iterator() {} - _Hashtable_const_iterator(const iterator& __it) - : _M_cur(__it._M_cur), _M_ht(__it._M_ht) {} - reference operator*() const { return _M_cur->_M_val; } - pointer operator->() const { return &(operator*()); } - const_iterator& operator++(); - const_iterator operator++(int); - bool operator==(const const_iterator& __it) const - { return _M_cur == __it._M_cur; } - bool operator!=(const const_iterator& __it) const - { return _M_cur != __it._M_cur; } -}; - -// Note: assumes long is at least 32 bits. -enum { _S_num_primes = 28 }; - -static const unsigned long __stl_prime_list[_S_num_primes] = -{ - 53ul, 97ul, 193ul, 389ul, 769ul, - 1543ul, 3079ul, 6151ul, 12289ul, 24593ul, - 49157ul, 98317ul, 196613ul, 393241ul, 786433ul, - 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul, - 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul, - 1610612741ul, 3221225473ul, 4294967291ul -}; - -inline unsigned long __stl_next_prime(unsigned long __n) -{ - const unsigned long* __first = __stl_prime_list; - const unsigned long* __last = __stl_prime_list + (int)_S_num_primes; - const unsigned long* pos = std::lower_bound(__first, __last, __n); - return pos == __last ? *(__last - 1) : *pos; -} - -// Forward declaration of operator==. - -template -class hashtable; - -template -bool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, - const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2); - - -// Hashtables handle allocators a bit differently than other -// containers do. If we're using standard-conforming allocators, then -// a hashtable unconditionally has a member variable to hold its -// allocator, even if it so happens that all instances of the -// allocator type are identical. This is because, for hashtables, -// this extra storage is negligible. Additionally, a base class -// wouldn't serve any other purposes; it wouldn't, for example, -// simplify the exception-handling code. - -template -class hashtable { -public: - typedef _Key key_type; - typedef _Val value_type; - typedef _HashFcn hasher; - typedef _EqualKey key_equal; - - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - - hasher hash_funct() const { return _M_hash; } - key_equal key_eq() const { return _M_equals; } - -private: - typedef _Hashtable_node<_Val> _Node; - -public: - typedef typename _Alloc::template rebind::other allocator_type; - allocator_type get_allocator() const { return _M_node_allocator; } -private: - typedef typename _Alloc::template rebind<_Node>::other _Node_Alloc; - typedef typename _Alloc::template rebind<_Node*>::other _Nodeptr_Alloc; - typedef vector<_Node*, _Nodeptr_Alloc> _Vector_type; - - _Node_Alloc _M_node_allocator; - _Node* _M_get_node() { return _M_node_allocator.allocate(1); } - void _M_put_node(_Node* __p) { _M_node_allocator.deallocate(__p, 1); } - -private: - hasher _M_hash; - key_equal _M_equals; - _ExtractKey _M_get_key; - _Vector_type _M_buckets; - size_type _M_num_elements; - -public: - typedef _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey, - _Alloc> - const_iterator; - - friend struct - _Hashtable_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>; - friend struct - _Hashtable_const_iterator<_Val,_Key,_HashFcn,_ExtractKey,_EqualKey,_Alloc>; - -public: - hashtable(size_type __n, - const _HashFcn& __hf, - const _EqualKey& __eql, - const _ExtractKey& __ext, - const allocator_type& __a = allocator_type()) - : _M_node_allocator(__a), - _M_hash(__hf), - _M_equals(__eql), - _M_get_key(__ext), - _M_buckets(__a), - _M_num_elements(0) - { - _M_initialize_buckets(__n); - } +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + using std::size_t; + using std::ptrdiff_t; + using std::forward_iterator_tag; + using std::input_iterator_tag; + using std::_Construct; + using std::_Destroy; + using std::distance; + using std::vector; + using std::pair; + using std::__iterator_category; + + template + struct _Hashtable_node + { + _Hashtable_node* _M_next; + _Val _M_val; + }; - hashtable(size_type __n, - const _HashFcn& __hf, - const _EqualKey& __eql, - const allocator_type& __a = allocator_type()) - : _M_node_allocator(__a), - _M_hash(__hf), - _M_equals(__eql), - _M_get_key(_ExtractKey()), - _M_buckets(__a), - _M_num_elements(0) - { - _M_initialize_buckets(__n); - } + template > + class hashtable; - hashtable(const hashtable& __ht) - : _M_node_allocator(__ht.get_allocator()), - _M_hash(__ht._M_hash), - _M_equals(__ht._M_equals), - _M_get_key(__ht._M_get_key), - _M_buckets(__ht.get_allocator()), - _M_num_elements(0) - { - _M_copy_from(__ht); - } + template + struct _Hashtable_iterator; + + template + struct _Hashtable_const_iterator; - hashtable& operator= (const hashtable& __ht) + template + struct _Hashtable_iterator + { + typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc> + _Hashtable; + typedef _Hashtable_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + const_iterator; + typedef _Hashtable_node<_Val> _Node; + typedef forward_iterator_tag iterator_category; + typedef _Val value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + typedef _Val& reference; + typedef _Val* pointer; + + _Node* _M_cur; + _Hashtable* _M_ht; + + _Hashtable_iterator(_Node* __n, _Hashtable* __tab) + : _M_cur(__n), _M_ht(__tab) { } + + _Hashtable_iterator() { } + + reference + operator*() const + { return _M_cur->_M_val; } + + pointer + operator->() const + { return &(operator*()); } + + iterator& + operator++(); + + iterator + operator++(int); + + bool + operator==(const iterator& __it) const + { return _M_cur == __it._M_cur; } + + bool + operator!=(const iterator& __it) const + { return _M_cur != __it._M_cur; } + }; + + template + struct _Hashtable_const_iterator + { + typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc> + _Hashtable; + typedef _Hashtable_iterator<_Val,_Key,_HashFcn, + _ExtractKey,_EqualKey,_Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + const_iterator; + typedef _Hashtable_node<_Val> _Node; + + typedef forward_iterator_tag iterator_category; + typedef _Val value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + typedef const _Val& reference; + typedef const _Val* pointer; + + const _Node* _M_cur; + const _Hashtable* _M_ht; + + _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab) + : _M_cur(__n), _M_ht(__tab) { } + + _Hashtable_const_iterator() { } + + _Hashtable_const_iterator(const iterator& __it) + : _M_cur(__it._M_cur), _M_ht(__it._M_ht) { } + + reference + operator*() const + { return _M_cur->_M_val; } + + pointer + operator->() const + { return &(operator*()); } + + const_iterator& + operator++(); + + const_iterator + operator++(int); + + bool + operator==(const const_iterator& __it) const + { return _M_cur == __it._M_cur; } + + bool + operator!=(const const_iterator& __it) const + { return _M_cur != __it._M_cur; } + }; + + // Note: assumes long is at least 32 bits. + enum { _S_num_primes = 28 }; + + static const unsigned long __stl_prime_list[_S_num_primes] = + { + 53ul, 97ul, 193ul, 389ul, 769ul, + 1543ul, 3079ul, 6151ul, 12289ul, 24593ul, + 49157ul, 98317ul, 196613ul, 393241ul, 786433ul, + 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul, + 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul, + 1610612741ul, 3221225473ul, 4294967291ul + }; + + inline unsigned long + __stl_next_prime(unsigned long __n) { - if (&__ht != this) { - clear(); - _M_hash = __ht._M_hash; - _M_equals = __ht._M_equals; - _M_get_key = __ht._M_get_key; - _M_copy_from(__ht); - } - return *this; + const unsigned long* __first = __stl_prime_list; + const unsigned long* __last = __stl_prime_list + (int)_S_num_primes; + const unsigned long* pos = std::lower_bound(__first, __last, __n); + return pos == __last ? *(__last - 1) : *pos; } - ~hashtable() { clear(); } + // Forward declaration of operator==. + template + class hashtable; + + template + bool + operator==(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, + const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2); + + // Hashtables handle allocators a bit differently than other + // containers do. If we're using standard-conforming allocators, then + // a hashtable unconditionally has a member variable to hold its + // allocator, even if it so happens that all instances of the + // allocator type are identical. This is because, for hashtables, + // this extra storage is negligible. Additionally, a base class + // wouldn't serve any other purposes; it wouldn't, for example, + // simplify the exception-handling code. + template + class hashtable + { + public: + typedef _Key key_type; + typedef _Val value_type; + typedef _HashFcn hasher; + typedef _EqualKey key_equal; + + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + hasher + hash_funct() const + { return _M_hash; } + + key_equal + key_eq() const + { return _M_equals; } + + private: + typedef _Hashtable_node<_Val> _Node; + + public: + typedef typename _Alloc::template rebind::other allocator_type; + allocator_type + get_allocator() const + { return _M_node_allocator; } + + private: + typedef typename _Alloc::template rebind<_Node>::other _Node_Alloc; + typedef typename _Alloc::template rebind<_Node*>::other _Nodeptr_Alloc; + typedef vector<_Node*, _Nodeptr_Alloc> _Vector_type; + + _Node_Alloc _M_node_allocator; + + _Node* + _M_get_node() + { return _M_node_allocator.allocate(1); } + + void + _M_put_node(_Node* __p) + { _M_node_allocator.deallocate(__p, 1); } + + private: + hasher _M_hash; + key_equal _M_equals; + _ExtractKey _M_get_key; + _Vector_type _M_buckets; + size_type _M_num_elements; + + public: + typedef _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, + _EqualKey, _Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, + _EqualKey, _Alloc> + const_iterator; + + friend struct + _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; + + friend struct + _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, + _EqualKey, _Alloc>; + + public: + hashtable(size_type __n, const _HashFcn& __hf, + const _EqualKey& __eql, const _ExtractKey& __ext, + const allocator_type& __a = allocator_type()) + : _M_node_allocator(__a), _M_hash(__hf), _M_equals(__eql), + _M_get_key(__ext), _M_buckets(__a), _M_num_elements(0) + { _M_initialize_buckets(__n); } + + hashtable(size_type __n, const _HashFcn& __hf, + const _EqualKey& __eql, + const allocator_type& __a = allocator_type()) + : _M_node_allocator(__a), _M_hash(__hf), _M_equals(__eql), + _M_get_key(_ExtractKey()), _M_buckets(__a), _M_num_elements(0) + { _M_initialize_buckets(__n); } + + hashtable(const hashtable& __ht) + : _M_node_allocator(__ht.get_allocator()), _M_hash(__ht._M_hash), + _M_equals(__ht._M_equals), _M_get_key(__ht._M_get_key), + _M_buckets(__ht.get_allocator()), _M_num_elements(0) + { _M_copy_from(__ht); } + + hashtable& + operator= (const hashtable& __ht) + { + if (&__ht != this) + { + clear(); + _M_hash = __ht._M_hash; + _M_equals = __ht._M_equals; + _M_get_key = __ht._M_get_key; + _M_copy_from(__ht); + } + return *this; + } - size_type size() const { return _M_num_elements; } - size_type max_size() const { return size_type(-1); } - bool empty() const { return size() == 0; } + ~hashtable() + { clear(); } - void swap(hashtable& __ht) - { - std::swap(_M_hash, __ht._M_hash); - std::swap(_M_equals, __ht._M_equals); - std::swap(_M_get_key, __ht._M_get_key); - _M_buckets.swap(__ht._M_buckets); - std::swap(_M_num_elements, __ht._M_num_elements); - } + size_type + size() const + { return _M_num_elements; } - iterator begin() - { - for (size_type __n = 0; __n < _M_buckets.size(); ++__n) - if (_M_buckets[__n]) - return iterator(_M_buckets[__n], this); - return end(); - } + size_type + max_size() const + { return size_type(-1); } - iterator end() { return iterator(0, this); } + bool + empty() const + { return size() == 0; } - const_iterator begin() const - { - for (size_type __n = 0; __n < _M_buckets.size(); ++__n) - if (_M_buckets[__n]) - return const_iterator(_M_buckets[__n], this); - return end(); - } + void + swap(hashtable& __ht) + { + std::swap(_M_hash, __ht._M_hash); + std::swap(_M_equals, __ht._M_equals); + std::swap(_M_get_key, __ht._M_get_key); + _M_buckets.swap(__ht._M_buckets); + std::swap(_M_num_elements, __ht._M_num_elements); + } - const_iterator end() const { return const_iterator(0, this); } + iterator + begin() + { + for (size_type __n = 0; __n < _M_buckets.size(); ++__n) + if (_M_buckets[__n]) + return iterator(_M_buckets[__n], this); + return end(); + } - template - friend bool operator== (const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&, - const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&); -public: + iterator + end() + { return iterator(0, this); } - size_type bucket_count() const { return _M_buckets.size(); } + const_iterator + begin() const + { + for (size_type __n = 0; __n < _M_buckets.size(); ++__n) + if (_M_buckets[__n]) + return const_iterator(_M_buckets[__n], this); + return end(); + } - size_type max_bucket_count() const - { return __stl_prime_list[(int)_S_num_primes - 1]; } + const_iterator + end() const + { return const_iterator(0, this); } - size_type elems_in_bucket(size_type __bucket) const - { - size_type __result = 0; - for (_Node* __cur = _M_buckets[__bucket]; __cur; __cur = __cur->_M_next) - __result += 1; - return __result; - } + template + friend bool + operator==(const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&, + const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&); - pair insert_unique(const value_type& __obj) - { - resize(_M_num_elements + 1); - return insert_unique_noresize(__obj); - } + public: + size_type + bucket_count() const + { return _M_buckets.size(); } - iterator insert_equal(const value_type& __obj) - { - resize(_M_num_elements + 1); - return insert_equal_noresize(__obj); - } + size_type + max_bucket_count() const + { return __stl_prime_list[(int)_S_num_primes - 1]; } - pair insert_unique_noresize(const value_type& __obj); - iterator insert_equal_noresize(const value_type& __obj); + size_type + elems_in_bucket(size_type __bucket) const + { + size_type __result = 0; + for (_Node* __n = _M_buckets[__bucket]; __n; __n = __n->_M_next) + __result += 1; + return __result; + } - template - void insert_unique(_InputIterator __f, _InputIterator __l) - { - insert_unique(__f, __l, __iterator_category(__f)); - } + pair + insert_unique(const value_type& __obj) + { + resize(_M_num_elements + 1); + return insert_unique_noresize(__obj); + } - template - void insert_equal(_InputIterator __f, _InputIterator __l) - { - insert_equal(__f, __l, __iterator_category(__f)); - } + iterator + insert_equal(const value_type& __obj) + { + resize(_M_num_elements + 1); + return insert_equal_noresize(__obj); + } - template - void insert_unique(_InputIterator __f, _InputIterator __l, - input_iterator_tag) - { - for ( ; __f != __l; ++__f) - insert_unique(*__f); - } + pair + insert_unique_noresize(const value_type& __obj); - template - void insert_equal(_InputIterator __f, _InputIterator __l, - input_iterator_tag) - { - for ( ; __f != __l; ++__f) - insert_equal(*__f); - } + iterator + insert_equal_noresize(const value_type& __obj); - template - void insert_unique(_ForwardIterator __f, _ForwardIterator __l, - forward_iterator_tag) - { - size_type __n = distance(__f, __l); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_unique_noresize(*__f); - } + template + void + insert_unique(_InputIterator __f, _InputIterator __l) + { insert_unique(__f, __l, __iterator_category(__f)); } - template - void insert_equal(_ForwardIterator __f, _ForwardIterator __l, - forward_iterator_tag) - { - size_type __n = distance(__f, __l); - resize(_M_num_elements + __n); - for ( ; __n > 0; --__n, ++__f) - insert_equal_noresize(*__f); - } + template + void + insert_equal(_InputIterator __f, _InputIterator __l) + { insert_equal(__f, __l, __iterator_category(__f)); } - reference find_or_insert(const value_type& __obj); + template + void + insert_unique(_InputIterator __f, _InputIterator __l, + input_iterator_tag) + { + for ( ; __f != __l; ++__f) + insert_unique(*__f); + } + + template + void + insert_equal(_InputIterator __f, _InputIterator __l, + input_iterator_tag) + { + for ( ; __f != __l; ++__f) + insert_equal(*__f); + } + + template + void + insert_unique(_ForwardIterator __f, _ForwardIterator __l, + forward_iterator_tag) + { + size_type __n = distance(__f, __l); + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_unique_noresize(*__f); + } + + template + void + insert_equal(_ForwardIterator __f, _ForwardIterator __l, + forward_iterator_tag) + { + size_type __n = distance(__f, __l); + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_equal_noresize(*__f); + } - iterator find(const key_type& __key) - { - size_type __n = _M_bkt_num_key(__key); - _Node* __first; - for ( __first = _M_buckets[__n]; - __first && !_M_equals(_M_get_key(__first->_M_val), __key); - __first = __first->_M_next) - {} - return iterator(__first, this); - } + reference + find_or_insert(const value_type& __obj); - const_iterator find(const key_type& __key) const - { - size_type __n = _M_bkt_num_key(__key); - const _Node* __first; - for ( __first = _M_buckets[__n]; - __first && !_M_equals(_M_get_key(__first->_M_val), __key); - __first = __first->_M_next) - {} - return const_iterator(__first, this); - } + iterator + find(const key_type& __key) + { + size_type __n = _M_bkt_num_key(__key); + _Node* __first; + for (__first = _M_buckets[__n]; + __first && !_M_equals(_M_get_key(__first->_M_val), __key); + __first = __first->_M_next) + { } + return iterator(__first, this); + } - size_type count(const key_type& __key) const - { - const size_type __n = _M_bkt_num_key(__key); - size_type __result = 0; + const_iterator + find(const key_type& __key) const + { + size_type __n = _M_bkt_num_key(__key); + const _Node* __first; + for (__first = _M_buckets[__n]; + __first && !_M_equals(_M_get_key(__first->_M_val), __key); + __first = __first->_M_next) + { } + return const_iterator(__first, this); + } - for (const _Node* __cur = _M_buckets[__n]; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), __key)) - ++__result; - return __result; - } + size_type + count(const key_type& __key) const + { + const size_type __n = _M_bkt_num_key(__key); + size_type __result = 0; + + for (const _Node* __cur = _M_buckets[__n]; __cur; + __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), __key)) + ++__result; + return __result; + } - pair - equal_range(const key_type& __key); + pair + equal_range(const key_type& __key); - pair - equal_range(const key_type& __key) const; + pair + equal_range(const key_type& __key) const; - size_type erase(const key_type& __key); - void erase(const iterator& __it); - void erase(iterator __first, iterator __last); + size_type + erase(const key_type& __key); + + void + erase(const iterator& __it); - void erase(const const_iterator& __it); - void erase(const_iterator __first, const_iterator __last); + void + erase(iterator __first, iterator __last); - void resize(size_type __num_elements_hint); - void clear(); + void + erase(const const_iterator& __it); -private: - size_type _M_next_size(size_type __n) const - { return __stl_next_prime(__n); } + void + erase(const_iterator __first, const_iterator __last); - void _M_initialize_buckets(size_type __n) - { - const size_type __n_buckets = _M_next_size(__n); - _M_buckets.reserve(__n_buckets); - _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*) 0); - _M_num_elements = 0; - } + void + resize(size_type __num_elements_hint); - size_type _M_bkt_num_key(const key_type& __key) const - { - return _M_bkt_num_key(__key, _M_buckets.size()); - } + void + clear(); - size_type _M_bkt_num(const value_type& __obj) const - { - return _M_bkt_num_key(_M_get_key(__obj)); - } + private: + size_type + _M_next_size(size_type __n) const + { return __stl_next_prime(__n); } - size_type _M_bkt_num_key(const key_type& __key, size_t __n) const - { - return _M_hash(__key) % __n; - } + void + _M_initialize_buckets(size_type __n) + { + const size_type __n_buckets = _M_next_size(__n); + _M_buckets.reserve(__n_buckets); + _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*) 0); + _M_num_elements = 0; + } - size_type _M_bkt_num(const value_type& __obj, size_t __n) const - { - return _M_bkt_num_key(_M_get_key(__obj), __n); - } + size_type + _M_bkt_num_key(const key_type& __key) const + { return _M_bkt_num_key(__key, _M_buckets.size()); } - _Node* _M_new_node(const value_type& __obj) - { - _Node* __n = _M_get_node(); - __n->_M_next = 0; - try { - _Construct(&__n->_M_val, __obj); - return __n; - } - catch(...) + size_type + _M_bkt_num(const value_type& __obj) const + { return _M_bkt_num_key(_M_get_key(__obj)); } + + size_type + _M_bkt_num_key(const key_type& __key, size_t __n) const + { return _M_hash(__key) % __n; } + + size_type + _M_bkt_num(const value_type& __obj, size_t __n) const + { return _M_bkt_num_key(_M_get_key(__obj), __n); } + + _Node* + _M_new_node(const value_type& __obj) + { + _Node* __n = _M_get_node(); + __n->_M_next = 0; + try + { + this->get_allocator().construct(&__n->_M_val, __obj); + return __n; + } + catch(...) + { + _M_put_node(__n); + __throw_exception_again; + } + } + + void + _M_delete_node(_Node* __n) { + this->get_allocator().destroy(&__n->_M_val); _M_put_node(__n); - __throw_exception_again; } - } + + void + _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last); + + void + _M_erase_bucket(const size_type __n, _Node* __last); + + void + _M_copy_from(const hashtable& __ht); + }; + + template + _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>& + _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++() + { + const _Node* __old = _M_cur; + _M_cur = _M_cur->_M_next; + if (!_M_cur) + { + size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); + while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) + _M_cur = _M_ht->_M_buckets[__bucket]; + } + return *this; + } - void _M_delete_node(_Node* __n) - { - _Destroy(&__n->_M_val); - _M_put_node(__n); - } + template + inline _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All> + _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++(int) + { + iterator __tmp = *this; + ++*this; + return __tmp; + } - void _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last); - void _M_erase_bucket(const size_type __n, _Node* __last); + template + _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>& + _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++() + { + const _Node* __old = _M_cur; + _M_cur = _M_cur->_M_next; + if (!_M_cur) + { + size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); + while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) + _M_cur = _M_ht->_M_buckets[__bucket]; + } + return *this; + } - void _M_copy_from(const hashtable& __ht); + template + inline _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All> + _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++(int) + { + const_iterator __tmp = *this; + ++*this; + return __tmp; + } -}; + template + bool + operator==(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, + const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2) + { + typedef typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_Node _Node; + + if (__ht1._M_buckets.size() != __ht2._M_buckets.size()) + return false; + + for (size_t __n = 0; __n < __ht1._M_buckets.size(); ++__n) + { + _Node* __cur1 = __ht1._M_buckets[__n]; + _Node* __cur2 = __ht2._M_buckets[__n]; + // Check same length of lists + for (; __cur1 && __cur2; + __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next) + { } + if (__cur1 || __cur2) + return false; + // Now check one's elements are in the other + for (__cur1 = __ht1._M_buckets[__n] ; __cur1; + __cur1 = __cur1->_M_next) + { + bool _found__cur1 = false; + for (__cur2 = __ht2._M_buckets[__n]; + __cur2; __cur2 = __cur2->_M_next) + { + if (__cur1->_M_val == __cur2->_M_val) + { + _found__cur1 = true; + break; + } + } + if (!_found__cur1) + return false; + } + } + return true; + } -template -_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>& -_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++() -{ - const _Node* __old = _M_cur; - _M_cur = _M_cur->_M_next; - if (!_M_cur) { - size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); - while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) - _M_cur = _M_ht->_M_buckets[__bucket]; - } - return *this; -} - -template -inline _Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All> -_Hashtable_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++(int) -{ - iterator __tmp = *this; - ++*this; - return __tmp; -} - -template -_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>& -_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++() -{ - const _Node* __old = _M_cur; - _M_cur = _M_cur->_M_next; - if (!_M_cur) { - size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); - while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) - _M_cur = _M_ht->_M_buckets[__bucket]; - } - return *this; -} - -template -inline _Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All> -_Hashtable_const_iterator<_Val,_Key,_HF,_ExK,_EqK,_All>::operator++(int) -{ - const_iterator __tmp = *this; - ++*this; - return __tmp; -} - -template -bool operator==(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, - const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2) -{ - typedef typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::_Node _Node; - if (__ht1._M_buckets.size() != __ht2._M_buckets.size()) - return false; - for (size_t __n = 0; __n < __ht1._M_buckets.size(); ++__n) { - _Node* __cur1 = __ht1._M_buckets[__n]; - _Node* __cur2 = __ht2._M_buckets[__n]; - // Check same length of lists - for ( ; __cur1 && __cur2; - __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next) - {} - if (__cur1 || __cur2) - return false; - // Now check one's elements are in the other - for (__cur1 = __ht1._M_buckets[__n] ; __cur1; __cur1 = __cur1->_M_next) + template + inline bool + operator!=(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, + const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2) + { return !(__ht1 == __ht2); } + + template + inline void + swap(hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht1, + hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht2) + { __ht1.swap(__ht2); } + + template + pair::iterator, bool> + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + insert_unique_noresize(const value_type& __obj) { - bool _found__cur1 = false; - for (_Node* __cur2 = __ht2._M_buckets[__n]; - __cur2; __cur2 = __cur2->_M_next) - { - if (__cur1->_M_val == __cur2->_M_val) - { - _found__cur1 = true; - break; - } - } - if (!_found__cur1) - return false; + const size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) + return pair(iterator(__cur, this), false); + + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; + ++_M_num_elements; + return pair(iterator(__tmp, this), true); } - } - return true; -} - -template -inline bool operator!=(const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht1, - const hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>& __ht2) { - return !(__ht1 == __ht2); -} - -template -inline void swap(hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht1, - hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht2) { - __ht1.swap(__ht2); -} - - -template -pair::iterator, bool> -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::insert_unique_noresize(const value_type& __obj) -{ - const size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) - return pair(iterator(__cur, this), false); - - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return pair(iterator(__tmp, this), true); -} - -template -typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::insert_equal_noresize(const value_type& __obj) -{ - const size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) { + + template + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + insert_equal_noresize(const value_type& __obj) + { + const size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) + { + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __cur->_M_next; + __cur->_M_next = __tmp; + ++_M_num_elements; + return iterator(__tmp, this); + } + _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __cur->_M_next; - __cur->_M_next = __tmp; + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; ++_M_num_elements; return iterator(__tmp, this); } - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return iterator(__tmp, this); -} - -template -typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::reference -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::find_or_insert(const value_type& __obj) -{ - resize(_M_num_elements + 1); - - size_type __n = _M_bkt_num(__obj); - _Node* __first = _M_buckets[__n]; - - for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) - if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) - return __cur->_M_val; - - _Node* __tmp = _M_new_node(__obj); - __tmp->_M_next = __first; - _M_buckets[__n] = __tmp; - ++_M_num_elements; - return __tmp->_M_val; -} - -template -pair::iterator, - typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::iterator> -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::equal_range(const key_type& __key) -{ - typedef pair _Pii; - const size_type __n = _M_bkt_num_key(__key); - - for (_Node* __first = _M_buckets[__n]; __first; __first = __first->_M_next) - if (_M_equals(_M_get_key(__first->_M_val), __key)) { - for (_Node* __cur = __first->_M_next; __cur; __cur = __cur->_M_next) - if (!_M_equals(_M_get_key(__cur->_M_val), __key)) - return _Pii(iterator(__first, this), iterator(__cur, this)); - for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) - if (_M_buckets[__m]) - return _Pii(iterator(__first, this), - iterator(_M_buckets[__m], this)); - return _Pii(iterator(__first, this), end()); + template + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::reference + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + find_or_insert(const value_type& __obj) + { + resize(_M_num_elements + 1); + + size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) + return __cur->_M_val; + + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; + ++_M_num_elements; + return __tmp->_M_val; } - return _Pii(end(), end()); -} - -template -pair::const_iterator, - typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::const_iterator> -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::equal_range(const key_type& __key) const -{ - typedef pair _Pii; - const size_type __n = _M_bkt_num_key(__key); - - for (const _Node* __first = _M_buckets[__n] ; - __first; - __first = __first->_M_next) { - if (_M_equals(_M_get_key(__first->_M_val), __key)) { - for (const _Node* __cur = __first->_M_next; - __cur; - __cur = __cur->_M_next) - if (!_M_equals(_M_get_key(__cur->_M_val), __key)) - return _Pii(const_iterator(__first, this), - const_iterator(__cur, this)); - for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) - if (_M_buckets[__m]) - return _Pii(const_iterator(__first, this), - const_iterator(_M_buckets[__m], this)); - return _Pii(const_iterator(__first, this), end()); + + template + pair::iterator, + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator> + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + equal_range(const key_type& __key) + { + typedef pair _Pii; + const size_type __n = _M_bkt_num_key(__key); + + for (_Node* __first = _M_buckets[__n]; __first; + __first = __first->_M_next) + if (_M_equals(_M_get_key(__first->_M_val), __key)) + { + for (_Node* __cur = __first->_M_next; __cur; + __cur = __cur->_M_next) + if (!_M_equals(_M_get_key(__cur->_M_val), __key)) + return _Pii(iterator(__first, this), iterator(__cur, this)); + for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) + if (_M_buckets[__m]) + return _Pii(iterator(__first, this), + iterator(_M_buckets[__m], this)); + return _Pii(iterator(__first, this), end()); + } + return _Pii(end(), end()); } - } - return _Pii(end(), end()); -} - -template -typename hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::size_type -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const key_type& __key) -{ - const size_type __n = _M_bkt_num_key(__key); - _Node* __first = _M_buckets[__n]; - size_type __erased = 0; - - if (__first) { - _Node* __cur = __first; - _Node* __next = __cur->_M_next; - while (__next) { - if (_M_equals(_M_get_key(__next->_M_val), __key)) { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - __next = __cur->_M_next; - ++__erased; - --_M_num_elements; - } - else { - __cur = __next; - __next = __cur->_M_next; - } + + template + pair::const_iterator, + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::const_iterator> + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + equal_range(const key_type& __key) const + { + typedef pair _Pii; + const size_type __n = _M_bkt_num_key(__key); + + for (const _Node* __first = _M_buckets[__n]; __first; + __first = __first->_M_next) + { + if (_M_equals(_M_get_key(__first->_M_val), __key)) + { + for (const _Node* __cur = __first->_M_next; __cur; + __cur = __cur->_M_next) + if (!_M_equals(_M_get_key(__cur->_M_val), __key)) + return _Pii(const_iterator(__first, this), + const_iterator(__cur, this)); + for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) + if (_M_buckets[__m]) + return _Pii(const_iterator(__first, this), + const_iterator(_M_buckets[__m], this)); + return _Pii(const_iterator(__first, this), end()); + } + } + return _Pii(end(), end()); } - if (_M_equals(_M_get_key(__first->_M_val), __key)) { - _M_buckets[__n] = __first->_M_next; - _M_delete_node(__first); - ++__erased; - --_M_num_elements; + + template + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::size_type + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const key_type& __key) + { + const size_type __n = _M_bkt_num_key(__key); + _Node* __first = _M_buckets[__n]; + size_type __erased = 0; + + if (__first) + { + _Node* __cur = __first; + _Node* __next = __cur->_M_next; + while (__next) + { + if (_M_equals(_M_get_key(__next->_M_val), __key)) + { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + __next = __cur->_M_next; + ++__erased; + --_M_num_elements; + } + else + { + __cur = __next; + __next = __cur->_M_next; + } + } + if (_M_equals(_M_get_key(__first->_M_val), __key)) + { + _M_buckets[__n] = __first->_M_next; + _M_delete_node(__first); + ++__erased; + --_M_num_elements; + } + } + return __erased; } - } - return __erased; -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const iterator& __it) -{ - _Node* __p = __it._M_cur; - if (__p) { - const size_type __n = _M_bkt_num(__p->_M_val); - _Node* __cur = _M_buckets[__n]; - - if (__cur == __p) { - _M_buckets[__n] = __cur->_M_next; - _M_delete_node(__cur); - --_M_num_elements; + + template + void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const iterator& __it) + { + _Node* __p = __it._M_cur; + if (__p) + { + const size_type __n = _M_bkt_num(__p->_M_val); + _Node* __cur = _M_buckets[__n]; + + if (__cur == __p) + { + _M_buckets[__n] = __cur->_M_next; + _M_delete_node(__cur); + --_M_num_elements; + } + else + { + _Node* __next = __cur->_M_next; + while (__next) + { + if (__next == __p) + { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + --_M_num_elements; + break; + } + else + { + __cur = __next; + __next = __cur->_M_next; + } + } + } + } } - else { - _Node* __next = __cur->_M_next; - while (__next) { - if (__next == __p) { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - --_M_num_elements; - break; - } - else { - __cur = __next; - __next = __cur->_M_next; - } - } + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(iterator __first, iterator __last) + { + size_type __f_bucket = __first._M_cur ? _M_bkt_num(__first._M_cur->_M_val) + : _M_buckets.size(); + + size_type __l_bucket = __last._M_cur ? _M_bkt_num(__last._M_cur->_M_val) + : _M_buckets.size(); + + if (__first._M_cur == __last._M_cur) + return; + else if (__f_bucket == __l_bucket) + _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur); + else + { + _M_erase_bucket(__f_bucket, __first._M_cur, 0); + for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n) + _M_erase_bucket(__n, 0); + if (__l_bucket != _M_buckets.size()) + _M_erase_bucket(__l_bucket, __last._M_cur); + } } - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::erase(iterator __first, iterator __last) -{ - size_type __f_bucket = __first._M_cur ? - _M_bkt_num(__first._M_cur->_M_val) : _M_buckets.size(); - size_type __l_bucket = __last._M_cur ? - _M_bkt_num(__last._M_cur->_M_val) : _M_buckets.size(); - - if (__first._M_cur == __last._M_cur) - return; - else if (__f_bucket == __l_bucket) - _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur); - else { - _M_erase_bucket(__f_bucket, __first._M_cur, 0); - for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n) - _M_erase_bucket(__n, 0); - if (__l_bucket != _M_buckets.size()) - _M_erase_bucket(__l_bucket, __last._M_cur); - } -} - -template -inline void -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const_iterator __first, - const_iterator __last) -{ - erase(iterator(const_cast<_Node*>(__first._M_cur), - const_cast(__first._M_ht)), - iterator(const_cast<_Node*>(__last._M_cur), - const_cast(__last._M_ht))); -} - -template -inline void -hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::erase(const const_iterator& __it) -{ - erase(iterator(const_cast<_Node*>(__it._M_cur), - const_cast(__it._M_ht))); -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::resize(size_type __num_elements_hint) -{ - const size_type __old_n = _M_buckets.size(); - if (__num_elements_hint > __old_n) { - const size_type __n = _M_next_size(__num_elements_hint); - if (__n > __old_n) { - _Vector_type __tmp(__n, (_Node*)(0), _M_buckets.get_allocator()); - try { - for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) { - _Node* __first = _M_buckets[__bucket]; - while (__first) { - size_type __new_bucket = _M_bkt_num(__first->_M_val, __n); - _M_buckets[__bucket] = __first->_M_next; - __first->_M_next = __tmp[__new_bucket]; - __tmp[__new_bucket] = __first; - __first = _M_buckets[__bucket]; - } - } - _M_buckets.swap(__tmp); - } - catch(...) { - for (size_type __bucket = 0; __bucket < __tmp.size(); ++__bucket) { - while (__tmp[__bucket]) { - _Node* __next = __tmp[__bucket]->_M_next; - _M_delete_node(__tmp[__bucket]); - __tmp[__bucket] = __next; - } - } - __throw_exception_again; - } + + template + inline void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const_iterator __first, const_iterator __last) + { + erase(iterator(const_cast<_Node*>(__first._M_cur), + const_cast(__first._M_ht)), + iterator(const_cast<_Node*>(__last._M_cur), + const_cast(__last._M_ht))); } - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::_M_erase_bucket(const size_type __n, _Node* __first, _Node* __last) -{ - _Node* __cur = _M_buckets[__n]; - if (__cur == __first) - _M_erase_bucket(__n, __last); - else { - _Node* __next; - for (__next = __cur->_M_next; - __next != __first; - __cur = __next, __next = __cur->_M_next) - ; - while (__next != __last) { - __cur->_M_next = __next->_M_next; - _M_delete_node(__next); - __next = __cur->_M_next; - --_M_num_elements; + + template + inline void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const const_iterator& __it) + { erase(iterator(const_cast<_Node*>(__it._M_cur), + const_cast(__it._M_ht))); } + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + resize(size_type __num_elements_hint) + { + const size_type __old_n = _M_buckets.size(); + if (__num_elements_hint > __old_n) + { + const size_type __n = _M_next_size(__num_elements_hint); + if (__n > __old_n) + { + _Vector_type __tmp(__n, (_Node*)(0), _M_buckets.get_allocator()); + try + { + for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) + { + _Node* __first = _M_buckets[__bucket]; + while (__first) + { + size_type __new_bucket = _M_bkt_num(__first->_M_val, + __n); + _M_buckets[__bucket] = __first->_M_next; + __first->_M_next = __tmp[__new_bucket]; + __tmp[__new_bucket] = __first; + __first = _M_buckets[__bucket]; + } + } + _M_buckets.swap(__tmp); + } + catch(...) + { + for (size_type __bucket = 0; __bucket < __tmp.size(); + ++__bucket) + { + while (__tmp[__bucket]) + { + _Node* __next = __tmp[__bucket]->_M_next; + _M_delete_node(__tmp[__bucket]); + __tmp[__bucket] = __next; + } + } + __throw_exception_again; + } + } + } } - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::_M_erase_bucket(const size_type __n, _Node* __last) -{ - _Node* __cur = _M_buckets[__n]; - while (__cur != __last) { - _Node* __next = __cur->_M_next; - _M_delete_node(__cur); - __cur = __next; - _M_buckets[__n] = __cur; - --_M_num_elements; - } -} - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>::clear() -{ - for (size_type __i = 0; __i < _M_buckets.size(); ++__i) { - _Node* __cur = _M_buckets[__i]; - while (__cur != 0) { - _Node* __next = __cur->_M_next; - _M_delete_node(__cur); - __cur = __next; + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last) + { + _Node* __cur = _M_buckets[__n]; + if (__cur == __first) + _M_erase_bucket(__n, __last); + else + { + _Node* __next; + for (__next = __cur->_M_next; + __next != __first; + __cur = __next, __next = __cur->_M_next) + ; + while (__next != __last) + { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + __next = __cur->_M_next; + --_M_num_elements; + } + } } - _M_buckets[__i] = 0; - } - _M_num_elements = 0; -} - - -template -void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> - ::_M_copy_from(const hashtable& __ht) -{ - _M_buckets.clear(); - _M_buckets.reserve(__ht._M_buckets.size()); - _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0); - try { - for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) { - const _Node* __cur = __ht._M_buckets[__i]; - if (__cur) { - _Node* __local_copy = _M_new_node(__cur->_M_val); - _M_buckets[__i] = __local_copy; - - for (_Node* __next = __cur->_M_next; - __next; - __cur = __next, __next = __cur->_M_next) { - __local_copy->_M_next = _M_new_node(__next->_M_val); - __local_copy = __local_copy->_M_next; - } - } + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + _M_erase_bucket(const size_type __n, _Node* __last) + { + _Node* __cur = _M_buckets[__n]; + while (__cur != __last) + { + _Node* __next = __cur->_M_next; + _M_delete_node(__cur); + __cur = __next; + _M_buckets[__n] = __cur; + --_M_num_elements; + } } - _M_num_elements = __ht._M_num_elements; - } - catch(...) + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + clear() { - clear(); - __throw_exception_again; + for (size_type __i = 0; __i < _M_buckets.size(); ++__i) + { + _Node* __cur = _M_buckets[__i]; + while (__cur != 0) + { + _Node* __next = __cur->_M_next; + _M_delete_node(__cur); + __cur = __next; + } + _M_buckets[__i] = 0; + } + _M_num_elements = 0; } -} -} // namespace __gnu_cxx + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + _M_copy_from(const hashtable& __ht) + { + _M_buckets.clear(); + _M_buckets.reserve(__ht._M_buckets.size()); + _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0); + try + { + for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) { + const _Node* __cur = __ht._M_buckets[__i]; + if (__cur) + { + _Node* __local_copy = _M_new_node(__cur->_M_val); + _M_buckets[__i] = __local_copy; + + for (_Node* __next = __cur->_M_next; + __next; + __cur = __next, __next = __cur->_M_next) + { + __local_copy->_M_next = _M_new_node(__next->_M_val); + __local_copy = __local_copy->_M_next; + } + } + } + _M_num_elements = __ht._M_num_elements; + } + catch(...) + { + clear(); + __throw_exception_again; + } + } + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/ext/iterator b/contrib/libstdc++/include/ext/iterator index 094313c..b59e5ca 100644 --- a/contrib/libstdc++/include/ext/iterator +++ b/contrib/libstdc++/include/ext/iterator @@ -1,6 +1,6 @@ // HP/SGI iterator extensions -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -55,8 +55,7 @@ /** @file ext/iterator * This file is a GNU extension to the Standard C++ Library (possibly - * containing extensions from the HP/SGI STL subset). You should only - * include this header if you are using GCC 3 or later. + * containing extensions from the HP/SGI STL subset). */ #ifndef _EXT_ITERATOR @@ -67,8 +66,8 @@ #include #include -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + // There are two signatures for distance. In addition to the one // taking two iterators and returning a result, there is another // taking two iterators and a reference-to-result variable, and @@ -81,7 +80,11 @@ namespace __gnu_cxx { // concept requirements __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) - while (__first != __last) { ++__first; ++__n; } + while (__first != __last) + { + ++__first; + ++__n; + } } template @@ -90,7 +93,8 @@ namespace __gnu_cxx _Distance& __n, std::random_access_iterator_tag) { // concept requirements - __glibcxx_function_requires(_RandomAccessIteratorConcept<_RandomAccessIterator>) + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) __n += __last - __first; } @@ -107,7 +111,8 @@ namespace __gnu_cxx // concept requirements -- taken care of in __distance __distance(__first, __last, __n, std::__iterator_category(__first)); } -} // namespace __gnu_cxx + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/ext/malloc_allocator.h b/contrib/libstdc++/include/ext/malloc_allocator.h index 938380c..0f23e06 100644 --- a/contrib/libstdc++/include/ext/malloc_allocator.h +++ b/contrib/libstdc++/include/ext/malloc_allocator.h @@ -1,6 +1,6 @@ // Allocator that wraps "C" malloc -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -27,21 +27,28 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file ext/malloc_allocator.h + * This file is a GNU extension to the Standard C++ Library. + */ + #ifndef _MALLOC_ALLOCATOR_H #define _MALLOC_ALLOCATOR_H 1 +#include #include +#include + +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + using std::size_t; + using std::ptrdiff_t; -namespace __gnu_cxx -{ /** - * @brief An allocator that uses malloc + * @brief An allocator that uses malloc. * * This is precisely the allocator defined in the C++ Standard. * - all allocation calls malloc * - all deallocation calls free - * - * (See @link Allocators allocators info @endlink for more.) */ template class malloc_allocator @@ -79,9 +86,12 @@ namespace __gnu_cxx pointer allocate(size_type __n, const void* = 0) { + if (__builtin_expect(__n > this->max_size(), false)) + std::__throw_bad_alloc(); + pointer __ret = static_cast<_Tp*>(malloc(__n * sizeof(_Tp))); if (!__ret) - throw std::bad_alloc(); + std::__throw_bad_alloc(); return __ret; } @@ -113,6 +123,7 @@ namespace __gnu_cxx inline bool operator!=(const malloc_allocator<_Tp>&, const malloc_allocator<_Tp>&) { return false; } -} // namespace __gnu_cxx + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/ext/memory b/contrib/libstdc++/include/ext/memory index 1d93f90..0755d89 100644 --- a/contrib/libstdc++/include/ext/memory +++ b/contrib/libstdc++/include/ext/memory @@ -1,6 +1,6 @@ // Memory extensions -*- C++ -*- -// Copyright (C) 2002 Free Software Foundation, Inc. +// Copyright (C) 2002, 2004, 2005 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -55,8 +55,7 @@ /** @file ext/memory * This file is a GNU extension to the Standard C++ Library (possibly - * containing extensions from the HP/SGI STL subset). You should only - * include this header if you are using GCC 3 or later. + * containing extensions from the HP/SGI STL subset). */ #ifndef _EXT_MEMORY @@ -67,8 +66,8 @@ #include #include -namespace __gnu_cxx -{ +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + using std::ptrdiff_t; using std::pair; using std::__iterator_category; @@ -82,7 +81,7 @@ namespace __gnu_cxx _ForwardIter __cur = __result; try { - for ( ; __count > 0 ; --__count, ++__first, ++__cur) + for (; __count > 0 ; --__count, ++__first, ++__cur) std::_Construct(&*__cur, *__first); return pair<_InputIter, _ForwardIter>(__first, __cur); } @@ -100,19 +99,16 @@ namespace __gnu_cxx std::random_access_iterator_tag) { _RandomAccessIter __last = __first + __count; - return pair<_RandomAccessIter, _ForwardIter>( - __last, - std::uninitialized_copy(__first, __last, __result)); + return (pair<_RandomAccessIter, _ForwardIter> + (__last, std::uninitialized_copy(__first, __last, __result))); } template inline pair<_InputIter, _ForwardIter> __uninitialized_copy_n(_InputIter __first, _Size __count, _ForwardIter __result) - { - return __uninitialized_copy_n(__first, __count, __result, - __iterator_category(__first)); - } + { return __uninitialized_copy_n(__first, __count, __result, + __iterator_category(__first)); } /** * @brief Copies the range [first,last) into result. @@ -128,11 +124,42 @@ namespace __gnu_cxx inline pair<_InputIter, _ForwardIter> uninitialized_copy_n(_InputIter __first, _Size __count, _ForwardIter __result) + { return __uninitialized_copy_n(__first, __count, __result, + __iterator_category(__first)); } + + + // An alternative version of uninitialized_copy_n that constructs + // and destroys objects with a user-provided allocator. + template + pair<_InputIter, _ForwardIter> + __uninitialized_copy_n_a(_InputIter __first, _Size __count, + _ForwardIter __result, + _Allocator __alloc) { - return __uninitialized_copy_n(__first, __count, __result, - __iterator_category(__first)); + _ForwardIter __cur = __result; + try + { + for (; __count > 0 ; --__count, ++__first, ++__cur) + __alloc.construct(&*__cur, *__first); + return pair<_InputIter, _ForwardIter>(__first, __cur); + } + catch(...) + { + std::_Destroy(__result, __cur, __alloc); + __throw_exception_again; + } } + template + inline pair<_InputIter, _ForwardIter> + __uninitialized_copy_n_a(_InputIter __first, _Size __count, + _ForwardIter __result, + std::allocator<_Tp>) + { + return uninitialized_copy_n(__first, __count, __result); + } /** * This class provides similar behavior and semantics of the standard @@ -155,17 +182,18 @@ namespace __gnu_cxx * @ingroup SGIextensions */ template ::value_type > - struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp> - { - /// Requests storage large enough to hold a copy of [first,last). - temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) - : _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) { } - - /// Destroys objects and frees storage. - ~temporary_buffer() { } - }; -} // namespace __gnu_cxx + = typename std::iterator_traits<_ForwardIterator>::value_type > + struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp> + { + /// Requests storage large enough to hold a copy of [first,last). + temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) + : _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) { } + + /// Destroys objects and frees storage. + ~temporary_buffer() { } + }; + +_GLIBCXX_END_NAMESPACE #endif diff --git a/contrib/libstdc++/include/ext/mt_allocator.h b/contrib/libstdc++/include/ext/mt_allocator.h index f0ee2eb..bc2d61f 100644 --- a/contrib/libstdc++/include/ext/mt_allocator.h +++ b/contrib/libstdc++/include/ext/mt_allocator.h @@ -1,6 +1,6 @@ // MT-optimized allocator -*- C++ -*- -// Copyright (C) 2003, 2004 Free Software Foundation, Inc. +// Copyright (C) 2003, 2004, 2005, 2006 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 @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -29,7 +29,6 @@ /** @file ext/mt_allocator.h * This file is a GNU extension to the Standard C++ Library. - * You should only include this header if you are using GCC 3 or later. */ #ifndef _MT_ALLOCATOR_H @@ -38,170 +37,231 @@ #include #include #include -#include -#include - -namespace __gnu_cxx -{ - /** - * This is a fixed size (power of 2) allocator which - when - * compiled with thread support - will maintain one freelist per - * size per thread plus a "global" one. Steps are taken to limit - * the per thread freelist sizes (by returning excess back to - * "global"). - * - * Further details: - * http://gcc.gnu.org/onlinedocs/libstdc++/ext/mt_allocator.html - */ - template - class __mt_alloc +#include + +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + using std::size_t; + using std::ptrdiff_t; + + typedef void (*__destroy_handler)(void*); + + /// @brief Base class for pool object. + struct __pool_base + { + // Using short int as type for the binmap implies we are never + // caching blocks larger than 32768 with this allocator. + typedef unsigned short int _Binmap_type; + + // Variables used to configure the behavior of the allocator, + // assigned and explained in detail below. + struct _Tune + { + // Compile time constants for the default _Tune values. + enum { _S_align = 8 }; + enum { _S_max_bytes = 128 }; + enum { _S_min_bin = 8 }; + enum { _S_chunk_size = 4096 - 4 * sizeof(void*) }; + enum { _S_max_threads = 4096 }; + enum { _S_freelist_headroom = 10 }; + + // Alignment needed. + // NB: In any case must be >= sizeof(_Block_record), that + // is 4 on 32 bit machines and 8 on 64 bit machines. + size_t _M_align; + + // Allocation requests (after round-up to power of 2) below + // this value will be handled by the allocator. A raw new/ + // call will be used for requests larger than this value. + // NB: Must be much smaller than _M_chunk_size and in any + // case <= 32768. + size_t _M_max_bytes; + + // Size in bytes of the smallest bin. + // NB: Must be a power of 2 and >= _M_align (and of course + // much smaller than _M_max_bytes). + size_t _M_min_bin; + + // In order to avoid fragmenting and minimize the number of + // new() calls we always request new memory using this + // value. Based on previous discussions on the libstdc++ + // mailing list we have choosen the value below. + // See http://gcc.gnu.org/ml/libstdc++/2001-07/msg00077.html + // NB: At least one order of magnitude > _M_max_bytes. + size_t _M_chunk_size; + + // The maximum number of supported threads. For + // single-threaded operation, use one. Maximum values will + // vary depending on details of the underlying system. (For + // instance, Linux 2.4.18 reports 4070 in + // /proc/sys/kernel/threads-max, while Linux 2.6.6 reports + // 65534) + size_t _M_max_threads; + + // Each time a deallocation occurs in a threaded application + // we make sure that there are no more than + // _M_freelist_headroom % of used memory on the freelist. If + // the number of additional records is more than + // _M_freelist_headroom % of the freelist, we move these + // records back to the global pool. + size_t _M_freelist_headroom; + + // Set to true forces all allocations to use new(). + bool _M_force_new; + + explicit + _Tune() + : _M_align(_S_align), _M_max_bytes(_S_max_bytes), _M_min_bin(_S_min_bin), + _M_chunk_size(_S_chunk_size), _M_max_threads(_S_max_threads), + _M_freelist_headroom(_S_freelist_headroom), + _M_force_new(std::getenv("GLIBCXX_FORCE_NEW") ? true : false) + { } + + explicit + _Tune(size_t __align, size_t __maxb, size_t __minbin, size_t __chunk, + size_t __maxthreads, size_t __headroom, bool __force) + : _M_align(__align), _M_max_bytes(__maxb), _M_min_bin(__minbin), + _M_chunk_size(__chunk), _M_max_threads(__maxthreads), + _M_freelist_headroom(__headroom), _M_force_new(__force) + { } + }; + + struct _Block_address { - public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef _Tp* pointer; - typedef const _Tp* const_pointer; - typedef _Tp& reference; - typedef const _Tp& const_reference; - typedef _Tp value_type; + void* _M_initial; + _Block_address* _M_next; + }; + + const _Tune& + _M_get_options() const + { return _M_options; } - template - struct rebind - { typedef __mt_alloc<_Tp1> other; }; + void + _M_set_options(_Tune __t) + { + if (!_M_init) + _M_options = __t; + } - __mt_alloc() throw() - { - // XXX - } + bool + _M_check_threshold(size_t __bytes) + { return __bytes > _M_options._M_max_bytes || _M_options._M_force_new; } - __mt_alloc(const __mt_alloc&) throw() - { - // XXX - } + size_t + _M_get_binmap(size_t __bytes) + { return _M_binmap[__bytes]; } - template - __mt_alloc(const __mt_alloc<_Tp1>& obj) throw() - { - // XXX - } + const size_t + _M_get_align() + { return _M_options._M_align; } - ~__mt_alloc() throw() { } + explicit + __pool_base() + : _M_options(_Tune()), _M_binmap(NULL), _M_init(false) { } - pointer - address(reference __x) const - { return &__x; } + explicit + __pool_base(const _Tune& __options) + : _M_options(__options), _M_binmap(NULL), _M_init(false) { } - const_pointer - address(const_reference __x) const - { return &__x; } + private: + explicit + __pool_base(const __pool_base&); - size_type - max_size() const throw() - { return size_t(-1) / sizeof(_Tp); } + __pool_base& + operator=(const __pool_base&); - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 402. wrong new expression in [some_] allocator::construct - void - construct(pointer __p, const _Tp& __val) - { ::new(__p) _Tp(__val); } + protected: + // Configuration options. + _Tune _M_options; + + _Binmap_type* _M_binmap; - void - destroy(pointer __p) { __p->~_Tp(); } + // Configuration of the pool object via _M_options can happen + // after construction but before initialization. After + // initialization is complete, this variable is set to true. + bool _M_init; + }; - pointer - allocate(size_type __n, const void* = 0); - void - deallocate(pointer __p, size_type __n); + /** + * @brief Data describing the underlying memory pool, parameterized on + * threading support. + */ + template + class __pool; - // Variables used to configure the behavior of the allocator, - // assigned and explained in detail below. - struct _Tune + /// Specialization for single thread. + template<> + class __pool : public __pool_base + { + public: + union _Block_record { - // Alignment needed. - // NB: In any case must be >= sizeof(_Block_record), that - // is 4 on 32 bit machines and 8 on 64 bit machines. - size_t _M_align; - - // Allocation requests (after round-up to power of 2) below - // this value will be handled by the allocator. A raw new/ - // call will be used for requests larger than this value. - size_t _M_max_bytes; - - // Size in bytes of the smallest bin. - // NB: Must be a power of 2 and >= _M_align. - size_t _M_min_bin; - - // In order to avoid fragmenting and minimize the number of - // new() calls we always request new memory using this - // value. Based on previous discussions on the libstdc++ - // mailing list we have choosen the value below. - // See http://gcc.gnu.org/ml/libstdc++/2001-07/msg00077.html - size_t _M_chunk_size; - - // The maximum number of supported threads. Our Linux 2.4.18 - // reports 4070 in /proc/sys/kernel/threads-max - size_t _M_max_threads; - - // Each time a deallocation occurs in a threaded application - // we make sure that there are no more than - // _M_freelist_headroom % of used memory on the freelist. If - // the number of additional records is more than - // _M_freelist_headroom % of the freelist, we move these - // records back to the global pool. - size_t _M_freelist_headroom; - - // Set to true forces all allocations to use new(). - bool _M_force_new; - - explicit - _Tune() - : _M_align(8), _M_max_bytes(128), _M_min_bin(8), - _M_chunk_size(4096 - 4 * sizeof(void*)), - _M_max_threads(4096), _M_freelist_headroom(10), - _M_force_new(getenv("GLIBCXX_FORCE_NEW") ? true : false) - { } - - explicit - _Tune(size_t __align, size_t __maxb, size_t __minbin, - size_t __chunk, size_t __maxthreads, size_t __headroom, - bool __force) - : _M_align(__align), _M_max_bytes(__maxb), _M_min_bin(__minbin), - _M_chunk_size(__chunk), _M_max_threads(__maxthreads), - _M_freelist_headroom(__headroom), _M_force_new(__force) - { } + // Points to the block_record of the next free block. + _Block_record* _M_next; }; - private: - // We need to create the initial lists and set up some variables - // before we can answer to the first request for memory. -#ifdef __GTHREADS - static __gthread_once_t _S_once; -#endif - static bool _S_init; + struct _Bin_record + { + // An "array" of pointers to the first free block. + _Block_record** _M_first; - static void - _S_initialize(); + // A list of the initial addresses of all allocated blocks. + _Block_address* _M_address; + }; + + void + _M_initialize_once() + { + if (__builtin_expect(_M_init == false, false)) + _M_initialize(); + } - // Configuration options. - static _Tune _S_options; + void + _M_destroy() throw(); - static const _Tune - _S_get_options() - { return _S_options; } + char* + _M_reserve_block(size_t __bytes, const size_t __thread_id); + + void + _M_reclaim_block(char* __p, size_t __bytes); + + size_t + _M_get_thread_id() { return 0; } + + const _Bin_record& + _M_get_bin(size_t __which) + { return _M_bin[__which]; } + + void + _M_adjust_freelist(const _Bin_record&, _Block_record*, size_t) + { } - static void - _S_set_options(_Tune __t) - { - if (!_S_init) - _S_options = __t; - } + explicit __pool() + : _M_bin(NULL), _M_bin_size(1) { } + + explicit __pool(const __pool_base::_Tune& __tune) + : __pool_base(__tune), _M_bin(NULL), _M_bin_size(1) { } - // Using short int as type for the binmap implies we are never - // caching blocks larger than 65535 with this allocator - typedef unsigned short int _Binmap_type; - static _Binmap_type* _S_binmap; + private: + // An "array" of bin_records each of which represents a specific + // power of 2 size. Memory to this "array" is allocated in + // _M_initialize(). + _Bin_record* _M_bin; + + // Actual value calculated in _M_initialize(). + size_t _M_bin_size; + void + _M_initialize(); + }; + +#ifdef __GTHREADS + /// Specialization for thread enabled, via gthreads.h. + template<> + class __pool : public __pool_base + { + public: // Each requesting thread is assigned an id ranging from 1 to // _S_max_threads. Thread id 0 is used as a global memory pool. // In order to get constant performance on the thread assignment @@ -211,508 +271,476 @@ namespace __gnu_cxx // __gthread_key we specify a destructor. When this destructor // (i.e. the thread dies) is called, we return the thread id to // the front of this list. -#ifdef __GTHREADS struct _Thread_record { - // Points to next free thread id record. NULL if last record in list. - _Thread_record* volatile _M_next; - + // Points to next free thread id record. NULL if last record in list. + _Thread_record* _M_next; + // Thread id ranging from 1 to _S_max_threads. - size_t _M_id; + size_t _M_id; }; - - static _Thread_record* volatile _S_thread_freelist_first; - static __gthread_mutex_t _S_thread_freelist_mutex; - static __gthread_key_t _S_thread_key; - - static void - _S_destroy_thread_key(void* __freelist_pos); -#endif - - static size_t - _S_get_thread_id(); - + union _Block_record { // Points to the block_record of the next free block. - _Block_record* volatile _M_next; - -#ifdef __GTHREADS + _Block_record* _M_next; + // The thread id of the thread which has requested this block. - size_t _M_thread_id; -#endif + size_t _M_thread_id; }; - + struct _Bin_record { // An "array" of pointers to the first free block for each - // thread id. Memory to this "array" is allocated in _S_initialize() - // for _S_max_threads + global pool 0. - _Block_record** volatile _M_first; + // thread id. Memory to this "array" is allocated in + // _S_initialize() for _S_max_threads + global pool 0. + _Block_record** _M_first; + + // A list of the initial addresses of all allocated blocks. + _Block_address* _M_address; -#ifdef __GTHREADS // An "array" of counters used to keep track of the amount of // blocks that are on the freelist/used for each thread id. - // Memory to these "arrays" is allocated in _S_initialize() for - // _S_max_threads + global pool 0. - size_t* volatile _M_free; - size_t* volatile _M_used; - + // - Note that the second part of the allocated _M_used "array" + // actually hosts (atomic) counters of reclaimed blocks: in + // _M_reserve_block and in _M_reclaim_block those numbers are + // subtracted from the first ones to obtain the actual size + // of the "working set" of the given thread. + // - Memory to these "arrays" is allocated in _S_initialize() + // for _S_max_threads + global pool 0. + size_t* _M_free; + size_t* _M_used; + // Each bin has its own mutex which is used to ensure data // integrity while changing "ownership" on a block. The mutex // is initialized in _S_initialize(). - __gthread_mutex_t* _M_mutex; -#endif + __gthread_mutex_t* _M_mutex; }; + + // XXX GLIBCXX_ABI Deprecated + void + _M_initialize(__destroy_handler); + void + _M_initialize_once() + { + if (__builtin_expect(_M_init == false, false)) + _M_initialize(); + } + + void + _M_destroy() throw(); + + char* + _M_reserve_block(size_t __bytes, const size_t __thread_id); + + void + _M_reclaim_block(char* __p, size_t __bytes); + + const _Bin_record& + _M_get_bin(size_t __which) + { return _M_bin[__which]; } + + void + _M_adjust_freelist(const _Bin_record& __bin, _Block_record* __block, + size_t __thread_id) + { + if (__gthread_active_p()) + { + __block->_M_thread_id = __thread_id; + --__bin._M_free[__thread_id]; + ++__bin._M_used[__thread_id]; + } + } + + // XXX GLIBCXX_ABI Deprecated + void + _M_destroy_thread_key(void*); + + size_t + _M_get_thread_id(); + + explicit __pool() + : _M_bin(NULL), _M_bin_size(1), _M_thread_freelist(NULL) + { } + + explicit __pool(const __pool_base::_Tune& __tune) + : __pool_base(__tune), _M_bin(NULL), _M_bin_size(1), + _M_thread_freelist(NULL) + { } + + private: // An "array" of bin_records each of which represents a specific // power of 2 size. Memory to this "array" is allocated in - // _S_initialize(). - static _Bin_record* volatile _S_bin; + // _M_initialize(). + _Bin_record* _M_bin; + + // Actual value calculated in _M_initialize(). + size_t _M_bin_size; - // Actual value calculated in _S_initialize(). - static size_t _S_bin_size; + _Thread_record* _M_thread_freelist; + void* _M_thread_freelist_initial; + + void + _M_initialize(); }; +#endif - template - typename __mt_alloc<_Tp>::pointer - __mt_alloc<_Tp>:: - allocate(size_type __n, const void*) + template