summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/util
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/util')
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/common_type.hpp799
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/detail/comb_hash_fn_string_form.hpp98
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/detail/ds_string_form.hpp255
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/detail/list_update_policy_string_form.hpp97
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/detail/probe_fn_string_form.hpp99
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/detail/resize_policy_string_form.hpp93
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/detail/size_policy_string_form.hpp95
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/detail/store_hash_string_form.hpp82
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/detail/tree_supports_order_statistics.hpp73
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/detail/trie_supports_order_statistics.hpp73
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/detail/trie_supports_prefix_search.hpp73
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/detail/trigger_policy_string_form.hpp141
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/native_set.hpp84
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/string_form.hpp179
-rw-r--r--libstdc++-v3/testsuite/util/common_type/assoc/template_policy.hpp145
-rw-r--r--libstdc++-v3/testsuite/util/common_type/priority_queue/common_type.hpp75
-rw-r--r--libstdc++-v3/testsuite/util/common_type/priority_queue/detail/ds_string_form.hpp130
-rw-r--r--libstdc++-v3/testsuite/util/common_type/priority_queue/string_form.hpp99
-rw-r--r--libstdc++-v3/testsuite/util/debug/checks.h379
-rw-r--r--libstdc++-v3/testsuite/util/exception/safety.h1304
-rw-r--r--libstdc++-v3/testsuite/util/hash_fn/dna_str_limit.hpp62
-rw-r--r--libstdc++-v3/testsuite/util/hash_fn/limit_string_hash_fn.hpp72
-rw-r--r--libstdc++-v3/testsuite/util/hash_fn/string_hash_fn.hpp68
-rw-r--r--libstdc++-v3/testsuite/util/hash_fn/string_ranged_hash_fn.hpp99
-rw-r--r--libstdc++-v3/testsuite/util/hash_fn/string_ranged_probe_fn.hpp103
-rw-r--r--libstdc++-v3/testsuite/util/io/illegal_input_error.hpp62
-rw-r--r--libstdc++-v3/testsuite/util/io/prog_bar.cc79
-rw-r--r--libstdc++-v3/testsuite/util/io/prog_bar.hpp86
-rw-r--r--libstdc++-v3/testsuite/util/io/text_populate.hpp153
-rw-r--r--libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc106
-rw-r--r--libstdc++-v3/testsuite/util/io/verified_cmd_line_input.hpp67
-rw-r--r--libstdc++-v3/testsuite/util/io/xml.hpp121
-rw-r--r--libstdc++-v3/testsuite/util/io/xml_test_formatter.hpp78
-rw-r--r--libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp103
-rw-r--r--libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp146
-rw-r--r--libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp125
-rw-r--r--libstdc++-v3/testsuite/util/native_type/native_hash_tag.hpp48
-rw-r--r--libstdc++-v3/testsuite/util/native_type/native_map.hpp87
-rw-r--r--libstdc++-v3/testsuite/util/native_type/native_multimap.hpp142
-rw-r--r--libstdc++-v3/testsuite/util/native_type/native_priority_queue.hpp224
-rw-r--r--libstdc++-v3/testsuite/util/native_type/native_set.hpp87
-rw-r--r--libstdc++-v3/testsuite/util/native_type/native_tree_tag.hpp49
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/mem_usage/erase_test.hpp109
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/mem_usage/multimap_insert_test.hpp144
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/multimap_common_type.hpp223
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/timing/common_type.hpp103
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/timing/find_test.hpp166
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/timing/insert_test.hpp143
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/timing/multimap_find_test.hpp191
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/timing/multimap_insert_test.hpp151
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/timing/subscript_find_test.hpp144
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/timing/subscript_insert_test.hpp134
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/timing/tree_order_statistics_test.hpp176
-rw-r--r--libstdc++-v3/testsuite/util/performance/assoc/timing/tree_split_join_test.hpp158
-rw-r--r--libstdc++-v3/testsuite/util/performance/io/xml_formatter.hpp78
-rw-r--r--libstdc++-v3/testsuite/util/performance/priority_queue/mem_usage/pop_test.hpp111
-rw-r--r--libstdc++-v3/testsuite/util/performance/priority_queue/timing/join_test.hpp167
-rw-r--r--libstdc++-v3/testsuite/util/performance/priority_queue/timing/modify_test.hpp329
-rw-r--r--libstdc++-v3/testsuite/util/performance/priority_queue/timing/push_pop_test.hpp141
-rw-r--r--libstdc++-v3/testsuite/util/performance/priority_queue/timing/push_test.hpp144
-rw-r--r--libstdc++-v3/testsuite/util/performance/time/elapsed_timer.cc68
-rw-r--r--libstdc++-v3/testsuite/util/performance/time/elapsed_timer.hpp67
-rw-r--r--libstdc++-v3/testsuite/util/performance/time/timing_test_base.hpp117
-rw-r--r--libstdc++-v3/testsuite/util/regression/basic_type.hpp94
-rw-r--r--libstdc++-v3/testsuite/util/regression/common_type.hpp194
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.h475
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.tcc2133
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp198
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.h265
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.tcc838
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp202
-rw-r--r--libstdc++-v3/testsuite/util/regression/rand/xml_formatter.hpp100
-rw-r--r--libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_load_trait.hpp90
-rw-r--r--libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_loads_trait.hpp90
-rw-r--r--libstdc++-v3/testsuite/util/regression/trait/assoc/native_type_trait.hpp185
-rw-r--r--libstdc++-v3/testsuite/util/regression/trait/assoc/node_update_trait.hpp124
-rw-r--r--libstdc++-v3/testsuite/util/regression/trait/assoc/resize_trait.hpp90
-rw-r--r--libstdc++-v3/testsuite/util/regression/trait/assoc/to_string.hpp81
-rw-r--r--libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp206
-rw-r--r--libstdc++-v3/testsuite/util/regression/trait/assoc/type_trait.hpp111
-rw-r--r--libstdc++-v3/testsuite/util/regression/trait/erase_if_fn.hpp85
-rw-r--r--libstdc++-v3/testsuite/util/regression/trait/priority_queue/trait.hpp82
-rw-r--r--libstdc++-v3/testsuite/util/replacement_memory_operators.h113
-rw-r--r--libstdc++-v3/testsuite/util/statistic/result_recorder.hpp98
-rw-r--r--libstdc++-v3/testsuite/util/statistic/sample_mean.hpp69
-rw-r--r--libstdc++-v3/testsuite/util/statistic/sample_mean_confidence_checker.hpp84
-rw-r--r--libstdc++-v3/testsuite/util/statistic/sample_variance.hpp81
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_abi.cc563
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_abi.h99
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_abi_check.cc86
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_allocator.cc56
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_allocator.h354
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_api.h197
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_character.cc186
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_character.h570
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_common_types.h833
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_container_traits.h260
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_containers.h229
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_error.h59
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_greedy_ops.h58
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_hooks.cc326
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_hooks.h345
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_io.h319
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_iterators.h552
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_performance.h485
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_rng.h97
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_rvalref.h267
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_shared.cc72
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_tr1.h288
-rw-r--r--libstdc++-v3/testsuite/util/thread/all.h62
110 files changed, 22055 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/common_type.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/common_type.hpp
new file mode 100644
index 000000000..562f418fa
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/common_type.hpp
@@ -0,0 +1,799 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file common_type.hpp
+ * Contains common types.
+ */
+
+#ifndef PB_DS_COMMON_TYPES_ASSOC_HPP
+#define PB_DS_COMMON_TYPES_ASSOC_HPP
+
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <common_type/assoc/template_policy.hpp>
+#include <ext/pb_ds/assoc_container.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ template<typename Key,
+ typename Data,
+ class Hash_Fn = typename __gnu_pbds::detail::default_hash_fn<Key>::type,
+ class Eq_Fn = std::equal_to<Key>,
+ class Allocator = std::allocator<std::pair<const Key, Data> > >
+ struct hash_common_types
+ {
+ private:
+ typedef typename Allocator::size_type size_type;
+
+ typedef
+ __gnu_pbds::test::hash_load_check_resize_trigger_t_<
+ Allocator,
+ 1, 8,
+ 1, 2,
+ false>
+ no_access_half_load_check_resize_trigger_policy;
+
+ typedef
+ __gnu_pbds::test::hash_load_check_resize_trigger_t_<
+ Allocator,
+ 1, 8,
+ 1, 2,
+ true>
+ access_half_load_check_resize_trigger_policy;
+
+ typedef
+ __gnu_pbds::test::hash_load_check_resize_trigger_t_<
+ Allocator,
+ 1, 8,
+ 1, 1,
+ false>
+ no_access_one_load_check_resize_trigger_policy;
+
+ typedef
+ __gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<
+ Allocator,
+ 1, 2,
+ false>
+ no_access_half_max_col_check_check_resize_trigger_policy;
+
+ typedef
+ __gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<
+ Allocator,
+ 1, 2,
+ true>
+ access_half_max_col_check_check_resize_trigger_policy;
+
+ typedef __gnu_pbds::test::linear_probe_fn_t_<Key, Allocator> lin_p_t;
+
+ typedef __gnu_pbds::test::quadratic_probe_fn_t_<Key, Allocator> quad_p_t;
+
+ typedef
+ typename __gnu_cxx::typelist::create4<
+ __gnu_pbds::detail::false_type,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<
+ Allocator>,
+ no_access_half_load_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_exponential_size_policy_t_<
+ Allocator> >::type
+ performance_cc_policy0;
+
+ typedef
+ typename __gnu_cxx::typelist::create4<
+ __gnu_pbds::detail::false_type,
+ __gnu_pbds::test::direct_mod_range_hashing_t_<
+ Allocator>,
+ no_access_half_load_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_prime_size_policy_t_>::type
+ performance_cc_policy1;
+
+ typedef
+ typename __gnu_cxx::typelist::create4<
+ __gnu_pbds::detail::false_type,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<
+ Allocator>,
+ no_access_one_load_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_exponential_size_policy_t_<
+ Allocator> >::type
+ performance_cc_policy2;
+
+ typedef
+ typename __gnu_cxx::typelist::create4<
+ __gnu_pbds::detail::false_type,
+ __gnu_pbds::test::direct_mod_range_hashing_t_<
+ Allocator>,
+ no_access_one_load_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_prime_size_policy_t_ >::type
+ performance_cc_policy3;
+
+ typedef
+ typename __gnu_cxx::typelist::create4<
+ __gnu_pbds::detail::true_type,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<
+ Allocator>,
+ no_access_half_load_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_exponential_size_policy_t_<
+ Allocator> >::type
+ performance_cc_policy4;
+
+ typedef
+ typename __gnu_cxx::typelist::create4<
+ __gnu_pbds::detail::false_type,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<
+ Allocator>,
+ no_access_half_max_col_check_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_exponential_size_policy_t_<
+ Allocator> >::type
+ performance_cc_policy5;
+
+ typedef
+ typename __gnu_cxx::typelist::create4<
+ __gnu_pbds::detail::false_type,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<
+ Allocator>,
+ access_half_max_col_check_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_exponential_size_policy_t_<
+ Allocator> >::type
+ regression_cc_policy0;
+
+ typedef
+ typename __gnu_cxx::typelist::create4<
+ __gnu_pbds::detail::false_type,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<
+ Allocator>,
+ access_half_load_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_exponential_size_policy_t_<
+ Allocator> >::type
+ regression_cc_policy1;
+
+ typedef
+ typename __gnu_cxx::typelist::create4<
+ __gnu_pbds::detail::true_type,
+ __gnu_pbds::test::direct_mod_range_hashing_t_<
+ Allocator>,
+ no_access_half_load_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_prime_size_policy_t_ >::type
+ regression_cc_policy2;
+
+ typedef
+ typename __gnu_cxx::typelist::create5<
+ __gnu_pbds::detail::false_type,
+ lin_p_t,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<
+ Allocator>,
+ no_access_half_load_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_exponential_size_policy_t_<
+ Allocator> >::type
+ performance_gp_policy0;
+
+ typedef
+ typename __gnu_cxx::typelist::create5<
+ __gnu_pbds::detail::false_type,
+ quad_p_t,
+ __gnu_pbds::test::direct_mod_range_hashing_t_<
+ Allocator>,
+ no_access_half_load_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_prime_size_policy_t_ >::type
+ performance_gp_policy1;
+
+ typedef
+ typename __gnu_cxx::typelist::create5<
+ __gnu_pbds::detail::false_type,
+ quad_p_t,
+ __gnu_pbds::test::direct_mod_range_hashing_t_<
+ Allocator>,
+ access_half_load_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_prime_size_policy_t_>::type
+ regression_gp_policy0;
+
+ typedef
+ typename __gnu_cxx::typelist::create5<
+ __gnu_pbds::detail::true_type,
+ lin_p_t,
+ __gnu_pbds::test::direct_mask_range_hashing_t_<
+ Allocator>,
+ access_half_load_check_resize_trigger_policy,
+ __gnu_pbds::test::hash_exponential_size_policy_t_<
+ Allocator> >::type
+ regression_gp_policy1;
+
+ typedef
+ typename __gnu_cxx::typelist::create6<
+ performance_cc_policy0,
+ performance_cc_policy1,
+ performance_cc_policy2,
+ performance_cc_policy3,
+ performance_cc_policy4,
+ performance_cc_policy5>::type
+ performance_cc_range_hashing_policies;
+
+ typedef
+ typename __gnu_cxx::typelist::create3<
+ regression_cc_policy0,
+ regression_cc_policy1,
+ regression_cc_policy2>::type
+ regression_cc_range_hashing_policies;
+
+ typedef
+ typename __gnu_cxx::typelist::create2<
+ performance_gp_policy0,
+ performance_gp_policy1>::type
+ performance_gp_range_hashing_policies;
+
+ typedef
+ typename __gnu_cxx::typelist::create2<
+ regression_gp_policy0,
+ regression_gp_policy1>::type
+ regression_gp_range_hashing_policies;
+
+ template<typename Policy_Tl>
+ struct no_access_generic_cc_hash_table_t
+ {
+ private:
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 0>::type
+ store_hash_indicator;
+
+ enum
+ {
+ store_hash = store_hash_indicator::value
+ };
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 1>::type
+ comb_hash_fn;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 2>::type
+ trigger_policy;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 3>::type
+ size_policy;
+
+ public:
+ typedef
+ __gnu_pbds::cc_hash_table<
+ Key,
+ Data,
+ Hash_Fn,
+ Eq_Fn,
+ comb_hash_fn,
+ __gnu_pbds::hash_standard_resize_policy<
+ size_policy,
+ trigger_policy,
+ false>,
+ store_hash,
+ Allocator>
+ type;
+ };
+
+ template<typename Policy_Tl>
+ struct access_generic_cc_hash_table_t
+ {
+ private:
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 0>::type
+ store_hash_indicator;
+
+ enum
+ {
+ store_hash = store_hash_indicator::value
+ };
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 1>::type
+ comb_hash_fn;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 2>::type
+ trigger_policy;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 3>::type
+ size_policy;
+
+ public:
+ typedef
+ __gnu_pbds::cc_hash_table<
+ Key,
+ Data,
+ Hash_Fn,
+ Eq_Fn,
+ comb_hash_fn,
+ __gnu_pbds::hash_standard_resize_policy<
+ size_policy,
+ trigger_policy,
+ true>,
+ store_hash,
+ Allocator>
+ type;
+ };
+
+ template<typename Policy_Tl>
+ struct no_access_generic_gp_hash_table_t
+ {
+ private:
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 0>::type
+ store_hash_indicator;
+
+ enum
+ {
+ store_hash = store_hash_indicator::value
+ };
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 1>::type
+ probe_fn;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 2>::type
+ comb_probe_fn;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 3>::type
+ trigger_policy;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 4>::type
+ size_policy;
+
+ public:
+ typedef
+ __gnu_pbds::gp_hash_table<
+ Key,
+ Data,
+ Hash_Fn,
+ Eq_Fn,
+ comb_probe_fn,
+ probe_fn,
+ __gnu_pbds::hash_standard_resize_policy<
+ size_policy,
+ trigger_policy,
+ false>,
+ store_hash,
+ Allocator>
+ type;
+ };
+
+ template<typename Policy_Tl>
+ struct access_generic_gp_hash_table_t
+ {
+ private:
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 0>::type
+ store_hash_indicator;
+
+ enum
+ {
+ store_hash = store_hash_indicator::value
+ };
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 1>::type
+ probe_fn;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 2>::type
+ comb_probe_fn;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 3>::type
+ trigger_policy;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ Policy_Tl, 4>::type
+ size_policy;
+
+ public:
+ typedef
+ __gnu_pbds::gp_hash_table<
+ Key,
+ Data,
+ Hash_Fn,
+ Eq_Fn,
+ comb_probe_fn,
+ probe_fn,
+ __gnu_pbds::hash_standard_resize_policy<
+ size_policy,
+ trigger_policy,
+ true>,
+ store_hash,
+ Allocator>
+ type;
+ };
+
+ typedef
+ typename __gnu_cxx::typelist::transform<
+ performance_cc_range_hashing_policies,
+ no_access_generic_cc_hash_table_t>::type
+ performance_cc_types;
+
+ typedef
+ typename __gnu_cxx::typelist::transform<
+ regression_cc_range_hashing_policies,
+ access_generic_cc_hash_table_t>::type
+ regression_cc_types;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ performance_cc_types,
+ 0>::type
+ performance_min_cc_type;
+
+ typedef
+ typename __gnu_cxx::typelist::transform<
+ performance_gp_range_hashing_policies,
+ no_access_generic_gp_hash_table_t>::type
+ performance_gp_types;
+
+ typedef
+ typename __gnu_cxx::typelist::transform<
+ regression_gp_range_hashing_policies,
+ access_generic_gp_hash_table_t>::type
+ regression_gp_types;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ performance_gp_types,
+ 0>::type
+ performance_min_gp_type;
+
+ public:
+ typedef
+ typename __gnu_cxx::typelist::append<
+ performance_cc_types,
+ performance_gp_types>::type
+ performance_tl;
+
+ typedef
+ typename __gnu_cxx::typelist::append<
+ regression_gp_types,
+ regression_cc_types>::type
+ regression_tl;
+
+ typedef
+ typename __gnu_cxx::typelist::create1<
+ performance_min_cc_type>::type
+ performance_min_tl;
+ };
+
+ template<typename Key,
+ typename Data,
+ class Comb_Hash_Fn_TL,
+ class Comb_Probe_Fn_TL,
+ class Eq_Fn =
+ std::equal_to<Key>,
+ class Allocator =
+ std::allocator<
+ std::pair<
+ const Key,
+ Data> > >
+ struct ranged_hash_common_types
+ {
+ private:
+ typedef typename Allocator::size_type size_type;
+
+ typedef
+ __gnu_pbds::test::hash_load_check_resize_trigger_t_<
+ Allocator,
+ 1, 8,
+ 1, 2,
+ false>
+ no_access_half_load_check_resize_trigger_policy;
+
+ typedef
+ __gnu_pbds::test::hash_load_check_resize_trigger_t_<
+ Allocator,
+ 1, 8,
+ 1, 1,
+ false>
+ no_access_one_load_check_resize_trigger_policy;
+
+ typedef
+ __gnu_pbds::hash_standard_resize_policy<
+ __gnu_pbds::test::hash_exponential_size_policy_t_<
+ Allocator>,
+ no_access_half_load_check_resize_trigger_policy>
+ mask_half_resize_policy_t;
+
+ typedef
+ __gnu_pbds::hash_standard_resize_policy<
+ __gnu_pbds::test::hash_exponential_size_policy_t_<
+ Allocator>,
+ no_access_one_load_check_resize_trigger_policy>
+ mask_one_resize_policy_t;
+
+ typedef
+ __gnu_pbds::hash_standard_resize_policy<
+ __gnu_pbds::test::hash_prime_size_policy_t_,
+ no_access_half_load_check_resize_trigger_policy>
+ mod_half_resize_policy_t;
+
+ typedef
+ __gnu_pbds::hash_standard_resize_policy<
+ __gnu_pbds::test::hash_prime_size_policy_t_,
+ no_access_one_load_check_resize_trigger_policy>
+ mod_one_resize_policy_t;
+
+ template<typename Comb_Hash_Fn_>
+ struct half_resize_policy_selector;
+
+ template<typename Allocator_>
+ struct half_resize_policy_selector<
+ __gnu_pbds::test::direct_mask_range_hashing_t_<
+ Allocator_> >
+ {
+ typedef mask_half_resize_policy_t type;
+ };
+
+ template<typename Allocator_>
+ struct half_resize_policy_selector<
+ __gnu_pbds::test::direct_mod_range_hashing_t_<
+ Allocator_> >
+ {
+ typedef mod_half_resize_policy_t type;
+ };
+
+ template<typename Comb_Hash_Fn_>
+ struct one_resize_policy_selector;
+
+ template<typename Allocator_>
+ struct one_resize_policy_selector<
+ __gnu_pbds::test::direct_mask_range_hashing_t_<
+ Allocator_> >
+ {
+ typedef mask_one_resize_policy_t type;
+ };
+
+ template<typename Allocator_>
+ struct one_resize_policy_selector<
+ __gnu_pbds::test::direct_mod_range_hashing_t_<
+ Allocator_> >
+ {
+ typedef mod_one_resize_policy_t type;
+ };
+
+ template<typename Comb_Hash_Fn>
+ struct generic_cc_hash_table_t
+ {
+ typedef
+ __gnu_pbds::cc_hash_table<
+ Key,
+ Data,
+ __gnu_pbds::null_hash_fn,
+ Eq_Fn,
+ Comb_Hash_Fn,
+ typename one_resize_policy_selector<
+ typename Comb_Hash_Fn::comb_fn>::type,
+ false,
+ Allocator>
+ type;
+ };
+
+ typedef
+ typename __gnu_cxx::typelist::transform<
+ Comb_Hash_Fn_TL,
+ generic_cc_hash_table_t>::type
+ performance_cc_types;
+
+ template<typename Comb_Probe_Fn>
+ struct no_access_generic_gp_hash_table_t
+ {
+ typedef
+ __gnu_pbds::gp_hash_table<
+ Key,
+ Data,
+ __gnu_pbds::null_hash_fn,
+ Eq_Fn,
+ Comb_Probe_Fn,
+ __gnu_pbds::null_probe_fn,
+ typename half_resize_policy_selector<
+ typename Comb_Probe_Fn::comb_fn>::type,
+ false,
+ Allocator>
+ type;
+ };
+
+ typedef
+ typename __gnu_cxx::typelist::transform<
+ Comb_Probe_Fn_TL,
+ no_access_generic_gp_hash_table_t>::type
+ performance_gp_types;
+
+ public:
+ typedef
+ typename __gnu_cxx::typelist::append<
+ performance_cc_types,
+ performance_gp_types>::type
+ performance_tl;
+ };
+
+ template<typename Key, typename Data, class Eq_Fn = std::equal_to<Key>,
+ class Allocator =
+ std::allocator<char> >
+ class lu_common_types
+ {
+ private:
+ typedef typename Allocator::size_type size_type;
+
+ typedef __gnu_pbds::test::move_to_front_lu_policy_t_ mtf_u;
+
+ typedef __gnu_pbds::test::counter_lu_policy_t_<Allocator, 5> cnt_5_u;
+
+ typedef typename __gnu_cxx::typelist::create1<mtf_u>::type lu_policy0;
+
+ typedef typename __gnu_cxx::typelist::create1<cnt_5_u>::type lu_policy1;
+
+ typedef
+ typename __gnu_cxx::typelist::create2<lu_policy0, lu_policy1>::type
+ lu_policies;
+
+ template<typename Policy_Tl>
+ struct generic_list_update_t
+ {
+ private:
+ typedef
+ typename __gnu_cxx::typelist::at_index<Policy_Tl, 0>::type
+ update_policy_t;
+
+ public:
+ typedef
+ __gnu_pbds::list_update<Key, Data, Eq_Fn, update_policy_t, Allocator>
+ type;
+ };
+
+ typedef
+ typename __gnu_cxx::typelist::transform<
+ lu_policies,
+ generic_list_update_t>::type
+ lu_types;
+
+ typedef
+ typename __gnu_cxx::typelist::at_index<
+ lu_types,
+ 0>::type
+ min_lu_type;
+
+ public:
+ typedef lu_types performance_tl;
+ typedef lu_types regression_tl;
+
+ typedef typename __gnu_cxx::typelist::create1<min_lu_type>::type performance_min_tl;
+ };
+
+ template<typename Key, typename Data, class Cmp_Fn = std::less<Key>,
+ template<typename Const_Node_Iterator,
+ class Node_Iterator,
+ class Cmp_Fn_,
+ class Allocator_>
+ class Node_Update = __gnu_pbds::null_tree_node_update,
+ class Allocator = std::allocator<std::pair<const Key, Data> > >
+ struct tree_common_types
+ {
+ private:
+ typedef
+ __gnu_pbds::tree<
+ Key,
+ Data,
+ Cmp_Fn,
+ __gnu_pbds::ov_tree_tag,
+ Node_Update,
+ Allocator>
+ ov_tree_assoc_container_t;
+
+ typedef
+ __gnu_pbds::tree<
+ Key,
+ Data,
+ Cmp_Fn,
+ __gnu_pbds::rb_tree_tag,
+ Node_Update,
+ Allocator>
+ rb_tree_assoc_container_t;
+
+ typedef
+ __gnu_pbds::tree<
+ Key,
+ Data,
+ Cmp_Fn,
+ __gnu_pbds::splay_tree_tag,
+ Node_Update,
+ Allocator>
+ splay_tree_assoc_container_t;
+
+ public:
+ typedef
+ typename __gnu_cxx::typelist::create3<
+ splay_tree_assoc_container_t,
+ rb_tree_assoc_container_t,
+ ov_tree_assoc_container_t>::type
+ performance_tl;
+
+ typedef
+ typename __gnu_cxx::typelist::create3<
+ ov_tree_assoc_container_t,
+ splay_tree_assoc_container_t,
+ rb_tree_assoc_container_t>::type
+ regression_tl;
+
+ typedef
+ typename __gnu_cxx::typelist::create1<
+ rb_tree_assoc_container_t>::type
+ performance_min_tl;
+ };
+
+ template<typename Key,
+ typename Data,
+ class E_Access_Traits =
+ typename __gnu_pbds::detail::default_trie_e_access_traits<Key>::type,
+ class Tag = __gnu_pbds::pat_trie_tag,
+ template<typename Const_Node_Iterator,
+ typename Node_Iterator,
+ class E_Access_Traits_,
+ typename Allocator_>
+ class Node_Update = __gnu_pbds::null_trie_node_update,
+ class Allocator = std::allocator<char> >
+ class trie_common_types
+ {
+ private:
+ typedef __gnu_pbds::trie<Key, Data, E_Access_Traits, Tag, Node_Update, Allocator> type;
+
+ public:
+ typedef typename __gnu_cxx::typelist::create1<type>::type performance_tl;
+ typedef typename __gnu_cxx::typelist::create1<type>::type regression_tl;
+ typedef typename __gnu_cxx::typelist::create1<type>::type performance_min_tl;
+ };
+
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_COMMON_TYPES_ASSOC_HPP
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/comb_hash_fn_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/comb_hash_fn_string_form.hpp
new file mode 100644
index 000000000..0410ec977
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/comb_hash_fn_string_form.hpp
@@ -0,0 +1,98 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file comb_hash_fn_string_form.hpp
+ * Transforms containers into string form.
+ */
+
+#ifndef PB_DS_COMB_HASH_FN_STRING_FORM_HPP
+#define PB_DS_COMB_HASH_FN_STRING_FORM_HPP
+
+#include <string>
+#include <common_type/assoc/template_policy.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+namespace test
+{
+namespace detail
+{
+
+ template<typename Comb_Hash_Fn>
+ struct comb_hash_fn_string_form
+ {
+ static std::string
+ name()
+ { return (Comb_Hash_Fn::name()); }
+
+ static std::string
+ desc()
+ { return (Comb_Hash_Fn::desc()); }
+ };
+
+ template<typename Size_Type>
+ struct comb_hash_fn_string_form<
+ direct_mask_range_hashing_t_<
+ Size_Type> >
+ {
+ static std::string
+ name()
+ { return ("mask_"); }
+
+ static std::string
+ desc()
+ {
+ return make_xml_tag("Comb_Hash_Fn", "value", "direct_mask_range_hashing");
+ }
+ };
+
+ template<typename Size_Type>
+ struct comb_hash_fn_string_form<direct_mod_range_hashing_t_<Size_Type> >
+ {
+ static std::string
+ name()
+ { return ("mod_"); }
+
+ static std::string
+ desc()
+ {
+ return make_xml_tag("Comb_Hash_Fn", "value", "direct_mod_range_hashing");
+ }
+ };
+
+} // namespace detail
+} // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_COMB_HASH_FN_STRING_FORM_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/ds_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/ds_string_form.hpp
new file mode 100644
index 000000000..9ee5c4dd7
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/ds_string_form.hpp
@@ -0,0 +1,255 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file ds_string_form.hpp
+ * Transforms containers into string form.
+ */
+
+#ifndef PB_DS_DS_STRING_FORM_HPP
+#define PB_DS_DS_STRING_FORM_HPP
+
+#include <string>
+#include <ext/pb_ds/tag_and_trait.hpp>
+#include <common_type/assoc/detail/list_update_policy_string_form.hpp>
+#include <common_type/assoc/detail/comb_hash_fn_string_form.hpp>
+#include <common_type/assoc/detail/resize_policy_string_form.hpp>
+#include <common_type/assoc/detail/probe_fn_string_form.hpp>
+#include <common_type/assoc/detail/tree_supports_order_statistics.hpp>
+#include <common_type/assoc/detail/trie_supports_order_statistics.hpp>
+#include <common_type/assoc/detail/trie_supports_prefix_search.hpp>
+#include <common_type/assoc/detail/store_hash_string_form.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename Cntnr, class Tag>
+ struct ds_string_form;
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::cc_hash_tag>
+ {
+ static std::string
+ name()
+ {
+ return ("cc_hash_" +
+ comb_hash_fn_string_form<typename Cntnr::comb_hash_fn>::name() +
+ resize_policy_string_form<typename Cntnr::resize_policy>::name() +
+ store_hash_string_form<Cntnr::store_hash>::name());
+ }
+
+ static std::string
+ desc()
+ {
+ const std::string comb_hash_fn_desc =
+ comb_hash_fn_string_form<typename Cntnr::comb_hash_fn>::desc();
+
+ const std::string resize_policy_desc =
+ resize_policy_string_form<typename Cntnr::resize_policy>::desc();
+
+ const std::string store_hash_desc =
+ store_hash_string_form<Cntnr::store_hash>::desc();
+
+ return (make_xml_tag("type", "value", "cc_hash_table", comb_hash_fn_desc + resize_policy_desc + store_hash_desc));
+ }
+ };
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::gp_hash_tag>
+ {
+ static std::string
+ name()
+ {
+ return ("gp_hash_" +
+ comb_hash_fn_string_form<typename Cntnr::comb_probe_fn>::name() +
+ probe_fn_string_form<typename Cntnr::probe_fn>::name() +
+ resize_policy_string_form<typename Cntnr::resize_policy>::name() +
+ store_hash_string_form<Cntnr::store_hash>::name());
+ }
+
+ static std::string
+ desc()
+ {
+ const std::string comb_probe_fn_desc =
+ comb_hash_fn_string_form<typename Cntnr::comb_probe_fn>::desc();
+
+ const std::string probe_fn_desc =
+ probe_fn_string_form<typename Cntnr::probe_fn>::desc();
+
+ const std::string resize_policy_desc =
+ resize_policy_string_form<typename Cntnr::resize_policy>::desc();
+
+ const std::string store_hash_desc =
+ store_hash_string_form<Cntnr::store_hash>::desc();
+
+ return make_xml_tag("type", "value", "gp_hash_table",
+ comb_probe_fn_desc + probe_fn_desc + resize_policy_desc + store_hash_desc);
+ }
+ };
+
+ template<typename Cntnr>
+ struct tree_ds_string_form
+ {
+ static std::string
+ name(const std::string container_category_str)
+ {
+ if (tree_supports_order_statistics<Cntnr>::value)
+ return (container_category_str + "ost_");
+ return container_category_str;
+ }
+
+ static std::string
+ desc(const std::string container_category_str)
+ {
+ const std::string category_str =
+ make_xml_tag("Tag", "value", container_category_str);
+
+ const std::string node_update_str =
+ make_xml_tag("Node_Update",
+ "value",(tree_supports_order_statistics<Cntnr>::value ?
+ "tree_order_statistics_node_update" : "null_tree_node_update"));
+
+ return make_xml_tag("type", "value", "tree", category_str + node_update_str);
+ }
+ };
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::rb_tree_tag>
+ : private tree_ds_string_form<Cntnr>
+ {
+ private:
+ typedef tree_ds_string_form< Cntnr> base_type;
+
+ public:
+ static std::string
+ name()
+ { return base_type::name("rb_tree_"); }
+
+ static std::string
+ desc()
+ { return base_type::desc("rb_tree_tag"); }
+ };
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::splay_tree_tag>
+ : private tree_ds_string_form<Cntnr>
+ {
+ private:
+ typedef tree_ds_string_form< Cntnr> base_type;
+
+ public:
+ static std::string
+ name()
+ { return base_type::name("splay_tree_"); }
+
+ static std::string
+ desc()
+ { return base_type::desc("splay_tree_tag"); }
+ };
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::ov_tree_tag>
+ : private tree_ds_string_form<Cntnr>
+ {
+ private:
+ typedef tree_ds_string_form< Cntnr> base_type;
+
+ public:
+ static std::string
+ name()
+ { return (base_type::name("ov_tree_")); }
+
+ static std::string
+ desc()
+ { return (base_type::desc("ov_tree_tag")); }
+ };
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::list_update_tag>
+ {
+ static std::string
+ name()
+ {
+ return ("lu_" +
+ lu_policy_string_form<typename Cntnr::update_policy>::name());
+ }
+
+ static std::string
+ desc()
+ {
+ return make_xml_tag("type", "value", "list_update",
+ lu_policy_string_form<typename Cntnr::update_policy>::desc());
+ }
+ };
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::pat_trie_tag>
+ {
+ static std::string
+ name()
+ {
+ if (trie_supports_order_statistics<Cntnr>::value)
+ return ("pat_trie_ost_");
+
+ if (trie_supports_prefix_search<Cntnr>::value)
+ return ("pat_trie_prs_");
+
+ return ("pat_trie_");
+ }
+
+ static std::string
+ desc()
+ {
+ std::string category_s = make_xml_tag("Tag", "value", "pat_trie_tag");
+ const char* s;
+ if (trie_supports_order_statistics<Cntnr>::value)
+ s = "trie_order_statistics_node_update";
+ else if (trie_supports_prefix_search<Cntnr>::value)
+ s = "trie_prefix_search_node_update";
+ else
+ s = "null_trie_node_update";
+ std::string node_s = make_xml_tag("Node_Update", "value", s);
+ return make_xml_tag("type", "value", "trie", category_s + node_s);
+ }
+ };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_DS_STRING_FORM_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/list_update_policy_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/list_update_policy_string_form.hpp
new file mode 100644
index 000000000..ed3747fa1
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/list_update_policy_string_form.hpp
@@ -0,0 +1,97 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file lu_policy_string_form.hpp
+ * Transforms containers into string form.
+ */
+
+#ifndef PB_DS_LU_POLICY_STRING_FORM_HPP
+#define PB_DS_LU_POLICY_STRING_FORM_HPP
+
+#include <string>
+#include <common_type/assoc/template_policy.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Update_Policy>
+ struct lu_policy_string_form;
+
+ template<>
+ struct lu_policy_string_form<move_to_front_lu_policy_t_>
+ {
+ static std::string
+ name()
+ { return ("mtf_"); }
+
+ static std::string
+ desc()
+ {
+ return make_xml_tag("Update_Policy", "value",
+ "move_to_front_lu_policy");
+ }
+ };
+
+ template<typename Allocator, typename Allocator::size_type Max_Count>
+ struct lu_policy_string_form<counter_lu_policy_t_<Allocator, Max_Count> >
+ {
+ static std::string
+ name()
+ {
+ std::ostringstream ret;
+ ret << "cnt_" << Max_Count << "_";
+ return (ret.str());
+ }
+
+ static std::string
+ desc()
+ {
+ return (make_xml_tag("Update_Policy", "value", "counter_lu_policy",
+ "Max_Count", Max_Count));
+ }
+ };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_LU_POLICY_STRING_FORM_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/probe_fn_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/probe_fn_string_form.hpp
new file mode 100644
index 000000000..15cbbfda5
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/probe_fn_string_form.hpp
@@ -0,0 +1,99 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file probe_fn_string_form.hpp
+ * Transforms containers into string form.
+ */
+
+#ifndef PB_DS_PROBE_FN_STRING_FORM_HPP
+#define PB_DS_PROBE_FN_STRING_FORM_HPP
+
+#include <string>
+#include <common_type/assoc/template_policy.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Probe_Fn>
+ struct probe_fn_string_form;
+
+ template<typename Key, class Allocator>
+ struct probe_fn_string_form<linear_probe_fn_t_<Key, Allocator> >
+ {
+ static std::string
+ name()
+ { return ("linp_"); }
+
+ static std::string
+ desc()
+ { return make_xml_tag("Probe_Fn", "value", "linear_probe_fn"); }
+ };
+
+ template<typename Key, class Allocator>
+ struct probe_fn_string_form<quadratic_probe_fn_t_<Key, Allocator> >
+ {
+ static std::string
+ name()
+ { return ("quadp_"); }
+
+ static std::string
+ desc()
+ { return make_xml_tag("Probe_Fn", "value", "quadratic_probe_fn"); }
+ };
+
+ template<>
+ struct probe_fn_string_form<__gnu_pbds::null_probe_fn>
+ {
+ static std::string
+ name()
+ { return (""); }
+
+ static std::string
+ desc()
+ { return make_xml_tag("Probe_Fn", "value", "null_probe_fn"); }
+ };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_PROBE_FN_STRING_FORM_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/resize_policy_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/resize_policy_string_form.hpp
new file mode 100644
index 000000000..8d5b68698
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/resize_policy_string_form.hpp
@@ -0,0 +1,93 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file resize_policy_string_form.hpp
+ * Transforms containers into string form.
+ */
+
+#ifndef PB_DS_RESIZE_POLICY_STRING_FORM_HPP
+#define PB_DS_RESIZE_POLICY_STRING_FORM_HPP
+
+#include <string>
+#include <common_type/assoc/detail/size_policy_string_form.hpp>
+#include <common_type/assoc/detail/trigger_policy_string_form.hpp>
+#include <common_type/assoc/template_policy.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Resize_Policy>
+ struct resize_policy_string_form;
+
+ template<typename Size_Policy,
+ class Trigger_Policy,
+ bool External_Size_Access,
+ typename Size_Type>
+ struct resize_policy_string_form<
+ __gnu_pbds::hash_standard_resize_policy<
+ Size_Policy, Trigger_Policy, External_Size_Access, Size_Type> >
+ {
+ static std::string
+ name()
+ {
+ return (size_policy_string_form<Size_Policy>::name() +
+ trigger_policy_string_form<Trigger_Policy>::name());
+ }
+
+ static std::string
+ desc()
+ {
+ const std::string size_policy_string_form_desc =
+ size_policy_string_form<Size_Policy>::desc();
+
+ const std::string trigger_policy_string_form_desc =
+ trigger_policy_string_form<Trigger_Policy>::desc();
+
+ return (make_xml_tag("Resize_Policy", "value", "hash_standard_resize_policy", size_policy_string_form_desc + trigger_policy_string_form_desc));
+ }
+ };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_RESIZE_POLICY_STRING_FORM_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/size_policy_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/size_policy_string_form.hpp
new file mode 100644
index 000000000..d2b61facb
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/size_policy_string_form.hpp
@@ -0,0 +1,95 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file size_policy_string_form.hpp
+ * Transforms containers into string form.
+ */
+
+#ifndef PB_DS_SIZE_POLICY_STRING_FORM_HPP
+#define PB_DS_SIZE_POLICY_STRING_FORM_HPP
+
+#include <string>
+#include <common_type/assoc/detail/size_policy_string_form.hpp>
+#include <common_type/assoc/detail/trigger_policy_string_form.hpp>
+#include <common_type/assoc/template_policy.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Size_Policy>
+ struct size_policy_string_form;
+
+ template<typename Allocator>
+ struct size_policy_string_form<
+ __gnu_pbds::test::hash_exponential_size_policy_t_<Allocator> >
+ {
+ static std::string
+ name()
+ { return ("exp_"); }
+
+ static std::string
+ desc()
+ {
+ return (make_xml_tag("Size_Policy", "value", "hash_exponential_size_policy"));
+ }
+ };
+
+ template<>
+ struct size_policy_string_form<
+ __gnu_pbds::test::hash_prime_size_policy_t_>
+ {
+ static std::string
+ name()
+ { return ("prime_"); }
+
+ static std::string
+ desc()
+ {
+ return (make_xml_tag("Size_Policy", "value", "hash_prime_size_policy"));
+ }
+ };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_SIZE_POLICY_STRING_FORM_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/store_hash_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/store_hash_string_form.hpp
new file mode 100644
index 000000000..a932948fa
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/store_hash_string_form.hpp
@@ -0,0 +1,82 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file store_hash_string_form.hpp
+ * Transforms containers into string form.
+ */
+
+#ifndef PB_DS_STORE_HASH_STRING_FORM_HPP
+#define PB_DS_STORE_HASH_STRING_FORM_HPP
+
+#include <string>
+#include <common_type/assoc/template_policy.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<bool Store_Hash>
+ struct store_hash_string_form
+ {
+ static std::string
+ name()
+ { return ("sth_"); }
+
+ static std::string
+ desc()
+ { return (make_xml_tag("Store_Hash", "value", "true")); }
+ };
+
+ template<>
+ struct store_hash_string_form<false>
+ {
+ static std::string
+ name()
+ { return ("nsth_"); }
+
+ static std::string
+ desc()
+ { return (make_xml_tag("Store_Hash", "value", "false")); }
+ };
+
+ } // namespace detail
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_STORE_HASH_STRING_FORM_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/tree_supports_order_statistics.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/tree_supports_order_statistics.hpp
new file mode 100644
index 000000000..80c1abe54
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/tree_supports_order_statistics.hpp
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_supports_order_statistics.hpp
+ * Checks whether a tree supports order statistics.
+ */
+
+#ifndef PB_DS_TREE_SUPPORTS_ORDER_STATISTICS_HPP
+#define PB_DS_TREE_SUPPORTS_ORDER_STATISTICS_HPP
+
+#include <ext/pb_ds/tree_policy.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Tree_Cntnr>
+ struct tree_supports_order_statistics
+ {
+ enum
+ {
+ value = __gnu_pbds::detail::is_same<
+ typename Tree_Cntnr::node_update,
+ __gnu_pbds::tree_order_statistics_node_update<
+ typename Tree_Cntnr::const_node_iterator,
+ typename Tree_Cntnr::node_iterator,
+ typename Tree_Cntnr::cmp_fn,
+ typename Tree_Cntnr::allocator_type> >::value
+ };
+ };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_TREE_SUPPORTS_ORDER_STATISTICS_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/trie_supports_order_statistics.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/trie_supports_order_statistics.hpp
new file mode 100644
index 000000000..fc9cacc63
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/trie_supports_order_statistics.hpp
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file trie_supports_order_statistics.hpp
+ * Checks whether a trie supports order stats.
+ */
+
+#ifndef PB_DS_TRIE_SUPPORTS_ORDER_STATISTICS_HPP
+#define PB_DS_TRIE_SUPPORTS_ORDER_STATISTICS_HPP
+
+#include <ext/pb_ds/trie_policy.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Tree_Cntnr>
+ struct trie_supports_order_statistics
+ {
+ enum
+ {
+ value = __gnu_pbds::detail::is_same<
+ typename Tree_Cntnr::node_update,
+ __gnu_pbds::trie_order_statistics_node_update<
+ typename Tree_Cntnr::const_node_iterator,
+ typename Tree_Cntnr::node_iterator,
+ typename Tree_Cntnr::e_access_traits,
+ typename Tree_Cntnr::allocator_type> >::value
+ };
+ };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_TRIE_SUPPORTS_ORDER_STATISTICS_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/trie_supports_prefix_search.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/trie_supports_prefix_search.hpp
new file mode 100644
index 000000000..20c521010
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/trie_supports_prefix_search.hpp
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file trie_supports_prefix_search.hpp
+ * Checks whether a trie supports prefix search.
+ */
+
+#ifndef PB_DS_TRIE_SUPPORTS_PREFIX_SEARCH_HPP
+#define PB_DS_TRIE_SUPPORTS_PREFIX_SEARCH_HPP
+
+#include <ext/pb_ds/trie_policy.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Tree_Cntnr>
+ struct trie_supports_prefix_search
+ {
+ enum
+ {
+ value = __gnu_pbds::detail::is_same<
+ typename Tree_Cntnr::node_update,
+ __gnu_pbds::trie_prefix_search_node_update<
+ typename Tree_Cntnr::const_node_iterator,
+ typename Tree_Cntnr::node_iterator,
+ typename Tree_Cntnr::e_access_traits,
+ typename Tree_Cntnr::allocator_type> >::value
+ };
+ };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_TRIE_SUPPORTS_PREFIX_SEARCH_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/detail/trigger_policy_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/detail/trigger_policy_string_form.hpp
new file mode 100644
index 000000000..be4fe264f
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/detail/trigger_policy_string_form.hpp
@@ -0,0 +1,141 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file trigger_policy_string_form.hpp
+ * Transforms containers into string form.
+ */
+
+#ifndef PB_DS_TRIGGER_POLICY_STRING_FORM_HPP
+#define PB_DS_TRIGGER_POLICY_STRING_FORM_HPP
+
+#include <string>
+#include <common_type/assoc/template_policy.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Trigger_Policy>
+ struct trigger_policy_string_form;
+
+ template<typename Allocator,
+ typename Allocator::size_type Min_Load_Nom,
+ typename Allocator::size_type Min_Load_Denom,
+ typename Allocator::size_type Max_Load_Nom,
+ typename Allocator::size_type Max_Load_Denom,
+ bool External_Access>
+ struct trigger_policy_string_form<
+ __gnu_pbds::test::hash_load_check_resize_trigger_t_<
+ Allocator,
+ Min_Load_Nom,
+ Min_Load_Denom,
+ Max_Load_Nom,
+ Max_Load_Denom,
+ External_Access> >
+ {
+ static std::string
+ name()
+ {
+ std::ostringstream ret;
+
+ ret << (External_Access? "": "n") << "ea_"
+ "lc_" << Min_Load_Nom << "div" << Min_Load_Denom << "_" <<
+ Max_Load_Nom << "div" << Max_Load_Denom << "_";
+
+ return (ret.str());
+ }
+
+ static std::string
+ desc()
+ {
+ const std::string ext_access_desc =
+ make_xml_tag("External_Access",
+ "value",(External_Access? "true" : "false"));
+
+ const std::string loads_desc =
+ make_xml_tag("alpha_min", "nom", Min_Load_Nom, "denom", Min_Load_Denom) +
+ make_xml_tag("alpha_max", "nom", Max_Load_Nom, "denom", Max_Load_Denom);
+
+ return (make_xml_tag("Trigger_Policy", "value", "hash_load_check_resize_trigger", ext_access_desc + loads_desc));
+ }
+ };
+
+ template<typename Allocator,
+ typename Allocator::size_type Load_Nom,
+ typename Allocator::size_type Load_Denom,
+ bool External_Access>
+ struct trigger_policy_string_form<
+ __gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<
+ Allocator,
+ Load_Nom,
+ Load_Denom,
+ External_Access> >
+ {
+ static std::string
+ name()
+ {
+ std::ostringstream ret;
+
+ ret << (External_Access? "": "n") << "ea_"
+ "mcolc_" << Load_Nom << "div" << Load_Denom << "_";
+
+ return (ret.str());
+ }
+
+ static std::string
+ desc()
+ {
+ const std::string ext_access_desc =
+ make_xml_tag("External_Access",
+ "value",(External_Access? "true" : "false"));
+
+ const std::string load_desc =
+ make_xml_tag("alpha", "nom", Load_Nom, "denom", Load_Denom);
+
+ return (make_xml_tag("Trigger_Policy", "value", "cc_hash_max_collision_check_resize_trigger", ext_access_desc + load_desc));
+ }
+ };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_TRIGGER_POLICY_STRING_FORM_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/native_set.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/native_set.hpp
new file mode 100644
index 000000000..a2655fe75
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/native_set.hpp
@@ -0,0 +1,84 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file native_set.hpp
+ * Contains an adapter to Dinkumware/SGI tree tables
+ */
+
+#ifndef PB_DS_NATIVE_SET_HPP
+#define PB_DS_NATIVE_SET_HPP
+
+#include <ext/pb_ds/detail/standard_policies.hpp>
+#include <native_type/native_tree_tag.hpp>
+#include <io/xml.hpp>
+#include <string>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ template<typename Key, class Cmp_Fn = std::less<Key>,
+ class Allocator = std::allocator<char> >
+ class native_set : public PB_DS_BASE_C_DEC
+ {
+ private:
+ typedef std::set<Key, Cmp_Fn, typename Allocator::template rebind<Key>::other> base_type;
+
+ public:
+ typedef native_tree_tag container_category;
+
+ typedef typename base_type::const_iterator const_iterator;
+
+ public:
+ native_set() : base_type()
+ { }
+
+ template<typename It>
+ native_set(It f, It l) : base_type(f, l)
+ { }
+
+ native_set(const_iterator f, const_iterator l) : base_type(f, l)
+ { }
+
+ static std::string
+ name()
+ { return ("n_set"); }
+
+ static std::string
+ desc()
+ { return (make_xml_tag("type", "value", "std_set")); }
+ };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/string_form.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/string_form.hpp
new file mode 100644
index 000000000..d7825ac63
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/string_form.hpp
@@ -0,0 +1,179 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file string_form.hpp
+ * Transforms containers into string form.
+ */
+
+#ifndef PB_DS_STRING_FORM_HPP
+#define PB_DS_STRING_FORM_HPP
+
+#include <string>
+#include <sstream>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <ext/pb_ds/tag_and_trait.hpp>
+#include <native_type/native_hash_map.hpp>
+#include <native_type/native_hash_set.hpp>
+#include <native_type/native_multimap.hpp>
+#include <native_type/native_hash_multimap.hpp>
+#include <native_type/native_set.hpp>
+#include <common_type/assoc/template_policy.hpp>
+#include <common_type/assoc/detail/ds_string_form.hpp>
+#include <regression/basic_type.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename Cntnr>
+ struct pb_ds_string_form
+ {
+ private:
+ typedef typename Cntnr::mapped_type mapped_type;
+
+ struct mapped_string_form
+ {
+ private:
+ template<typename D_Cntnr>
+ static std::string
+ name(D_Cntnr)
+ { return ("mmap_" + pb_ds_string_form<D_Cntnr>::name()); }
+
+ template<typename D_Cntnr>
+ static std::string
+ desc(D_Cntnr)
+ { return pb_ds_string_form<D_Cntnr>::desc(); }
+
+ static std::string
+ name(size_t)
+ { return ("map"); }
+
+ static std::string
+ desc(size_t)
+ { return (""); }
+
+ static std::string
+ name(basic_type)
+ { return ("map"); }
+
+ static std::string
+ desc(basic_type)
+ { return (""); }
+
+ static std::string
+ name(int)
+ { return ("map"); }
+
+ static std::string
+ desc(int)
+ { return (""); }
+
+ static std::string
+ name(char)
+ { return ("map"); }
+
+ static std::string
+ desc(char)
+ { return (""); }
+
+ static std::string
+ name(__gnu_pbds::null_mapped_type)
+ { return ("set"); }
+
+ static std::string
+ desc(__gnu_pbds::null_mapped_type)
+ { return (""); }
+
+ public:
+ static std::string
+ name()
+ { return name(mapped_type()); }
+
+ static std::string
+ desc()
+ { return desc(mapped_type()); }
+ };
+
+ typedef
+ detail::ds_string_form<Cntnr, typename Cntnr::container_category>
+ ds_string_form_t;
+
+ public:
+ static std::string
+ name()
+ { return (ds_string_form_t::name() + mapped_string_form::name()); }
+
+ static std::string
+ desc()
+ { return (ds_string_form_t::desc() + mapped_string_form::desc()); }
+ };
+
+ template<typename Cntnr>
+ struct native_string_form
+ {
+ static std::string
+ name()
+ { return Cntnr::name(); }
+
+ static std::string
+ desc()
+ { return Cntnr::desc(); }
+ };
+
+ template<typename Cntnr, class Tag>
+ struct tag_select_string_form : public pb_ds_string_form<Cntnr>
+ { };
+
+ template<typename Cntnr>
+ struct tag_select_string_form<Cntnr, native_hash_tag>
+ : public native_string_form<Cntnr>
+ { };
+
+ template<typename Cntnr>
+ struct tag_select_string_form<Cntnr, native_tree_tag>
+ : public native_string_form<Cntnr>
+ { };
+ } // namespace detail
+
+ template<typename Cntnr>
+ struct string_form
+ : public detail::tag_select_string_form<Cntnr,
+ typename Cntnr::container_category>
+ { };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/common_type/assoc/template_policy.hpp b/libstdc++-v3/testsuite/util/common_type/assoc/template_policy.hpp
new file mode 100644
index 000000000..86db029e2
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/assoc/template_policy.hpp
@@ -0,0 +1,145 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file template_policy.hpp
+ * Contains template versions of policies.
+ */
+
+#ifndef PB_DS_TEMPLATE_POLICY_HPP
+#define PB_DS_TEMPLATE_POLICY_HPP
+
+#include <ext/typelist.h>
+#include <ext/pb_ds/hash_policy.hpp>
+#include <ext/pb_ds/tree_policy.hpp>
+#include <ext/pb_ds/list_update_policy.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ template<typename Allocator>
+ struct direct_mask_range_hashing_t_
+ : public __gnu_pbds::direct_mask_range_hashing<typename Allocator::size_type>
+ {
+ typedef typename Allocator::size_type size_type;
+ typedef __gnu_pbds::direct_mask_range_hashing<size_type> base_type;
+ };
+
+ template<typename Allocator>
+ struct direct_mod_range_hashing_t_
+ : public __gnu_pbds::direct_mod_range_hashing<typename Allocator::size_type>
+ {
+ typedef typename Allocator::size_type size_type;
+ typedef __gnu_pbds::direct_mod_range_hashing<size_type> base_type;
+ };
+
+ template<typename Allocator,
+ typename Allocator::size_type Min_Load_Nom,
+ typename Allocator::size_type Min_Load_Denom,
+ typename Allocator::size_type Max_Load_Nom,
+ typename Allocator::size_type Max_Load_Denom,
+ bool External_Access>
+ struct hash_load_check_resize_trigger_t_
+ : public __gnu_pbds::hash_load_check_resize_trigger<External_Access,
+ typename Allocator::size_type>
+ {
+ typedef typename Allocator::size_type size_type;
+ typedef __gnu_pbds::hash_load_check_resize_trigger<External_Access, size_type> base_type;
+
+ inline
+ hash_load_check_resize_trigger_t_()
+ : base_type(static_cast<float>(Min_Load_Nom) / static_cast<float>(Min_Load_Denom), static_cast<float>(Max_Load_Nom) / static_cast<float>(Max_Load_Denom))
+ { }
+
+ enum
+ {
+ get_set_loads = External_Access,
+ get_set_load = false
+ };
+ };
+
+ template<typename Allocator,
+ typename Allocator::size_type Load_Nom,
+ typename Allocator::size_type Load_Denom,
+ bool External_Access>
+ struct cc_hash_max_collision_check_resize_trigger_t_
+ : public __gnu_pbds::cc_hash_max_collision_check_resize_trigger<External_Access,
+ typename Allocator::size_type>
+ {
+ typedef typename Allocator::size_type size_type;
+ typedef __gnu_pbds::cc_hash_max_collision_check_resize_trigger<External_Access, size_type> base_type;
+
+ inline
+ cc_hash_max_collision_check_resize_trigger_t_()
+ : base_type(static_cast<float>(Load_Nom) / static_cast<float>(Load_Denom))
+ { }
+
+ enum
+ {
+ get_set_load = External_Access,
+ get_set_loads = false
+ };
+ };
+
+ struct hash_prime_size_policy_t_ : public __gnu_pbds::hash_prime_size_policy
+ { };
+
+ template<typename Allocator>
+ struct hash_exponential_size_policy_t_
+ : public __gnu_pbds::hash_exponential_size_policy<typename Allocator::size_type>
+ { };
+
+ template<typename Key, class Allocator>
+ struct linear_probe_fn_t_
+ : public __gnu_pbds::linear_probe_fn<typename Allocator::size_type>
+ { };
+
+ template<typename Key, class Allocator>
+ struct quadratic_probe_fn_t_
+ : public __gnu_pbds::quadratic_probe_fn<typename Allocator::size_type>
+ { };
+
+ template<typename Allocator, typename Allocator::size_type Max_Count>
+ struct counter_lu_policy_t_
+ : public __gnu_pbds::counter_lu_policy<Max_Count, Allocator>
+ {
+ typedef __gnu_pbds::counter_lu_policy<Max_Count, Allocator> base_type;
+ };
+
+ struct move_to_front_lu_policy_t_
+ : public __gnu_pbds::move_to_front_lu_policy<>
+ { };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/common_type/priority_queue/common_type.hpp b/libstdc++-v3/testsuite/util/common_type/priority_queue/common_type.hpp
new file mode 100644
index 000000000..cc79b3eec
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/priority_queue/common_type.hpp
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file common_type.hpp
+ * Contains common types.
+ */
+
+#ifndef PB_DS_COMMON_TYPES_PQ_HPP
+#define PB_DS_COMMON_TYPES_PQ_HPP
+
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <ext/pb_ds/priority_queue.hpp>
+#include <ext/typelist.h>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ template<typename Value_Type, typename Cmp_Fn = std::less<Value_Type>,
+ class Allocator = std::allocator<Value_Type> >
+ struct pq_common_types
+ {
+ private:
+ typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::pairing_heap_tag, Allocator> pairing_heap_t;
+
+ typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::binomial_heap_tag, Allocator> binomial_heap_t;
+
+ typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::rc_binomial_heap_tag, Allocator> rc_binomial_heap_t;
+
+ typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::binary_heap_tag, Allocator> binary_heap_t;
+
+ typedef __gnu_pbds::priority_queue<Value_Type, Cmp_Fn, __gnu_pbds::thin_heap_tag, Allocator> thin_heap_t;
+
+ typedef typename __gnu_cxx::typelist::create5<thin_heap_t, pairing_heap_t, binomial_heap_t, rc_binomial_heap_t, binary_heap_t>::type all_tl;
+
+ public:
+ typedef all_tl performance_tl;
+ typedef all_tl regression_tl;
+ typedef all_tl performance_min_tl;
+ typedef all_tl regression_min_tl;
+ };
+
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_COMMON_TYPES_PQ_HPP
diff --git a/libstdc++-v3/testsuite/util/common_type/priority_queue/detail/ds_string_form.hpp b/libstdc++-v3/testsuite/util/common_type/priority_queue/detail/ds_string_form.hpp
new file mode 100644
index 000000000..8194356b7
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/priority_queue/detail/ds_string_form.hpp
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file ds_string_form.hpp
+ * Transforms containers into string form.
+ */
+
+#ifndef PB_DS_DS_STRING_FORM_HPP
+#define PB_DS_DS_STRING_FORM_HPP
+
+#include <string>
+#include <ext/pb_ds/tag_and_trait.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename Cntnr, class Tag>
+ struct ds_string_form;
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::pairing_heap_tag>
+ {
+ static std::string
+ name()
+ { return "pairing_heap"; }
+
+ static std::string
+ desc()
+ { return make_xml_tag("type", "value", "pairing_heap"); }
+ };
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::thin_heap_tag>
+ {
+ static std::string
+ name()
+ { return "thin_heap"; }
+
+ static std::string
+ desc()
+ { return make_xml_tag("type", "value", "thin_heap"); }
+ };
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::binomial_heap_tag>
+ {
+ static std::string
+ name()
+ { return "binomial_heap"; }
+
+ static std::string
+ desc()
+ { return make_xml_tag("type", "value", "binomial_heap"); }
+ };
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::rc_binomial_heap_tag>
+ {
+ static std::string
+ name()
+ { return "rc_binomial_heap"; }
+
+ static std::string
+ desc()
+ { return make_xml_tag("type", "value", "rc_binomial_heap"); }
+ };
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::binary_heap_tag>
+ {
+ static std::string
+ name()
+ { return "binary_heap"; }
+
+ static std::string
+ desc()
+ { return make_xml_tag("type", "value", "binary_heap"); }
+ };
+
+ template<typename Cntnr>
+ struct ds_string_form<Cntnr, __gnu_pbds::sequence_tag>
+ {
+ static std::string
+ name()
+ { return "sequence"; }
+
+ static std::string
+ desc()
+ { return make_xml_tag("type", "value", "sequence"); }
+ };
+
+ } // namespace detail
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_DS_STRING_FORM_HPP
+
diff --git a/libstdc++-v3/testsuite/util/common_type/priority_queue/string_form.hpp b/libstdc++-v3/testsuite/util/common_type/priority_queue/string_form.hpp
new file mode 100644
index 000000000..e3e13f87d
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/common_type/priority_queue/string_form.hpp
@@ -0,0 +1,99 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file string_form.hpp
+ * Transforms containers into string form.
+ */
+
+#ifndef PB_DS_STRING_FORM_HPP
+#define PB_DS_STRING_FORM_HPP
+
+#include <string>
+#include <sstream>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <native_type/native_priority_queue.hpp>
+#include <common_type/priority_queue/detail/ds_string_form.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename Cntnr>
+ struct pb_ds_string_form
+ {
+ private:
+ typedef ds_string_form<Cntnr, typename Cntnr::container_category> ds_string_form_t;
+
+ public:
+ static std::string
+ name()
+ { return ds_string_form_t::name(); }
+
+ static std::string
+ desc()
+ { return ds_string_form_t::desc(); }
+ };
+
+ template<typename Cntnr>
+ struct native_string_form
+ {
+ static std::string
+ name()
+ { return Cntnr::name(); }
+
+ static std::string
+ desc()
+ { return Cntnr::desc(); }
+ };
+
+ template<typename Cntnr, class Tag>
+ struct tag_select_string_form : public pb_ds_string_form<Cntnr>
+ { };
+
+ template<typename Cntnr>
+ struct tag_select_string_form<Cntnr, native_pq_tag>
+ : public native_string_form<Cntnr>
+ { };
+ } // namespace detail
+
+ template<typename Cntnr>
+ struct string_form
+ : public detail::tag_select_string_form<Cntnr, typename Cntnr::container_category>
+ { };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_STRING_FORM_HPP
+
diff --git a/libstdc++-v3/testsuite/util/debug/checks.h b/libstdc++-v3/testsuite/util/debug/checks.h
new file mode 100644
index 000000000..b42ef1a44
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/debug/checks.h
@@ -0,0 +1,379 @@
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#include <vector>
+#include <deque>
+#include <list>
+#ifndef _GLIBCXX_DEBUG
+# include <debug/vector>
+# include <debug/deque>
+# include <debug/list>
+#endif
+#include <testsuite_hooks.h>
+
+namespace __gnu_test
+{
+ template<typename _Tp>
+ struct CopyableValueType
+ {
+ typedef _Tp value_type;
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct CopyableValueType<std::pair<const _Tp1, _Tp2> >
+ {
+ typedef std::pair<_Tp1, _Tp2> value_type;
+ };
+
+ template<typename _Tp>
+ struct generate_unique
+ {
+ typedef _Tp value_type;
+
+ operator value_type()
+ {
+ static value_type _S_;
+ ++_S_;
+ return _S_;
+ }
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct generate_unique<std::pair<_Tp1, _Tp2> >
+ {
+ typedef _Tp1 first_type;
+ typedef _Tp2 second_type;
+ typedef std::pair<_Tp1, _Tp2> pair_type;
+
+ operator pair_type()
+ {
+ static first_type _S_1;
+ static second_type _S_2;
+ ++_S_1;
+ ++_S_2;
+ return pair_type(_S_1, _S_2);
+ }
+ };
+
+ // Check that invalid range of pointers is detected
+ template<typename _Tp>
+ void
+ check_assign1()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ typedef std::vector<val_type> vector_type;
+
+ generate_unique<val_type> gu;
+
+ vector_type v;
+ for (int i = 0; i != 5; ++i)
+ v.push_back(gu);
+ VERIFY(v.size() == 5);
+
+ const val_type* first = &v.front() + 1;
+ const val_type* last = first + 2;
+
+ cont_type c1;
+ c1.assign(first, last);
+ VERIFY(c1.size() == 2);
+
+ cont_type c2;
+ c2.assign(last, first); // Expected failure
+ }
+
+ // Check that invalid range of debug random iterators is detected
+ template<typename _Tp>
+ void
+ check_assign2()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ typedef std::vector<val_type> vector_type;
+
+ generate_unique<val_type> gu;
+
+ vector_type v;
+ for (int i = 0; i != 5; ++i)
+ v.push_back(gu);
+ VERIFY(v.size() == 5);
+
+ typename vector_type::iterator first = v.begin() + 1;
+ typename vector_type::iterator last = first + 2;
+ cont_type c1;
+ c1.assign(first, last);
+ VERIFY(c1.size() == 2);
+
+ cont_type c2;
+ c2.assign(last, first); // Expected failure
+ }
+
+ // Check that invalid range of debug !random debug iterators is detected
+ template<typename _Tp>
+ void
+ check_assign3()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ typedef std::list<val_type> list_type;
+
+ generate_unique<val_type> gu;
+
+ list_type l;
+ for (int i = 0; i != 5; ++i)
+ l.push_back(gu);
+ VERIFY(l.size() == 5);
+
+ typename list_type::iterator first = l.begin(); ++first;
+ typename list_type::iterator last = first; ++last; ++last;
+ cont_type c1;
+ c1.assign(first, last);
+ VERIFY(c1.size() == 2);
+
+ cont_type c2;
+ c2.assign(last, first); // Expected failure
+ }
+
+ // Check that invalid range of pointers is detected
+ template<typename _Tp>
+ void
+ check_construct1()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ typedef std::vector<val_type> vector_type;
+
+ generate_unique<val_type> gu;
+
+ vector_type v;
+ for (int i = 0; i != 5; ++i)
+ v.push_back(gu);
+ VERIFY(v.size() == 5);
+
+ val_type *first = &v.front() + 1;
+ val_type *last = first + 2;
+ cont_type c1(first, last);
+ VERIFY(c1.size() == 2);
+
+ cont_type c2(last, first); // Expected failure
+ }
+
+ // Check that invalid range of debug random iterators is detected
+ template<typename _Tp>
+ void
+ check_construct2()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ typedef std::vector<val_type> vector_type;
+
+ generate_unique<val_type> gu;
+
+ vector_type v;
+ for (int i = 0; i != 5; ++i)
+ v.push_back(gu);
+ VERIFY(v.size() == 5);
+
+ typename vector_type::iterator first = v.begin() + 1;
+ typename vector_type::iterator last = first + 2;
+ cont_type c1(first, last);
+ VERIFY(c1.size() == 2);
+
+ cont_type c2(last, first); // Expected failure
+ }
+
+ // Check that invalid range of debug not random iterators is detected
+ template<typename _Tp>
+ void
+ check_construct3()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ typedef std::list<val_type> list_type;
+
+ generate_unique<val_type> gu;
+
+ list_type l;
+ for (int i = 0; i != 5; ++i)
+ l.push_back(gu);
+ VERIFY(l.size() == 5);
+
+ typename list_type::iterator first = l.begin(); ++first;
+ typename list_type::iterator last = first; ++last; ++last;
+ cont_type c1(first, last);
+ VERIFY(c1.size() == 2);
+
+ cont_type c2(last, first); // Expected failure
+ }
+
+ template <typename _Cont>
+ struct InsertRangeHelper
+ {
+ template <typename _It>
+ static void
+ Insert(_Cont& cont, _It first, _It last)
+ { cont.insert(first, last); }
+ };
+
+ template <typename _Cont>
+ struct InsertRangeHelperAux
+ {
+ template <typename _It>
+ static void
+ Insert(_Cont& cont, _It first, _It last)
+ { cont.insert(cont.begin(), first, last); }
+ };
+
+ template <typename _Tp1, typename _Tp2>
+ struct InsertRangeHelper<std::vector<_Tp1, _Tp2> >
+ : InsertRangeHelperAux<std::vector<_Tp1, _Tp2> >
+ { };
+
+ template <typename _Tp1, typename _Tp2>
+ struct InsertRangeHelper<std::deque<_Tp1, _Tp2> >
+ : InsertRangeHelperAux<std::deque<_Tp1, _Tp2> >
+ { };
+
+ template <typename _Tp1, typename _Tp2>
+ struct InsertRangeHelper<std::list<_Tp1, _Tp2> >
+ : InsertRangeHelperAux<std::list<_Tp1, _Tp2> >
+ { };
+
+#ifndef _GLIBCXX_DEBUG
+ template <typename _Tp1, typename _Tp2>
+ struct InsertRangeHelper<__gnu_debug::vector<_Tp1, _Tp2> >
+ : InsertRangeHelperAux<__gnu_debug::vector<_Tp1, _Tp2> >
+ { };
+
+ template <typename _Tp1, typename _Tp2>
+ struct InsertRangeHelper<__gnu_debug::deque<_Tp1, _Tp2> >
+ : InsertRangeHelperAux<__gnu_debug::deque<_Tp1, _Tp2> >
+ { };
+
+ template <typename _Tp1, typename _Tp2>
+ struct InsertRangeHelper<__gnu_debug::list<_Tp1, _Tp2> >
+ : InsertRangeHelperAux<__gnu_debug::list<_Tp1, _Tp2> >
+ { };
+#endif
+
+ template<typename _Tp>
+ void
+ check_insert1()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ typedef std::vector<val_type> vector_type;
+
+ generate_unique<val_type> gu;
+
+ vector_type v;
+ for (int i = 0; i != 5; ++i)
+ v.push_back(gu);
+ VERIFY(v.size() == 5);
+
+ const val_type* first = &v.front() + 1;
+ const val_type* last = first + 2;
+
+ cont_type c1;
+ InsertRangeHelper<cont_type>::Insert(c1, first, last);
+ VERIFY(c1.size() == 2);
+
+ cont_type c2;
+ InsertRangeHelper<cont_type>::Insert(c2, last, first); // Expected failure
+ }
+
+ template<typename _Tp>
+ void
+ check_insert2()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ typedef std::vector<val_type> vector_type;
+
+ generate_unique<val_type> gu;
+
+ vector_type v;
+ for (int i = 0; i != 5; ++i)
+ v.push_back(gu);
+ VERIFY(v.size() == 5);
+
+ typename vector_type::iterator first = v.begin() + 1;
+ typename vector_type::iterator last = first + 2;
+
+ cont_type c1;
+ InsertRangeHelper<cont_type>::Insert(c1, first, last);
+ VERIFY(c1.size() == 2);
+
+ cont_type c2;
+ InsertRangeHelper<cont_type>::Insert(c2, last, first); // Expected failure
+ }
+
+ template<typename _Tp>
+ void
+ check_insert3()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ typedef std::list<val_type> list_type;
+
+ generate_unique<val_type> gu;
+
+ list_type l;
+ for (int i = 0; i != 5; ++i)
+ l.push_back(gu);
+ VERIFY(l.size() == 5);
+
+ typename list_type::iterator first = l.begin(); ++first;
+ typename list_type::iterator last = first; ++last; ++last;
+
+ cont_type c1;
+ InsertRangeHelper<cont_type>::Insert(c1, first, last);
+ VERIFY(c1.size() == 2);
+
+ cont_type c2;
+ InsertRangeHelper<cont_type>::Insert(c2, last, first); // Expected failure
+ }
+}
+
diff --git a/libstdc++-v3/testsuite/util/exception/safety.h b/libstdc++-v3/testsuite/util/exception/safety.h
new file mode 100644
index 000000000..9468bffd8
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/exception/safety.h
@@ -0,0 +1,1304 @@
+// -*- C++ -*-
+
+// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#ifndef _GLIBCXX_EXCEPTION_SAFETY_H
+#define _GLIBCXX_EXCEPTION_SAFETY_H
+
+#include <testsuite_container_traits.h>
+#include <ext/throw_allocator.h>
+
+// Container requirement testing.
+namespace __gnu_test
+{
+ // Base class for exception testing, contains utilities.
+ struct setup_base
+ {
+ typedef std::size_t size_type;
+ typedef std::uniform_int_distribution<size_type> distribution_type;
+ typedef std::mt19937 engine_type;
+
+ // Return randomly generated integer on range [0, __max_size].
+ static size_type
+ generate(size_type __max_size)
+ {
+ // Make the generator static...
+ const engine_type engine;
+ const distribution_type distribution;
+ static auto generator = std::bind(distribution, engine,
+ std::placeholders::_1);
+
+ // ... but set the range for this particular invocation here.
+ const typename distribution_type::param_type p(0, __max_size);
+ size_type random = generator(p);
+ if (random < distribution.min() || random > distribution.max())
+ {
+ std::string __s("setup_base::generate");
+ __s += "\n";
+ __s += "random number generated is: ";
+ char buf[40];
+ __builtin_sprintf(buf, "%lu", (unsigned long)random);
+ __s += buf;
+ __s += " on range [";
+ __builtin_sprintf(buf, "%lu", (unsigned long)distribution.min());
+ __s += buf;
+ __s += ", ";
+ __builtin_sprintf(buf, "%lu", (unsigned long)distribution.max());
+ __s += buf;
+ __s += "]\n";
+ std::__throw_out_of_range(__s.c_str());
+ }
+ return random;
+ }
+
+ // Given an instantiating type, return a unique value.
+ template<typename _Tp>
+ struct generate_unique
+ {
+ typedef _Tp value_type;
+
+ operator value_type()
+ {
+ static value_type __ret;
+ ++__ret;
+ return __ret;
+ }
+ };
+
+ // Partial specialization for pair.
+ template<typename _Tp1, typename _Tp2>
+ struct generate_unique<std::pair<const _Tp1, _Tp2>>
+ {
+ typedef _Tp1 first_type;
+ typedef _Tp2 second_type;
+ typedef std::pair<const _Tp1, _Tp2> pair_type;
+
+ operator pair_type()
+ {
+ static first_type _S_1;
+ static second_type _S_2;
+ ++_S_1;
+ ++_S_2;
+ return pair_type(_S_1, _S_2);
+ }
+ };
+
+ // Partial specialization for throw_value
+ template<typename _Cond>
+ struct generate_unique<__gnu_cxx::throw_value_base<_Cond>>
+ {
+ typedef __gnu_cxx::throw_value_base<_Cond> value_type;
+
+ operator value_type()
+ {
+ static size_t _S_i(0);
+ return value_type(_S_i++);
+ }
+ };
+
+
+ // Construct container of size n directly. _Tp == container type.
+ template<typename _Tp>
+ struct make_container_base
+ {
+ _Tp _M_container;
+
+ make_container_base() = default;
+ make_container_base(const size_type n): _M_container(n) { }
+
+ operator _Tp&() { return _M_container; }
+ };
+
+ // Construct container of size n, via multiple insertions. For
+ // associated and unordered types, unique value_type elements are
+ // necessary.
+ template<typename _Tp, bool = traits<_Tp>::is_mapped::value>
+ struct make_insert_container_base
+ : public make_container_base<_Tp>
+ {
+ using make_container_base<_Tp>::_M_container;
+ typedef typename _Tp::value_type value_type;
+
+ make_insert_container_base(const size_type n)
+ {
+ for (size_type i = 0; i < n; ++i)
+ {
+ value_type v = generate_unique<value_type>();
+ _M_container.insert(v);
+ }
+ assert(_M_container.size() == n);
+ }
+ };
+
+ template<typename _Tp>
+ struct make_insert_container_base<_Tp, false>
+ : public make_container_base<_Tp>
+ {
+ using make_container_base<_Tp>::_M_container;
+ typedef typename _Tp::value_type value_type;
+
+ make_insert_container_base(const size_type n)
+ {
+ for (size_type i = 0; i < n; ++i)
+ {
+ value_type v = generate_unique<value_type>();
+ _M_container.insert(_M_container.end(), v);
+ }
+ assert(_M_container.size() == n);
+ }
+ };
+
+ template<typename _Tp, bool = traits<_Tp>::has_size_type_constructor::value>
+ struct make_container_n;
+
+ // Specialization for non-associative types that have a constructor with
+ // a size argument.
+ template<typename _Tp>
+ struct make_container_n<_Tp, true>
+ : public make_container_base<_Tp>
+ {
+ make_container_n(const size_type n) : make_container_base<_Tp>(n) { }
+ };
+
+ template<typename _Tp>
+ struct make_container_n<_Tp, false>
+ : public make_insert_container_base<_Tp>
+ {
+ make_container_n(const size_type n)
+ : make_insert_container_base<_Tp>(n) { }
+ };
+
+
+ // Randomly size and populate a given container reference.
+ // NB: Responsibility for turning off exceptions lies with caller.
+ template<typename _Tp, bool = traits<_Tp>::is_allocator_aware::value>
+ struct populate
+ {
+ typedef _Tp container_type;
+ typedef typename container_type::allocator_type allocator_type;
+ typedef typename container_type::value_type value_type;
+
+ populate(_Tp& __container)
+ {
+ const allocator_type a = __container.get_allocator();
+
+ // Size test container.
+ const size_type max_elements = 100;
+ size_type n = generate(max_elements);
+
+ // Construct new container.
+ make_container_n<container_type> made(n);
+ container_type& tmp = made;
+ std::swap(tmp, __container);
+ }
+ };
+
+ // Partial specialization, empty.
+ template<typename _Tp>
+ struct populate<_Tp, false>
+ {
+ populate(_Tp&) { }
+ };
+
+ // Compare two containers for equivalence.
+ // Right now, that means size.
+ // Returns true if equal, throws if not.
+ template<typename _Tp>
+ static bool
+ compare(const _Tp& __control, const _Tp& __test)
+ {
+ // Make sure test container is in a consistent state, as
+ // compared to the control container.
+ // NB: Should be equivalent to __test != __control, but
+ // computed without equivalence operators
+ const size_type szt = std::distance(__test.begin(), __test.end());
+ const size_type szc = std::distance(__control.begin(),
+ __control.end());
+ bool __equal_size = szt == szc;
+
+ // Should test iterator validity before and after exception.
+ bool __equal_it = std::equal(__test.begin(), __test.end(),
+ __control.begin());
+
+ if (!__equal_size || !__equal_it)
+ throw std::logic_error("setup_base::compare containers not equal");
+
+ return true;
+ }
+ };
+
+
+ // Containing structure holding functors.
+ struct functor_base : public setup_base
+ {
+ // Abstract the erase function.
+ template<typename _Tp>
+ struct erase_base
+ {
+ typedef typename _Tp::iterator iterator;
+ typedef typename _Tp::const_iterator const_iterator;
+
+ iterator (_Tp::* _F_erase_point)(const_iterator);
+ iterator (_Tp::* _F_erase_range)(const_iterator, const_iterator);
+
+ erase_base()
+ : _F_erase_point(&_Tp::erase), _F_erase_range(&_Tp::erase) { }
+ };
+
+ // Specializations, old C++03 signatures.
+ template<typename _Tp1, typename _Tp2, typename _Tp3>
+ struct erase_base<std::basic_string<_Tp1, _Tp2, _Tp3>>
+ {
+ typedef std::basic_string<_Tp1, _Tp2, _Tp3> container_type;
+ typedef typename container_type::iterator iterator;
+
+ iterator (container_type::* _F_erase_point)(iterator);
+ iterator (container_type::* _F_erase_range)(iterator, iterator);
+
+ erase_base()
+ : _F_erase_point(&container_type::erase),
+ _F_erase_range(&container_type::erase) { }
+ };
+
+ template<typename _Tp1, typename _Tp2, typename _Tp3,
+ template <typename, typename, typename> class _Tp4>
+ struct erase_base<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>>
+ {
+ typedef __gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>
+ container_type;
+ typedef typename container_type::iterator iterator;
+
+ iterator (container_type::* _F_erase_point)(iterator);
+ iterator (container_type::* _F_erase_range)(iterator, iterator);
+
+ erase_base()
+ : _F_erase_point(&container_type::erase),
+ _F_erase_range(&container_type::erase) { }
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct erase_base<std::deque<_Tp1, _Tp2>>
+ {
+ typedef std::deque<_Tp1, _Tp2> container_type;
+ typedef typename container_type::iterator iterator;
+
+ iterator (container_type::* _F_erase_point)(iterator);
+ iterator (container_type::* _F_erase_range)(iterator, iterator);
+
+ erase_base()
+ : _F_erase_point(&container_type::erase),
+ _F_erase_range(&container_type::erase) { }
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct erase_base<std::list<_Tp1, _Tp2>>
+ {
+ typedef std::list<_Tp1, _Tp2> container_type;
+ typedef typename container_type::iterator iterator;
+
+ iterator (container_type::* _F_erase_point)(iterator);
+ iterator (container_type::* _F_erase_range)(iterator, iterator);
+
+ erase_base()
+ : _F_erase_point(&container_type::erase),
+ _F_erase_range(&container_type::erase) { }
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct erase_base<std::vector<_Tp1, _Tp2>>
+ {
+ typedef std::vector<_Tp1, _Tp2> container_type;
+ typedef typename container_type::iterator iterator;
+
+ iterator (container_type::* _F_erase_point)(iterator);
+ iterator (container_type::* _F_erase_range)(iterator, iterator);
+
+ erase_base()
+ : _F_erase_point(&container_type::erase),
+ _F_erase_range(&container_type::erase) { }
+ };
+
+ // Specialization, as forward_list has erase_after.
+ template<typename _Tp1, typename _Tp2>
+ struct erase_base<std::forward_list<_Tp1, _Tp2>>
+ {
+ typedef std::forward_list<_Tp1, _Tp2> container_type;
+ typedef typename container_type::iterator iterator;
+ typedef typename container_type::const_iterator const_iterator;
+
+ iterator (container_type::* _F_erase_point)(const_iterator);
+ iterator (container_type::* _F_erase_range)(const_iterator,
+ const_iterator);
+
+ erase_base()
+ : _F_erase_point(&container_type::erase_after),
+ _F_erase_range(&container_type::erase_after) { }
+ };
+
+ template<typename _Tp,
+ bool = traits<_Tp>::has_erase::value,
+ bool = traits<_Tp>::has_erase_after::value>
+ struct erase_point;
+
+ // Specialization for most containers.
+ template<typename _Tp>
+ struct erase_point<_Tp, true, false> : public erase_base<_Tp>
+ {
+ using erase_base<_Tp>::_F_erase_point;
+
+ void
+ operator()(_Tp& __container)
+ {
+ try
+ {
+ // NB: Should be equivalent to size() member function, but
+ // computed with begin() and end().
+ const size_type sz = std::distance(__container.begin(),
+ __container.end());
+
+ // NB: Lowest common denominator: use forward iterator operations.
+ auto i = __container.begin();
+ std::advance(i, generate(sz));
+
+ // Makes it easier to think of this as __container.erase(i)
+ (__container.*_F_erase_point)(i);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization for forward_list.
+ template<typename _Tp>
+ struct erase_point<_Tp, false, true> : public erase_base<_Tp>
+ {
+ using erase_base<_Tp>::_F_erase_point;
+
+ void
+ operator()(_Tp& __container)
+ {
+ try
+ {
+ // NB: Should be equivalent to size() member function, but
+ // computed with begin() and end().
+ const size_type sz = std::distance(__container.begin(),
+ __container.end());
+
+ // NB: Lowest common denominator: use forward iterator operations.
+ auto i = __container.before_begin();
+ std::advance(i, generate(sz));
+
+ // Makes it easier to think of this as __container.erase(i)
+ (__container.*_F_erase_point)(i);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization, empty.
+ template<typename _Tp>
+ struct erase_point<_Tp, false, false>
+ {
+ void
+ operator()(_Tp&) { }
+ };
+
+
+ template<typename _Tp,
+ bool = traits<_Tp>::has_erase::value,
+ bool = traits<_Tp>::has_erase_after::value>
+ struct erase_range;
+
+ // Specialization for most containers.
+ template<typename _Tp>
+ struct erase_range<_Tp, true, false> : public erase_base<_Tp>
+ {
+ using erase_base<_Tp>::_F_erase_range;
+
+ void
+ operator()(_Tp& __container)
+ {
+ try
+ {
+ const size_type sz = std::distance(__container.begin(),
+ __container.end());
+ size_type s1 = generate(sz);
+ size_type s2 = generate(sz);
+ auto i1 = __container.begin();
+ auto i2 = __container.begin();
+ std::advance(i1, std::min(s1, s2));
+ std::advance(i2, std::max(s1, s2));
+
+ // Makes it easier to think of this as __container.erase(i1, i2).
+ (__container.*_F_erase_range)(i1, i2);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization for forward_list.
+ template<typename _Tp>
+ struct erase_range<_Tp, false, true> : public erase_base<_Tp>
+ {
+ using erase_base<_Tp>::_F_erase_range;
+
+ void
+ operator()(_Tp& __container)
+ {
+ try
+ {
+ const size_type sz = std::distance(__container.begin(),
+ __container.end());
+ size_type s1 = generate(sz);
+ size_type s2 = generate(sz);
+ auto i1 = __container.before_begin();
+ auto i2 = __container.before_begin();
+ std::advance(i1, std::min(s1, s2));
+ std::advance(i2, std::max(s1, s2));
+
+ // Makes it easier to think of this as __container.erase(i1, i2).
+ (__container.*_F_erase_range)(i1, i2);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization, empty.
+ template<typename _Tp>
+ struct erase_range<_Tp, false, false>
+ {
+ void
+ operator()(_Tp&) { }
+ };
+
+
+ template<typename _Tp, bool = traits<_Tp>::has_push_pop::value>
+ struct pop_front
+ {
+ void
+ operator()(_Tp& __container)
+ {
+ try
+ {
+ __container.pop_front();
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization, empty.
+ template<typename _Tp>
+ struct pop_front<_Tp, false>
+ {
+ void
+ operator()(_Tp&) { }
+ };
+
+
+ template<typename _Tp, bool = traits<_Tp>::has_push_pop::value
+ && traits<_Tp>::is_reversible::value>
+ struct pop_back
+ {
+ void
+ operator()(_Tp& __container)
+ {
+ try
+ {
+ __container.pop_back();
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization, empty.
+ template<typename _Tp>
+ struct pop_back<_Tp, false>
+ {
+ void
+ operator()(_Tp&) { }
+ };
+
+
+ template<typename _Tp, bool = traits<_Tp>::has_push_pop::value>
+ struct push_front
+ {
+ typedef _Tp container_type;
+ typedef typename container_type::value_type value_type;
+
+ void
+ operator()(_Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ __test.push_front(cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+
+ // Assumes containers start out equivalent.
+ void
+ operator()(_Tp& __control, _Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ __test.push_front(cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization, empty.
+ template<typename _Tp>
+ struct push_front<_Tp, false>
+ {
+ void
+ operator()(_Tp&) { }
+
+ void
+ operator()(_Tp&, _Tp&) { }
+ };
+
+
+ template<typename _Tp, bool = traits<_Tp>::has_push_pop::value
+ && traits<_Tp>::is_reversible::value>
+ struct push_back
+ {
+ typedef _Tp container_type;
+ typedef typename container_type::value_type value_type;
+
+ void
+ operator()(_Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ __test.push_back(cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+
+ // Assumes containers start out equivalent.
+ void
+ operator()(_Tp& __control, _Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ __test.push_back(cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization, empty.
+ template<typename _Tp>
+ struct push_back<_Tp, false>
+ {
+ void
+ operator()(_Tp&) { }
+
+ void
+ operator()(_Tp&, _Tp&) { }
+ };
+
+
+ // Abstract the insert function into two parts:
+ // 1, insert_base_functions == holds function pointer
+ // 2, insert_base == links function pointer to class insert method
+ template<typename _Tp>
+ struct insert_base
+ {
+ typedef typename _Tp::iterator iterator;
+ typedef typename _Tp::const_iterator const_iterator;
+ typedef typename _Tp::value_type value_type;
+
+ iterator (_Tp::* _F_insert_point)(const_iterator, const value_type&);
+
+ insert_base() : _F_insert_point(&_Tp::insert) { }
+ };
+
+ // Specializations, old C++03 signatures.
+ template<typename _Tp1, typename _Tp2>
+ struct insert_base<std::deque<_Tp1, _Tp2>>
+ {
+ typedef std::deque<_Tp1, _Tp2> container_type;
+ typedef typename container_type::iterator iterator;
+ typedef typename container_type::value_type value_type;
+
+ iterator (container_type::* _F_insert_point)(iterator,
+ const value_type&);
+
+ insert_base() : _F_insert_point(&container_type::insert) { }
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct insert_base<std::list<_Tp1, _Tp2>>
+ {
+ typedef std::list<_Tp1, _Tp2> container_type;
+ typedef typename container_type::iterator iterator;
+ typedef typename container_type::value_type value_type;
+
+ iterator (container_type::* _F_insert_point)(iterator,
+ const value_type&);
+
+ insert_base() : _F_insert_point(&container_type::insert) { }
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct insert_base<std::vector<_Tp1, _Tp2>>
+ {
+ typedef std::vector<_Tp1, _Tp2> container_type;
+ typedef typename container_type::iterator iterator;
+ typedef typename container_type::value_type value_type;
+
+ iterator (container_type::* _F_insert_point)(iterator,
+ const value_type&);
+
+ insert_base() : _F_insert_point(&container_type::insert) { }
+ };
+
+ // Specialization, as string insertion has a different signature.
+ template<typename _Tp1, typename _Tp2, typename _Tp3>
+ struct insert_base<std::basic_string<_Tp1, _Tp2, _Tp3>>
+ {
+ typedef std::basic_string<_Tp1, _Tp2, _Tp3> container_type;
+ typedef typename container_type::iterator iterator;
+ typedef typename container_type::value_type value_type;
+
+ iterator (container_type::* _F_insert_point)(iterator, value_type);
+
+ insert_base() : _F_insert_point(&container_type::insert) { }
+ };
+
+ // Likewise for __versa_string.
+ template<typename _Tp1, typename _Tp2, typename _Tp3,
+ template <typename, typename, typename> class _Tp4>
+ struct insert_base<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>>
+ {
+ typedef __gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>
+ container_type;
+ typedef typename container_type::iterator iterator;
+ typedef typename container_type::value_type value_type;
+
+ iterator (container_type::* _F_insert_point)(iterator, value_type);
+
+ insert_base() : _F_insert_point(&container_type::insert) { }
+ };
+
+ // Specialization, as forward_list has insert_after.
+ template<typename _Tp1, typename _Tp2>
+ struct insert_base<std::forward_list<_Tp1, _Tp2>>
+ {
+ typedef std::forward_list<_Tp1, _Tp2> container_type;
+ typedef typename container_type::iterator iterator;
+ typedef typename container_type::const_iterator const_iterator;
+ typedef typename container_type::value_type value_type;
+
+ iterator (container_type::* _F_insert_point)(const_iterator,
+ const value_type&);
+
+ insert_base() : _F_insert_point(&container_type::insert_after) { }
+ };
+
+ template<typename _Tp,
+ bool = traits<_Tp>::has_insert::value,
+ bool = traits<_Tp>::has_insert_after::value>
+ struct insert_point;
+
+ // Specialization for most containers.
+ template<typename _Tp>
+ struct insert_point<_Tp, true, false> : public insert_base<_Tp>
+ {
+ typedef _Tp container_type;
+ typedef typename container_type::value_type value_type;
+ using insert_base<_Tp>::_F_insert_point;
+
+ void
+ operator()(_Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ const size_type sz = std::distance(__test.begin(), __test.end());
+ size_type s = generate(sz);
+ auto i = __test.begin();
+ std::advance(i, s);
+ (__test.*_F_insert_point)(i, cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+
+ // Assumes containers start out equivalent.
+ void
+ operator()(_Tp& __control, _Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ const size_type sz = std::distance(__test.begin(), __test.end());
+ size_type s = generate(sz);
+ auto i = __test.begin();
+ std::advance(i, s);
+ (__test.*_F_insert_point)(i, cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization for forward_list.
+ template<typename _Tp>
+ struct insert_point<_Tp, false, true> : public insert_base<_Tp>
+ {
+ typedef _Tp container_type;
+ typedef typename container_type::value_type value_type;
+ using insert_base<_Tp>::_F_insert_point;
+
+ void
+ operator()(_Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ const size_type sz = std::distance(__test.begin(), __test.end());
+ size_type s = generate(sz);
+ auto i = __test.before_begin();
+ std::advance(i, s);
+ (__test.*_F_insert_point)(i, cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+
+ // Assumes containers start out equivalent.
+ void
+ operator()(_Tp& __control, _Tp& __test)
+ {
+ try
+ {
+ const value_type cv = generate_unique<value_type>();
+ const size_type sz = std::distance(__test.begin(), __test.end());
+ size_type s = generate(sz);
+ auto i = __test.before_begin();
+ std::advance(i, s);
+ (__test.*_F_insert_point)(i, cv);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization, empty.
+ template<typename _Tp>
+ struct insert_point<_Tp, false, false>
+ {
+ void
+ operator()(_Tp&) { }
+
+ void
+ operator()(_Tp&, _Tp&) { }
+ };
+
+
+ template<typename _Tp, bool = traits<_Tp>::is_associative::value
+ || traits<_Tp>::is_unordered::value>
+ struct clear
+ {
+ void
+ operator()(_Tp& __container)
+ {
+ try
+ {
+ __container.clear();
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+ // Specialization, empty.
+ template<typename _Tp>
+ struct clear<_Tp, false>
+ {
+ void
+ operator()(_Tp&) { }
+ };
+
+
+ template<typename _Tp, bool = traits<_Tp>::is_unordered::value>
+ struct rehash
+ {
+ void
+ operator()(_Tp& __test)
+ {
+ try
+ {
+ size_type s = generate(__test.bucket_count());
+ __test.rehash(s);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+
+ void
+ operator()(_Tp& __control, _Tp& __test)
+ {
+ try
+ {
+ size_type s = generate(__test.bucket_count());
+ __test.rehash(s);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ {
+ // Also check hash status.
+ bool fail(false);
+ if (__control.load_factor() != __test.load_factor())
+ fail = true;
+ if (__control.max_load_factor() != __test.max_load_factor())
+ fail = true;
+ if (__control.bucket_count() != __test.bucket_count())
+ fail = true;
+ if (__control.max_bucket_count() != __test.max_bucket_count())
+ fail = true;
+
+ if (fail)
+ {
+ char buf[40];
+ std::string __s("setup_base::rehash "
+ "containers not equal");
+ __s += "\n";
+ __s += "\n";
+ __s += "\t\t\tcontrol : test";
+ __s += "\n";
+ __s += "load_factor\t\t";
+ __builtin_sprintf(buf, "%lu", __control.load_factor());
+ __s += buf;
+ __s += " : ";
+ __builtin_sprintf(buf, "%lu", __test.load_factor());
+ __s += buf;
+ __s += "\n";
+
+ __s += "max_load_factor\t\t";
+ __builtin_sprintf(buf, "%lu", __control.max_load_factor());
+ __s += buf;
+ __s += " : ";
+ __builtin_sprintf(buf, "%lu", __test.max_load_factor());
+ __s += buf;
+ __s += "\n";
+
+ __s += "bucket_count\t\t";
+ __builtin_sprintf(buf, "%lu", __control.bucket_count());
+ __s += buf;
+ __s += " : ";
+ __builtin_sprintf(buf, "%lu", __test.bucket_count());
+ __s += buf;
+ __s += "\n";
+
+ __s += "max_bucket_count\t";
+ __builtin_sprintf(buf, "%lu", __control.max_bucket_count());
+ __s += buf;
+ __s += " : ";
+ __builtin_sprintf(buf, "%lu", __test.max_bucket_count());
+ __s += buf;
+ __s += "\n";
+
+ std::__throw_logic_error(__s.c_str());
+ }
+ }
+ }
+ };
+
+ // Specialization, empty.
+ template<typename _Tp>
+ struct rehash<_Tp, false>
+ {
+ void
+ operator()(_Tp&) { }
+
+ void
+ operator()(_Tp&, _Tp&) { }
+ };
+
+
+ template<typename _Tp>
+ struct swap
+ {
+ _Tp _M_other;
+
+ void
+ operator()(_Tp& __container)
+ {
+ try
+ {
+ __container.swap(_M_other);
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+
+ template<typename _Tp>
+ struct iterator_operations
+ {
+ typedef _Tp container_type;
+ typedef typename container_type::iterator iterator;
+
+ void
+ operator()(_Tp& __container)
+ {
+ try
+ {
+ // Any will do.
+ iterator i = __container.begin();
+ iterator __attribute__((unused)) icopy(i);
+ iterator __attribute__((unused)) iassign = i;
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+
+
+ template<typename _Tp>
+ struct const_iterator_operations
+ {
+ typedef _Tp container_type;
+ typedef typename container_type::const_iterator const_iterator;
+
+ void
+ operator()(_Tp& __container)
+ {
+ try
+ {
+ // Any will do.
+ const_iterator i = __container.begin();
+ const_iterator __attribute__((unused)) icopy(i);
+ const_iterator __attribute__((unused)) iassign = i;
+ }
+ catch(const __gnu_cxx::forced_error&)
+ { throw; }
+ }
+ };
+ };
+
+ // Base class for exception tests.
+ template<typename _Tp>
+ struct test_base: public functor_base
+ {
+ typedef _Tp container_type;
+
+ typedef functor_base base_type;
+ typedef populate<container_type> populate;
+ typedef make_container_n<container_type> make_container_n;
+
+ typedef clear<container_type> clear;
+ typedef erase_point<container_type> erase_point;
+ typedef erase_range<container_type> erase_range;
+ typedef insert_point<container_type> insert_point;
+ typedef pop_front<container_type> pop_front;
+ typedef pop_back<container_type> pop_back;
+ typedef push_front<container_type> push_front;
+ typedef push_back<container_type> push_back;
+ typedef rehash<container_type> rehash;
+ typedef swap<container_type> swap;
+ typedef iterator_operations<container_type> iterator_ops;
+ typedef const_iterator_operations<container_type> const_iterator_ops;
+
+ using base_type::compare;
+
+ // Functor objects.
+ clear _M_clear;
+ erase_point _M_erasep;
+ erase_range _M_eraser;
+ insert_point _M_insertp;
+ pop_front _M_popf;
+ pop_back _M_popb;
+ push_front _M_pushf;
+ push_back _M_pushb;
+ rehash _M_rehash;
+ swap _M_swap;
+
+ iterator_ops _M_iops;
+ const_iterator_ops _M_ciops;
+ };
+
+
+ // Run through all member functions for basic exception safety
+ // guarantee: no resource leaks when exceptions are thrown.
+ //
+ // Types of resources checked: memory.
+ //
+ // For each member function, use throw_value and throw_allocator as
+ // value_type and allocator_type to force potential exception safety
+ // errors.
+ //
+ // NB: Assumes
+ // _Tp::value_type is __gnu_cxx::throw_value_*
+ // _Tp::allocator_type is __gnu_cxx::throw_allocator_*
+ // And that the _Cond template parameter for them both is
+ // __gnu_cxx::limit_condition.
+ template<typename _Tp>
+ struct basic_safety : public test_base<_Tp>
+ {
+ typedef _Tp container_type;
+ typedef test_base<container_type> base_type;
+ typedef typename base_type::populate populate;
+ typedef std::function<void(container_type&)> function_type;
+ typedef __gnu_cxx::limit_condition condition_type;
+
+ using base_type::generate;
+
+ container_type _M_container;
+ std::vector<function_type> _M_functions;
+
+ basic_safety() { run(); }
+
+ void
+ run()
+ {
+ // Setup.
+ condition_type::never_adjustor off;
+
+ // Construct containers.
+ populate p1(_M_container);
+ populate p2(base_type::_M_swap._M_other);
+
+ // Construct list of member functions to exercise.
+ _M_functions.push_back(function_type(base_type::_M_iops));
+ _M_functions.push_back(function_type(base_type::_M_ciops));
+
+ _M_functions.push_back(function_type(base_type::_M_erasep));
+ _M_functions.push_back(function_type(base_type::_M_eraser));
+ _M_functions.push_back(function_type(base_type::_M_insertp));
+ _M_functions.push_back(function_type(base_type::_M_popf));
+ _M_functions.push_back(function_type(base_type::_M_popb));
+ _M_functions.push_back(function_type(base_type::_M_pushf));
+ _M_functions.push_back(function_type(base_type::_M_pushb));
+ _M_functions.push_back(function_type(base_type::_M_rehash));
+ _M_functions.push_back(function_type(base_type::_M_swap));
+
+ // Last.
+ _M_functions.push_back(function_type(base_type::_M_clear));
+
+ // Run tests.
+ for (auto i = _M_functions.begin(); i != _M_functions.end(); ++i)
+ {
+ function_type& f = *i;
+ run_steps_to_limit(f);
+ }
+ }
+
+ template<typename _Funct>
+ void
+ run_steps_to_limit(const _Funct& __f)
+ {
+ size_t i(1);
+ bool exit(false);
+ auto a = _M_container.get_allocator();
+
+ do
+ {
+ // Use the current step as an allocator label.
+ a.set_label(i);
+
+ try
+ {
+ condition_type::limit_adjustor limit(i);
+ __f(_M_container);
+
+ // If we get here, done.
+ exit = true;
+ }
+ catch(const __gnu_cxx::forced_error&)
+ {
+ // Check this step for allocations.
+ // NB: Will throw std::logic_error if allocations.
+ a.check_allocated(i);
+
+ // Check memory allocated with operator new.
+
+ ++i;
+ }
+ }
+ while (!exit);
+
+ // Log count info.
+ std::cout << __f.target_type().name() << std::endl;
+ std::cout << "end count " << i << std::endl;
+ }
+ };
+
+
+ // Run through all member functions with a no throw requirement, sudden death.
+ // all: member functions erase, pop_back, pop_front, swap
+ // iterator copy ctor, assignment operator
+ // unordered and associative: clear
+ // NB: Assumes _Tp::allocator_type is __gnu_cxx::throw_allocator_random.
+ template<typename _Tp>
+ struct generation_prohibited : public test_base<_Tp>
+ {
+ typedef _Tp container_type;
+ typedef test_base<container_type> base_type;
+ typedef typename base_type::populate populate;
+ typedef __gnu_cxx::random_condition condition_type;
+
+ container_type _M_container;
+
+ generation_prohibited() { run(); }
+
+ void
+ run()
+ {
+ // Furthermore, assumes that the test functor will throw
+ // forced_exception via throw_allocator, that all errors are
+ // propagated and in error. Sudden death!
+
+ // Setup.
+ {
+ condition_type::never_adjustor off;
+ populate p1(_M_container);
+ populate p2(base_type::_M_swap._M_other);
+ }
+
+ // Run tests.
+ {
+ condition_type::always_adjustor on;
+
+ // NB: Vector and deque are special, erase can throw if the copy
+ // constructor or assignment operator of value_type throws.
+ if (!traits<container_type>::has_throwing_erase::value)
+ {
+ _M_erasep(_M_container);
+ _M_eraser(_M_container);
+ }
+
+ _M_popf(_M_container);
+ _M_popb(_M_container);
+
+ _M_iops(_M_container);
+ _M_ciops(_M_container);
+
+ _M_swap(_M_container);
+
+ // Last.
+ _M_clear(_M_container);
+ }
+ }
+ };
+
+
+ // Test strong exception guarantee.
+ // Run through all member functions with a roll-back, consistent
+ // coherent requirement.
+ // all: member functions insert of a single element, push_back, push_front
+ // unordered: rehash
+ template<typename _Tp>
+ struct propagation_consistent : public test_base<_Tp>
+ {
+ typedef _Tp container_type;
+ typedef test_base<container_type> base_type;
+ typedef typename base_type::populate populate;
+ typedef std::function<void(container_type&)> function_type;
+ typedef __gnu_cxx::limit_condition condition_type;
+
+ using base_type::compare;
+
+ container_type _M_container_test;
+ container_type _M_container_control;
+ std::vector<function_type> _M_functions;
+
+ propagation_consistent() { run(); }
+
+ void
+ sync()
+ { _M_container_test = _M_container_control; }
+
+ // Run test.
+ void
+ run()
+ {
+ // Setup.
+ condition_type::never_adjustor off;
+
+ // Construct containers.
+ populate p(_M_container_control);
+ sync();
+
+ // Construct list of member functions to exercise.
+ _M_functions.push_back(function_type(base_type::_M_pushf));
+ _M_functions.push_back(function_type(base_type::_M_pushb));
+ _M_functions.push_back(function_type(base_type::_M_insertp));
+ _M_functions.push_back(function_type(base_type::_M_rehash));
+
+ // Run tests.
+ for (auto i = _M_functions.begin(); i != _M_functions.end(); ++i)
+ {
+ function_type& f = *i;
+ run_steps_to_limit(f);
+ }
+ }
+
+ template<typename _Funct>
+ void
+ run_steps_to_limit(const _Funct& __f)
+ {
+ size_t i(1);
+ bool exit(false);
+
+ do
+ {
+ sync();
+
+ try
+ {
+ condition_type::limit_adjustor limit(i);
+ __f(_M_container_test);
+
+ // If we get here, done.
+ exit = true;
+ }
+ catch(const __gnu_cxx::forced_error&)
+ {
+ compare(_M_container_control, _M_container_test);
+ ++i;
+ }
+ }
+ while (!exit);
+
+ // Log count info.
+ std::cout << __f.target_type().name() << std::endl;
+ std::cout << "end count " << i << std::endl;
+ }
+ };
+
+} // namespace __gnu_test
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/hash_fn/dna_str_limit.hpp b/libstdc++-v3/testsuite/util/hash_fn/dna_str_limit.hpp
new file mode 100644
index 000000000..e81804ec0
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/hash_fn/dna_str_limit.hpp
@@ -0,0 +1,62 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file dna_str_limit.hpp
+ * Contains a function for finding the numer of characters
+ * to access in a DNA string.
+ */
+
+#ifndef PB_DS_DNA_STR_LIMIT_HPP
+#define PB_DS_DNA_STR_LIMIT_HPP
+
+#include <string>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ size_t
+ dna_str_limit(size_t size)
+ {
+ size_t ret = 1;
+ size_t calc_size = 4;
+ while (calc_size < size)
+ {
+ ++ret;
+ calc_size = calc_size << 2;
+ }
+ return ret;
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_DNA_STR_LIMIT_HPP
diff --git a/libstdc++-v3/testsuite/util/hash_fn/limit_string_hash_fn.hpp b/libstdc++-v3/testsuite/util/hash_fn/limit_string_hash_fn.hpp
new file mode 100644
index 000000000..d040e1161
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/hash_fn/limit_string_hash_fn.hpp
@@ -0,0 +1,72 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file limit_string_hash_fn.hpp
+ * Contains a string hash function.
+ */
+
+#ifndef PB_DS_LIMIT_STRING_HASH_FN_HPP
+#define PB_DS_LIMIT_STRING_HASH_FN_HPP
+
+#include <string>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ struct limit_string_hash_fn
+ {
+ static size_t _S_max;
+
+ inline size_t
+ operator()(const std::string& r_str) const
+ {
+ size_t ret = 0;
+ std::string::const_iterator b = r_str.begin();
+ std::string::const_iterator e = r_str.end();
+
+ size_t i = 0;
+ while (b != e&& i < _S_max)
+ {
+ ret *= 5;
+ ret += static_cast<size_t>(*(b++));
+ }
+ return ret;
+ }
+ };
+
+ size_t limit_string_hash_fn::_S_max;
+
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/hash_fn/string_hash_fn.hpp b/libstdc++-v3/testsuite/util/hash_fn/string_hash_fn.hpp
new file mode 100644
index 000000000..9a1a415a0
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/hash_fn/string_hash_fn.hpp
@@ -0,0 +1,68 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file string_hash_fn.hpp
+ * Contains a string hash function.
+ */
+
+#ifndef PB_DS_STRING_HASH_FN_HPP
+#define PB_DS_STRING_HASH_FN_HPP
+
+#include <string>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ struct string_hash_fn
+ {
+ template<typename String_T>
+ inline size_t
+ operator()(const String_T& r_str) const
+ {
+ typedef typename String_T::const_iterator const_iterator;
+ const_iterator b = r_str.begin();
+ const_iterator e = r_str.end();
+
+ size_t ret = 0;
+ while (b != e)
+ {
+ ret *= 5;
+ ret += static_cast<size_t>(*(b++));
+ }
+ return ret;
+ }
+ };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/hash_fn/string_ranged_hash_fn.hpp b/libstdc++-v3/testsuite/util/hash_fn/string_ranged_hash_fn.hpp
new file mode 100644
index 000000000..fcf9f60ac
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/hash_fn/string_ranged_hash_fn.hpp
@@ -0,0 +1,99 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file string_ranged_hash_fn.hpp
+ * Contains a ranged string hash function.
+ */
+
+#ifndef PB_DS_STRING_RANGED_HASH_FN_HPP
+#define PB_DS_STRING_RANGED_HASH_FN_HPP
+
+#include <string>
+#include <hash_fn/dna_str_limit.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ template<typename Comb_Fn>
+ class string_ranged_hash_fn : public Comb_Fn
+ {
+ private:
+ size_t _M_limit;
+
+ public:
+ typedef Comb_Fn comb_fn;
+ typedef detail::comb_hash_fn_string_form<comb_fn> string_form;
+
+ inline size_t
+ operator()(const std::string& r_str) const
+ {
+ size_t ret = 0;
+ std::string::const_iterator b = r_str.begin();
+ std::string::const_iterator e = r_str.end();
+
+ size_t i = 0;
+ while (i < _M_limit&& b != e)
+ {
+ ret *= 5;
+ ret += static_cast<size_t>(*(b++));
+ ++i;
+ }
+ return (comb_fn::operator()(ret));
+ }
+
+ void
+ swap(string_ranged_hash_fn<Comb_Fn>& other)
+ {
+ std::swap(_M_limit, other._M_limit);
+ comb_fn::swap(other);
+ }
+
+ void
+ notify_resized(size_t new_size)
+ {
+ comb_fn::notify_resized(new_size);
+ _M_limit = dna_str_limit(new_size);
+ }
+
+ static std::string
+ name()
+ { return ("string_ranged_hash_fn_" + string_form<comb_fn>::name()); }
+
+ static std::string
+ desc()
+ { return ("string ranged-hash using" + string_form<comb_fn>::desc()); }
+ };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/hash_fn/string_ranged_probe_fn.hpp b/libstdc++-v3/testsuite/util/hash_fn/string_ranged_probe_fn.hpp
new file mode 100644
index 000000000..c74991658
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/hash_fn/string_ranged_probe_fn.hpp
@@ -0,0 +1,103 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file string_ranged_probe_fn.hpp
+ * Contains a ranged string probe function.
+ */
+
+#ifndef PB_DS_STRING_RANGED_PROBE_FN_HPP
+#define PB_DS_STRING_RANGED_PROBE_FN_HPP
+
+#include <string>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ template<typename Comb_Fn, typename Probe_Fn>
+ class string_ranged_probe_fn : public Probe_Fn, public Comb_Fn
+ {
+ private:
+ size_t _M_limit;
+
+ public:
+ typedef Comb_Fn comb_fn;
+ typedef Probe_Fn probe_fn;
+ typedef detail::comb_hash_fn_string_form<comb_fn> string_form;
+
+ inline size_t
+ operator()(const std::string& r_str) const
+ {
+ size_t ret = 0;
+ std::string::const_iterator b = r_str.begin();
+ std::string::const_iterator e = r_str.end();
+
+ size_t i = 0;
+ while (i < _M_limit&& b != e)
+ {
+ ret *= 5;
+ ret += static_cast<size_t>(*(b++));
+ ++i;
+ }
+ return (comb_fn::operator()(ret));
+ }
+
+ inline size_t
+ operator()(const std::string&, const size_t hash, size_t i) const
+ { return comb_fn::operator()(hash + probe_fn::operator()(i)); }
+
+ void
+ swap(string_ranged_probe_fn<Comb_Fn, Probe_Fn>& other)
+ {
+ std::swap(_M_limit, other._M_limit);
+ comb_fn::swap(other);
+ }
+
+ void
+ notify_resized(size_t new_size)
+ {
+ comb_fn::notify_resized(new_size);
+ _M_limit = dna_str_limit(new_size);
+ }
+
+ static std::string
+ name()
+ { return ("string_ranged_probe_fn_" + string_form<comb_fn>::name()); }
+
+ static std::string
+ desc()
+ { return ("string ranged-probe using" + string_form<comb_fn>::desc());}
+ };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/io/illegal_input_error.hpp b/libstdc++-v3/testsuite/util/io/illegal_input_error.hpp
new file mode 100644
index 000000000..79f003b77
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/io/illegal_input_error.hpp
@@ -0,0 +1,62 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file illegal_input_error.hpp
+ * Contains an input exception.
+ */
+
+#ifndef PB_DS_ILLEGAL_INPUT_EX_HPP
+#define PB_DS_ILLEGAL_INPUT_EX_HPP
+
+#include <exception>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ class illegal_input_error : public std::exception
+ { };
+
+ // Substitute for concurrence_error object in the case of -fno-exceptions.
+ inline void
+ __throw_illegal_input_error()
+ {
+#if __EXCEPTIONS
+ throw illegal_input_error();
+#else
+ __builtin_abort();
+#endif
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_ILLEGAL_INPUT_EX_HPP
diff --git a/libstdc++-v3/testsuite/util/io/prog_bar.cc b/libstdc++-v3/testsuite/util/io/prog_bar.cc
new file mode 100644
index 000000000..9b73298e0
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/io/prog_bar.cc
@@ -0,0 +1,79 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file prog_bar.cpp
+ * Contains a progress bar - idea taken from boost::timer by Beman Dawes.
+ */
+
+#include <util/io/prog_bar.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ prog_bar::
+ prog_bar(size_t max, std::ostream& r_os, bool display/*= true*/) :
+ m_cur(0),
+ m_max(max),
+ m_cur_disp(0),
+ m_r_os(r_os),
+ m_display(display)
+ {
+ if (m_display == false)
+ return;
+
+ for (std::size_t i = 0; i < num_disp; ++i)
+ m_r_os << "-";
+
+ m_r_os << std::endl;
+ }
+
+ void
+ prog_bar::
+ inc()
+ {
+ ++m_cur;
+
+ if (m_display == false)
+ return;
+
+ while (m_cur * num_disp >= m_max * m_cur_disp && m_cur_disp < num_disp)
+ {
+ m_r_os << '*';
+ m_r_os.flush();
+ ++m_cur_disp;
+ }
+ }
+
+ } // namespace test
+
+} // namespace __gnu_pbds
diff --git a/libstdc++-v3/testsuite/util/io/prog_bar.hpp b/libstdc++-v3/testsuite/util/io/prog_bar.hpp
new file mode 100644
index 000000000..0d4b44853
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/io/prog_bar.hpp
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file prog_bar.hpp
+ * Contains a progress bar - idea taken from boost::timer by Beman Dawes.
+ */
+
+#ifndef PB_DS_PROG_BAR_HPP
+#define PB_DS_PROG_BAR_HPP
+
+#include <limits.h>
+#include <iostream>
+#include <string>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ /**
+ * Progress bar.
+ * Simplified from part of boost::timer by Beman Dawes.
+ **/
+ class prog_bar
+ {
+ protected:
+ enum{num_disp = 40};
+
+ public:
+ prog_bar(size_t max, std::ostream& r_os, bool display = true);
+
+ void
+ inc();
+
+ private:
+ prog_bar(const prog_bar& );
+
+ prog_bar&
+ operator=(const prog_bar& );
+
+ private:
+ size_t m_cur;
+ const size_t m_max;
+
+ size_t m_cur_disp;
+
+ std::ostream& m_r_os;
+
+ bool m_display;
+ };
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_PROG_BAR_HPP
diff --git a/libstdc++-v3/testsuite/util/io/text_populate.hpp b/libstdc++-v3/testsuite/util/io/text_populate.hpp
new file mode 100644
index 000000000..97731dd9f
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/io/text_populate.hpp
@@ -0,0 +1,153 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file text_populate.hpp
+ * Contains a function for populating a vector with text words from
+ * a file.
+ */
+
+#ifndef PB_DS_TEXT_POPULATE_HPP
+#define PB_DS_TEXT_POPULATE_HPP
+
+#include <io/illegal_input_error.hpp>
+#include <set>
+#include <fstream>
+#include <string>
+#include <iostream>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ template<typename Vec>
+ void
+ text_populate(const std::string& r_f_name, Vec& r_a_txt)
+ {
+ const size_t size = r_a_txt.size();
+
+ try
+ {
+ std::ifstream f(r_f_name.c_str());
+
+ if (!f.good())
+ {
+ std::cerr << "Cannot open file " << r_f_name.c_str() <<
+ std::endl;
+
+ throw __gnu_pbds::test::illegal_input_error();
+ }
+
+ size_t i = 0;
+
+ while (f.good()&& i < size)
+ {
+ f >> r_a_txt[i].first;
+ r_a_txt[i].second = 0;
+
+ ++i;
+ }
+
+ if (i < size)
+ {
+ std::cerr << "Read only " << static_cast<unsigned long>(i) <<
+ " words" << std::endl;
+
+ throw __gnu_pbds::test::illegal_input_error();
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Error reading from file" << std::endl;
+
+ throw;
+ }
+ }
+
+ template<typename Vec>
+ void
+ distinct_text_populate(const std::string& r_f_name, Vec& r_a_txt)
+ {
+ const size_t size = r_a_txt.size();
+
+ try
+ {
+ std::ifstream f(r_f_name.c_str());
+
+ if (!f.good())
+ {
+ std::cerr << "Cannot open file " << r_f_name.c_str() <<
+ std::endl;
+
+ throw __gnu_pbds::test::illegal_input_error();
+ }
+
+ typedef std::set< typename Vec::value_type::first_type> set_t;
+
+ set_t s;
+
+ while (f.good()&& s.size() < size)
+ {
+ typename Vec::value_type::first_type v;
+
+ f >> v;
+
+ if (s.find(v) == s.end())
+ {
+ r_a_txt[s.size()] = std::make_pair(v, 0);
+
+ s.insert(v);
+ }
+ }
+
+ if (s.size() < size)
+ {
+ std::cerr << "Read only " << static_cast<unsigned long>(s.size()) <<
+ " words" << std::endl;
+
+ throw __gnu_pbds::test::illegal_input_error();
+ }
+ }
+ catch(...)
+ {
+ std::cerr << "Error reading from file" << std::endl;
+
+ throw;
+ }
+ }
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_TEXT_POPULATE_HPP
diff --git a/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc b/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc
new file mode 100644
index 000000000..3f94a2759
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc
@@ -0,0 +1,106 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file verified_cmd_line_input.cpp
+ * Contains definitions for tests - verified command line input.
+ */
+
+#include <util/io/verified_cmd_line_input.hpp>
+#include <limits.h>
+#include <utility>
+#include <stdlib.h>
+#include <bits/functexcept.h>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ void
+ verify_argc(size_t given, size_t required)
+ {
+ if (given != required)
+ __throw_illegal_input_error();
+ }
+
+ void
+ verify_prob(double prob)
+ {
+ if (prob < 0 || prob > 1)
+ __throw_illegal_input_error();
+ }
+
+ std::string
+ get_cmd_line_str(int argc, char* a_p_argv[], int argn)
+ {
+ if (argc <= argn)
+ __throw_illegal_input_error();
+ const std::string ret(a_p_argv[argn]);
+ return ret;
+ }
+
+ double
+ get_cmd_line_prob(int argc, char* a_p_argv[], int argn)
+ {
+ if (argc <= argn)
+ __throw_illegal_input_error();
+ const double ret = ::atof(a_p_argv[argn]);
+ verify_prob(ret);
+ return ret;
+ }
+
+ size_t
+ get_cmd_line_size(int argc, char* a_p_argv[], int argn)
+ {
+ if (argc <= argn)
+ __throw_illegal_input_error();
+ const size_t ret = static_cast<size_t>(::atoi(a_p_argv[argn]));
+ return ret;
+ }
+
+ bool
+ get_cmd_line_bool(int argc, char* a_p_argv[], int argn)
+ {
+ if (argc <= argn)
+ __throw_illegal_input_error();
+
+ const std::string opt(a_p_argv[argn]);
+ if (opt.size() != 1)
+ __throw_illegal_input_error();
+ if (opt[0] == 't')
+ return true;
+ if (opt[0] == 'f')
+ return false;
+ __throw_illegal_input_error();
+ return false;
+ }
+ } // namespace test
+} // namespace __gnu_pbds
diff --git a/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.hpp b/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.hpp
new file mode 100644
index 000000000..29651f7ae
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.hpp
@@ -0,0 +1,67 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file verified_cmd_line_input.hpp
+ * Contains definitions for tests - verified command line input.
+ */
+
+#ifndef PB_DS_VERIFIED_CMD_LINE_INPUT_HPP
+#define PB_DS_VERIFIED_CMD_LINE_INPUT_HPP
+
+#include <io/illegal_input_error.hpp>
+#include <string>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ void
+ verify_argc(size_t given, size_t required);
+
+ void
+ verify_prob(double prob);
+
+ std::string
+ get_cmd_line_str(int argc, char* a_p_argv[], int argn);
+
+ double
+ get_cmd_line_prob(int argc, char* a_p_argv[], int argn);
+
+ size_t
+ get_cmd_line_size(int argc, char* a_p_argv[], int argn);
+
+ bool
+ get_cmd_line_bool(int argc, char* a_p_argv[], int argn);
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_VERIFIED_CMD_LINE_INPUT_HPP
diff --git a/libstdc++-v3/testsuite/util/io/xml.hpp b/libstdc++-v3/testsuite/util/io/xml.hpp
new file mode 100644
index 000000000..d945a3bef
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/io/xml.hpp
@@ -0,0 +1,121 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file xml.hpp
+ * Contains some xml utilities.
+ */
+
+#ifndef PB_DS_XML_HPP
+#define PB_DS_XML_HPP
+
+#include <string>
+#include <sstream>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ std::string
+ make_xml_name_start_tag(std::string name)
+ { return ("<" + name); }
+
+ template<typename V>
+ std::string
+ make_xml_attrib_val(std::string attrib, const V val)
+ {
+ std::ostringstream sstrm;
+ sstrm << " " << attrib << " = \"" << val << "\"";
+ return (sstrm.str());
+ }
+
+ std::string
+ make_xml_name_start_tag_end_delimiter()
+ { return (">\n"); }
+
+ std::string
+ make_xml_name_end_tag(std::string name)
+ { return ("</" + name + ">\n"); }
+ } // namespace detail
+
+ std::string
+ make_xml_tag(const std::string name,
+ const std::string data = std::string(""))
+ {
+ std::ostringstream sstrm;
+ sstrm << detail::make_xml_name_start_tag(name);
+ sstrm << detail::make_xml_name_start_tag_end_delimiter();
+ sstrm << data;
+ sstrm << detail::make_xml_name_end_tag(name);
+ return sstrm.str();
+ }
+
+ template<typename Val0>
+ std::string
+ make_xml_tag(const std::string name,
+ const std::string attrib0,
+ const Val0 val0,
+ const std::string data = std::string(""))
+ {
+ std::ostringstream sstrm;
+
+ sstrm << detail::make_xml_name_start_tag(name);
+ sstrm << detail::make_xml_attrib_val(attrib0, val0);
+ sstrm << detail::make_xml_name_start_tag_end_delimiter();
+ sstrm << data;
+ sstrm << detail::make_xml_name_end_tag(name);
+ return sstrm.str();
+ }
+
+ template<typename Val0, typename Val1>
+ std::string
+ make_xml_tag(const std::string name,
+ const std::string attrib0,
+ const Val0 val0,
+ const std::string attrib1,
+ const Val1 val1,
+ const std::string data = std::string(""))
+ {
+ std::ostringstream sstrm;
+ sstrm << detail::make_xml_name_start_tag(name);
+ sstrm << detail::make_xml_attrib_val(attrib0, val0);
+ sstrm << detail::make_xml_attrib_val(attrib1, val1);
+ sstrm << detail::make_xml_name_start_tag_end_delimiter();
+ sstrm << data;
+ sstrm << detail::make_xml_name_end_tag(name);
+ return sstrm.str();
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_XML_HPP
diff --git a/libstdc++-v3/testsuite/util/io/xml_test_formatter.hpp b/libstdc++-v3/testsuite/util/io/xml_test_formatter.hpp
new file mode 100644
index 000000000..b06d3e49d
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/io/xml_test_formatter.hpp
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file xml_test_formatter.hpp
+ * Contains an XML formatter for tests.
+ */
+
+#ifndef PB_DS_XML_TEST_FORMATTER_HPP
+#define PB_DS_XML_TEST_FORMATTER_HPP
+
+#include <string>
+#include <iostream>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ struct xml_test_formatter
+ {
+ xml_test_formatter()
+ {
+ std::cout << "<?xml version = \"1.0\"?>" << std::endl;
+ std::cout << "<test>" << std::endl;
+ }
+
+ virtual
+ ~xml_test_formatter()
+ { std::cout << "</test>" << std::endl; }
+ };
+
+ struct xml_result_set_formatter
+ {
+ xml_result_set_formatter(const std::string& name, const std::string& desc)
+ {
+ std::cout << detail::make_xml_name_start_tag("cntnr");
+ std::cout << detail::make_xml_attrib_val("name", name);
+ std::cout << detail::make_xml_name_start_tag_end_delimiter();
+ std::cout << make_xml_tag("desc", desc);
+ }
+
+ virtual
+ ~xml_result_set_formatter()
+ { std::cout << "</cntnr>" << std::endl; }
+ };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_XML_TEST_FORMATTER_HPP
diff --git a/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp
new file mode 100644
index 000000000..6fa3667f3
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp
@@ -0,0 +1,103 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file native_hash_map.hpp
+ * Contains an adapter to TR1 unordered containers.
+ */
+
+#ifndef PB_DS_NATIVE_HASH_MAP_HPP
+#define PB_DS_NATIVE_HASH_MAP_HPP
+
+#include <string>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <ext/pb_ds/detail/standard_policies.hpp>
+#include <native_type/native_hash_tag.hpp>
+#include <io/xml.hpp>
+#include <tr1/unordered_map>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+#define PB_DS_BASE_C_DEC \
+ std::tr1::__unordered_map<Key, Data, Hash_Fn, Eq_Fn, \
+ typename Allocator::template rebind<std::pair<const Key, Data> >::other, Cache_Hash>
+
+ template<typename Key,
+ typename Data,
+ size_t Init_Size = 8,
+ typename Hash_Fn = typename __gnu_pbds::detail::default_hash_fn<Key>::type,
+ typename Eq_Fn = std::equal_to<Key>,
+ typename Less_Fn = std::less<Key>,
+ typename Allocator = std::allocator<char>, bool Cache_Hash = false
+ >
+ class native_hash_map : public PB_DS_BASE_C_DEC
+ {
+ private:
+ typedef PB_DS_BASE_C_DEC base_type;
+
+ public:
+ typedef native_hash_tag container_category;
+
+ public:
+ native_hash_map() : base_type(Init_Size) { }
+
+ template<typename It>
+ native_hash_map(It f, It l) : base_type(f, l) { }
+
+ static std::string
+ name()
+ {
+ return std::string("n_hash_map_")
+ + (Cache_Hash ? std::string("cah") : std::string("ncah"));
+ }
+
+ static std::string
+ desc()
+ {
+ const std::string cache_hash_desc =
+ make_xml_tag("cache_hash_code",
+ "value",
+ (Cache_Hash ? std::string("true") : std::string("false")));
+
+ return make_xml_tag("type", "value", "std_tr1_unordered_map",
+ cache_hash_desc);
+ }
+ };
+
+#undef PB_DS_BASE_C_DEC
+
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp
new file mode 100644
index 000000000..8273edf36
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp
@@ -0,0 +1,146 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file native_hash_multimap.hpp
+ * Contains an adapter to TR1 unordered containers.
+ */
+
+#ifndef PB_DS_NATIVE_HASH_MULTIMAP_HPP
+#define PB_DS_NATIVE_HASH_MULTIMAP_HPP
+
+#include <string>
+#include <tr1/unordered_map>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <ext/pb_ds/detail/standard_policies.hpp>
+#include <native_type/native_hash_tag.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+#define PB_DS_BASE_C_DEC \
+ std::tr1::unordered_multimap<Key, Data, Hash_Fn, Eq_Fn, Allocator>
+
+ template<typename Key,
+ typename Data,
+ size_t Init_Size = 8,
+ class Hash_Fn = typename __gnu_pbds::detail::default_hash_fn<Key>::type,
+ class Eq_Fn = std::equal_to<Key>,
+ class Less_Fn = std::less<Key>,
+ class Allocator = std::allocator<char> >
+ class native_hash_multimap : public PB_DS_BASE_C_DEC
+ {
+ private:
+ typedef PB_DS_BASE_C_DEC base_type;
+ typedef std::pair<Key, Data> pair_type;
+
+ public:
+ typedef native_hash_tag container_category;
+ typedef Allocator allocator;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+
+ typedef
+ typename allocator::template rebind<pair_type>::other::const_reference
+ const_reference;
+
+ native_hash_multimap() : base_type(Init_Size)
+ { }
+
+ template<typename It>
+ native_hash_multimap(It f, It l) : base_type(f, l)
+ { }
+
+ inline void
+ insert(const_reference r_val)
+ {
+ typedef std::pair<iterator, iterator> eq_range_t;
+ eq_range_t f = base_type::equal_range(r_val.first);
+
+ iterator it = f.first;
+ while (it != f.second)
+ {
+ if (it->second == r_val.second)
+ return;
+ ++it;
+ }
+ base_type::insert(r_val);
+ }
+
+ inline iterator
+ find(const_reference r_val)
+ {
+ typedef std::pair<iterator, iterator> eq_range_t;
+ eq_range_t f = base_type::equal_range(r_val.first);
+
+ iterator it = f.first;
+ while (it != f.second)
+ {
+ if (it->second == r_val.second)
+ return it;
+ ++it;
+ }
+ return base_type::end();
+ }
+
+ inline const_iterator
+ find(const_reference r_val) const
+ {
+ typedef std::pair<const_iterator, const_iterator> eq_range_t;
+ eq_range_t f = base_type::equal_range(r_val.first);
+
+ const_iterator it = f.first;
+ while (it != f.second)
+ {
+ if (it->second == r_val.second)
+ return it;
+ ++it;
+ }
+ return base_type::end();
+ }
+
+ static std::string
+ name()
+ { return std::string("n_hash_mmap"); }
+
+ static std::string
+ desc()
+ { return make_xml_tag("type", "value", "__gnucxx_hash_multimap"); }
+ };
+
+#undef PB_DS_BASE_C_DEC
+
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp
new file mode 100644
index 000000000..d3f459624
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp
@@ -0,0 +1,125 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file native_hash_set.hpp
+ * Contains an adapter to TR1 unordered containers.
+ */
+
+#ifndef PB_DS_NATIVE_HASH_SET_HPP
+#define PB_DS_NATIVE_HASH_SET_HPP
+
+#include <string>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <ext/pb_ds/detail/standard_policies.hpp>
+#include <native_type/native_hash_tag.hpp>
+#include <io/xml.hpp>
+#include <tr1/unordered_set>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+#define PB_DS_BASE_C_DEC \
+ std::tr1::__unordered_set<Key, Hash_Fn, Eq_Fn, \
+ typename Allocator::template rebind<Key>::other, Cache_Hash>
+
+ template<typename Key,
+ size_t Init_Size = 8,
+ typename Hash_Fn = typename __gnu_pbds::detail::default_hash_fn<Key>::type,
+ typename Eq_Fn = std::equal_to<Key>,
+ typename Less_Fn = std::less<Key>,
+ typename Allocator = std::allocator<char>, bool Cache_Hash = false
+ >
+ class native_hash_set : public PB_DS_BASE_C_DEC
+ {
+ private:
+ typedef PB_DS_BASE_C_DEC base_type;
+
+ public:
+ typedef native_hash_tag container_category;
+
+ native_hash_set() : base_type(Init_Size) { }
+
+ template<typename It>
+ native_hash_set(It f, It l) : base_type(f, l) { }
+
+ template<typename Pred>
+ inline size_t
+ erase_if(Pred pred)
+ {
+ size_t ersd = 0;
+ bool done = false;
+ while (!done)
+ {
+ typename base_type::iterator b_it = base_type::begin();
+ typename base_type::iterator e_it = base_type::end();
+ done = true;
+ while (b_it != e_it)
+ {
+ if (pred(*b_it))
+ {
+ ++ersd;
+ done = false;
+ base_type::erase(*b_it);
+ b_it = e_it;
+ }
+ else
+ ++b_it;
+ }
+ }
+ return ersd;
+ }
+
+ static std::string
+ name()
+ {
+ return std::string("n_hash_set_")
+ + (Cache_Hash ? std::string("cah") : std::string("ncah"));
+ }
+
+ static std::string
+ desc()
+ {
+ const std::string cache_hash_desc =
+ make_xml_tag("cache_hash_code", "value",
+ Cache_Hash ? std::string("true") : std::string("false"));
+
+ return make_xml_tag("type", "value", "std_tr1_unordered_set",
+ cache_hash_desc);
+ }
+ };
+
+#undef PB_DS_BASE_C_DEC
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/native_type/native_hash_tag.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_tag.hpp
new file mode 100644
index 000000000..3ee6c0efa
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/native_type/native_hash_tag.hpp
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file native_hash_tag.hpp
+ * Contains a tag for native hash-based containers
+ */
+
+#ifndef PB_DS_NATIVE_HASH_DS_TAG_HPP
+#define PB_DS_NATIVE_HASH_DS_TAG_HPP
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ struct native_hash_tag { };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/native_type/native_map.hpp b/libstdc++-v3/testsuite/util/native_type/native_map.hpp
new file mode 100644
index 000000000..29170cae8
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/native_type/native_map.hpp
@@ -0,0 +1,87 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file native_map.hpp
+ * Contains an adapter to std::map
+ */
+
+#ifndef PB_DS_NATIVE_MAP_HPP
+#define PB_DS_NATIVE_MAP_HPP
+
+#include <map>
+#include <string>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <ext/pb_ds/detail/standard_policies.hpp>
+#include <native_type/native_tree_tag.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+#define PB_DS_BASE_C_DEC \
+ std::map<Key, Data, Cmp_Fn, \
+typename Allocator::template rebind<std::pair<const Key, Data > >::other >
+
+ template<typename Key, typename Data, class Cmp_Fn = std::less<Key>,
+ class Allocator = std::allocator<char> >
+ class native_map : public PB_DS_BASE_C_DEC
+ {
+ private:
+ typedef PB_DS_BASE_C_DEC base_type;
+
+ public:
+ typedef native_tree_tag container_category;
+
+ native_map() : base_type()
+ { }
+
+ template<typename It>
+ native_map(It f, It l) : base_type(f, l)
+ { }
+
+ static std::string
+ name()
+ { return std::string("n_map"); }
+
+ static std::string
+ desc()
+ { return make_xml_tag("type", "value", "std_map"); }
+ };
+
+#undef PB_DS_BASE_C_DEC
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_NATIVE_MAP_HPP
diff --git a/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp b/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp
new file mode 100644
index 000000000..4bda5562d
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp
@@ -0,0 +1,142 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file native_multimap.hpp
+ * Contains an adapter to std::multimap
+ */
+
+#ifndef PB_DS_NATIVE_MULTIMAP_HPP
+#define PB_DS_NATIVE_MULTIMAP_HPP
+
+#include <map>
+#include <string>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <native_type/native_tree_tag.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+#define PB_DS_BASE_C_DEC \
+ std::multimap<Key, Data, Less_Fn, \
+ typename Allocator::template rebind<std::pair<const Key, Data> >::other>
+
+ template<typename Key, typename Data, class Less_Fn = std::less<Key>,
+ class Allocator = std::allocator<char> >
+ class native_multimap : public PB_DS_BASE_C_DEC
+ {
+ private:
+ typedef PB_DS_BASE_C_DEC base_type;
+
+ public:
+ typedef native_tree_tag container_category;
+
+ typedef Allocator allocator;
+
+ typedef
+ typename Allocator::template rebind<
+ std::pair<Key, Data> >::other::const_reference
+ const_reference;
+
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+
+ native_multimap() { }
+
+ template<typename It>
+ native_multimap(It f, It l) : base_type(f, l)
+ { }
+
+ inline void
+ insert(const_reference r_val)
+ {
+ typedef std::pair<iterator, iterator> eq_range_t;
+ eq_range_t f = base_type::equal_range(r_val.first);
+
+ iterator it = f.first;
+ while (it != f.second)
+ {
+ if (it->second == r_val.second)
+ return;
+ ++it;
+ }
+ base_type::insert(r_val);
+ }
+
+ inline iterator
+ find(const_reference r_val)
+ {
+ typedef std::pair<iterator, iterator> eq_range_t;
+ eq_range_t f = base_type::equal_range(r_val.first);
+
+ iterator it = f.first;
+ while (it != f.second)
+ {
+ if (it->second == r_val.second)
+ return it;
+ ++it;
+ }
+
+ return base_type::end();
+ }
+
+ inline const_iterator
+ find(const_reference r_val) const
+ {
+ typedef std::pair<const_iterator, const_iterator> eq_range_t;
+ eq_range_t f = base_type::equal_range(r_val.first);
+
+ const_iterator it = f.first;
+ while (it != f.second)
+ {
+ if (it->second == r_val.second)
+ return it;
+ ++it;
+ }
+ return base_type::end();
+ }
+
+ static std::string
+ name()
+ { return std::string("n_mmap"); }
+
+ static std::string
+ desc()
+ { return make_xml_tag("type", "value", "std_multimap"); }
+ };
+
+#undef PB_DS_BASE_C_DEC
+} // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_NATIVE_MULTIMAP_HPP
diff --git a/libstdc++-v3/testsuite/util/native_type/native_priority_queue.hpp b/libstdc++-v3/testsuite/util/native_type/native_priority_queue.hpp
new file mode 100644
index 000000000..4367fca30
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/native_type/native_priority_queue.hpp
@@ -0,0 +1,224 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file native_priority_queue.hpp
+ * Contains an adapter to Dinkumware/SGI tree tables
+ */
+
+#ifndef PB_DS_NATIVE_PRIORITY_QUEUE_HPP
+#define PB_DS_NATIVE_PRIORITY_QUEUE_HPP
+
+#include <string>
+#include <vector>
+#include <queue>
+#include <deque>
+#include <ext/pb_ds/detail/standard_policies.hpp>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename Value_Type, bool Vector, typename Allocator>
+ struct base_seq
+ {
+ private:
+ typedef typename Allocator::template rebind<Value_Type> value_rebind;
+
+ public:
+ typedef std::vector<Value_Type, typename value_rebind::other> type;
+ };
+
+ template<typename Value_Type, typename Allocator>
+ struct base_seq<Value_Type, false, Allocator>
+ {
+ private:
+ typedef typename Allocator::template rebind<Value_Type> value_rebind;
+
+ public:
+ typedef std::deque<Value_Type, typename value_rebind::other> type;
+ };
+ } // namespace detail
+
+ struct native_pq_tag
+ { };
+
+#define PB_DS_CLASS_C_DEC \
+ native_priority_queue<Value_Type, Vector, Cmp_Fn, Allocator>
+
+#define PB_DS_BASE_C_DEC \
+ std::priority_queue<Value_Type, typename detail::base_seq<Value_Type, Vector, Allocator>::type, Cmp_Fn>
+
+ template<typename Value_Type,
+ bool Vector,
+ typename Cmp_Fn = std::less<Value_Type>,
+ typename Allocator = std::allocator<char> >
+ class native_priority_queue : public PB_DS_BASE_C_DEC
+ {
+ private:
+ typedef PB_DS_BASE_C_DEC base_type;
+ typedef typename Allocator::template rebind<Value_Type> value_rebind;
+
+ public:
+ typedef Value_Type value_type;
+ typedef typename value_rebind::other::const_reference const_reference;
+ typedef native_pq_tag container_category;
+ typedef Cmp_Fn cmp_fn;
+
+ native_priority_queue() : base_type()
+ { }
+
+ template<typename It>
+ native_priority_queue(It f, It l) : base_type(f, l)
+ { }
+
+ static std::string
+ name()
+ {
+ if (Vector)
+ return ("n_pq_vector");
+ return ("n_pq_deque");
+ }
+
+ static std::string
+ desc()
+ {
+ if (Vector)
+ return make_xml_tag("type", "value", "std::priority_queue_vector");
+ return make_xml_tag("type", "value", "std::priority_queue_deque");
+ }
+
+ void
+ clear()
+ { *static_cast<base_type*>(this) = base_type(); }
+
+ void
+ erase(const_reference r_val)
+ {
+ base_type tmp;
+ Cmp_Fn cmp;
+
+ while (cmp(base_type::top(), r_val) || cmp(r_val, base_type::top()))
+ {
+ tmp.push(base_type::top());
+ base_type::pop();
+ }
+
+ if (!base_type::empty())
+ {
+ base_type::pop();
+ while (!base_type::empty())
+ {
+ tmp.push(base_type::top());
+ base_type::pop();
+ }
+ }
+ *static_cast<base_type* >(this) = tmp;
+ }
+
+ template<typename Pred>
+ size_t
+ erase_if(Pred pred)
+ {
+ base_type tmp;
+ std::size_t ersd = 0;
+ while (!base_type::empty())
+ {
+ if (!pred(base_type::top()))
+ tmp.push(base_type::top());
+ else
+ ++ersd;
+ base_type::pop();
+ }
+
+ *static_cast<base_type*>(this) = tmp;
+ return ersd;
+ }
+
+ template<typename Pred>
+ void
+ split(Pred pred, PB_DS_CLASS_C_DEC& other)
+ {
+ base_type tmp;
+ other.clear();
+ while (!base_type::empty())
+ {
+ if (!pred(base_type::top()))
+ tmp.push(base_type::top());
+ else
+ other.push(base_type::top());
+ base_type::pop();
+ }
+ *static_cast<base_type*>(this) = tmp;
+ }
+
+ void
+ modify(const_reference r_old, const_reference r_new)
+ {
+ erase(r_old);
+ push(r_new);
+ }
+
+ void
+ join(PB_DS_CLASS_C_DEC& other)
+ {
+ std::vector<value_type> a_tmp;
+ while (!base_type::empty())
+ {
+ a_tmp.push_back(base_type::top());
+ base_type::pop();
+ }
+
+ while (!other.empty())
+ {
+ a_tmp.push_back(other.top());
+ other.pop();
+ }
+
+ *static_cast<base_type*>(this) = base_type(a_tmp.begin(), a_tmp.end());
+ }
+
+ Cmp_Fn
+ get_cmp_fn() const
+ { return Cmp_Fn(); }
+ };
+
+#undef PB_DS_BASE_C_DEC
+#undef PB_DS_CLASS_C_DEC
+
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/native_type/native_set.hpp b/libstdc++-v3/testsuite/util/native_type/native_set.hpp
new file mode 100644
index 000000000..c9f448bf1
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/native_type/native_set.hpp
@@ -0,0 +1,87 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file native_set.hpp
+ * Contains an adapter to std::set
+ */
+
+#ifndef PB_DS_NATIVE_SET_HPP
+#define PB_DS_NATIVE_SET_HPP
+
+#include <string>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <ext/pb_ds/detail/standard_policies.hpp>
+#include <native_type/native_tree_tag.hpp>
+#include <io/xml.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+#define PB_DS_BASE_C_DEC \
+ std::set<Key, Cmp_Fn, typename Allocator::template rebind<Key>::other>
+
+ template<typename Key, class Cmp_Fn = std::less<Key>,
+ class Allocator = std::allocator<char> >
+ class native_set : public PB_DS_BASE_C_DEC
+ {
+ private:
+ typedef PB_DS_BASE_C_DEC base_type;
+
+ public:
+ typedef native_tree_tag container_category;
+ typedef typename base_type::const_iterator const_iterator;
+
+ native_set() : base_type()
+ { }
+
+ template<typename It>
+ native_set(It f, It l) : base_type(f, l)
+ { }
+
+ native_set(const_iterator f, const_iterator l) : base_type(f, l)
+ { }
+
+ static std::string
+ name()
+ { return std::string("n_set"); }
+
+ static std::string
+ desc()
+ { return make_xml_tag("type", "value", "std_set"); }
+ };
+
+#undef PB_DS_BASE_C_DEC
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_NATIVE_SET_HPP
diff --git a/libstdc++-v3/testsuite/util/native_type/native_tree_tag.hpp b/libstdc++-v3/testsuite/util/native_type/native_tree_tag.hpp
new file mode 100644
index 000000000..60127c164
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/native_type/native_tree_tag.hpp
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file native_tree_tag.hpp
+ * Contains a tag for native tree-based containers
+ */
+
+#ifndef PB_DS_NATIVE_TREE_DS_TAG_HPP
+#define PB_DS_NATIVE_TREE_DS_TAG_HPP
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ struct native_tree_tag
+ { };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/erase_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/erase_test.hpp
new file mode 100644
index 000000000..6ad797a66
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/erase_test.hpp
@@ -0,0 +1,109 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file erase_test.hpp
+ * Contains a generic erase test.
+ */
+
+#ifndef PB_DS_ERASE_TEST_HPP
+#define PB_DS_ERASE_TEST_HPP
+
+#include <iterator>
+#include <testsuite_allocator.h>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/assoc/string_form.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ template<typename It>
+ class erase_test
+ {
+ public:
+ erase_test(It ins_b, size_t ins_vn, size_t ins_vs, size_t ins_vm)
+ : m_ins_b(ins_b), m_ins_vn(ins_vn), m_ins_vs(ins_vs), m_ins_vm(ins_vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ erase_test(const erase_test&);
+
+ const It m_ins_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ };
+
+ template<typename It>
+ template<typename Cntnr>
+ void
+ erase_test<It>::
+ operator()(Cntnr)
+ {
+ typedef string_form<Cntnr> sform_type;
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(sform_type::name(), sform_type::desc());
+
+ for (size_t i = 0; m_ins_vn + i * m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t ins_size = m_ins_vn + i * m_ins_vs;
+
+ It ins_it_b = m_ins_b;
+ It ins_it_e = m_ins_b;
+ std::advance(ins_it_e, ins_size);
+
+ typedef __gnu_test::tracker_allocator_counter counter_type;
+ __gnu_test::tracker_allocator<char> alloc;
+ const size_t init_mem = counter_type::get_allocation_count()
+ - counter_type::get_deallocation_count();
+ Cntnr cntnr(ins_it_b, ins_it_e);
+
+ while (cntnr.size() > 1)
+ cntnr.erase(*cntnr.begin());
+
+ const size_t final_mem = counter_type::get_allocation_count()
+ - counter_type::get_deallocation_count();
+ assert(final_mem > init_mem);
+ const size_t delta_mem = final_mem - init_mem;
+ res_set_fmt.add_res(ins_size, static_cast<double>(delta_mem));
+ }
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/multimap_insert_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/multimap_insert_test.hpp
new file mode 100644
index 000000000..110dd923f
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/mem_usage/multimap_insert_test.hpp
@@ -0,0 +1,144 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file multimap_insert_test.hpp
+ * Contains a generic multimap_insert_test test.
+ */
+
+#ifndef PB_DS_MULTIMAP_INSERT_TEST_HPP
+#define PB_DS_MULTIMAP_INSERT_TEST_HPP
+
+#include <iterator>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <testsuite_allocator.h>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/assoc/string_form.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ template<typename It, bool Native>
+ class multimap_insert_test
+ {
+ public:
+ multimap_insert_test(It b, size_t ins_vn, size_t ins_vs, size_t ins_vm):
+ m_ins_b(b), m_ins_vn(ins_vn), m_ins_vs(ins_vs), m_ins_vm(ins_vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ multimap_insert_test(const multimap_insert_test&);
+
+ template<typename Cntnr>
+ size_t
+ insert(Cntnr, It ins_it_b, It ins_it_e, __gnu_pbds::detail::true_type);
+
+ template<typename Cntnr>
+ size_t
+ insert(Cntnr, It ins_it_b, It ins_it_e, __gnu_pbds::detail::false_type);
+
+ const It m_ins_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ };
+
+ template<typename It, bool Native>
+ template<typename Cntnr>
+ void
+ multimap_insert_test<It, Native>::
+ operator()(Cntnr)
+ {
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t i = 0; m_ins_vn + i * m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t ins_size = m_ins_vn + i * m_ins_vs;
+ It ins_it_b = m_ins_b;
+ It ins_it_e = m_ins_b;
+ std::advance(ins_it_e, ins_size);
+
+ const size_t delta_mem = insert(Cntnr(), ins_it_b, ins_it_e,
+ __gnu_pbds::detail::integral_constant<int,Native>());
+
+ res_set_fmt.add_res(ins_size, static_cast<double>(delta_mem));
+ }
+ }
+
+ template<typename It, bool Native>
+ template<typename Cntnr>
+ size_t
+ multimap_insert_test<It, Native>::
+ insert(Cntnr, It ins_it_b, It ins_it_e, __gnu_pbds::detail::true_type)
+ {
+ typedef __gnu_test::tracker_allocator_counter counter_type;
+ __gnu_test::tracker_allocator<char> alloc;
+ const size_t init_mem = counter_type::get_allocation_count()
+ - counter_type::get_deallocation_count();
+ Cntnr cntnr;
+ for (It ins_it = ins_it_b; ins_it != ins_it_e; ++ins_it)
+ cntnr.insert((typename Cntnr::const_reference)(*ins_it));
+ const size_t final_mem = counter_type::get_allocation_count()
+ - counter_type::get_deallocation_count();
+ assert(final_mem > init_mem);
+ return (final_mem - init_mem);
+ }
+
+ template<typename It, bool Native>
+ template<typename Cntnr>
+ size_t
+ multimap_insert_test<It, Native>::
+ insert(Cntnr, It ins_it_b, It ins_it_e, __gnu_pbds::detail::false_type)
+ {
+ typedef __gnu_test::tracker_allocator_counter counter_type;
+ __gnu_test::tracker_allocator<char> alloc;
+ const size_t init_mem = counter_type::get_allocation_count()
+ - counter_type::get_deallocation_count();
+ Cntnr cntnr;
+ for (It ins_it = ins_it_b; ins_it != ins_it_e; ++ins_it)
+ cntnr[ins_it->first].insert(ins_it->second);
+ const size_t final_mem = counter_type::get_allocation_count()
+ - counter_type::get_deallocation_count();
+ assert(final_mem > init_mem);
+ return (final_mem - init_mem);
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/multimap_common_type.hpp b/libstdc++-v3/testsuite/util/performance/assoc/multimap_common_type.hpp
new file mode 100644
index 000000000..e31abe106
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/multimap_common_type.hpp
@@ -0,0 +1,223 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file multimap_common_type.hpp
+ * Contains types for a generic multimap_insert_test test.
+ */
+
+#ifndef PB_DS_MULTIMAP_RANDOM_INT_INSERT_TEST_COMMON_TYPE_HPP
+#define PB_DS_MULTIMAP_RANDOM_INT_INSERT_TEST_COMMON_TYPE_HPP
+
+#include <hash_fn/string_hash_fn.hpp>
+#include <common_type/assoc/common_type.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ struct int_hash : public std::unary_function<int, size_t>
+ {
+ inline size_t
+ operator()(const int i) const
+ { return (static_cast<size_t>(i)); }
+ };
+
+ template<typename Key, typename Allocator = std::allocator<char> >
+ struct hash_set_tl_t
+ {
+ typedef
+ typename __gnu_pbds::test::hash_common_types<
+ Key,
+ __gnu_pbds::null_mapped_type,
+ int_hash,
+ std::equal_to<Key>,
+ Allocator>::performance_min_tl
+ type;
+ };
+
+ template<typename Key, typename Allocator = std::allocator<char> >
+ struct lu_set_tl_t
+ {
+ typedef
+ typename __gnu_pbds::test::lu_common_types<
+ Key,
+ __gnu_pbds::null_mapped_type,
+ std::equal_to<
+ Key>,
+ Allocator>::performance_min_tl
+ type;
+ };
+
+ template<typename Key,
+ class Sec_Tl,
+ typename Allocator = std::allocator<char> >
+ struct hash_mmap_tl_t
+ {
+ private:
+ typedef
+ typename __gnu_pbds::detail::__conditional_type<
+ __gnu_pbds::detail::is_same<
+ int,
+ Key>::value,
+ int_hash,
+ string_hash_fn>::__type
+ hash_fn_t;
+
+ template<typename Cntnr_T>
+ struct hash_mmap_transform
+ {
+ typedef
+ typename __gnu_pbds::test::hash_common_types<
+ Key,
+ Cntnr_T,
+ hash_fn_t,
+ std::equal_to<
+ Key>,
+ Allocator>::performance_min_tl
+ type;
+ };
+
+ public:
+ typedef
+ typename __gnu_cxx::typelist::flatten<
+ typename __gnu_cxx::typelist::transform<
+ Sec_Tl,
+ hash_mmap_transform>::type>::type
+ type;
+ };
+
+ template<typename Key,
+ class Sec_Tl,
+ typename Allocator = std::allocator<char> >
+ struct tree_mmap_tl_t
+ {
+ private:
+ template<typename Cntnr_T>
+ struct tree_mmap_transform
+ {
+ typedef
+ typename __gnu_pbds::test::tree_common_types<
+ Key,
+ Cntnr_T,
+ std::less<
+ Key>,
+ __gnu_pbds::null_tree_node_update,
+ Allocator>::performance_min_tl
+ type;
+ };
+
+ public:
+ typedef
+ typename __gnu_cxx::typelist::flatten<
+ typename __gnu_cxx::typelist::transform<
+ Sec_Tl,
+ tree_mmap_transform>::type>::type
+ type;
+ };
+
+ template<typename Key, typename Mapped, typename Allocator>
+ struct hash_hash_mmap_tl_t
+ {
+ private:
+ typedef typename hash_set_tl_t<Mapped, Allocator>::type sec_tl_t;
+
+ public:
+ typedef typename hash_mmap_tl_t<Key, sec_tl_t, Allocator>::type type;
+ };
+
+ template<typename Key, typename Mapped, typename Allocator>
+ struct tree_hash_mmap_tl_t
+ {
+ private:
+ typedef typename hash_set_tl_t<Mapped, Allocator>::type sec_tl_t;
+
+ public:
+ typedef typename tree_mmap_tl_t<Key, sec_tl_t, Allocator>::type type;
+ };
+
+ template<typename Key, typename Mapped, typename Allocator>
+ struct tree_lu_mmap_tl_t
+ {
+ private:
+ typedef typename lu_set_tl_t<Mapped, Allocator>::type sec_tl_t;
+
+ public:
+ typedef typename tree_mmap_tl_t<Key, sec_tl_t, Allocator>::type type;
+ };
+
+ template<typename Key, typename Mapped, typename Allocator>
+ struct hash_lu_mmap_tl_t
+ {
+ private:
+ typedef typename lu_set_tl_t<Mapped, Allocator>::type sec_tl_t;
+
+ public:
+ typedef typename hash_mmap_tl_t<Key, sec_tl_t, Allocator>::type type;
+ };
+ } // namespace detail
+
+ template<typename Key, typename Mapped, typename Allocator>
+ struct mmap_tl_t
+ {
+ private:
+ typedef
+ typename detail::hash_hash_mmap_tl_t<Key, Mapped, Allocator>::type
+ hh_mmap_tl_t;
+
+ typedef
+ typename detail::hash_lu_mmap_tl_t<Key, Mapped, Allocator>::type
+ hl_mmap_tl_t;
+
+ typedef
+ typename detail::tree_hash_mmap_tl_t<Key, Mapped, Allocator>::type
+ th_mmap_tl_t;
+
+ typedef
+ typename detail::tree_lu_mmap_tl_t<Key, Mapped, Allocator>::type
+ tl_mmap_tl_t;
+
+ public:
+ typedef
+ typename __gnu_cxx::typelist::append<hl_mmap_tl_t,
+ typename __gnu_cxx::typelist::append<hh_mmap_tl_t,
+ typename __gnu_cxx::typelist::append<th_mmap_tl_t,
+ tl_mmap_tl_t>::type>::type>::type
+ type;
+ };
+
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/timing/common_type.hpp b/libstdc++-v3/testsuite/util/performance/assoc/timing/common_type.hpp
new file mode 100644
index 000000000..a553afeab
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/timing/common_type.hpp
@@ -0,0 +1,103 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file common_type.hpp
+ * Contains types for a generic multimap_insert_test test.
+ */
+
+#ifndef PB_DS_MULTIMAP_RANDOM_INT_INSERT_TEST_COMMON_TYPE_HPP
+#define PB_DS_MULTIMAP_RANDOM_INT_INSERT_TEST_COMMON_TYPE_HPP
+
+#include <common_type/assoc/common_type.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ typedef
+ __gnu_pbds::test::hash_common_types<
+ int,
+ __gnu_pbds::null_mapped_type>::tl
+ hash_set_tl_t;
+
+ template<typename Cntnr_T>
+ struct hash_mmap_transform
+ {
+ typedef
+ typename __gnu_pbds::test::hash_common_types<
+ int,
+ __gnu_pbds::compound_data_type<
+ Cntnr_T> >::tl
+ type;
+ };
+
+ typedef
+ __gnu_cxx::typelist::flatten<
+ __gnu_cxx::typelist::transform<
+ hash_set_tl_t,
+ hash_mmap_transform>::type>::type
+ hash_mmap_tl_t;
+
+ typedef
+ __gnu_pbds::test::tree_common_types<
+ int,
+ __gnu_pbds::null_mapped_type>::tl
+ tree_set_tl_t;
+
+ template<typename Cntnr_T>
+ struct tree_mmap_transform
+ {
+ typedef
+ typename __gnu_pbds::test::tree_common_types<
+ int,
+ __gnu_pbds::compound_data_type<
+ Cntnr_T> >::tl
+ type;
+ };
+
+ typedef
+ __gnu_cxx::typelist::flatten<
+ __gnu_cxx::typelist::transform<
+ tree_set_tl_t,
+ tree_mmap_transform>::type>::type
+ tree_mmap_tl_t;
+
+ typedef hash_mmap_tl_t mmap_tl_t;
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_MULTIMAP_RANDOM_INT_INSERT_TEST_COMMON_TYPE_HPP
+
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/timing/find_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/timing/find_test.hpp
new file mode 100644
index 000000000..f53a1273c
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/timing/find_test.hpp
@@ -0,0 +1,166 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file find_test.hpp
+ * Contains a generic find test.
+ */
+
+#ifndef PB_DS_FIND_TEST_HPP
+#define PB_DS_FIND_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/assoc/string_form.hpp>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename It, class Cntnr, bool LOR>
+ class find_find_functor
+ {
+ public:
+ find_find_functor(Cntnr& contnr, It fnd_it_b, It fnd_it_e)
+ : m_contnr(contnr), m_fnd_it_b(fnd_it_b), m_fnd_it_e(fnd_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ It fnd_it = m_fnd_it_b;
+ while (fnd_it != m_fnd_it_e)
+ ++m_contnr.find((fnd_it++)->first)->second;
+ }
+ }
+
+ private:
+ Cntnr& m_contnr;
+ const It m_fnd_it_b;
+ const It m_fnd_it_e;
+ };
+
+ template<typename It, class Cntnr>
+ class find_find_functor<It, Cntnr, true>
+ {
+ public:
+ find_find_functor(Cntnr& contnr, It fnd_it_b, It fnd_it_e)
+ : m_contnr(contnr), m_fnd_it_b(fnd_it_b), m_fnd_it_e(fnd_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ It fnd_it = m_fnd_it_b;
+ while (fnd_it != m_fnd_it_e)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ ++m_contnr.find(fnd_it->first)->second;
+ ++fnd_it;
+ }
+ }
+
+ private:
+ Cntnr& m_contnr;
+ const It m_fnd_it_b;
+ const It m_fnd_it_e;
+ };
+ } // namespace detail
+
+ template<typename It, bool LOR = false>
+ class find_test : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ find_test(It ins_b, It fnd_it_b, size_t ins_vn, size_t ins_vs,
+ size_t ins_vm, size_t fnd_vn, size_t fnd_vs, size_t fnd_vm):
+ m_ins_b(ins_b), m_fnd_it_b(fnd_it_b), m_ins_vn(ins_vn), m_ins_vs(ins_vs),
+ m_ins_vm(ins_vm), m_fnd_vn(fnd_vn), m_fnd_vs(fnd_vs), m_fnd_vm(fnd_vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ find_test(const find_test& );
+
+ private:
+ const It m_ins_b;
+ const It m_fnd_it_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ const size_t m_fnd_vn;
+ const size_t m_fnd_vs;
+ const size_t m_fnd_vm;
+ };
+
+ template<typename It, bool LOR>
+ template<typename Cntnr>
+ void
+ find_test<It, LOR>::
+ operator()(Cntnr)
+ {
+ typedef string_form<Cntnr> sform_type;
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(sform_type::name(), sform_type::desc());
+
+ for (size_t i = 0; m_ins_vn + i * m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t v = m_ins_vn + i * m_ins_vs;
+ const size_t fnd_size = m_fnd_vn + i * m_fnd_vs;
+ It ins_it_b = m_ins_b;
+ It ins_it_e = m_ins_b;
+ std::advance(ins_it_e, v);
+
+ Cntnr test_container(ins_it_b, ins_it_e);
+ It fnd_it_b = m_fnd_it_b;
+ It fnd_it_e = m_fnd_it_b;
+ std::advance(fnd_it_e, fnd_size);
+
+ __gnu_pbds::test::detail::find_find_functor<It, Cntnr, LOR>
+ fn(test_container, fnd_it_b, fnd_it_e);
+
+ const double res =
+ __gnu_pbds::test::detail::timing_test_base::operator()(fn);
+ res_set_fmt.add_res(v, res / fnd_size);
+ }
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/timing/insert_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/timing/insert_test.hpp
new file mode 100644
index 000000000..e71d755ba
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/timing/insert_test.hpp
@@ -0,0 +1,143 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file insert_test.hpp
+ * Contains an insert performance test.
+ */
+
+#ifndef PB_DS_INSERT_TEST_HPP
+#define PB_DS_INSERT_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/assoc/string_form.hpp>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename It, class Cntnr>
+ class insert_insert_functor
+ {
+ public:
+ insert_insert_functor(It ins_it_b, It ins_it_e)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr cntnr;
+ for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ cntnr.insert((typename Cntnr::const_reference)(*ins_it));
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ };
+ } // namespace detail
+
+ template<typename It>
+ class insert_test : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ insert_test(It ins_b, size_t ins_vn, size_t ins_vs, size_t ins_vm)
+ : m_ins_b(ins_b), m_ins_vn(ins_vn), m_ins_vs(ins_vs), m_ins_vm(ins_vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ insert_test(const insert_test& );
+
+ template<typename Cntnr>
+ void
+ insert(Cntnr, It ins_it_b, It ins_it_e);
+
+ const It m_ins_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ };
+
+ template<typename It>
+ template<typename Cntnr>
+ void
+ insert_test<It>::
+ operator()(Cntnr)
+ {
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t i = 0; m_ins_vn + i* m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t v = m_ins_vn + i* m_ins_vs;
+ It ins_it_b = m_ins_b;
+ It ins_it_e = m_ins_b;
+ std::advance(ins_it_e, v);
+
+ __gnu_pbds::test::detail::insert_insert_functor<It, Cntnr>
+ fn(ins_it_b, ins_it_e);
+
+ const double res =
+ __gnu_pbds::test::detail::timing_test_base::operator()(fn);
+
+ res_set_fmt.add_res(v, res / v);
+ }
+ }
+
+ template<typename It>
+ template<typename Cntnr>
+ void
+ insert_test<It>::
+ insert(Cntnr, It ins_it_b, It ins_it_e)
+ {
+ Cntnr cntnr;
+ for (It ins_it = ins_it_b; ins_it != ins_it_e; ++ins_it)
+ cntnr.insert((typename Cntnr::const_reference)(*ins_it));
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/timing/multimap_find_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/timing/multimap_find_test.hpp
new file mode 100644
index 000000000..7e3f95bfc
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/timing/multimap_find_test.hpp
@@ -0,0 +1,191 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file multimap_find_test.hpp
+ * Contains a generic multimap_find_test test.
+ */
+
+#ifndef PB_DS_MULTIMAP_INSERT_TEST_HPP
+#define PB_DS_MULTIMAP_INSERT_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/assoc/string_form.hpp>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename It, class Cntnr, bool Native>
+ class multimap_find_functor
+ {
+ public:
+ multimap_find_functor(const Cntnr& container, It fnd_it_b, It fnd_it_e)
+ : m_r_container(container), m_fnd_it_b(fnd_it_b), m_fnd_it_e(fnd_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ size_t not_found_count = 0;
+ typedef typename Cntnr::const_point_iterator iterator_type;
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ iterator_type end = m_r_container.end();
+ for (It fnd_it = m_fnd_it_b; fnd_it != m_fnd_it_e; ++fnd_it)
+ {
+ iterator_type it = m_r_container.find(fnd_it->first);
+ if (it == end ||
+ it->second.find(fnd_it->second) == it->second.end())
+ ++not_found_count;
+ }
+ }
+
+ if (not_found_count != 0)
+ std::abort();
+ }
+
+ private:
+ const Cntnr& m_r_container;
+ const It m_fnd_it_b;
+ const It m_fnd_it_e;
+ };
+
+ template<typename It, class Cntnr>
+ class multimap_find_functor<It, Cntnr, true>
+ {
+ public:
+ multimap_find_functor(const Cntnr& container, It fnd_it_b, It fnd_it_e)
+ : m_r_container(container), m_fnd_it_b(fnd_it_b), m_fnd_it_e(fnd_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ typedef typename Cntnr::const_reference const_reference;
+ size_t not_found_count = 0;
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr cntnr;
+ for (It fnd_it = m_fnd_it_b; fnd_it != m_fnd_it_e; ++fnd_it)
+ if (m_r_container.find(const_reference(*fnd_it))
+ == m_r_container.end())
+ ++not_found_count;
+ }
+
+ if (not_found_count != 0)
+ std::abort();
+ }
+
+ private:
+ const Cntnr& m_r_container;
+ const It m_fnd_it_b;
+ const It m_fnd_it_e;
+ };
+ } // namespace detail
+
+
+ template<typename It, bool Native>
+ class multimap_find_test
+ : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ multimap_find_test(It ins_b, size_t ins_vn, size_t vs, size_t ins_vm)
+ : m_ins_b(ins_b), m_ins_vn(ins_vn), m_ins_vs(vs), m_ins_vm(ins_vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ multimap_find_test(const multimap_find_test&);
+
+ template<typename Cntnr>
+ Cntnr
+ init(It ins_b, It ins_e, Cntnr, __gnu_pbds::detail::true_type)
+ { return Cntnr(ins_b, ins_e); }
+
+ template<typename Cntnr>
+ Cntnr
+ init(It ins_b, It ins_e, Cntnr, __gnu_pbds::detail::false_type)
+ {
+ Cntnr ret;
+ for (It it = ins_b; it != ins_e; ++it)
+ ret[it->first].insert(it->second);
+ return ret;
+ }
+
+ const It m_ins_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ };
+
+
+ template<typename It, bool Native>
+ template<typename Cntnr>
+ void
+ multimap_find_test<It, Native>::
+ operator()(Cntnr)
+ {
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t i = 0; m_ins_vn + i * m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t v = m_ins_vn + i * m_ins_vs;
+ It ins_it_b = m_ins_b;
+ It ins_it_e = m_ins_b;
+ std::advance(ins_it_e, v);
+
+ Cntnr c = init(ins_it_b, ins_it_e, Cntnr(),
+ __gnu_pbds::detail::integral_constant<int,Native>());
+
+ __gnu_pbds::test::detail::multimap_find_functor<It, Cntnr, Native>
+ fn(c, ins_it_b, ins_it_e);
+
+ const double res =
+ __gnu_pbds::test::detail::timing_test_base::operator()(fn);
+
+ res_set_fmt.add_res(v, res / v);
+ }
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/timing/multimap_insert_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/timing/multimap_insert_test.hpp
new file mode 100644
index 000000000..2e8539857
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/timing/multimap_insert_test.hpp
@@ -0,0 +1,151 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file multimap_insert_test.hpp
+ * Contains a generic multimap_insert_test test.
+ */
+
+#ifndef PB_DS_MULTIMAP_INSERT_TEST_HPP
+#define PB_DS_MULTIMAP_INSERT_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/assoc/string_form.hpp>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename It, class Cntnr, bool Native>
+ class multimap_insert_functor
+ {
+ public:
+ multimap_insert_functor(It ins_it_b, It ins_it_e)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr cntnr;
+ for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ cntnr[ins_it->first].insert(ins_it->second);
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ };
+
+ template<typename It, class Cntnr>
+ class multimap_insert_functor<It, Cntnr, true>
+ {
+ public:
+ multimap_insert_functor(It ins_it_b, It ins_it_e)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr cntnr;
+ for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ cntnr.insert((typename Cntnr::const_reference)(*ins_it));
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ };
+ } // namespace detail
+
+ template<typename It, bool Native>
+ class multimap_insert_test
+ : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ multimap_insert_test(It b, size_t ins_vn, size_t ins_vs, size_t ins_vm)
+ : m_ins_b(b), m_ins_vn(ins_vn), m_ins_vs(ins_vs), m_ins_vm(ins_vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ multimap_insert_test(const multimap_insert_test&);
+
+ const It m_ins_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ };
+
+ template<typename It, bool Native>
+ template<typename Cntnr>
+ void
+ multimap_insert_test<It, Native>::
+ operator()(Cntnr)
+ {
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t i = 0; m_ins_vn + i * m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t v = m_ins_vn + i * m_ins_vs;
+ It ins_it_b = m_ins_b;
+ It ins_it_e = m_ins_b;
+ std::advance(ins_it_e, v);
+
+ __gnu_pbds::test::detail::multimap_insert_functor<It, Cntnr, Native>
+ fn(ins_it_b, ins_it_e);
+
+ const double res =
+ __gnu_pbds::test::detail::timing_test_base::operator()(fn);
+ res_set_fmt.add_res(v, res / v);
+ }
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/timing/subscript_find_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/timing/subscript_find_test.hpp
new file mode 100644
index 000000000..d37121b8c
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/timing/subscript_find_test.hpp
@@ -0,0 +1,144 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file subscript_find_test.hpp
+ * Contains a generic subscript_find_test test.
+ */
+
+#ifndef PB_DS_SUBSCRIPT_TEST_HPP
+#define PB_DS_SUBSCRIPT_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <common_type/assoc/string_form.hpp>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename It, class Cntnr>
+ class subscript_find_functor
+ {
+ public:
+ subscript_find_functor(Cntnr& container, It fnd_it_b, It fnd_it_e)
+ : m_r_container(container), m_fnd_it_b(fnd_it_b), m_fnd_it_e(fnd_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ It fnd_it = m_fnd_it_b;
+ while (fnd_it != m_fnd_it_e)
+ ++m_r_container[(fnd_it++)->first];
+ ++fnd_it;
+ }
+ }
+
+ private:
+ Cntnr& m_r_container;
+ const It m_fnd_it_b;
+ const It m_fnd_it_e;
+ };
+
+ } // namespace detail
+
+ template<typename It>
+ class subscript_find_test : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ subscript_find_test(It ins_b, It b, size_t ins_vn, size_t ins_vs,
+ size_t ins_vm, size_t vn, size_t vs, size_t vm)
+ : m_ins_b(ins_b), m_fnd_b(b), m_ins_vn(ins_vn), m_ins_vs(ins_vs),
+ m_ins_vm(ins_vm), m_fnd_vn(vn), m_fnd_vs(vs), m_fnd_vm(vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ subscript_find_test(const subscript_find_test&);
+
+ private:
+ const It m_ins_b;
+ const It m_fnd_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ const size_t m_fnd_vn;
+ const size_t m_fnd_vs;
+ const size_t m_fnd_vm;
+ };
+
+ template<typename It>
+ template<typename Cntnr>
+ void
+ subscript_find_test<It>::
+ operator()(Cntnr)
+ {
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t i = 0; m_ins_vn + i* m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t v = m_ins_vn + i* m_ins_vs;
+ const size_t fnd_size = m_fnd_vn + i* m_fnd_vs;
+
+ It ins_it_b = m_ins_b;
+ It ins_it_e = m_ins_b;
+ std::advance(ins_it_e, v);
+
+ Cntnr test_container(ins_it_b, ins_it_e);
+
+ It fnd_it_b = m_fnd_b;
+ It fnd_it_e = m_fnd_b;
+ std::advance(fnd_it_e, fnd_size);
+
+ __gnu_pbds::test::detail::subscript_find_functor<It, Cntnr>
+ fn(test_container, fnd_it_b, fnd_it_e);
+
+ const double res =
+ __gnu_pbds::test::detail::timing_test_base::operator()(fn);
+
+ res_set_fmt.add_res(v, res / fnd_size);
+ }
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/timing/subscript_insert_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/timing/subscript_insert_test.hpp
new file mode 100644
index 000000000..10925fd60
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/timing/subscript_insert_test.hpp
@@ -0,0 +1,134 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file subscript_insert_test.hpp
+ * Contains a generic subscript_insert_test test.
+ */
+
+#ifndef PB_DS_SUBSCRIPT_TEST_HPP
+#define PB_DS_SUBSCRIPT_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/assoc/string_form.hpp>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename It, class Cntnr>
+ class subscript_insert_functor
+ {
+ public:
+ subscript_insert_functor(It ins_it_b, It ins_it_e)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr cntnr;
+ for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ ++cntnr[ins_it->first];
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ };
+
+ } // namespace detail
+
+ template<typename It>
+ class subscript_insert_test : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ subscript_insert_test(It ins_b, It b, size_t ins_vn, size_t ins_vs,
+ size_t ins_vm, size_t vn, size_t vs, size_t vm)
+ : m_ins_b(ins_b), m_fnd_b(b), m_ins_vn(ins_vn), m_ins_vs(ins_vs),
+ m_ins_vm(ins_vm), m_fnd_vn(vn), m_fnd_vs(vs), m_fnd_vm(vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ subscript_insert_test(const subscript_insert_test& );
+
+ private:
+ const It m_ins_b;
+ const It m_fnd_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ const size_t m_fnd_vn;
+ const size_t m_fnd_vs;
+ const size_t m_fnd_vm;
+ };
+
+ template<typename It>
+ template<typename Cntnr>
+ void
+ subscript_insert_test<It>::
+ operator()(Cntnr)
+ {
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t i = 0; m_ins_vn + i * m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t v = m_ins_vn + i * m_ins_vs;
+ It ins_it_b = m_ins_b;
+ It ins_it_e = m_ins_b;
+ std::advance(ins_it_e, v);
+ __gnu_pbds::test::detail::subscript_insert_functor<It, Cntnr>
+ fn(ins_it_b, ins_it_e);
+
+ const double res =
+ __gnu_pbds::test::detail::timing_test_base::operator()(fn);
+
+ res_set_fmt.add_res(v, res / v);
+ }
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/timing/tree_order_statistics_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/timing/tree_order_statistics_test.hpp
new file mode 100644
index 000000000..0fb028687
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/timing/tree_order_statistics_test.hpp
@@ -0,0 +1,176 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_order_statistics_test.hpp
+ * Contains a test for order_statisticsing trees
+ */
+
+#ifndef PB_DS_TREE_ORDER_STATISTICS_TEST_HPP
+#define PB_DS_TREE_ORDER_STATISTICS_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/assoc/string_form.hpp>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <iterator>
+#include <cstdlib>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename Cntnr, bool Native>
+ class order_statistics_functor
+ {
+ public:
+ order_statistics_functor(Cntnr& container) : m_r_container(container)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ enum
+ {
+ support_detected =
+ __gnu_pbds::test::detail::tree_supports_order_statistics<Cntnr>::value
+ };
+
+ PB_DS_STATIC_ASSERT(correct_type, support_detected);
+
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ typename Cntnr::const_iterator it = m_r_container.begin();
+ typename Cntnr::const_iterator e = m_r_container.end();
+ const size_t max_size = m_r_container.size();
+ while (it != e)
+ if (m_r_container.order_of_key(*(it++)) > max_size)
+ std::abort();
+ }
+ }
+
+ private:
+ Cntnr& m_r_container;
+ };
+
+ template<typename Cntnr>
+ class order_statistics_functor<Cntnr, false>
+ {
+ public:
+ order_statistics_functor(Cntnr& container) : m_r_container(container)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ typedef typename Cntnr::const_iterator const_iterator;
+ const_iterator b = m_r_container.begin();
+ const_iterator e = m_r_container.end();
+ const_iterator it = b;
+ const size_t max_size = m_r_container.size();
+ while (it != e)
+ {
+ const_iterator f_it = m_r_container.find(*(it++));
+ if (static_cast<size_t>(std::distance(b, f_it)) > max_size)
+ std::abort();
+ }
+ }
+ }
+
+ private:
+ Cntnr& m_r_container;
+ };
+ } // namespace detail
+
+ template<bool Support_Order_Statistics>
+ class tree_order_statistics_test
+ : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ tree_order_statistics_test(size_t vn, size_t vs, size_t vm)
+ : m_vn(vn), m_vs(vs), m_vm(vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ tree_order_statistics_test(const tree_order_statistics_test& );
+
+ template<typename Cntnr>
+ void
+ order_statistics(Cntnr& r_container, __gnu_pbds::detail::true_type);
+
+ template<typename Cntnr>
+ void
+ order_statistics(Cntnr& r_container, __gnu_pbds::detail::false_type);
+
+ private:
+ const size_t m_vn;
+ const size_t m_vs;
+ const size_t m_vm;
+ };
+
+ template<bool Support_Order_Statistics>
+ template<typename Cntnr>
+ void
+ tree_order_statistics_test<Support_Order_Statistics>::
+ operator()(Cntnr)
+ {
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t v = m_vn; v < m_vm; v += m_vs)
+ {
+ Cntnr cntnr;
+ for (size_t ins = 0; ins < v; ++ ins)
+ cntnr.insert((typename Cntnr::value_type)ins);
+
+ __gnu_pbds::test::detail::order_statistics_functor<Cntnr, Support_Order_Statistics>
+ fn(cntnr);
+
+ const double res =
+ __gnu_pbds::test::detail::timing_test_base::operator()(fn);
+
+ res_set_fmt.add_res(v, res / v);
+ }
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/assoc/timing/tree_split_join_test.hpp b/libstdc++-v3/testsuite/util/performance/assoc/timing/tree_split_join_test.hpp
new file mode 100644
index 000000000..6872291df
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/assoc/timing/tree_split_join_test.hpp
@@ -0,0 +1,158 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file tree_split_join_test.hpp
+ * Contains a test for splitting and joining trees
+ */
+
+#ifndef PB_DS_TREE_SPLIT_JOIN_TEST_HPP
+#define PB_DS_TREE_SPLIT_JOIN_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/assoc/string_form.hpp>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename Cntnr, bool Support_Split_Join>
+ class split_join_functor
+ {
+ public:
+ split_join_functor(Cntnr& r_container) : m_r_container(r_container)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ typename Cntnr::const_iterator mid_it = m_r_container.begin();
+ std::advance(mid_it, m_r_container.size() / 2);
+ Cntnr other;
+ m_r_container.split(*mid_it, other);
+ m_r_container.join(other);
+ }
+ }
+
+ private:
+ Cntnr& m_r_container;
+ };
+
+ template<typename Cntnr>
+ class split_join_functor<Cntnr, false>
+ {
+ public:
+ split_join_functor(Cntnr& r_container) : m_r_container(r_container)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ typename Cntnr::iterator mid_it = m_r_container.begin();
+ std::advance(mid_it, m_r_container.size() / 2);
+
+ Cntnr other(mid_it, m_r_container.end());
+ m_r_container.erase(mid_it, m_r_container.end());
+
+ m_r_container.insert(other.begin(), other.end());
+ other.clear();
+ }
+ }
+
+ private:
+ Cntnr& m_r_container;
+ };
+ } // namespace detail
+
+ template<bool Support_Split_Join>
+ class tree_split_join_test : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ tree_split_join_test(size_t vn, size_t vs, size_t vm);
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ tree_split_join_test(const tree_split_join_test& );
+
+ private:
+ const size_t m_vn;
+ const size_t m_vs;
+ const size_t m_vm;
+ };
+
+ template<bool Support_Split_Join>
+ tree_split_join_test<Support_Split_Join>::
+ tree_split_join_test(size_t vn, size_t vs, size_t vm) :
+ m_vn(vn),
+ m_vs(vs),
+ m_vm(vm)
+ { }
+
+ template<bool Support_Split_Join>
+ template<typename Cntnr>
+ void
+ tree_split_join_test<Support_Split_Join>::
+ operator()(Cntnr)
+ {
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t v = m_vn; v < m_vm; v += m_vs)
+ {
+ Cntnr cntnr;
+ for (size_t ins = 0; ins < v; ++ ins)
+ cntnr.insert((typename Cntnr::value_type)ins);
+
+ __gnu_pbds::test::detail::split_join_functor<Cntnr, Support_Split_Join>
+ fn(cntnr);
+
+ const double res =
+ __gnu_pbds::test::detail::timing_test_base::operator()(fn);
+ res_set_fmt.add_res(v, res);
+ }
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/io/xml_formatter.hpp b/libstdc++-v3/testsuite/util/performance/io/xml_formatter.hpp
new file mode 100644
index 000000000..535964bdd
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/io/xml_formatter.hpp
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file xml_formatter.hpp
+ * Contains an XML formatter for performance tests.
+ */
+
+#ifndef PB_DS_XML_TEST_PERFORMANCE_FORMATTER_HPP
+#define PB_DS_XML_TEST_PERFORMANCE_FORMATTER_HPP
+
+#include <string>
+#include <iostream>
+#include <io/xml_test_formatter.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ class xml_test_performance_formatter : public xml_test_formatter
+ {
+ public:
+ xml_test_performance_formatter(const std::string& r_x_name, const std::string& r_y_name)
+ {
+ std::cout << make_xml_tag("x_name", r_x_name);
+ std::cout << make_xml_tag("y_name", r_y_name);
+ }
+ };
+
+ class xml_result_set_performance_formatter : public xml_result_set_formatter
+ {
+ public:
+ xml_result_set_performance_formatter(const std::string& r_container_name, const std::string& r_container_desc)
+ : xml_result_set_formatter(r_container_name, r_container_desc)
+ {
+ { }
+ }
+
+ void
+ add_res(size_t x, double y)
+ {
+ const unsigned long ul = static_cast<unsigned long>(x);
+ const std::string res = make_xml_tag("result", "x", ul, "y", y);
+ std::cout << res;
+ }
+ };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_XML_TEST_PERFORMANCE_FORMATTER_HPP
diff --git a/libstdc++-v3/testsuite/util/performance/priority_queue/mem_usage/pop_test.hpp b/libstdc++-v3/testsuite/util/performance/priority_queue/mem_usage/pop_test.hpp
new file mode 100644
index 000000000..3a98813df
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/priority_queue/mem_usage/pop_test.hpp
@@ -0,0 +1,111 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file pop_test.hpp
+ * Contains a generic pop test.
+ */
+
+#ifndef PB_DS_POP_TEST_HPP
+#define PB_DS_POP_TEST_HPP
+
+#include <iterator>
+#include <testsuite_allocator.h>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/priority_queue/string_form.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ template<typename It>
+ class pop_test
+ {
+ public:
+ pop_test(It ins_b, size_t ins_vn, size_t ins_vs, size_t ins_vm)
+ : m_ins_b(ins_b), m_ins_vn(ins_vn), m_ins_vs(ins_vs), m_ins_vm(ins_vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ pop_test(const pop_test&);
+
+ const It m_ins_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ };
+
+ template<typename It>
+ template<typename Cntnr>
+ void
+ pop_test<It>::
+ operator()(Cntnr)
+ {
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t i = 0; m_ins_vn + i * m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t ins_size = m_ins_vn + i * m_ins_vs;
+ It ins_it_b = m_ins_b;
+ It ins_it_e = m_ins_b;
+ std::advance(ins_it_e, ins_size);
+
+ typedef __gnu_test::tracker_allocator_counter counter_type;
+ __gnu_test::tracker_allocator<char> alloc;
+
+ const size_t init_mem = counter_type::get_allocation_count()
+ - counter_type::get_deallocation_count();
+ Cntnr cntnr;
+ for (It ins_it = ins_it_b; ins_it != ins_it_e; ++ins_it)
+ cntnr.push(ins_it->first);
+
+ while (cntnr.size() > 1)
+ cntnr.pop();
+
+ const size_t final_mem = counter_type::get_allocation_count()
+ - counter_type::get_deallocation_count();
+ assert(final_mem > init_mem);
+ const size_t delta_mem = final_mem - init_mem;
+ res_set_fmt.add_res(ins_size, static_cast<double>(delta_mem));
+ }
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/priority_queue/timing/join_test.hpp b/libstdc++-v3/testsuite/util/performance/priority_queue/timing/join_test.hpp
new file mode 100644
index 000000000..1281f40c3
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/priority_queue/timing/join_test.hpp
@@ -0,0 +1,167 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file join_test.hpp
+ * Contains a join performance test.
+ */
+
+#ifndef PB_DS_JOIN_TEST_HPP
+#define PB_DS_JOIN_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/priority_queue/string_form.hpp>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename It, typename Cntnr>
+ class double_push_functor
+ {
+ const It _M_begin;
+ const It _M_end;
+
+ public:
+ double_push_functor(It b, It e) : _M_begin(b), _M_end(e) { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ typedef typename Cntnr::const_reference const_reference;
+ for (std::size_t n = 0; n < resolution; ++n)
+ {
+ Cntnr c0;
+ Cntnr c1;
+ for (It it = _M_begin; it != _M_end; ++it)
+ {
+ c0.push(const_reference(it->first));
+ c1.push(const_reference(it->first));
+ }
+ }
+ }
+ };
+
+ template<typename It, typename Cntnr>
+ class double_push_join_functor
+ {
+ const It _M_begin;
+ const It _M_end;
+
+ public:
+ double_push_join_functor(It b, It e) : _M_begin(b), _M_end(e) { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ typedef typename Cntnr::const_reference const_reference;
+ for (std::size_t n = 0; n < resolution; ++n)
+ {
+ Cntnr c0;
+ Cntnr c1;
+ for (It it = _M_begin; it != _M_end; ++it)
+ {
+ c0.push(const_reference(it->first));
+ c1.push(const_reference(it->first));
+ }
+ c0.join(c1);
+ }
+ }
+ };
+ } // namespace detail
+
+ template<typename It>
+ class join_test : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ join_test(It ins_b, size_t ins_vn, size_t ins_vs, size_t ins_vm)
+ : m_ins_b(ins_b), m_ins_vn(ins_vn), m_ins_vs(ins_vs), m_ins_vm(ins_vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr)
+ {
+ using __gnu_pbds::test::detail::double_push_functor;
+ using __gnu_pbds::test::detail::double_push_join_functor;
+ typedef __gnu_pbds::test::detail::timing_test_base base_type;
+ typedef double_push_functor<It, Cntnr> psh_fnct;
+ typedef double_push_join_functor<It, Cntnr> psh_jn_fnct;
+
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t n = 0; m_ins_vn + n* m_ins_vs < m_ins_vm; ++n)
+ {
+ const size_t v = m_ins_vn + n * m_ins_vs;
+ It b = m_ins_b;
+ It e = m_ins_b;
+ std::advance(e, v);
+
+ psh_fnct double_push_fn(b, e);
+ const double dbl_psh_res = base_type::operator()(double_push_fn);
+ psh_jn_fnct dbl_psh_jn_fn(b, e);
+ const double dbl_psh_jn_res = base_type::operator()(dbl_psh_jn_fn);
+ const double min_res = double(timing_test_base::min_time_res());
+ const double effective_delta = std::max(dbl_psh_jn_res - dbl_psh_res, min_res);
+ res.add_res(v, effective_delta / v);
+ }
+ }
+
+ private:
+ join_test(const join_test&);
+
+ template<typename Cntnr>
+ void
+ join(Cntnr, It b, It e)
+ {
+ Cntnr cntnr;
+ typedef typename Cntnr::const_reference const_reference;
+ for (It it = b; it != e; ++it)
+ cntnr.join(const_reference(*it));
+ }
+
+ const It m_ins_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/priority_queue/timing/modify_test.hpp b/libstdc++-v3/testsuite/util/performance/priority_queue/timing/modify_test.hpp
new file mode 100644
index 000000000..01e082058
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/priority_queue/timing/modify_test.hpp
@@ -0,0 +1,329 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file modify_test.hpp
+ * Contains a modify performance test.
+ */
+
+#ifndef PB_DS_JOIN_TEST_HPP
+#define PB_DS_JOIN_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/priority_queue/string_form.hpp>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ // Primary templates.
+ template<typename It, class Cntnr, class Tag>
+ class push_functor
+ {
+ public:
+ push_functor(It ins_it_b, It ins_it_e)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ typedef typename Cntnr::point_iterator point_iterator;
+ typedef typename Cntnr::const_reference const_reference;
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr c;
+ typedef std::vector<point_iterator> it_vec_t;
+ it_vec_t m_a_its;
+ for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ m_a_its.push_back(c.push(const_reference(ins_it->first)));
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ };
+
+ template<typename It, class Cntnr, class Tag>
+ class push_modify_functor
+ {
+ private:
+ typedef typename Cntnr::point_iterator point_iterator;
+ typedef typename Cntnr::const_reference const_reference;
+ typedef typename Cntnr::value_type value_type;
+
+ public:
+ push_modify_functor(It ins_it_b, It ins_it_e, value_type mod_val)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e), m_mod_val(mod_val)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr c;
+ typedef std::vector<typename Cntnr::point_iterator> it_vec_t;
+ it_vec_t m_a_its;
+ for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ m_a_its.push_back(c.push(const_reference(ins_it->first)));
+
+ typename it_vec_t::iterator mod_it = m_a_its.begin();
+ while (mod_it != m_a_its.end())
+ c.modify(*mod_it++, m_mod_val);
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ const value_type m_mod_val;
+ };
+
+ // Specializations.
+ template<typename It, class Cntnr>
+ class push_functor<It, Cntnr, __gnu_pbds::binary_heap_tag>
+ {
+ public:
+ push_functor(It ins_it_b, It ins_it_e)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ typedef typename Cntnr::const_reference const_reference;
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr c;
+ for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ c.push(const_reference(ins_it->first));
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ };
+
+ template<typename It, class Cntnr>
+ class push_functor<It, Cntnr, __gnu_pbds::test::native_pq_tag>
+ {
+ public:
+ push_functor(It ins_it_b, It ins_it_e)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ typedef typename Cntnr::const_reference const_reference;
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr c;
+
+ for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ c.push(const_reference(ins_it->first));
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ };
+
+
+ template<typename It, class Cntnr>
+ class push_modify_functor<It, Cntnr, __gnu_pbds::binary_heap_tag>
+ {
+ private:
+ typedef typename Cntnr::iterator iterator;
+ typedef typename Cntnr::const_reference const_reference;
+ typedef typename Cntnr::value_type value_type;
+
+ public:
+ push_modify_functor(It ins_it_b, It ins_it_e, value_type mod_val)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e), m_mod_val(mod_val)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr c;
+ It ins_it;
+ for (ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ c.push(const_reference(ins_it->first));
+
+ for (ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ {
+ bool modified = false;
+ for (iterator it = c.begin(); !modified && it != c.end(); ++it)
+ if (*it == ins_it->first)
+ {
+ c.modify(it, m_mod_val);
+ modified = true;
+ }
+ }
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ const value_type m_mod_val;
+ };
+
+ template<typename It, class Cntnr>
+ class push_modify_functor<It, Cntnr, __gnu_pbds::test::native_pq_tag>
+ {
+ private:
+ typedef typename Cntnr::value_type value_type;
+ typedef typename Cntnr::const_reference const_reference;
+
+ public:
+ push_modify_functor(It ins_it_b, It ins_it_e, value_type mod_val)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e), m_mod_val(mod_val)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr c;
+ It ins_it;
+ for (ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ c.push(const_reference(ins_it->first));
+ for (ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ c.modify(ins_it->first, m_mod_val);
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ const value_type m_mod_val;
+ };
+ } // namespace detail
+
+ template<typename It>
+ class modify_test : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ modify_test(It b, size_t vn, size_t vs, size_t vm, bool modify_up)
+ : m_ins_b(b), m_ins_vn(vn), m_ins_vs(vs), m_ins_vm(vm),
+ m_modify_up(modify_up)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ modify_test(const modify_test&);
+
+ template<typename Cntnr>
+ void
+ modify(Cntnr, It ins_it_b, It ins_it_e)
+ {
+ typedef typename Cntnr::const_reference const_reference;
+ Cntnr cntnr;
+ for (It ins_it = ins_it_b; ins_it != ins_it_e; ++ins_it)
+ cntnr.modify(const_reference(*ins_it));
+ }
+
+ const It m_ins_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ const bool m_modify_up;
+ };
+
+ template<typename It>
+ template<typename Cntnr>
+ void
+ modify_test<It>::
+ operator()(Cntnr)
+ {
+ typedef typename Cntnr::value_type value_type;
+ typedef typename Cntnr::container_category container_category;
+ typedef typename Cntnr::const_reference const_reference;
+ typedef detail::timing_test_base timing_test_base;
+ typedef detail::push_functor<It, Cntnr, container_category> psh_fnct;
+ typedef detail::push_modify_functor<It, Cntnr, container_category> psh_mod_fnct;
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t i = 0; m_ins_vn + i * m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t v = m_ins_vn + i * m_ins_vs;
+ It b = m_ins_b;
+ It e = m_ins_b;
+ std::advance(e, v);
+
+ psh_fnct psh_fn(b, e);
+ const double psh_res = timing_test_base::operator()(psh_fn);
+
+ value_type val = b->first;
+ {
+ Cntnr mod_val_container;
+ for (It mod_val_it = b; mod_val_it != e; ++mod_val_it)
+ {
+ value_type pot = mod_val_it->first;
+ if (m_modify_up == mod_val_container.get_cmp_fn()(val, pot))
+ val = pot;
+ }
+ }
+
+ psh_mod_fnct psh_mod_fn(b, e, val);
+ const double psh_mod_res = timing_test_base::operator()(psh_mod_fn);
+
+ const double min_res = double(timing_test_base::min_time_res());
+ const double effective_delta = std::max(psh_mod_res - psh_res,
+ min_res);
+
+ res_set_fmt.add_res(v, effective_delta / v);
+ }
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/priority_queue/timing/push_pop_test.hpp b/libstdc++-v3/testsuite/util/performance/priority_queue/timing/push_pop_test.hpp
new file mode 100644
index 000000000..d3a9a736e
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/priority_queue/timing/push_pop_test.hpp
@@ -0,0 +1,141 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file push_pop_test.hpp
+ * Contains a push performance test.
+ */
+
+#ifndef PB_DS_PUSH_TEST_HPP
+#define PB_DS_PUSH_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/priority_queue/string_form.hpp>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename It, class Cntnr>
+ class push_pop_push_pop_functor
+ {
+ public:
+ push_pop_push_pop_functor(It ins_it_b, It ins_it_e)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr cntnr;
+ for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ cntnr.push((typename Cntnr::const_reference)(ins_it->first));
+ while (!cntnr.empty())
+ cntnr.pop();
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ };
+
+ } // namespace detail
+
+ template<typename It>
+ class push_pop_test : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ push_pop_test(It ins_b, size_t ins_vn, size_t ins_vs, size_t ins_vm)
+ : m_ins_b(ins_b), m_ins_vn(ins_vn), m_ins_vs(ins_vs), m_ins_vm(ins_vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ push_pop_test(const push_pop_test&);
+
+ template<typename Cntnr>
+ void
+ push(Cntnr, It ins_it_b, It ins_it_e)
+ {
+ Cntnr cntnr;
+ for (It ins_it = ins_it_b; ins_it != ins_it_e; ++ins_it)
+ cntnr.push((typename Cntnr::const_reference)(*ins_it));
+ }
+
+ const It m_ins_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ };
+
+
+ template<typename It>
+ template<typename Cntnr>
+ void
+ push_pop_test<It>::
+ operator()(Cntnr)
+ {
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t i = 0; m_ins_vn + i * m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t v = m_ins_vn + i * m_ins_vs;
+ It ins_it_b = m_ins_b;
+ It ins_it_e = m_ins_b;
+ std::advance(ins_it_e, v);
+
+ __gnu_pbds::test::detail::push_pop_push_pop_functor<It, Cntnr>
+ fn(ins_it_b, ins_it_e);
+
+ const double res =
+ __gnu_pbds::test::detail::timing_test_base::operator()(fn);
+
+ res_set_fmt.add_res(v, res / v);
+ }
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/priority_queue/timing/push_test.hpp b/libstdc++-v3/testsuite/util/performance/priority_queue/timing/push_test.hpp
new file mode 100644
index 000000000..b398a7549
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/priority_queue/timing/push_test.hpp
@@ -0,0 +1,144 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file push_test.hpp
+ * Contains a push performance test.
+ */
+
+#ifndef PB_DS_PUSH_TEST_HPP
+#define PB_DS_PUSH_TEST_HPP
+
+#include <performance/time/timing_test_base.hpp>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <performance/io/xml_formatter.hpp>
+#include <common_type/priority_queue/string_form.hpp>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename It, class Cntnr>
+ class push_push_functor
+ {
+ public:
+ push_push_functor(It ins_it_b, It ins_it_e)
+ : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e)
+ { }
+
+ void
+ operator()(std::size_t resolution)
+ {
+ for (std::size_t i = 0; i < resolution; ++i)
+ {
+ Cntnr cntnr;
+ for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+ cntnr.push((typename Cntnr::const_reference)(ins_it->first));
+ }
+ }
+
+ private:
+ const It m_ins_it_b;
+ const It m_ins_it_e;
+ };
+ } // namespace detail
+
+ template<typename It>
+ class push_test : private __gnu_pbds::test::detail::timing_test_base
+ {
+ public:
+ push_test(It ins_b, size_t ins_vn, size_t ins_vs, size_t ins_vm)
+ : m_ins_b(ins_b), m_ins_vn(ins_vn), m_ins_vs(ins_vs), m_ins_vm(ins_vm)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr);
+
+ private:
+ push_test(const push_test& );
+
+ template<typename Cntnr>
+ void
+ push(Cntnr, It ins_it_b, It ins_it_e);
+
+ const It m_ins_b;
+ const size_t m_ins_vn;
+ const size_t m_ins_vs;
+ const size_t m_ins_vm;
+ };
+
+
+ template<typename It>
+ template<typename Cntnr>
+ void
+ push_test<It>::
+ operator()(Cntnr)
+ {
+ typedef xml_result_set_performance_formatter formatter_type;
+ formatter_type res_set_fmt(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ for (size_t i = 0; m_ins_vn + i * m_ins_vs < m_ins_vm; ++i)
+ {
+ const size_t v = m_ins_vn + i * m_ins_vs;
+ It ins_it_b = m_ins_b;
+ It ins_it_e = m_ins_b;
+ std::advance(ins_it_e, v);
+
+ __gnu_pbds::test::detail::push_push_functor<It, Cntnr>
+ fn(ins_it_b, ins_it_e);
+
+ const double res =
+ __gnu_pbds::test::detail::timing_test_base::operator()(fn);
+
+ res_set_fmt.add_res(v, res / v);
+ }
+ }
+
+ template<typename It>
+ template<typename Cntnr>
+ void
+ push_test<It>::
+ push(Cntnr, It ins_it_b, It ins_it_e)
+ {
+ Cntnr cntnr;
+ for (It ins_it = ins_it_b; ins_it != ins_it_e; ++ins_it)
+ cntnr.push((typename Cntnr::const_reference)(*ins_it));
+ }
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/performance/time/elapsed_timer.cc b/libstdc++-v3/testsuite/util/performance/time/elapsed_timer.cc
new file mode 100644
index 000000000..6b46402fe
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/time/elapsed_timer.cc
@@ -0,0 +1,68 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file elapsed_timer.cpp
+ * Contains utilities for tests.
+ */
+
+#include <util/performance/time/elapsed_timer.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ elapsed_timer::
+ elapsed_timer()
+ {
+ reset();
+ }
+
+ void
+ elapsed_timer::
+ reset()
+ {
+ m_start = ::clock();
+ }
+
+ elapsed_timer::
+ operator double() const
+ {
+ const clock_t now = ::clock();
+
+ return (((double)now - m_start) / CLOCKS_PER_SEC);
+ }
+
+ } // namespace test
+
+} // namespace __gnu_pbds
diff --git a/libstdc++-v3/testsuite/util/performance/time/elapsed_timer.hpp b/libstdc++-v3/testsuite/util/performance/time/elapsed_timer.hpp
new file mode 100644
index 000000000..5f7937b92
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/time/elapsed_timer.hpp
@@ -0,0 +1,67 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file elapsed_timer.hpp
+ * Contains time utilities for tests.
+ */
+
+#ifndef PB_DS_TEST_TIME_HPP
+#define PB_DS_TEST_TIME_HPP
+
+#include <time.h>
+#include <iosfwd>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ class elapsed_timer
+ {
+ public:
+ elapsed_timer();
+
+ void
+ reset();
+
+ operator double() const;
+
+ protected:
+ clock_t m_start;
+ };
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_TEST_TIME_HPP
diff --git a/libstdc++-v3/testsuite/util/performance/time/timing_test_base.hpp b/libstdc++-v3/testsuite/util/performance/time/timing_test_base.hpp
new file mode 100644
index 000000000..961583273
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/performance/time/timing_test_base.hpp
@@ -0,0 +1,117 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file timing_test_base.hpp
+ * Contains a base class for timing tests.
+ */
+
+#ifndef PB_DS_TIMING_TEST_BASE_HPP
+#define PB_DS_TIMING_TEST_BASE_HPP
+
+#include <performance/time/elapsed_timer.hpp>
+#include <statistic/result_recorder.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ class timing_test_base
+ {
+ protected:
+ template<typename Functor>
+ double
+ operator()(Functor& fn);
+
+ static double
+ min_time_res();
+
+ private:
+ template<typename Functor>
+ std::size_t
+ get_min_resolution(Functor&);
+
+ template<typename Functor>
+ double
+ run_at_resolution(Functor&, std::size_t);
+ };
+
+ template<typename Functor>
+ double
+ timing_test_base::operator()(Functor& fn)
+ {
+ const std::size_t resolution = get_min_resolution(fn);
+ __gnu_pbds::test::detail::result_recorder<double> rec;
+ double res;
+ do
+ res = run_at_resolution(fn, resolution);
+ while (rec.add_result(res) == false);
+ res = rec.get_sample_mean() / resolution;
+ return res;
+ }
+
+ double
+ timing_test_base::min_time_res()
+ { return 1e-7; }
+
+ template<typename Functor>
+ std::size_t
+ timing_test_base::get_min_resolution(Functor& fn)
+ {
+ std::size_t guess = 0;
+ const double epsilon_val = min_time_res();
+ double res;
+ do
+ {
+ guess = guess * 2 + 1;
+ res = run_at_resolution(fn, guess);
+ }
+ while (res < epsilon_val);
+ return guess;
+ }
+
+ template<typename Functor>
+ double
+ timing_test_base::run_at_resolution(Functor& fn, std::size_t resolution)
+ {
+ elapsed_timer res;
+ fn(resolution);
+ return res;
+ }
+
+ } // namespace detail
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/regression/basic_type.hpp b/libstdc++-v3/testsuite/util/regression/basic_type.hpp
new file mode 100644
index 000000000..9fe6ef24d
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/basic_type.hpp
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file basic_type.hpp
+ * Contains a type used for regression tests' key and data.
+ */
+
+#ifndef PB_DS_BASIC_TYPE_HPP
+#define PB_DS_BASIC_TYPE_HPP
+
+#include <string>
+#include <ext/throw_allocator.h>
+
+namespace __gnu_pbds
+{
+namespace test
+{
+#define PB_DS_BASE_C_DEC \
+ std::basic_string<char, std::char_traits<char>, \
+ __gnu_cxx::throw_allocator_random<char> >
+
+ struct basic_type : public PB_DS_BASE_C_DEC
+ {
+ private:
+ typedef PB_DS_BASE_C_DEC base_type;
+
+ public:
+ enum
+ {
+ distinct_chars = 4
+ };
+
+ basic_type() { }
+
+ template<typename Gen>
+ basic_type(Gen& r_gen, size_t max)
+ {
+ size_t rnd = r_gen.get_unsigned_long(0, static_cast<unsigned long>(max));
+ while (rnd > 0)
+ {
+ base_type::push_back('a' + static_cast<char>(rnd % distinct_chars));
+ rnd /= distinct_chars;
+ }
+ }
+
+ basic_type(const std::string other)
+ {
+ std::string::const_iterator it = other.begin();
+ while (it != other.end())
+ {
+ base_type::push_back(*it);
+ ++it;
+ }
+ }
+
+ operator std::string() const
+ { return std::string(base_type::c_str());}
+ };
+
+#undef PB_DS_BASE_C_DEC
+
+} // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/regression/common_type.hpp b/libstdc++-v3/testsuite/util/regression/common_type.hpp
new file mode 100644
index 000000000..37705bc2d
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/common_type.hpp
@@ -0,0 +1,194 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file common_type.hpp
+ * Contains types used for regression tests.
+ */
+
+#ifndef PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP
+#define PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP
+
+#include <vector>
+#include <regression/basic_type.hpp>
+#include <common_type/assoc/common_type.hpp>
+#include <common_type/priority_queue/common_type.hpp>
+
+namespace __gnu_pbds
+{
+namespace test
+{
+ typedef __gnu_cxx::throw_allocator_random<basic_type> alloc_type;
+
+ struct hash
+ {
+ typedef alloc_type::rebind<basic_type>::other basic_type_rebind;
+ typedef basic_type_rebind::const_reference const_reference;
+ typedef basic_type::const_iterator const_iterator;
+
+ size_t
+ operator()(const_reference r_key) const
+ {
+ size_t ret = 0;
+ for (const_iterator it = r_key.begin(); it != r_key.end(); ++it)
+ ret = ret * 5 + static_cast<size_t>(*it);
+ return ret;
+ }
+ };
+
+ typedef __gnu_pbds::string_trie_e_access_traits<basic_type, 'a', 'a' + basic_type::distinct_chars - 1, false, alloc_type> e_access_traits_t;
+
+ template<typename Data_Type>
+ struct tree_types
+ {
+ private:
+ typedef typename tree_common_types<basic_type, Data_Type, std::less<basic_type>, __gnu_pbds::null_tree_node_update, alloc_type>::regression_tl no_order_statistics_tl_t;
+
+ typedef typename tree_common_types<basic_type, Data_Type, std::less<basic_type>, __gnu_pbds::tree_order_statistics_node_update, alloc_type>::regression_tl order_statistics_tl_t;
+
+ public:
+ typedef typename __gnu_cxx::typelist::append<no_order_statistics_tl_t, order_statistics_tl_t>::type tl_t;
+
+ typedef no_order_statistics_tl_t min_tl_t;
+ };
+
+ template<typename Data_Type>
+ struct trie_types
+ {
+ private:
+ typedef typename trie_common_types<basic_type, Data_Type, e_access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::null_trie_node_update, alloc_type>::regression_tl no_updates_tl_t;
+
+ typedef typename trie_common_types<basic_type, Data_Type, e_access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::trie_order_statistics_node_update, alloc_type>::regression_tl order_statistics_tl_t;
+
+ typedef typename trie_common_types<basic_type, Data_Type, e_access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::trie_prefix_search_node_update, alloc_type>::regression_tl prefix_search_tl_t;
+
+ public:
+ typedef typename __gnu_cxx::typelist::append<no_updates_tl_t, typename __gnu_cxx::typelist::append<prefix_search_tl_t, order_statistics_tl_t>::type>::type tl_t;
+
+ typedef no_updates_tl_t min_tl_t;
+ };
+
+ template<typename Data_Type>
+ struct hash_types
+ {
+ typedef typename hash_common_types<basic_type, Data_Type, hash, std::equal_to<basic_type>, alloc_type>::regression_tl tl_t;
+
+ typedef tl_t min_tl_t;
+ };
+
+ template<typename Data_Type>
+ struct lu_types
+ {
+ typedef typename lu_common_types<basic_type, Data_Type, std::equal_to<basic_type>, alloc_type>::regression_tl tl_t;
+
+ typedef tl_t min_tl_t;
+ };
+
+ // Sequence types.
+ typedef pq_common_types<basic_type, std::less<basic_type>, alloc_type> pq_types;
+
+ typedef pq_types::regression_tl pq_tl_t;
+ typedef pq_tl_t min_pq_tl_t;
+
+ template<typename _Tp, typename _Alloc>
+ struct vector_adaptor : public std::vector<_Tp, _Alloc>
+ {
+ private:
+ typedef std::vector<_Tp, _Alloc> base_type;
+
+ public:
+ typedef typename base_type::value_type value_type;
+ typedef typename base_type::pointer pointer;
+ typedef typename base_type::const_pointer const_pointer;
+ typedef typename base_type::reference reference;
+ typedef typename base_type::const_reference const_reference;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef typename base_type::reverse_iterator reverse_iterator;
+ typedef typename base_type::const_reverse_iterator const_reverse_iterator;
+ typedef typename base_type::size_type size_type;
+ typedef typename base_type::difference_type difference_type;
+ typedef typename base_type::allocator_type allocator_type;
+
+ typedef __gnu_pbds::sequence_tag container_category;
+ typedef std::less<_Tp> cmp_fn;
+
+ const cmp_fn&
+ get_cmp_fn() const
+ { return _M_cmp; }
+
+ vector_adaptor() { }
+ vector_adaptor(iterator) { }
+ vector_adaptor(iterator, iterator) { }
+ vector_adaptor(iterator, iterator, const cmp_fn&) { }
+ vector_adaptor(const cmp_fn& other) { }
+
+ using base_type::push_back;
+ using base_type::pop_back;
+
+ // erase_if
+
+ cmp_fn _M_cmp;
+
+ };
+
+ namespace detail
+ {
+
+ };
+
+ typedef vector_adaptor<basic_type, alloc_type> vector_type;
+ typedef __gnu_cxx::typelist::create1<vector_type>::type vector_tl_t;
+
+ // Associative types.
+ typedef tree_types<null_mapped_type>::tl_t tree_set_tl_t;
+ typedef tree_types<null_mapped_type>::min_tl_t min_tree_set_tl_t;
+ typedef tree_types<basic_type>::tl_t tree_map_tl_t;
+ typedef tree_types<basic_type>::min_tl_t min_tree_map_tl_t;
+
+ typedef hash_types<null_mapped_type>::tl_t hash_set_tl_t;
+ typedef hash_types<null_mapped_type>::min_tl_t min_hash_set_tl_t;
+ typedef hash_types<basic_type>::tl_t hash_map_tl_t;
+ typedef hash_types<basic_type>::min_tl_t min_hash_map_tl_t;
+
+ typedef lu_types<null_mapped_type>::tl_t lu_set_tl_t;
+ typedef lu_types<null_mapped_type>::min_tl_t min_lu_set_tl_t;
+ typedef lu_types<basic_type>::tl_t lu_map_tl_t;
+ typedef lu_types<basic_type>::min_tl_t min_lu_map_tl_t;
+
+ typedef trie_types<null_mapped_type>::tl_t trie_set_tl_t;
+ typedef trie_types<null_mapped_type>::min_tl_t min_trie_set_tl_t;
+ typedef trie_types<basic_type>::tl_t trie_map_tl_t;
+ typedef trie_types<basic_type>::min_tl_t min_trie_map_tl_t;
+} // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.h b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.h
new file mode 100644
index 000000000..ca4433212
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.h
@@ -0,0 +1,475 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file container_rand_regression_test.h
+ * Contains a random regression test for a specific container type.
+ */
+
+#ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_H
+#define PB_DS_CONTAINER_RAND_REGRESSION_TEST_H
+
+#include <algorithm>
+#include <string>
+#include <sstream>
+#include <utility>
+#include <ext/pb_ds/assoc_container.hpp>
+#include <io/prog_bar.hpp>
+#include <testsuite_rng.h>
+#include <regression/trait/assoc/trait.hpp>
+#include <common_type/assoc/string_form.hpp>
+#include <regression/rand/xml_formatter.hpp>
+
+namespace __gnu_pbds
+{
+namespace test
+{
+namespace detail
+{
+ // Rand test specialized for a specific container.
+ template<typename Cntnr>
+ class container_rand_regression_test
+ {
+ public:
+
+ container_rand_regression_test(unsigned long, size_t, size_t, double,
+ double, double, double, double, bool);
+
+ virtual
+ ~container_rand_regression_test();
+
+ void
+ operator()();
+
+ private:
+ typedef Cntnr cntnr;
+ typedef typename cntnr::allocator_type allocator_type;
+ typedef typename cntnr::size_type size_type;
+ typedef regression_test_traits<Cntnr> test_traits;
+ typedef typename test_traits::key_type key_type;
+ typedef typename test_traits::const_key_reference const_key_reference;
+ typedef typename test_traits::value_type value_type;
+ typedef typename test_traits::native_type native_type;
+ typedef twister_rand_gen gen;
+ typedef __gnu_pbds::container_traits<Cntnr> container_traits;
+ typedef __gnu_cxx::throw_allocator_random<char> alloc_t;
+
+ enum op
+ {
+ insert_op,
+ erase_op,
+ clear_op,
+ other_op
+ };
+
+ op
+ get_next_op();
+
+ size_t
+ get_next_sub_op(size_t);
+
+ static void
+ defs();
+
+ static void
+ key_defs();
+
+ static void
+ mapped_defs();
+
+ static void
+ value_defs();
+
+ static void
+ ds_defs();
+
+ static void
+ iterator_defs();
+
+ static void
+ node_iterator_defs(__gnu_pbds::detail::false_type);
+
+ static void
+ node_iterator_defs(__gnu_pbds::detail::true_type);
+
+ static void
+ policy_defs();
+
+ static void
+ policy_defs(__gnu_pbds::basic_hash_tag);
+
+ static void
+ policy_defs(__gnu_pbds::cc_hash_tag);
+
+ static void
+ policy_defs(__gnu_pbds::gp_hash_tag);
+
+ static void
+ policy_defs(__gnu_pbds::tree_tag);
+
+ static void
+ policy_defs(__gnu_pbds::list_update_tag);
+
+ static void
+ policy_defs(__gnu_pbds::pat_trie_tag);
+
+ void
+ policy_access();
+
+ void
+ policy_access(__gnu_pbds::basic_hash_tag);
+
+ void
+ policy_access(__gnu_pbds::cc_hash_tag);
+
+ void
+ policy_access(__gnu_pbds::gp_hash_tag);
+
+ void
+ policy_access(__gnu_pbds::tree_tag);
+
+ void
+ policy_access(__gnu_pbds::list_update_tag);
+
+ void
+ policy_access(__gnu_pbds::pat_trie_tag);
+
+ void
+ it_copy();
+
+ void
+ it_assign();
+
+ void
+ rev_it_copy();
+
+ void
+ rev_it_assign();
+
+ void
+ rev_it_copy_imp(__gnu_pbds::detail::false_type);
+
+ void
+ rev_it_copy_imp(__gnu_pbds::detail::true_type);
+
+ void
+ rev_it_assign_imp(__gnu_pbds::detail::false_type);
+
+ void
+ rev_it_assign_imp(__gnu_pbds::detail::true_type);
+
+ bool
+ default_constructor();
+
+ void
+ swap();
+
+ bool
+ copy_constructor();
+
+ bool
+ assignment_operator();
+
+ bool
+ it_constructor();
+
+ bool
+ it_constructor_imp(__gnu_pbds::cc_hash_tag);
+
+ bool
+ it_constructor_imp(__gnu_pbds::gp_hash_tag);
+
+ bool
+ it_constructor_imp(__gnu_pbds::tree_tag);
+
+ bool
+ it_constructor_imp(__gnu_pbds::list_update_tag);
+
+ bool
+ it_constructor_imp(__gnu_pbds::pat_trie_tag);
+
+ bool
+ insert();
+
+ bool
+ erase();
+
+ bool
+ erase_it();
+
+ bool
+ erase_it_imp(__gnu_pbds::detail::false_type);
+
+ bool
+ erase_it_imp(__gnu_pbds::detail::true_type);
+
+ bool
+ erase_rev_it();
+
+ bool
+ erase_rev_it_imp(__gnu_pbds::detail::false_type);
+
+ bool
+ erase_rev_it_imp(__gnu_pbds::detail::true_type);
+
+ bool
+ erase_if();
+
+ bool
+ clear();
+
+ bool
+ resize();
+
+ bool
+ resize_imp(__gnu_pbds::detail::true_type);
+
+ bool
+ resize_imp(__gnu_pbds::detail::false_type);
+
+ bool
+ get_set_loads();
+
+ bool
+ get_set_loads_imp(__gnu_pbds::detail::true_type);
+
+ bool
+ get_set_loads_imp(__gnu_pbds::detail::false_type);
+
+ void
+ get_set_load();
+
+ void
+ get_set_load_imp(__gnu_pbds::detail::true_type);
+
+ void
+ get_set_load_imp(__gnu_pbds::detail::false_type);
+
+ bool
+ subscript();
+
+ bool
+ subscript_imp(__gnu_pbds::detail::false_type);
+
+ bool
+ subscript_imp(__gnu_pbds::detail::true_type);
+
+ bool
+ split_join();
+
+ bool
+ split_join_imp(__gnu_pbds::detail::false_type);
+
+ bool
+ split_join_imp(__gnu_pbds::detail::true_type);
+
+ void
+ cmp(const Cntnr&, const native_type&, const std::string&);
+
+ void
+ basic_cmp_(const Cntnr&, const native_type&);
+
+ void
+ cmp_(const Cntnr&, const native_type&);
+
+ void
+ order_preserving_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::false_type);
+
+ void
+ order_preserving_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::true_type);
+
+ void
+ back_order_preserving_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::false_type);
+
+ void
+ back_order_preserving_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::true_type);
+
+ void
+ reverse_iteration_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::false_type);
+
+ void
+ reverse_iteration_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::true_type);
+
+ void
+ order_statistics_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::false_type);
+
+ void
+ order_statistics_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::true_type);
+
+ void
+ prefix_search_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::false_type);
+
+ void
+ prefix_search_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::true_type);
+
+ template<typename Const_It, class Const_Native_It>
+ void
+ it_cmp_imp(Const_It, Const_It, Const_Native_It, Const_Native_It);
+
+ template<typename Const_It, class Const_Native_It>
+ void
+ back_it_cmp_imp(Const_It, Const_It, Const_Native_It, Const_Native_It);
+
+ void
+ lower_bound_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::false_type);
+
+ void
+ lower_bound_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::true_type);
+
+ void
+ upper_bound_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::false_type);
+
+ void
+ upper_bound_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::true_type);
+
+ void
+ print_container(const native_type&, std::ostream& r_os = std::cerr) const;
+
+ void
+ print_container(const cntnr&, std::ostream& r_os = std::cerr) const;
+
+ struct destructor_printer
+ {
+ destructor_printer(const std::string& r_msg)
+ : m_msg(r_msg), m_print(true) { }
+
+ void
+ cancel_print()
+ { m_print = false; }
+
+ ~destructor_printer()
+ {
+ if (!m_print)
+ return;
+
+ std::cerr << std::endl << "Uncaught exception: " << std::endl
+ << m_msg << std::endl;
+ }
+
+ private:
+ const std::string m_msg;
+ bool m_print;
+ };
+
+ const unsigned long m_seed;
+ const size_t m_n;
+ const size_t m_m;
+ const double m_tp;
+ const double m_ip;
+ const double m_ep;
+ const double m_cp;
+ const double m_mp;
+ const bool m_disp;
+ twister_rand_gen m_g;
+ Cntnr* m_p_c;
+ native_type m_native_c;
+ alloc_t m_alloc;
+ size_t m_i;
+ };
+
+#ifdef PB_DS_REGRESSION_TRACE
+#define PB_DS_TRACE(X) std::cerr << X << std::endl
+#else
+#define PB_DS_TRACE(X)
+#endif
+
+#define PB_DS_CLASS_T_DEC \
+ template<typename Cntnr>
+
+#define PB_DS_CLASS_C_DEC \
+ container_rand_regression_test<Cntnr>
+
+#define PB_DS_COND_COMPARE(L, R) \
+ if (m_g.get_prob() < m_mp) \
+ cmp(L, R, __FUNCTION__);
+
+#define PB_DS_RUN_MTHD(MTHD) \
+ { \
+ bool done = false; \
+ \
+ while (!done) \
+ done = MTHD(); \
+ }
+
+#define PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, F, L) \
+ if (!(PRED)) \
+ { \
+ std::cerr << "Failure at " << F << ": " << L << std::endl; \
+ std::cerr << MORE << std::endl; \
+ std::cerr << "container:" << std::endl; \
+ print_container(*(P_C)); \
+ std::cerr << std::endl; \
+ std::cerr << "native container:" << std::endl; \
+ print_container(*(P_NC)); \
+ std::cerr << std::endl; \
+ throw std::logic_error("fucked!"); \
+ }
+
+#define PB_DS_THROW_IF_FAILED(PRED, MORE, P_C, P_NC) \
+ PB_DS_THROW_IF_FAILED_(PRED, MORE, P_C, P_NC, __FILE__, __LINE__)
+
+#define PB_DS_SET_DESTRUCT_PRINT \
+ destructor_printer dest_print___(__FUNCTION__);
+
+#define PB_DS_CANCEL_DESTRUCT_PRINT \
+ dest_print___.cancel_print();
+
+#include <regression/rand/assoc/container_rand_regression_test.tcc>
+
+#undef PB_DS_COND_COMPARE
+#undef PB_DS_RUN_MTHD
+#undef PB_DS_CLASS_T_DEC
+#undef PB_DS_CLASS_C_DEC
+#undef PB_DS_THROW_IF_FAILED_
+#undef PB_DS_THROW_IF_FAILED
+#undef PB_DS_SET_DESTRUCT_PRINT
+#undef PB_DS_CANCEL_DESTRUCT_PRINT
+#undef PB_DS_TRACE
+
+} // namespace detail
+} // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.tcc b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.tcc
new file mode 100644
index 000000000..0f1586648
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/container_rand_regression_test.tcc
@@ -0,0 +1,2133 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file container_rand_regression_test.tcc
+ * Contains a random regression test for a specific container type.
+ */
+
+#ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC
+#define PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC
+
+// Constructors/Destructors.
+PB_DS_CLASS_T_DEC
+PB_DS_CLASS_C_DEC::
+container_rand_regression_test(unsigned long seed, size_t n, size_t m,
+ double tp, double ip, double ep, double cp,
+ double mp, bool disp)
+: m_seed((seed == 0) ? twister_rand_gen::get_time_determined_seed() : seed),
+ m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_ep(ep), m_cp(cp), m_mp(mp),
+ m_disp(disp), m_p_c(0)
+{ }
+
+PB_DS_CLASS_T_DEC
+PB_DS_CLASS_C_DEC::
+~container_rand_regression_test()
+{ }
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+default_constructor()
+{
+ PB_DS_TRACE("default_constructor");
+ bool done = true;
+ m_alloc.set_probability(m_tp);
+
+ try
+ {
+ m_p_c = new Cntnr;
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ if (m_p_c)
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+swap()
+{
+ PB_DS_TRACE("swap");
+ m_alloc.set_probability(0);
+ Cntnr* p_c = new Cntnr;
+ m_alloc.set_probability(1);
+ p_c->swap(*m_p_c);
+ std::swap(p_c, m_p_c);
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+copy_constructor()
+{
+ PB_DS_TRACE("copy_constructor");
+ bool done = true;
+ Cntnr* p_c = 0;
+ m_alloc.set_probability(m_tp);
+ typename alloc_t::group_adjustor adjust(m_p_c->size());
+
+ try
+ {
+ p_c = new Cntnr(*m_p_c);
+ std::swap(p_c, m_p_c);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+assignment_operator()
+{
+ PB_DS_TRACE("assignment operator");
+ bool done = true;
+ Cntnr* p_c = 0;
+ m_alloc.set_probability(m_tp);
+ typename alloc_t::group_adjustor adjust(m_p_c->size());
+
+ try
+ {
+ p_c = new Cntnr();
+ * p_c =* m_p_c;
+ std::swap(p_c, m_p_c);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+it_constructor()
+{
+ PB_DS_TRACE("it_constructor");
+ return it_constructor_imp(typename Cntnr::container_category());
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+it_constructor_imp(__gnu_pbds::cc_hash_tag)
+{
+ bool done = true;
+ Cntnr* p_c = 0;
+ m_alloc.set_probability(m_tp);
+ typename alloc_t::group_adjustor adjust(m_p_c->size());
+
+ try
+ {
+ switch(get_next_sub_op(8))
+ {
+ case 0:
+ p_c = new Cntnr(m_p_c->get_hash_fn());
+ m_native_c.clear();
+ break;
+ case 1:
+ p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn());
+ m_native_c.clear();
+ break;
+ case 2:
+ p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
+ m_p_c->get_comb_hash_fn());
+ m_native_c.clear();
+ break;
+ case 3:
+ p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
+ m_p_c->get_comb_hash_fn(),
+ m_p_c->get_resize_policy());
+ m_native_c.clear();
+ break;
+ case 4:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end());
+ break;
+ case 5:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn());
+ break;
+ case 6:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
+ m_p_c->get_eq_fn());
+ break;
+ case 7:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
+ m_p_c->get_eq_fn(), m_p_c->get_comb_hash_fn());
+ break;
+ case 8:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
+ m_p_c->get_eq_fn(), m_p_c->get_comb_hash_fn(),
+ m_p_c->get_resize_policy());
+ break;
+ default:
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
+ };
+ std::swap(p_c, m_p_c);
+ }
+ catch (__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+it_constructor_imp(__gnu_pbds::gp_hash_tag)
+{
+ bool done = true;
+ Cntnr* p_c = 0;
+ m_alloc.set_probability(m_tp);
+ typename alloc_t::group_adjustor adjust(m_p_c->size());
+
+ try
+ {
+ switch(get_next_sub_op(11))
+ {
+ case 0:
+ p_c = new Cntnr(m_p_c->get_hash_fn());
+ m_native_c.clear();
+ break;
+ case 1:
+ p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn());
+ m_native_c.clear();
+ break;
+ case 2:
+ p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
+ m_p_c->get_comb_probe_fn());
+ m_native_c.clear();
+ break;
+ case 3:
+ p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
+ m_p_c->get_comb_probe_fn());
+ m_native_c.clear();
+ break;
+ case 4:
+ p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
+ m_p_c->get_comb_probe_fn(), m_p_c->get_probe_fn());
+ m_native_c.clear();
+ break;
+ case 5:
+ p_c = new Cntnr(m_p_c->get_hash_fn(), m_p_c->get_eq_fn(),
+ m_p_c->get_comb_probe_fn(), m_p_c->get_probe_fn(),
+ m_p_c->get_resize_policy());
+ m_native_c.clear();
+ break;
+ case 6:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn());
+ break;
+ case 7:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
+ m_p_c->get_eq_fn());
+ break;
+ case 8:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
+ m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn());
+ break;
+ case 9:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
+ m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn());
+ break;
+ case 10:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
+ m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn(),
+ m_p_c->get_probe_fn());
+ break;
+ case 11:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_hash_fn(),
+ m_p_c->get_eq_fn(), m_p_c->get_comb_probe_fn(),
+ m_p_c->get_probe_fn(), m_p_c->get_resize_policy());
+ break;
+ default:
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
+ };
+ std::swap(p_c, m_p_c);
+ }
+ catch (__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+it_constructor_imp(__gnu_pbds::tree_tag)
+{
+ bool done = true;
+ Cntnr* p_c = 0;
+ m_alloc.set_probability(m_tp);
+ typename alloc_t::group_adjustor adjust(m_p_c->size());
+
+ try
+ {
+ switch(get_next_sub_op(2))
+ {
+ case 0:
+ p_c = new Cntnr(m_p_c->get_cmp_fn());
+ m_native_c.clear();
+ break;
+ case 1:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_cmp_fn());
+ break;
+ default:
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
+ };
+ std::swap(p_c, m_p_c);
+ }
+ catch (__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+it_constructor_imp(__gnu_pbds::list_update_tag)
+{
+ bool done = true;
+ Cntnr* p_c = 0;
+ m_alloc.set_probability(m_tp);
+ typename alloc_t::group_adjustor adjust(m_p_c->size());
+
+ try
+ {
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end());
+ std::swap(p_c, m_p_c);
+ }
+ catch (__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+it_constructor_imp(__gnu_pbds::pat_trie_tag)
+{
+ bool done = true;
+ Cntnr* p_c = 0;
+ m_alloc.set_probability(m_tp);
+ typename alloc_t::group_adjustor adjust(m_p_c->size());
+
+ try
+ {
+ switch(get_next_sub_op(2))
+ {
+ case 0:
+ p_c = new Cntnr(m_p_c->get_e_access_traits());
+ m_native_c.clear();
+ break;
+ case 1:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(),
+ m_p_c->get_e_access_traits());
+ break;
+ default:
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
+ };
+
+ std::swap(p_c, m_p_c);
+ }
+ catch (__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ return done;
+}
+
+// Cmp.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+cmp(const Cntnr& r_c, const native_type& r_native_c,
+ const std::string& r_call_fn)
+{
+ m_alloc.set_probability(1);
+ const size_t size = r_c.size();
+ const size_t native_size = r_native_c.size();
+ PB_DS_THROW_IF_FAILED(size == native_size,
+ size << " " << native_size, &r_c, &r_native_c);
+
+ const bool empty = r_c.empty();
+ const bool native_empty = r_native_c.empty();
+ PB_DS_THROW_IF_FAILED(empty == native_empty,
+ empty << " " << native_empty, &r_c, &r_native_c);
+
+ try
+ {
+ basic_cmp_(r_c, r_native_c);
+ cmp_(r_c, r_native_c);
+ }
+ catch(...)
+ {
+ PB_DS_THROW_IF_FAILED(false, "call-fn: " + r_call_fn, &r_c, &r_native_c);
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+basic_cmp_(const Cntnr& r_c, const native_type& r_native_c)
+{
+ PB_DS_SET_DESTRUCT_PRINT
+
+ if (static_cast<size_t>(std::distance(r_c.begin(), r_c.end())) != r_c.size())
+ PB_DS_THROW_IF_FAILED(false,
+ static_cast<unsigned long>(std::distance(r_c.begin(), r_c.end())) << " " << static_cast<unsigned long>(r_c.size()), &r_c, &r_native_c);
+
+ typename native_type::const_iterator it = r_native_c.begin();
+ while (it != r_native_c.end())
+ {
+ typename native_type::key_type native_key = test_traits::extract_native_key(*it);
+
+ m_alloc.set_probability(0);
+ const key_type k = native_key;
+ m_alloc.set_probability(1);
+ typename cntnr::const_point_iterator found_it = r_c.find(k);
+ PB_DS_THROW_IF_FAILED(found_it != r_c.end(),
+ test_traits::native_val_to_string(*it),
+ &r_c, &r_native_c);
+
+ if (!test_traits::cmp(*found_it, * it))
+ PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c);
+
+ ++it;
+ }
+ PB_DS_CANCEL_DESTRUCT_PRINT
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+cmp_(const Cntnr& r_c, const native_type& r_native_c)
+{
+ enum
+ {
+ order_preserving = container_traits::order_preserving,
+ back_order_preserving = container_traits::order_preserving
+ &&
+ !__gnu_pbds::detail::is_same<
+ typename std::iterator_traits<
+ typename cntnr::const_iterator>::iterator_category,
+ std::forward_iterator_tag>::value,
+ reverse_iteration = container_traits::reverse_iteration,
+ order_statistics = test_traits::order_statistics,
+ prefix_search = test_traits::prefix_search,
+ has_mapped = !__gnu_pbds::detail::is_same<
+ typename Cntnr::mapped_type,
+ __gnu_pbds::null_mapped_type>::value
+ };
+
+ order_preserving_cmp_imp(r_c, r_native_c,
+ __gnu_pbds::detail::integral_constant<int,order_preserving>());
+
+ back_order_preserving_cmp_imp(r_c, r_native_c,
+ __gnu_pbds::detail::integral_constant<int,back_order_preserving>());
+
+ order_statistics_cmp_imp(r_c, r_native_c,
+ __gnu_pbds::detail::integral_constant<int,order_statistics>());
+
+ prefix_search_cmp_imp(r_c, r_native_c,
+ __gnu_pbds::detail::integral_constant<int,prefix_search>());
+
+ reverse_iteration_cmp_imp(r_c, r_native_c,
+ __gnu_pbds::detail::integral_constant<int,reverse_iteration>());
+
+ lower_bound_cmp_imp(r_c, r_native_c,
+ __gnu_pbds::detail::integral_constant<int,order_preserving>());
+
+ upper_bound_cmp_imp(r_c, r_native_c,
+ __gnu_pbds::detail::integral_constant<int,order_preserving>());
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+order_preserving_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
+{
+ PB_DS_SET_DESTRUCT_PRINT
+
+ typename cntnr::const_iterator b = r_c.begin();
+ typename cntnr::const_iterator e = r_c.end();
+
+ typename native_type::const_iterator native_b = r_native_c.begin();
+ typename native_type::const_iterator native_e = r_native_c.end();
+
+ try
+ {
+ it_cmp_imp(b, e, native_b, native_e);
+ }
+ catch(...)
+ {
+ PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c)
+ }
+
+ try
+ {
+ back_it_cmp_imp(b, e, native_b, native_e);
+ }
+ catch(...)
+ {
+ PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c)
+ }
+
+ PB_DS_CANCEL_DESTRUCT_PRINT
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+back_order_preserving_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::false_type)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+back_order_preserving_cmp_imp(const Cntnr& r_c, const native_type& r_native_c,
+ __gnu_pbds::detail::true_type)
+{
+ PB_DS_SET_DESTRUCT_PRINT
+ typename cntnr::const_iterator b = r_c.begin();
+ typename cntnr::const_iterator e = r_c.end();
+ typename native_type::const_iterator native_b = r_native_c.begin();
+ typename native_type::const_iterator native_e = r_native_c.end();
+ it_cmp_imp(b, e, native_b, native_e);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+reverse_iteration_cmp_imp(const Cntnr&, const native_type&,
+ __gnu_pbds::detail::false_type)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+reverse_iteration_cmp_imp(const Cntnr& r_c, const native_type&r_native_c, __gnu_pbds::detail::true_type)
+{
+ PB_DS_SET_DESTRUCT_PRINT
+
+ typename cntnr::const_reverse_iterator b = r_c.rbegin();
+ typename cntnr::const_reverse_iterator e = r_c.rend();
+
+ typename native_type::const_reverse_iterator native_b = r_native_c.rbegin();
+ typename native_type::const_reverse_iterator native_e = r_native_c.rend();
+
+ try
+ {
+ it_cmp_imp(b, e, native_b, native_e);
+ }
+ catch(...)
+ {
+ PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c)
+ }
+
+ try
+ {
+ back_it_cmp_imp(b, e, native_b, native_e);
+ }
+ catch(...)
+ {
+ PB_DS_THROW_IF_FAILED(false, "", &r_c, &r_native_c)
+ }
+
+ PB_DS_CANCEL_DESTRUCT_PRINT
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+order_statistics_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+order_statistics_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
+{
+ {
+ m_alloc.set_probability(0);
+ const key_type k = test_traits::generate_key(m_g, m_m);
+ m_alloc.set_probability(1);
+ const size_type order = r_c.order_of_key(k);
+ const size_type native_order = std::distance(r_native_c.begin(),
+ r_native_c.lower_bound(test_traits::native_key(k)));
+
+ PB_DS_THROW_IF_FAILED(order == native_order,
+ test_traits::key_to_string(k) << " " <<
+ static_cast<unsigned long>(order) << " " <<
+ static_cast<unsigned long>(native_order),
+ &r_c,
+ &r_native_c);
+ }
+
+ const size_type rand_ord =
+ static_cast<size_t>(m_g.get_unsigned_long(0,
+ 2 * static_cast<unsigned long>(m_m)));
+
+ typename cntnr::const_iterator it = r_c.find_by_order(rand_ord);
+ typename native_type::const_iterator native_it = r_native_c.begin();
+ std::advance(native_it, std::min(rand_ord, r_native_c.size()));
+ if (it == r_c.end()&& native_it != r_native_c.end())
+ PB_DS_THROW_IF_FAILED(false,
+ static_cast<unsigned long>(rand_ord),
+ m_p_c,
+ &m_native_c);
+
+ if (it != r_c.end()&& native_it == r_native_c.end())
+ PB_DS_THROW_IF_FAILED(false,
+ static_cast<unsigned long>(rand_ord),
+ m_p_c,
+ &m_native_c);
+
+ if (it != r_c.end()&& native_it != r_native_c.end())
+ PB_DS_THROW_IF_FAILED(test_traits::cmp(*it, * native_it),
+ static_cast<unsigned long>(rand_ord),
+ m_p_c,
+ &m_native_c);
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+prefix_search_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+prefix_search_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
+{
+ PB_DS_SET_DESTRUCT_PRINT
+ m_alloc.set_probability(0);
+ const key_type k = test_traits::generate_key(m_g, m_m);
+ m_alloc.set_probability(1);
+ try
+ {
+ typedef
+ std::pair<typename Cntnr::const_iterator, typename Cntnr::const_iterator>
+ pref_ret_t;
+
+ const pref_ret_t pref_ret = r_c.prefix_range(k);
+
+ typename native_type::const_iterator native_start_it = r_native_c.begin();
+
+ while (native_start_it != r_native_c.end() &&
+ !test_traits::prefix_match(k,
+ test_traits::extract_native_key(*native_start_it)))
+ ++native_start_it;
+
+ typename native_type::const_iterator native_end_it =
+ native_start_it;
+
+ do
+ {
+ if (native_end_it != r_native_c.end())
+ ++native_end_it;
+ }
+ while (native_end_it != r_native_c.end() &&
+ test_traits::prefix_match(k,
+ test_traits::extract_native_key(*native_end_it)));
+
+ it_cmp_imp(pref_ret.first, pref_ret.second, native_start_it, native_end_it);
+ }
+ catch(...)
+ {
+ PB_DS_THROW_IF_FAILED(false, "prefix key " << k, &r_c, &r_native_c);
+ }
+
+ PB_DS_CANCEL_DESTRUCT_PRINT
+}
+
+PB_DS_CLASS_T_DEC
+template<typename Const_It, class Const_Native_It>
+void
+PB_DS_CLASS_C_DEC::
+it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b,
+ Const_Native_It native_e)
+{
+ PB_DS_SET_DESTRUCT_PRINT
+
+ if (std::distance(b, e) != std::distance(native_b, native_e))
+ {
+ const size_t dist = std::distance(b, e);
+ const size_t native_dist = std::distance(native_b, native_e);
+ PB_DS_THROW_IF_FAILED(false,
+ static_cast<unsigned long>(dist) << " "
+ << static_cast<unsigned long>(native_dist),
+ m_p_c, &m_native_c);
+ }
+
+ while (b != e)
+ {
+ PB_DS_THROW_IF_FAILED(native_b != native_e, "", m_p_c, &m_native_c);
+
+ if (!test_traits::cmp(*b, * native_b))
+ PB_DS_THROW_IF_FAILED(false,
+ test_traits::val_to_string(*b) << " " <<
+ test_traits::val_to_string(*native_b),
+ m_p_c, &m_native_c);
+
+ ++b;
+ ++native_b;
+ }
+
+ PB_DS_THROW_IF_FAILED(native_b == native_e, "", m_p_c, &m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+}
+
+PB_DS_CLASS_T_DEC
+template<typename Const_It, class Const_Native_It>
+void
+PB_DS_CLASS_C_DEC::
+back_it_cmp_imp(Const_It b, Const_It e, Const_Native_It native_b,
+ Const_Native_It native_e)
+{
+ PB_DS_SET_DESTRUCT_PRINT
+ while (b != e)
+ {
+ PB_DS_THROW_IF_FAILED(native_b != native_e,
+ test_traits::val_to_string(*native_e),
+ m_p_c, &m_native_c);
+
+ --e;
+ --native_e;
+
+ PB_DS_THROW_IF_FAILED(test_traits::cmp(*e, * native_e),
+ test_traits::val_to_string(*e) <<
+ test_traits::val_to_string(*native_e),
+ m_p_c, &m_native_c);
+ }
+
+ PB_DS_THROW_IF_FAILED(native_b == native_e,
+ test_traits::val_to_string(*native_e),
+ m_p_c, &m_native_c);
+
+ PB_DS_CANCEL_DESTRUCT_PRINT
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+lower_bound_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+lower_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
+{
+ PB_DS_SET_DESTRUCT_PRINT
+ m_alloc.set_probability(0);
+ const key_type k = test_traits::generate_key(m_g, m_m);
+ m_alloc.set_probability(1);
+ typename cntnr::const_iterator it = r_c.lower_bound(k);
+ typename native_type::key_type native_k = test_traits::native_key(k);
+ typename native_type::const_iterator native_it = r_native_c.lower_bound(native_k);
+
+ if (it != r_c.end() && native_it == r_native_c.end())
+ PB_DS_THROW_IF_FAILED("",
+ "it: " + test_traits::val_to_string(*it) + "\n\n",
+ &r_c, &r_native_c);
+
+ if (it == r_c.end() && native_it != r_native_c.end())
+ PB_DS_THROW_IF_FAILED("",
+ "native_it: " + test_traits::val_to_string(*native_it) + "\n\n",
+ &r_c, &r_native_c);
+
+ if (it != r_c.end() && !test_traits::cmp(*it, * native_it))
+ PB_DS_THROW_IF_FAILED(false,
+ "key: " + test_traits::key_to_string(k) + "\n\n" +
+ "it: " + test_traits::val_to_string(*it) + "\n\n" +
+ "native_it: " + test_traits::val_to_string(*native_it) + "\n\n",
+ &r_c, &r_native_c);
+
+ PB_DS_CANCEL_DESTRUCT_PRINT
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+upper_bound_cmp_imp(const Cntnr& /*r_c*/, const native_type& /*r_native_c*/, __gnu_pbds::detail::false_type)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+upper_bound_cmp_imp(const Cntnr& r_c, const native_type& r_native_c, __gnu_pbds::detail::true_type)
+{
+ PB_DS_SET_DESTRUCT_PRINT
+ m_alloc.set_probability(0);
+ const key_type k = test_traits::generate_key(m_g, m_m);
+ m_alloc.set_probability(1);
+ typename cntnr::const_iterator it = r_c.upper_bound(k);
+ typename native_type::key_type native_k = test_traits::native_key(k);
+ typename native_type::const_iterator native_it = r_native_c.upper_bound(native_k);
+
+ if (it == r_c.end() && native_it != r_native_c.end())
+ PB_DS_THROW_IF_FAILED(false,
+ "key: " + test_traits::key_to_string(k) + "\n\n" +
+ "native_it: " + test_traits::val_to_string(*native_it) + "\n\n",
+ &r_c, &r_native_c);
+
+ if (it != r_c.end() && native_it == r_native_c.end())
+ PB_DS_THROW_IF_FAILED(false,
+ "key: " + test_traits::key_to_string(k) + "\n\n" +
+ "it: " + test_traits::val_to_string(*it) + "\n\n",
+ &r_c, &r_native_c);
+
+ if (it != r_c.end() && !test_traits::cmp(*it, * native_it))
+ PB_DS_THROW_IF_FAILED(false,
+ "key: " + test_traits::key_to_string(k) + "\n\n" +
+ "it: " + test_traits::val_to_string(*it) + "\n\n" +
+ "native_it: " + test_traits::val_to_string(*native_it) + "\n\n",
+ &r_c, &r_native_c);
+
+ PB_DS_CANCEL_DESTRUCT_PRINT
+}
+
+// Operators.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+operator()()
+{
+ typedef xml_result_set_regression_formatter formatter_type;
+ formatter_type* p_fmt = 0;
+
+ if (m_disp)
+ p_fmt = new formatter_type(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ m_g.init(m_seed);
+
+ // Track allocation from this point only.
+ const size_t memory_label = 775;
+ m_alloc.seed(m_seed);
+ m_alloc.set_label(memory_label);
+
+ prog_bar pb(m_n, std::cout, m_disp);
+ m_i = 0;
+
+ try
+ {
+ for (m_i = 0; m_i < m_n; ++m_i)
+ {
+ PB_DS_TRACE("Op #" << static_cast<unsigned long>(m_i));
+ allocator_type::set_label(m_i);
+ switch (m_i)
+ {
+ case 0:
+ PB_DS_RUN_MTHD(default_constructor);
+ break;
+ case 1:
+ defs();
+ break;
+ case 2:
+ policy_access();
+ break;
+ case 3:
+ it_copy();
+ break;
+ case 4:
+ it_assign();
+ break;
+ case 5:
+ rev_it_copy();
+ break;
+ case 6:
+ rev_it_assign();
+ break;
+ default:
+ switch(get_next_op())
+ {
+ case insert_op:
+ switch(get_next_sub_op(2))
+ {
+ case 0:
+ PB_DS_RUN_MTHD(insert)
+ break;
+ case 1:
+ PB_DS_RUN_MTHD(subscript)
+ break;
+ default:
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
+ }
+ break;
+ case erase_op:
+ switch(get_next_sub_op(4))
+ {
+ case 0:
+ PB_DS_RUN_MTHD(erase)
+ break;
+ case 1:
+ PB_DS_RUN_MTHD(erase_if)
+ break;
+ case 2:
+ PB_DS_RUN_MTHD(erase_it)
+ break;
+ case 3:
+ PB_DS_RUN_MTHD(erase_rev_it)
+ break;
+ default:
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
+ }
+ break;
+ case clear_op:
+ PB_DS_RUN_MTHD(clear)
+ break;
+ case other_op:
+ switch(get_next_sub_op(8))
+ {
+ case 0:
+ swap();
+ break;
+ case 1:
+ PB_DS_RUN_MTHD(copy_constructor)
+ break;
+ case 2:
+ PB_DS_RUN_MTHD(it_constructor)
+ break;
+ case 3:
+ PB_DS_RUN_MTHD(assignment_operator)
+ break;
+ case 4:
+ PB_DS_RUN_MTHD(split_join)
+ break;
+ case 5:
+ resize();
+ break;
+ case 6:
+ get_set_load();
+ break;
+ case 7:
+ get_set_loads();
+ break;
+ default:
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
+ }
+ break;
+ default:
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
+ };
+ }
+
+ pb.inc();
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Failed at index " << static_cast<unsigned long>(m_i)
+ << std::endl;
+ delete m_p_c;
+ throw;
+ }
+
+ // Clean up, then check for allocation by special label, set above.
+ delete m_p_c;
+
+ try
+ { m_alloc.check_allocated(memory_label); }
+ catch (...)
+ {
+ std::cerr << "detected leaks!" << std::endl;
+ std::cerr << m_alloc << std::endl;
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
+ }
+
+ // Reset throw probability.
+ m_alloc.set_probability(0);
+
+ if (m_disp)
+ {
+ std::cout << std::endl;
+ delete p_fmt;
+ }
+}
+
+PB_DS_CLASS_T_DEC
+typename PB_DS_CLASS_C_DEC::op
+PB_DS_CLASS_C_DEC::
+get_next_op()
+{
+ const double prob = m_g.get_prob();
+ if (prob < m_ip)
+ return insert_op;
+
+ if (prob < m_ip + m_ep)
+ return erase_op;
+
+ if (prob < m_ip + m_ep + m_cp)
+ return clear_op;
+
+ PB_DS_THROW_IF_FAILED(prob <= 1, prob, m_p_c, &m_native_c);
+ return other_op;
+}
+
+PB_DS_CLASS_T_DEC
+size_t
+PB_DS_CLASS_C_DEC::
+get_next_sub_op(size_t max)
+{
+ const double p = m_g.get_prob();
+ const double delta = 1 / static_cast<double>(max);
+ size_t i = 0;
+ while (true)
+ if (p <= (i + 1) * delta)
+ {
+ PB_DS_THROW_IF_FAILED(i < max, i << " " << max, m_p_c, &m_native_c);
+ return i;
+ }
+ else
+ ++i;
+}
+
+// Insert.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+insert()
+{
+ PB_DS_TRACE("insert");
+ bool done = true;
+ PB_DS_SET_DESTRUCT_PRINT
+ try
+ {
+ m_alloc.set_probability(0);
+ value_type v = test_traits::generate_value(m_g, m_m);
+ m_alloc.set_probability(m_tp);
+ const_key_reference r_k = test_traits::extract_key(v);
+ typename cntnr::const_point_iterator found_it = m_p_c->find(r_k);
+ const bool existed = (found_it != m_p_c->end());
+ const std::pair<typename cntnr::point_iterator, bool> ins_ret = m_p_c->insert(v);
+
+ if (ins_ret.second)
+ {
+ PB_DS_THROW_IF_FAILED(!existed, "", m_p_c, &m_native_c);
+ }
+ else
+ {
+ PB_DS_THROW_IF_FAILED(existed, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(found_it == ins_ret.first, "", m_p_c, &m_native_c);
+ }
+ m_native_c.insert(test_traits::native_value(v));
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+ catch(__gnu_pbds::insert_error&)
+ {
+ PB_DS_THROW_IF_FAILED(false, "", m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+ return done;
+}
+
+// Subscript.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+subscript()
+{
+ PB_DS_TRACE("subscript");
+
+ enum
+ {
+ no_data = __gnu_pbds::detail::is_same<
+ typename Cntnr::const_key_reference,
+ typename Cntnr::const_reference>::value
+ };
+
+ return (subscript_imp(__gnu_pbds::detail::integral_constant<int,no_data>()));
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+subscript_imp(__gnu_pbds::detail::false_type)
+{
+ bool done = true;
+ PB_DS_SET_DESTRUCT_PRINT
+
+ try
+ {
+ m_alloc.set_probability(0);
+ value_type v = test_traits::generate_value(m_g, m_m);
+
+ m_alloc.set_probability(m_tp);
+ (*m_p_c)[v.first] = v.second;
+
+ m_native_c[test_traits::native_value(v).first] =
+ test_traits::native_value(v).second;
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+subscript_imp(__gnu_pbds::detail::true_type)
+{
+ bool done = true;
+ PB_DS_SET_DESTRUCT_PRINT
+ try
+ {
+ m_alloc.set_probability(0);
+ value_type v = test_traits::generate_value(m_g, m_m);
+ m_alloc.set_probability(m_tp);
+ (*m_p_c)[v] = __gnu_pbds::null_mapped_type();
+ m_native_c.insert(test_traits::native_value(v));
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+ return done;
+}
+
+// Clear.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+clear()
+{
+ m_p_c->clear();
+ m_native_c.clear();
+ return true;
+}
+
+
+// Erase.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+erase()
+{
+ PB_DS_TRACE("erase");
+ bool done = true;
+ PB_DS_SET_DESTRUCT_PRINT
+ m_alloc.set_probability(0);
+ const key_type k = test_traits::generate_key(m_g, m_m);
+ m_alloc.set_probability(m_tp);
+
+ try
+ {
+ const bool cntnd = m_p_c->find(k) != m_p_c->end();
+ PB_DS_THROW_IF_FAILED(cntnd ==(m_native_c.find(test_traits::native_key(k)) != m_native_c.end()), test_traits::key_to_string(k), m_p_c, &m_native_c);
+
+ const bool ersd = m_p_c->erase(k);
+ const bool native_ersd = m_native_c.erase(test_traits::native_key(k)) != 0;
+
+ PB_DS_THROW_IF_FAILED(ersd == native_ersd, ersd << " " << native_ersd,
+ m_p_c, &m_native_c);
+
+ PB_DS_THROW_IF_FAILED(m_p_c->find(k) == m_p_c->end(), "",
+ m_p_c, &m_native_c);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+
+ PB_DS_THROW_IF_FAILED( container_traits::erase_can_throw, container_traits::erase_can_throw, m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+erase_if()
+{
+ PB_DS_TRACE("erase_if");
+ bool done = true;
+ PB_DS_SET_DESTRUCT_PRINT
+
+ try
+ {
+ typedef
+ typename std::iterator_traits<typename cntnr::iterator>::reference
+ it_const_reference;
+
+ typedef
+ typename test_traits::template erase_if_fn<value_type>
+ erase_if_fn_t;
+
+ m_alloc.set_probability(m_tp);
+
+ const size_t ersd = m_p_c->erase_if(erase_if_fn_t());
+ const size_t native_ersd = test_traits::erase_if(m_native_c);
+ PB_DS_THROW_IF_FAILED(ersd == native_ersd,
+ ersd << " " << native_ersd, m_p_c, &m_native_c);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ PB_DS_THROW_IF_FAILED(container_traits::erase_can_throw,
+ container_traits::erase_can_throw,
+ m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+erase_it()
+{
+ enum
+ {
+ erase_iterators = container_traits::order_preserving
+ };
+
+ return (erase_it_imp(__gnu_pbds::detail::integral_constant<int,erase_iterators>()));
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+erase_it_imp(__gnu_pbds::detail::false_type)
+{
+ return true;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+erase_it_imp(__gnu_pbds::detail::true_type)
+{
+ PB_DS_TRACE("erase_it");
+ bool done = true;
+ PB_DS_SET_DESTRUCT_PRINT
+
+ try
+ {
+ m_alloc.set_probability(0);
+ const key_type k = test_traits::generate_key(m_g, m_m);
+ m_alloc.set_probability(m_tp);
+
+ typename cntnr::iterator found_it = m_p_c->find(k);
+
+ typename native_type::iterator native_it = m_native_c.find(test_traits::native_key(k));
+
+ const bool found = found_it != m_p_c->end();
+ const bool native_found = native_it != m_native_c.end();
+
+ PB_DS_THROW_IF_FAILED(
+ found == native_found,
+ found << " " << native_found,
+ m_p_c,
+ &m_native_c);
+
+ typename cntnr::const_iterator next_it = found_it;
+ if (next_it != m_p_c->end())
+ ++next_it;
+
+ typename cntnr::iterator next_ers_it = m_p_c->erase(found_it);
+
+ if (native_it != m_native_c.end())
+ m_native_c.erase(native_it);
+
+ bool range_guarantee = __gnu_pbds::detail::is_same<
+ typename container_traits::invalidation_guarantee,
+ __gnu_pbds::range_invalidation_guarantee>::value ;
+
+ if (range_guarantee)
+ PB_DS_THROW_IF_FAILED(next_ers_it == next_it, "", m_p_c, &m_native_c);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ PB_DS_THROW_IF_FAILED(container_traits::erase_can_throw, container_traits::erase_can_throw, m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+erase_rev_it()
+{
+ enum
+ {
+ erase_iterators = container_traits::order_preserving
+ && container_traits::reverse_iteration
+ };
+
+ return (erase_rev_it_imp(__gnu_pbds::detail::integral_constant<int,erase_iterators>()));
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+erase_rev_it_imp(__gnu_pbds::detail::false_type)
+{
+ return true;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+erase_rev_it_imp(__gnu_pbds::detail::true_type)
+{
+ PB_DS_TRACE("erase_rev_it");
+ bool done = true;
+ PB_DS_SET_DESTRUCT_PRINT
+
+ try
+ {
+ m_alloc.set_probability(0);
+ const key_type k = test_traits::generate_key(m_g, m_m);
+ m_alloc.set_probability(m_tp);
+
+ typename cntnr::iterator found_it = m_p_c->find(k);
+ typename native_type::iterator native_it = m_native_c.find(test_traits::native_key(k));
+
+ typename cntnr::const_reverse_iterator next_it = found_it;
+ if (next_it != m_p_c->end())
+ ++next_it;
+
+ typename cntnr::reverse_iterator next_ers_it =
+ m_p_c->erase((typename cntnr::reverse_iterator)found_it);
+
+ PB_DS_THROW_IF_FAILED(next_ers_it == next_it, "", m_p_c, &m_native_c);
+
+ if (native_it != m_native_c.end())
+ m_native_c.erase(native_it);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ PB_DS_THROW_IF_FAILED(container_traits::erase_can_throw,
+ container_traits::erase_can_throw,
+ m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+ return done;
+}
+
+// Defs.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+defs()
+{
+ // General container types.
+ typedef typename Cntnr::size_type test_size_type;
+ typedef typename Cntnr::difference_type difference_type;
+
+ key_defs();
+ mapped_defs();
+ value_defs();
+ iterator_defs();
+ node_iterator_defs(__gnu_pbds::detail::integral_constant<int,
+ container_traits::order_preserving>());
+ policy_defs();
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+key_defs()
+{
+ typedef typename Cntnr::key_type test_key_type;
+ typedef typename Cntnr::key_reference test_key_reference;
+ typedef typename Cntnr::const_key_reference test_const_key_reference;
+ typedef typename Cntnr::key_pointer test_key_pointer;
+ typedef typename Cntnr::const_key_pointer test_const_key_pointer;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+mapped_defs()
+{
+ typedef typename Cntnr::mapped_type test_mapped_type;
+ typedef typename Cntnr::mapped_reference test_mapped_reference;
+ typedef typename Cntnr::const_mapped_reference test_const_mapped_reference;
+ typedef typename Cntnr::mapped_pointer test_mapped_pointer;
+ typedef typename Cntnr::const_mapped_pointer test_const_mapped_pointer;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+value_defs()
+{
+ typedef typename Cntnr::value_type test_value_type;
+ typedef typename Cntnr::reference test_reference;
+ typedef typename Cntnr::const_reference test_const_reference;
+ typedef typename Cntnr::pointer test_pointer;
+ typedef typename Cntnr::const_pointer test_const_pointer;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+ds_defs()
+{
+ typedef __gnu_pbds::container_traits< Cntnr> test_container_traits;
+
+ typedef typename test_container_traits::container_category test_container_category;
+
+ typedef
+ typename test_container_traits::invalidation_guarantee
+ test_invalidation_guarantee;
+
+ enum
+ {
+ test_order_preserving = test_container_traits::order_preserving
+ };
+
+ enum
+ {
+ test_erase_can_throw = test_container_traits::erase_can_throw
+ };
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+iterator_defs()
+{
+ typedef typename Cntnr::point_iterator test_point_iterator;
+ typedef typename Cntnr::const_point_iterator const_test_point_iterator;
+ typedef typename Cntnr::iterator test_iterator;
+ typedef typename Cntnr::const_iterator const_test_iterator;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+node_iterator_defs(__gnu_pbds::detail::false_type)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+node_iterator_defs(__gnu_pbds::detail::true_type)
+{
+ typedef typename Cntnr::node_iterator test_node_iterator;
+ typedef typename Cntnr::const_node_iterator test_const_node_iterator;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_defs()
+{
+ typedef typename Cntnr::allocator_type test_allocator;
+ policy_defs(typename Cntnr::container_category());
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_defs(__gnu_pbds::basic_hash_tag)
+{
+ typedef typename Cntnr::hash_fn test_hash_fn;
+ typedef typename Cntnr::eq_fn test_eq_fn;
+ typedef typename Cntnr::resize_policy test_resize_policy;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_defs(__gnu_pbds::cc_hash_tag)
+{
+ policy_defs(__gnu_pbds::basic_hash_tag());
+ typedef typename Cntnr::comb_hash_fn test_comb_hash_fn;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_defs(__gnu_pbds::gp_hash_tag)
+{
+ policy_defs(__gnu_pbds::basic_hash_tag());
+ typedef typename Cntnr::comb_probe_fn test_comb_probe_fn;
+ typedef typename Cntnr::probe_fn test_probe_fn;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_defs(__gnu_pbds::tree_tag)
+{
+ typedef typename Cntnr::cmp_fn test_cmp_fn;
+ typedef typename Cntnr::node_update test_node_update;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_defs(__gnu_pbds::list_update_tag)
+{
+ typedef typename Cntnr::eq_fn test_eq_fn;
+ typedef typename Cntnr::update_policy test_update_policy;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_defs(__gnu_pbds::pat_trie_tag)
+{
+ typedef typename Cntnr::e_access_traits e_access_traits;
+}
+
+
+// Policy Access.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_access()
+{
+ policy_access(typename Cntnr::container_category());
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_access(__gnu_pbds::basic_hash_tag)
+{
+ {
+ typename Cntnr::hash_fn& r_t = m_p_c->get_hash_fn();
+ assert(&r_t);
+ }
+ {
+ const typename Cntnr::hash_fn& r_t =((const Cntnr& )*m_p_c).get_hash_fn();
+ assert(&r_t);
+ }
+
+ {
+ typename Cntnr::eq_fn& r_t = m_p_c->get_eq_fn();
+ assert(&r_t);
+ }
+ {
+ const typename Cntnr::eq_fn& r_t =((const Cntnr& )*m_p_c).get_eq_fn();
+ assert(&r_t);
+ }
+
+ {
+ typename Cntnr::resize_policy& r_t = m_p_c->get_resize_policy();
+ assert(&r_t);
+ }
+ {
+ const typename Cntnr::resize_policy& r_t =((const Cntnr& )*m_p_c).get_resize_policy();
+
+ assert(&r_t);
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_access(__gnu_pbds::cc_hash_tag)
+{
+ policy_access(__gnu_pbds::basic_hash_tag());
+
+ {
+ typename Cntnr::comb_hash_fn& r_t = m_p_c->get_comb_hash_fn();
+ assert(&r_t);
+ }
+ {
+ const typename Cntnr::comb_hash_fn& r_t =((const Cntnr& )*m_p_c).get_comb_hash_fn();
+
+ assert(&r_t);
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_access(__gnu_pbds::gp_hash_tag)
+{
+ policy_access(__gnu_pbds::basic_hash_tag());
+
+ {
+ typename Cntnr::comb_probe_fn& r_t = m_p_c->get_comb_probe_fn();
+ assert(&r_t);
+ }
+ {
+ const typename Cntnr::comb_probe_fn& r_t =((const Cntnr& )*m_p_c).get_comb_probe_fn();
+
+ assert(&r_t);
+ }
+
+ {
+ typename Cntnr::probe_fn& r_t = m_p_c->get_probe_fn();
+ assert(&r_t);
+ }
+ {
+ const typename Cntnr::probe_fn& r_t =((const Cntnr& )*m_p_c).get_probe_fn();
+ assert(&r_t);
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_access(__gnu_pbds::tree_tag)
+{
+ {
+ typename Cntnr::cmp_fn& r_t = m_p_c->get_cmp_fn();
+ assert(&r_t);
+ }
+
+ {
+ const typename Cntnr::cmp_fn& r_t =((const Cntnr& )*m_p_c).get_cmp_fn();
+ assert(&r_t);
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_access(__gnu_pbds::list_update_tag)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_access(__gnu_pbds::pat_trie_tag)
+{
+ typename Cntnr::e_access_traits& r_t = m_p_c->get_e_access_traits();
+ assert(&r_t);
+}
+
+
+// Split/Join.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+split_join()
+{
+ enum
+ {
+ split_join = container_traits::order_preserving
+ };
+
+ return (split_join_imp(__gnu_pbds::detail::integral_constant<int,split_join>()));
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+split_join_imp(__gnu_pbds::detail::false_type)
+{
+ return true;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+split_join_imp(__gnu_pbds::detail::true_type)
+{
+ PB_DS_TRACE("split_join");
+ bool done = true;
+ PB_DS_SET_DESTRUCT_PRINT
+
+ try
+ {
+ m_alloc.set_probability(0);
+ Cntnr lhs(*m_p_c);
+ Cntnr rhs;
+ native_type native_lhs(m_native_c);
+ native_type native_rhs;
+ const key_type k = test_traits::generate_key(m_g, m_m);
+
+ m_alloc.set_probability(m_tp);
+ lhs.split(k, rhs);
+
+ typename native_type::const_iterator it =
+ native_lhs.upper_bound(test_traits::native_key(k));
+
+ while (!native_lhs.empty()&& it != native_lhs.end())
+ {
+ native_rhs.insert(*it);
+ typename native_type::const_iterator next_it = it;
+ ++next_it;
+ native_lhs.erase(test_traits::extract_native_key(*it));
+ it = next_it;
+ }
+
+ PB_DS_COND_COMPARE(lhs, native_lhs);
+ PB_DS_COND_COMPARE(rhs, native_rhs);
+
+ m_alloc.set_probability(m_tp);
+
+ if (m_g.get_prob() < 0.5)
+ lhs.swap(rhs);
+
+ lhs.join(rhs);
+ PB_DS_THROW_IF_FAILED(rhs.size() == 0, rhs.size(), m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(rhs.empty(), rhs.size(), m_p_c, &m_native_c);
+ m_p_c->swap(lhs);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ PB_DS_THROW_IF_FAILED(container_traits::split_join_can_throw,
+ container_traits::split_join_can_throw,
+ m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+ return done;
+}
+
+// Iterator conversions.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+it_copy()
+{
+ {
+ typename cntnr::iterator it = m_p_c->end();
+ typename cntnr::const_iterator const_it(it);
+ PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
+
+ typename cntnr::const_point_iterator const_find_it(it);
+ PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
+
+ typename cntnr::point_iterator find_it(it);
+ PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c);
+ }
+
+ {
+ typename cntnr::const_iterator const_it = m_p_c->end();
+ typename cntnr::const_point_iterator const_find_it(const_it);
+ PB_DS_THROW_IF_FAILED(const_find_it == const_it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(const_find_it != const_it), "", m_p_c, &m_native_c);
+ }
+
+ {
+ typename cntnr::point_iterator find_it = m_p_c->end();
+ typename cntnr::const_point_iterator const_find_it(find_it);
+ PB_DS_THROW_IF_FAILED(find_it == const_find_it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(find_it != const_find_it), "", m_p_c, &m_native_c);
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+it_assign()
+{
+ {
+ typename cntnr::iterator it = m_p_c->end();
+ typename cntnr::const_iterator const_it;
+ const_it = it;
+ PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
+
+ typename cntnr::const_point_iterator const_find_it;
+ const_find_it = it;
+ PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
+
+ typename cntnr::point_iterator find_it;
+ find_it = it;
+ PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c);
+ }
+
+ {
+ typename cntnr::const_iterator const_it = m_p_c->end();
+ typename cntnr::const_point_iterator const_find_it;
+ const_find_it = const_it;
+ PB_DS_THROW_IF_FAILED(const_find_it == const_it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(const_find_it != const_it), "", m_p_c, &m_native_c);
+ }
+
+ {
+ typename cntnr::point_iterator find_it = m_p_c->end();
+ typename cntnr::const_point_iterator const_find_it;
+ const_find_it = find_it;
+ PB_DS_THROW_IF_FAILED(find_it == const_find_it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(find_it != const_find_it), "", m_p_c, &m_native_c);
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+rev_it_copy()
+{
+ enum
+ {
+ reverse_iteration = container_traits::reverse_iteration
+ };
+
+ rev_it_copy_imp(__gnu_pbds::detail::integral_constant<int,reverse_iteration>());
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+rev_it_assign()
+{
+ enum
+ {
+ reverse_iteration = container_traits::reverse_iteration
+ };
+
+ rev_it_assign_imp(__gnu_pbds::detail::integral_constant<int,reverse_iteration>());
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+rev_it_copy_imp(__gnu_pbds::detail::false_type)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+rev_it_copy_imp(__gnu_pbds::detail::true_type)
+{
+ {
+ typename cntnr::iterator it = m_p_c->end();
+ typename cntnr::const_reverse_iterator const_it(it);
+ PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
+
+ typename cntnr::const_point_iterator const_find_it(it);
+ PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
+
+ typename cntnr::point_iterator find_it(it);
+ PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c);
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+rev_it_assign_imp(__gnu_pbds::detail::false_type)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+rev_it_assign_imp(__gnu_pbds::detail::true_type)
+{
+ {
+ typename cntnr::iterator it = m_p_c->end();
+ typename cntnr::const_reverse_iterator const_it;
+ const_it = it;
+ PB_DS_THROW_IF_FAILED(const_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(const_it != it), "", m_p_c, &m_native_c);
+
+ typename cntnr::const_point_iterator const_find_it;
+ const_find_it = it;
+ PB_DS_THROW_IF_FAILED(const_find_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(const_find_it != it), "", m_p_c, &m_native_c);
+
+ typename cntnr::point_iterator find_it;
+ find_it = it;
+ PB_DS_THROW_IF_FAILED(find_it == it, "", m_p_c, &m_native_c);
+ PB_DS_THROW_IF_FAILED(!(find_it != it), "", m_p_c, &m_native_c);
+ }
+}
+
+// Resize.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+resize()
+{
+ typedef __gnu_pbds::detail::integral_constant<int, test_traits::resize> resize_ind;
+
+ return resize_imp(resize_ind());
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+resize_imp(__gnu_pbds::detail::false_type)
+{
+ return true;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+resize_imp(__gnu_pbds::detail::true_type)
+{
+ PB_DS_TRACE("resize");
+ bool done = true;
+ PB_DS_SET_DESTRUCT_PRINT
+ const size_t old_size = m_p_c->get_actual_size();
+
+ try
+ {
+ enum
+ {
+ min_new_size = 200,
+ max_new_size = 2000
+ };
+
+ m_alloc.set_probability(m_tp);
+ typename alloc_t::group_adjustor adjust(m_p_c->size());
+ const size_t new_size = m_g.get_unsigned_long(min_new_size, max_new_size);
+ m_p_c->resize(new_size);
+ const size_t actual_new_size = m_p_c->get_actual_size();
+ PB_DS_THROW_IF_FAILED(actual_new_size >= new_size,
+ actual_new_size << " " << new_size,
+ m_p_c, &m_native_c);
+ }
+ catch(...)
+ {
+ PB_DS_THROW_IF_FAILED(m_p_c->get_actual_size() == old_size,
+ m_p_c->get_actual_size() << " " << old_size,
+ m_p_c, &m_native_c);
+
+ done = false;
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+ return done;
+}
+
+
+// Get/Set load.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+get_set_load()
+{
+ typedef
+ __gnu_pbds::detail::integral_constant<int, test_traits::get_set_load>
+ get_set_load_ind;
+
+ get_set_load_imp(get_set_load_ind());
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+get_set_load_imp(__gnu_pbds::detail::false_type)
+{ }
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+get_set_load_imp(__gnu_pbds::detail::true_type)
+{
+ PB_DS_TRACE("get_set_load");
+ PB_DS_SET_DESTRUCT_PRINT
+ m_p_c->get_load();
+ m_alloc.set_probability(1);
+ typename alloc_t::group_adjustor adjust(m_p_c->size());
+ const float min_load = static_cast<float>(0.05);
+ const float max_load = static_cast<float>(0.9);
+
+ const float new_load = static_cast<float>(m_g.get_prob() * (max_load - min_load) + min_load);
+
+ m_p_c->set_load(new_load);
+ PB_DS_THROW_IF_FAILED(m_p_c->get_load() == new_load, "", m_p_c, &m_native_c);
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+}
+
+
+// Get/Set loads.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+get_set_loads()
+{
+ typedef
+ __gnu_pbds::detail::integral_constant<int, test_traits::get_set_loads>
+ get_set_loads_ind;
+
+ return get_set_loads_imp(get_set_loads_ind());
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+get_set_loads_imp(__gnu_pbds::detail::false_type)
+{
+ return true;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+get_set_loads_imp(__gnu_pbds::detail::true_type)
+{
+ PB_DS_TRACE("get_set_loads");
+ bool done = true;
+ PB_DS_SET_DESTRUCT_PRINT
+ const std::pair<float, float> old_loads = m_p_c->get_loads();
+
+ try
+ {
+ m_alloc.set_probability(m_tp);
+
+ typename alloc_t::group_adjustor adjust(m_p_c->size());
+
+ const float min_min_load = static_cast<float>(0.05);
+ const float max_min_load = static_cast<float>(0.2);
+
+ const float new_min_load =
+ static_cast<float>(m_g.get_prob()* (max_min_load - min_min_load) +
+ min_min_load);
+
+ const float new_max_load = static_cast<float>(new_min_load* 2.5);
+ PB_DS_THROW_IF_FAILED(new_max_load < 1, new_max_load, m_p_c, &m_native_c);
+ m_p_c->set_loads(std::make_pair(new_min_load, new_max_load));
+ }
+ catch(...)
+ {
+ PB_DS_THROW_IF_FAILED(old_loads == m_p_c->get_loads(),
+ old_loads.first << " " << old_loads.second << " " <<
+ m_p_c->get_loads().first << " " <<
+ m_p_c->get_loads().second,
+ m_p_c, &m_native_c);
+
+ done = false;
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ PB_DS_CANCEL_DESTRUCT_PRINT
+ return done;
+}
+
+// Diagnostics.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+print_container(const native_type& r_cnt, std::ostream& r_os) const
+{
+ m_alloc.set_probability(0);
+ typename native_type::const_iterator it = r_cnt.begin();
+ while (it != r_cnt.end())
+ {
+ r_os << test_traits::val_to_string(*it) + "\n";
+ ++it;
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+print_container(const cntnr& r_cnt, std::ostream& r_os) const
+{
+ m_alloc.set_probability(0);
+ typename cntnr::const_iterator it = r_cnt.begin();
+ while (it != r_cnt.end())
+ {
+ r_os << test_traits::val_to_string(*it) + "\n";
+ ++it;
+ }
+}
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp b/libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp
new file mode 100644
index 000000000..5f2304952
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/rand/assoc/rand_regression_test.hpp
@@ -0,0 +1,198 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file rand_regression_test.hpp
+ * Contains a random-operation test.
+ */
+
+#ifndef PB_DS_ASSOC_RAND_REGRESSION_TEST_HPP
+#define PB_DS_ASSOC_RAND_REGRESSION_TEST_HPP
+
+#include <iostream>
+#include <vector>
+#include <regression/rand/assoc/container_rand_regression_test.h>
+#include <io/verified_cmd_line_input.hpp>
+#include <common_type/assoc/common_type.hpp>
+#include <regression/basic_type.hpp>
+#include <regression/common_type.hpp>
+
+namespace __gnu_pbds
+{
+namespace test
+{
+namespace detail
+{
+#ifndef PB_DS_REGRESSION
+#error "Must define PB_DS_REGRESSION"
+#endif
+
+ struct rand_reg_test
+ {
+ public:
+ rand_reg_test(size_t seed, size_t n, size_t m, double tp, double ip,
+ double ep, double cp, double mp, bool d)
+ : m_sd(seed), m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_ep(ep), m_cp(cp),
+ m_mp(mp), m_disp(d)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr)
+ {
+ unsigned long ul = static_cast<unsigned long>(m_sd);
+ container_rand_regression_test<Cntnr> t(ul, m_n, m_n, m_tp, m_ip,
+ m_ep, m_cp, m_mp, m_disp);
+ t();
+ }
+
+ private:
+ const size_t m_sd;
+ const size_t m_n;
+ const size_t m_m;
+ const double m_tp;
+ const double m_ip;
+ const double m_ep;
+ const double m_cp;
+ const double m_mp;
+ const bool m_disp;
+ };
+
+ void
+ usage(const std::string& r_name);
+
+ void
+ verify_params(size_t&, size_t&, size_t&,
+ double&, double&, double&, double&, double&, bool&);
+} // namespace detail
+
+ template<typename TL>
+ int
+ rand_regression_test(size_t iter, size_t keys, const std::string name, TL tl)
+ {
+ // Sane defaults.
+ size_t n = iter;
+ size_t m = keys;
+ size_t sd = twister_rand_gen::get_time_determined_seed();
+ double tp = 0.2;
+ double ip = 0.6;
+ double ep = 0.2;
+ double cp = 0.001;
+ double mp = 0.25;
+ bool disp = false; // show progress
+
+ try
+ {
+ detail::verify_params(sd, n, m, tp, ip, ep, cp, mp, disp);
+ }
+ catch (__gnu_pbds::test::illegal_input_error&)
+ {
+ detail::usage(name);
+ return -1;
+ }
+ catch (...)
+ {
+ return -2;
+ };
+
+ // XXX RAII, constructor takes bool for display
+ xml_test_rand_regression_formatter* p_fmt = 0;
+ if (disp)
+ p_fmt = new xml_test_rand_regression_formatter(sd, n, m, tp, ip, ep, cp, mp);
+
+ try
+ {
+ detail::rand_reg_test tst(sd, n, m, tp, ip, ep, cp, mp, disp);
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+ catch (...)
+ {
+ std::cerr << "Test failed with seed " << sd << std::endl;
+ if (disp)
+ delete p_fmt;
+ throw;
+ }
+
+ if (disp)
+ delete p_fmt;
+ return 0;
+ }
+
+namespace detail
+{
+ inline void
+ usage(const std::string& name)
+ {
+ using namespace std;
+ cerr << "usage: " << name << " <sd> <n> <m> <tp> <ip> <ep> <cp> <mp> ['t' | 'f']" <<
+ endl << endl;
+
+ cerr << "This test performs basic regression tests on various associative containers."
+ "For each container, it performs a sequence of operations. At each iteration, it does "
+ "the following: " << endl;
+ cerr << "* Performs an operation on the container " << endl;
+ cerr << "* Performs the same operation on an cntnr object" << endl;
+ cerr << "* Possibly compares the container to the cntnr object" << endl;
+ cerr << "* Checks that exceptions (thrown by an allocator) "
+ "do not violate exception guarantees";
+
+ cerr << endl << endl;
+
+ cerr << "sd = seed for random-number generator; "
+ "0 = time determined value" << endl;
+ cerr << "n = number of iterations" << endl;
+ cerr << "m = number of distinct values" << endl;
+ cerr << "tp = probability that an exception will be actively thrown" << endl;
+ cerr << "ip = probability that an operation will be insert" << endl;
+ cerr << "ep = probability that an operation will be erase" << endl;
+ cerr << "cp = probability that an operation will be clear" << endl;
+ cerr << "(therefore, 1 - (ip + ep + cp) = probability of any other operation)" << endl;
+ cerr << "mp = probability that the container will be compared to the cntnr object" << endl;
+ cerr << "'t' or 'f' determine whether progress will be displayed" << endl;
+ }
+
+ inline void
+ verify_params(size_t& r_seed, size_t& r_n,
+ size_t& r_m, double& r_tp, double& r_ip, double& r_ep,
+ double& r_cp, double& r_mp, bool& r_d)
+ {
+ verify_prob(r_tp);
+ verify_prob(r_ip);
+ verify_prob(r_ep);
+ verify_prob(r_cp);
+ verify_prob(r_mp);
+ verify_prob(r_ip + r_ep + r_cp);
+ }
+} // namespace detail
+} // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.h b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.h
new file mode 100644
index 000000000..828541ce7
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.h
@@ -0,0 +1,265 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file container_rand_regression_test.h
+ * Contains a random regression test for a specific container type.
+ */
+
+#ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_H
+#define PB_DS_CONTAINER_RAND_REGRESSION_TEST_H
+
+#include <algorithm>
+#include <string>
+#include <sstream>
+#include <utility>
+#include <cassert>
+#include <regression/basic_type.hpp>
+#include <ext/pb_ds/priority_queue.hpp>
+#include <io/prog_bar.hpp>
+#include <testsuite_rng.h>
+#include <common_type/priority_queue/string_form.hpp>
+#include <regression/rand/xml_formatter.hpp>
+#include <regression/trait/priority_queue/trait.hpp>
+
+namespace __gnu_pbds
+{
+namespace test
+{
+namespace detail
+{
+ // Rand test specialized for a specific container.
+ template<typename Cntnr>
+ class container_rand_regression_test
+ {
+ private:
+ typedef Cntnr cntnr;
+ typedef typename cntnr::allocator_type allocator_type;
+ typedef typename cntnr::size_type size_type;
+ typedef twister_rand_gen gen;
+ typedef basic_type value_type;
+ typedef native_priority_queue<std::string, true> native_type;
+ typedef regression_test_traits<cntnr> test_traits;
+
+ enum op
+ {
+ insert_op,
+ modify_op,
+ erase_op,
+ clear_op,
+ other_op
+ };
+
+ op
+ get_next_op();
+
+ size_t
+ get_next_sub_op(size_t max);
+
+ static void
+ defs();
+
+ static void
+ value_defs();
+
+ static void
+ ds_defs();
+
+ static void
+ iterator_defs();
+
+ static void
+ policy_defs();
+
+ void
+ policy_access();
+
+ void
+ it_copy();
+
+ void
+ it_assign();
+
+ bool
+ default_constructor();
+
+ void
+ swap();
+
+ bool
+ copy_constructor();
+
+ bool
+ assignment_operator();
+
+ bool
+ it_constructor();
+
+ bool
+ push();
+
+ bool
+ modify();
+
+ bool
+ pop();
+
+ bool
+ erase_if();
+
+ bool
+ erase_it();
+
+ bool
+ clear();
+
+ bool
+ split_join();
+
+ void
+ cmp(const Cntnr& r_container, const native_type& r_native_c,
+ const std::string& r_call_fn);
+
+ void
+ print_container(const native_type& r_cnt,
+ std::ostream& r_os = std::cerr) const;
+
+ void
+ print_container(const cntnr& r_cnt,
+ std::ostream& r_os = std::cerr) const;
+
+ struct destructor_printer
+ {
+ destructor_printer(const std::string& r_msg)
+ : m_msg(r_msg), m_print(true) { }
+
+ void
+ cancel()
+ { m_print = false; }
+
+ ~destructor_printer()
+ {
+ if (m_print)
+ {
+ std::cerr << std::endl << "Uncaught exception: " << std::endl
+ << m_msg << std::endl;
+ }
+ }
+
+ const std::string m_msg;
+ bool m_print;
+ };
+
+ const unsigned long m_seed;
+ const size_t m_n;
+ const size_t m_m;
+ const double m_tp;
+ const double m_ip;
+ const double m_dp;
+ const double m_ep;
+ const double m_cp;
+ const double m_mp;
+ const bool m_disp;
+ twister_rand_gen m_g;
+ Cntnr* m_p_c;
+ native_type m_native_c;
+ allocator_type m_alloc;
+ size_t m_i;
+
+ public:
+ container_rand_regression_test(unsigned long seed, size_t n, size_t m,
+ double tp, double ip, double dp,
+ double ep, double cp, double mp,
+ bool disp);
+
+ virtual
+ ~container_rand_regression_test();
+
+ void
+ operator()();
+ };
+
+
+#ifdef PB_DS_REGRESSION_TRACE
+# define PB_DS_TRACE(X) std::cerr << X << std::endl
+#else
+# define PB_DS_TRACE(X)
+#endif
+
+#define PB_DS_CLASS_T_DEC \
+ template<typename Cntnr>
+
+#define PB_DS_CLASS_C_DEC \
+ container_rand_regression_test<Cntnr>
+
+#define PB_DS_COND_COMPARE(L, R) \
+ if (m_g.get_prob() < m_mp) \
+ cmp(L, R, __FUNCTION__);
+
+#define PB_DS_RUN_MTHD(MTHD) \
+ { \
+ bool done = false; \
+ while (!done) \
+ done = MTHD(); \
+ }
+
+#define _GLIBCXX_THROW_IF_(PRED, MORE, P_C, P_NC, F, L) \
+ if (PRED) \
+ { \
+ std::cerr << "Failure at " << F << ": " << L << std::endl; \
+ std::cerr << MORE << std::endl; \
+ std::cerr << "container:" << std::endl; \
+ print_container(*(P_C)); \
+ std::cerr << std::endl; \
+ std::cerr << "native container:" << std::endl; \
+ print_container(*(P_NC)); \
+ std::cerr << std::endl; \
+ throw std::logic_error("pbds throw if failed"); \
+ }
+
+#define _GLIBCXX_THROW_IF(PRED, MORE, P_C, P_NC) \
+ _GLIBCXX_THROW_IF_(PRED, MORE, P_C, P_NC, __FILE__, __LINE__)
+
+#include <regression/rand/priority_queue/container_rand_regression_test.tcc>
+
+#undef PB_DS_COND_COMPARE
+#undef PB_DS_RUN_MTHD
+#undef PB_DS_CLASS_T_DEC
+#undef PB_DS_CLASS_C_DEC
+#undef _GLIBCXX_THROW_IF_
+#undef _GLIBCXX_THROW_IF
+#undef PB_DS_TRACE
+
+} // namespace detail
+} // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.tcc b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.tcc
new file mode 100644
index 000000000..e929f3533
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/container_rand_regression_test.tcc
@@ -0,0 +1,838 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file container_rand_regression_test.tcc
+ * Contains a random regression test for a specific container type.
+ */
+
+#ifndef PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC
+#define PB_DS_CONTAINER_RAND_REGRESSION_TEST_TCC
+
+ // Constructor, copy constructor, assignment and destructor.
+PB_DS_CLASS_T_DEC
+PB_DS_CLASS_C_DEC::
+container_rand_regression_test(unsigned long seed, size_t n, size_t m,
+ double tp, double ip, double dp, double ep,
+ double cp, double mp, bool disp)
+: m_seed(seed == 0 ? twister_rand_gen::get_time_determined_seed(): seed),
+ m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_dp(dp), m_ep(ep), m_cp(cp),
+ m_mp(mp), m_disp(disp), m_p_c(0)
+{ }
+
+PB_DS_CLASS_T_DEC
+PB_DS_CLASS_C_DEC::
+~container_rand_regression_test()
+{ }
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+default_constructor()
+{
+ PB_DS_TRACE("default_constructor");
+ bool done = true;
+ m_alloc.set_probability(m_tp);
+
+ try
+ {
+ m_p_c = new Cntnr;
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ if (m_p_c)
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+swap()
+{
+ PB_DS_TRACE("swap");
+ m_alloc.set_probability(0);
+ Cntnr* p_c = new Cntnr;
+ m_alloc.set_probability(1);
+ p_c->swap(*m_p_c);
+ std::swap(p_c, m_p_c);
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+copy_constructor()
+{
+ PB_DS_TRACE("copy_constructor");
+ bool done = true;
+ Cntnr* p_c = 0;
+ m_alloc.set_probability(m_tp);
+
+ typedef typename allocator_type::group_adjustor adjustor;
+ adjustor adjust(m_p_c->size());
+
+ try
+ {
+ p_c = new Cntnr(*m_p_c);
+ std::swap(p_c, m_p_c);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+assignment_operator()
+{
+ PB_DS_TRACE("assignment operator");
+ bool done = true;
+ Cntnr* p_c = 0;
+ m_alloc.set_probability(m_tp);
+
+ typedef typename allocator_type::group_adjustor adjustor;
+ adjustor adjust(m_p_c->size());
+
+ try
+ {
+ p_c = new Cntnr();
+ *p_c = *m_p_c;
+ std::swap(p_c, m_p_c);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+it_constructor()
+{
+ bool done = true;
+ Cntnr* p_c = 0;
+ m_alloc.set_probability(m_tp);
+ typedef typename allocator_type::group_adjustor adjustor;
+ adjustor adjust(m_p_c->size());
+
+ try
+ {
+ switch(get_next_sub_op(3))
+ {
+ case 0:
+ p_c = new Cntnr(m_p_c->get_cmp_fn());
+ m_native_c.clear();
+ break;
+ case 1:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end());
+ break;
+ case 2:
+ p_c = new Cntnr(m_p_c->begin(), m_p_c->end(), m_p_c->get_cmp_fn());
+ break;
+ default:
+ _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
+ };
+
+ std::swap(p_c, m_p_c);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+
+ delete p_c;
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ return done;
+}
+
+
+ // Compare.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+cmp(const Cntnr& c, const native_type& native, const std::string& callfn)
+{
+ destructor_printer notify(__FUNCTION__);
+
+ try
+ {
+ m_alloc.set_probability(1);
+
+ const size_t size = c.size();
+ const size_t native_size = native.size();
+ _GLIBCXX_THROW_IF(size != native_size, size << " " << native_size,
+ &c, &native);
+
+ const bool empty = c.empty();
+ const bool native_empty = native.empty();
+ _GLIBCXX_THROW_IF(empty != native_empty, empty << " " << native_empty,
+ &c, &native);
+
+ const size_t it_size = std::distance(c.begin(), c.end());
+ _GLIBCXX_THROW_IF(it_size != size, it_size << " " << size, &c, &native);
+
+ if (!c.empty())
+ {
+ const std::string native_top = native.top();
+ const std::string top = test_traits::native_value(c.top());
+ const bool top_smaller = std::less<std::string>()(top, native_top);
+ const bool top_larger = std::less<std::string>()(native_top, top);
+
+ if (top_smaller || top_larger)
+ _GLIBCXX_THROW_IF(true, top << " " << native_top, &c, &native);
+ }
+ }
+ catch(...)
+ {
+ _GLIBCXX_THROW_IF(true, "call-fn: " + callfn, &c, &native);
+ }
+
+ notify.cancel();
+}
+
+ // Operators.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+operator()()
+{
+ typedef xml_result_set_regression_formatter formatter_type;
+ formatter_type* p_fmt = 0;
+ if (m_disp)
+ p_fmt = new formatter_type(string_form<Cntnr>::name(),
+ string_form<Cntnr>::desc());
+
+ m_g.init(m_seed);
+ m_alloc.seed(m_seed);
+
+ // The __throw_allocator::_S_label defaults to 0, so to make things
+ // easier and more precise when debugging, start at 1.
+ const size_t starting_label(1);
+
+ try
+ {
+ prog_bar pb(m_n, std::cout, m_disp);
+
+ for (m_i = starting_label; m_i <= m_n; ++m_i)
+ {
+ PB_DS_TRACE("Op #" << m_i);
+
+ // Track allocation from this point only.
+ allocator_type::set_label(m_i);
+ switch(m_i)
+ {
+ case 1:
+ PB_DS_RUN_MTHD(default_constructor);
+ break;
+ case 2:
+ defs();
+ break;
+ case 3:
+ policy_access();
+ break;
+ case 4:
+ it_copy();
+ break;
+ case 5:
+ it_assign();
+ break;
+ default:
+ switch(get_next_op())
+ {
+ case insert_op:
+ PB_DS_RUN_MTHD(push)
+ break;
+ case modify_op:
+ PB_DS_RUN_MTHD(modify)
+ break;
+ case erase_op:
+ switch(get_next_sub_op(3))
+ {
+ case 0:
+ PB_DS_RUN_MTHD(pop)
+ break;
+ case 1:
+ PB_DS_RUN_MTHD(erase_if)
+ break;
+ case 2:
+ PB_DS_RUN_MTHD(erase_it)
+ break;
+ default:
+ _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
+ }
+ break;
+ case clear_op:
+ PB_DS_RUN_MTHD(clear)
+ break;
+ case other_op:
+ switch(get_next_sub_op(5))
+ {
+ case 0:
+ swap();
+ break;
+ case 1:
+ PB_DS_RUN_MTHD(copy_constructor)
+ break;
+ case 2:
+ PB_DS_RUN_MTHD(it_constructor)
+ break;
+ case 3:
+ PB_DS_RUN_MTHD(assignment_operator)
+ break;
+ case 4:
+ PB_DS_RUN_MTHD(split_join)
+ break;
+ default:
+ _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
+ }
+ break;
+ default:
+ _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
+ };
+ }
+ pb.inc();
+ }
+ }
+ catch (...)
+ {
+ std::cerr << "Failed at index " << m_i << std::endl;
+ delete m_p_c;
+ throw;
+ }
+
+ // Clean up, then check for allocation by special label, set above.
+ allocator_type::set_label(0);
+ delete m_p_c;
+
+ try
+ {
+ for (size_t n = starting_label; n <= m_n; ++n)
+ m_alloc.check_allocated(n);
+ }
+ catch (std::logic_error& obj)
+ {
+ // On fail, check_allocated should throw std::logic_error.
+ std::cerr << obj.what() << std::endl;
+ std::cerr << typeid(Cntnr).name() << std::endl;
+ throw;
+ }
+
+ // Reset throw probability.
+ m_alloc.set_probability(0);
+
+ if (m_disp)
+ {
+ std::cout << std::endl;
+ delete p_fmt;
+ }
+}
+
+PB_DS_CLASS_T_DEC
+typename PB_DS_CLASS_C_DEC::op
+PB_DS_CLASS_C_DEC::
+get_next_op()
+{
+ const double prob = m_g.get_prob();
+
+ if (prob < m_ip)
+ return insert_op;
+
+ if (prob < m_ip + m_dp)
+ return modify_op;
+
+ if (prob < m_ip + m_dp + m_ep)
+ return erase_op;
+
+ if (prob < m_ip + m_dp + m_ep + m_cp)
+ return clear_op;
+
+ _GLIBCXX_THROW_IF(prob > 1, prob, m_p_c, &m_native_c);
+ return other_op;
+}
+
+PB_DS_CLASS_T_DEC
+size_t
+PB_DS_CLASS_C_DEC::
+get_next_sub_op(size_t max)
+{
+ const double p = m_g.get_prob();
+ const double delta = 1 / static_cast<double>(max);
+ size_t i = 0;
+ while (true)
+ if (p <= (i + 1) * delta)
+ {
+ _GLIBCXX_THROW_IF(i >= max, i << " " << max, m_p_c, &m_native_c);
+ return i;
+ }
+ else
+ ++i;
+}
+
+ // Insert.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+push()
+{
+ PB_DS_TRACE("push");
+ bool done = true;
+ destructor_printer notify(__FUNCTION__);
+
+ try
+ {
+ m_alloc.set_probability(0);
+ value_type v = test_traits::generate_value(m_g, m_m);
+ m_alloc.set_probability(m_tp);
+ const typename cntnr::size_type sz = m_p_c->size();
+ m_p_c->push(v);
+ _GLIBCXX_THROW_IF(sz != m_p_c->size() - 1, sz, m_p_c, &m_native_c);
+ m_native_c.push(test_traits::native_value(v));
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ }
+ catch(...)
+ {
+ _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ notify.cancel();
+ return done;
+}
+
+
+ // Modify.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+modify()
+{
+ PB_DS_TRACE("modify");
+ destructor_printer notify(__FUNCTION__);
+
+ bool done = true;
+ try
+ {
+ m_alloc.set_probability(0);
+ value_type v = test_traits::generate_value(m_g, m_m);
+
+ m_alloc.set_probability(m_tp);
+ typename cntnr::iterator it = m_p_c->begin();
+ std::advance(it, m_g.get_unsigned_long(0, m_p_c->size()));
+ if (it != m_p_c->end())
+ {
+ typedef typename test_traits::native_value_type native_value_type;
+ native_value_type native_v = test_traits::native_value(*it);
+ native_value_type new_native_v = test_traits::native_value(v);
+ m_p_c->modify(it, v);
+ m_native_c.modify(native_v, new_native_v);
+ }
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ notify.cancel();
+ return done;
+}
+
+ // Clear.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+clear()
+{
+ PB_DS_TRACE("clear");
+ m_p_c->clear();
+ m_native_c.clear();
+ return true;
+}
+
+ // Erase.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+pop()
+{
+ PB_DS_TRACE("pop");
+ destructor_printer notify(__FUNCTION__);
+
+ bool done = true;
+ try
+ {
+ m_alloc.set_probability(1);
+ if (!m_p_c->empty())
+ {
+ m_p_c->pop();
+ m_native_c.pop();
+ }
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ notify.cancel();
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+erase_if()
+{
+ PB_DS_TRACE("erase_if");
+ destructor_printer notify(__FUNCTION__);
+
+ bool done = true;
+ try
+ {
+ typedef
+ typename std::iterator_traits<typename cntnr::iterator>::reference
+ it_const_reference;
+
+ m_alloc.set_probability(1);
+
+ typedef
+ typename test_traits::template erase_if_fn<value_type>
+ erase_if_fn_t;
+
+ const size_t ersd = m_p_c->erase_if(erase_if_fn_t());
+
+ typedef
+ typename test_traits::template erase_if_fn<std::string>
+ native_erase_if_fn_t;
+
+ const size_t native_ersd = m_native_c.erase_if(native_erase_if_fn_t());
+
+ _GLIBCXX_THROW_IF(ersd != native_ersd, ersd << " " << native_ersd,
+ m_p_c, &m_native_c);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ notify.cancel();
+ return done;
+}
+
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+erase_it()
+{
+ PB_DS_TRACE("erase_it");
+ destructor_printer notify(__FUNCTION__);
+
+ bool done = true;
+ try
+ {
+ m_alloc.set_probability(1);
+ typename cntnr::iterator it = m_p_c->begin();
+ std::advance(it, m_g.get_unsigned_long(0, m_p_c->size()));
+
+ if (it != m_p_c->end())
+ {
+ m_native_c.erase(*it);
+ m_p_c->erase(it);
+ }
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ _GLIBCXX_THROW_IF(true, "", m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ notify.cancel();
+ return done;
+}
+
+ // Defs.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+defs()
+{
+ // General container types.
+ typedef typename Cntnr::size_type test_size_type;
+ typedef typename Cntnr::difference_type difference_type;
+ value_defs();
+ iterator_defs();
+ policy_defs();
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+value_defs()
+{
+ typedef typename Cntnr::value_type test_value_type;
+ typedef typename Cntnr::reference test_reference;
+ typedef typename Cntnr::const_reference test_const_reference;
+ typedef typename Cntnr::pointer test_pointer;
+ typedef typename Cntnr::const_pointer test_const_pointer;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+ds_defs()
+{
+ typedef typename Cntnr::container_category test_container_category;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+iterator_defs()
+{
+ typedef typename Cntnr::point_iterator test_point_iterator;
+ typedef typename Cntnr::const_point_iterator const_test_point_iterator;
+ typedef typename Cntnr::iterator test_iterator;
+ typedef typename Cntnr::const_iterator const_test_iterator;
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_defs()
+{
+ typedef typename Cntnr::allocator_type test_allocator;
+ typedef typename Cntnr::cmp_fn test_cmp_fn;
+}
+
+
+// Policy access.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+policy_access()
+{
+ PB_DS_TRACE("policy_access");
+
+ {
+ typename Cntnr::cmp_fn& r_t = m_p_c->get_cmp_fn();
+ assert(&r_t);
+ }
+
+ {
+ const typename Cntnr::cmp_fn& r_t =((const Cntnr& )*m_p_c).get_cmp_fn();
+ assert(&r_t);
+ }
+}
+
+// Split join.
+PB_DS_CLASS_T_DEC
+bool
+PB_DS_CLASS_C_DEC::
+split_join()
+{
+ PB_DS_TRACE("split_join");
+ destructor_printer notify(__FUNCTION__);
+
+ bool done = true;
+ try
+ {
+ m_alloc.set_probability(0);
+ Cntnr lhs(*m_p_c);
+ Cntnr rhs;
+ native_type native_lhs(m_native_c);
+ m_alloc.set_probability(m_tp);
+
+ typedef typename test_traits::template erase_if_fn<value_type> split_fn_t;
+ lhs.split(split_fn_t(), rhs);
+
+ typedef typename test_traits::template erase_if_fn<std::string>
+ native_split_fn_t;
+
+ native_type native_rhs;
+ native_lhs.split(native_split_fn_t(), native_rhs);
+ PB_DS_COND_COMPARE(lhs, native_lhs);
+ PB_DS_COND_COMPARE(rhs, native_rhs);
+
+ m_alloc.set_probability(m_tp);
+
+ if (m_g.get_prob() < 0.5)
+ lhs.swap(rhs);
+ lhs.join(rhs);
+
+ _GLIBCXX_THROW_IF(rhs.size() != 0, rhs.size(), m_p_c, &m_native_c);
+ _GLIBCXX_THROW_IF(!rhs.empty(), rhs.size(), m_p_c, &m_native_c);
+ }
+ catch(__gnu_cxx::forced_error&)
+ {
+ done = false;
+ const bool b = __gnu_pbds::container_traits<cntnr>::split_join_can_throw;
+ _GLIBCXX_THROW_IF(!b, b, m_p_c, &m_native_c);
+ }
+
+ PB_DS_COND_COMPARE(*m_p_c, m_native_c);
+ notify.cancel();
+ return done;
+}
+
+// Iterator conversions.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+it_copy()
+{
+ PB_DS_TRACE("it_copy");
+
+ {
+ typename cntnr::iterator it = m_p_c->end();
+ typename cntnr::const_iterator const_it(it);
+ _GLIBCXX_THROW_IF(const_it != it, "", m_p_c, &m_native_c);
+ _GLIBCXX_THROW_IF(!(const_it == it), "", m_p_c, &m_native_c);
+ }
+
+ {
+ typename cntnr::const_iterator const_it = m_p_c->end();
+ typename cntnr::const_point_iterator const_find_it(const_it);
+ _GLIBCXX_THROW_IF(const_find_it != const_it, "", m_p_c, &m_native_c);
+ _GLIBCXX_THROW_IF(!(const_find_it == const_it), "", m_p_c, &m_native_c);
+ }
+
+ {
+ typename cntnr::iterator it = m_p_c->end();
+ typename cntnr::const_point_iterator const_find_it1(it);
+ _GLIBCXX_THROW_IF(const_find_it1 != it, "", m_p_c, &m_native_c);
+ _GLIBCXX_THROW_IF(!(const_find_it1 == it), "", m_p_c, &m_native_c);
+
+ typename cntnr::point_iterator find_it1(it);
+ _GLIBCXX_THROW_IF(find_it1 != it, "", m_p_c, &m_native_c);
+ _GLIBCXX_THROW_IF(!(find_it1 == it), "", m_p_c, &m_native_c);
+
+ typename cntnr::point_iterator find_it = m_p_c->end();
+ typename cntnr::const_point_iterator const_find_it(find_it);
+ _GLIBCXX_THROW_IF(find_it != const_find_it, "", m_p_c, &m_native_c);
+ _GLIBCXX_THROW_IF(!(find_it == const_find_it), "", m_p_c, &m_native_c);
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+it_assign()
+{
+ PB_DS_TRACE("it_assign");
+
+ {
+ typename cntnr::iterator it = m_p_c->end();
+ typename cntnr::const_iterator const_it;
+ const_it = it;
+ _GLIBCXX_THROW_IF(const_it != it, "", m_p_c, &m_native_c);
+ _GLIBCXX_THROW_IF(!(const_it == it), "", m_p_c, &m_native_c);
+
+ typename cntnr::const_point_iterator const_find_it;
+ const_find_it = it;
+ _GLIBCXX_THROW_IF(const_find_it != it, "", m_p_c, &m_native_c);
+ _GLIBCXX_THROW_IF(!(const_find_it == it), "", m_p_c, &m_native_c);
+
+ typename cntnr::point_iterator find_it;
+ find_it = it;
+ _GLIBCXX_THROW_IF(find_it != it, "", m_p_c, &m_native_c);
+ _GLIBCXX_THROW_IF(!(find_it == it), "", m_p_c, &m_native_c);
+ }
+
+ {
+ typename cntnr::const_iterator const_it = m_p_c->end();
+ typename cntnr::const_point_iterator const_find_it;
+ const_find_it = const_it;
+ _GLIBCXX_THROW_IF(const_find_it != const_it, "", m_p_c, &m_native_c);
+ _GLIBCXX_THROW_IF(!(const_find_it == const_it), "", m_p_c, &m_native_c);
+ }
+
+ {
+ typename cntnr::point_iterator find_it = m_p_c->end();
+ typename cntnr::const_point_iterator const_find_it;
+ const_find_it = find_it;
+ _GLIBCXX_THROW_IF(find_it != const_find_it, "", m_p_c, &m_native_c);
+ _GLIBCXX_THROW_IF(!(find_it == const_find_it), "", m_p_c, &m_native_c);
+ }
+}
+
+
+// Diagnostics.
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+print_container(const native_type& cnt, std::ostream& os) const
+{
+ m_alloc.set_probability(0);
+ native_type cpy(cnt);
+ while (!cpy.empty())
+ {
+ os << cpy.top() << std::endl;
+ cpy.pop();
+ }
+}
+
+PB_DS_CLASS_T_DEC
+void
+PB_DS_CLASS_C_DEC::
+print_container(const cntnr& cnt, std::ostream& os) const
+{
+ typedef typename cntnr::const_iterator const_iterator;
+ m_alloc.set_probability(0);
+ for (const_iterator it = cnt.begin(); it != cnt.end(); ++it)
+ os << *it << std::endl;
+}
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp
new file mode 100644
index 000000000..37f8d51af
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/rand/priority_queue/rand_regression_test.hpp
@@ -0,0 +1,202 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file rand_regression_test.hpp
+ * Contains a random-operation test.
+ */
+
+#ifndef PB_DS_PQ_RAND_REGRESSION_TEST_HPP
+#define PB_DS_PQ_RAND_REGRESSION_TEST_HPP
+
+#include <iostream>
+#include <vector>
+#include <io/verified_cmd_line_input.hpp>
+#include <regression/common_type.hpp>
+#include <regression/rand/priority_queue/container_rand_regression_test.h>
+
+namespace __gnu_pbds
+{
+namespace test
+{
+namespace detail
+{
+#ifndef PB_DS_REGRESSION
+#error "Must define PB_DS_REGRESSION"
+#endif
+
+ struct rand_reg_test
+ {
+ public:
+ rand_reg_test(size_t seed, size_t n, size_t m, double tp, double ip,
+ double dp, double ep, double cp, double mp, bool d)
+ : m_sd(seed), m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_dp(dp), m_ep(ep),
+ m_cp(cp), m_mp(mp), m_disp(d)
+ { }
+
+ template<typename Cntnr>
+ void
+ operator()(Cntnr)
+ {
+ unsigned long ul = static_cast<unsigned long>(m_sd);
+ container_rand_regression_test<Cntnr> t(ul, m_n, m_n, m_tp, m_ip, m_dp,
+ m_ep, m_cp, m_mp, m_disp);
+ t();
+ }
+
+ private:
+ const size_t m_sd;
+ const size_t m_n;
+ const size_t m_m;
+ const double m_tp;
+ const double m_ip;
+ const double m_dp;
+ const double m_ep;
+ const double m_cp;
+ const double m_mp;
+ const bool m_disp;
+ };
+
+ void
+ usage(const std::string& r_name);
+
+ void
+ verify_params(size_t&, size_t&, size_t&,
+ double&, double&, double&, double&, double&, double&, bool&);
+} // namespace detail
+
+ template<typename TL>
+ int
+ rand_regression_test(size_t iter, size_t keys, const std::string name, TL tl)
+ {
+ // Sane defaults.
+ size_t n = iter;
+ size_t m = keys;
+ size_t sd = 0; // 0 = time-determined arbitrary
+ double tp = 0.2;
+ double ip = 0.6;
+ double dp = 0.1;
+ double ep = 0.2;
+ double cp = 0.001;
+ double mp = 1;
+ bool disp = false; // show progress
+
+ try
+ {
+ detail::verify_params(sd, n, m, tp, ip, dp, ep, cp, mp, disp);
+ }
+ catch(__gnu_pbds::test::illegal_input_error&)
+ {
+ detail::usage(name);
+ return -1;
+ }
+ catch(...)
+ {
+ return -2;
+ };
+
+ xml_test_rand_regression_formatter* p_fmt = 0;
+ if (sd == 0)
+ sd = twister_rand_gen::get_time_determined_seed();
+ if (disp)
+ p_fmt = new xml_test_rand_regression_formatter(sd, n, m, tp, ip, dp,
+ ep, cp, mp);
+
+ try
+ {
+ detail::rand_reg_test tst(sd, n, m, tp, ip, dp, ep, cp, mp, disp);
+ __gnu_cxx::typelist::apply(tst, tl);
+ }
+ catch(...)
+ {
+ std::cerr << "Test failed with seed " << sd << std::endl;
+ if (disp)
+ delete p_fmt;
+ return -1;
+ }
+
+ if (disp)
+ delete p_fmt;
+ return 0;
+ }
+
+namespace detail
+{
+ inline void
+ usage(const std::string& name)
+ {
+ using namespace std;
+ cerr << "usage: " << name << " <sd> <n> <m> <tp> <ip> <dp> <ep> <cp> <mp> ['t' | 'f']" <<
+ endl << endl;
+
+ cerr << "This test performs basic regression tests on various priority queues."
+ "For each container, it performs a sequence of operations. At each iteration, it does "
+ "the following: " << endl;
+ cerr << "* Performs an operation on the container " << endl;
+ cerr << "* Performs the same operation on an cntnr object" << endl;
+ cerr << "* Possibly compares the container to the cntnr object" << endl;
+ cerr << "* Checks that exceptions (thrown by an allocator) "
+ "do not violate exception guarantees";
+
+ cerr << endl << endl;
+
+ cerr << "sd = seed for random-number generator; 0 = "
+ "time determined value" << endl;
+ cerr << "n = number of iterations" << endl;
+ cerr << "m = number of distinct values" << endl;
+ cerr << "tp = probability that an exception will be actively thrown" << endl;
+ cerr << "ip = probability that an operation will be insert" << endl;
+ cerr << "dp = probability that an operation will be modify" << endl;
+ cerr << "ep = probability that an operation will be erase" << endl;
+ cerr << "cp = probability that an operation will be clear" << endl;
+ cerr << "(therefore, 1 - (ip + dp + ep + cp) = probability of any other operation)" << endl;
+ cerr << "mp = probability that the container will be compared to the cntnr object" << endl;
+ cerr << "'t' or 'f' determine whether progress will be displayed" << endl;
+ }
+
+ inline void
+ verify_params(size_t& r_seed, size_t& r_n,
+ size_t& r_m, double& r_tp, double& r_ip, double& r_dp,
+ double& r_ep, double& r_cp, double& r_mp, bool& r_d)
+ {
+ verify_prob(r_tp);
+ verify_prob(r_ip);
+ verify_prob(r_dp);
+ verify_prob(r_ep);
+ verify_prob(r_cp);
+ verify_prob(r_mp);
+ verify_prob(r_ip + r_dp + r_ep + r_cp);
+ }
+} // namespace detail
+} // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/regression/rand/xml_formatter.hpp b/libstdc++-v3/testsuite/util/regression/rand/xml_formatter.hpp
new file mode 100644
index 000000000..5dca782c5
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/rand/xml_formatter.hpp
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file xml_formatter.hpp
+ * Contains an XML formatter for regression tests.
+ */
+
+#ifndef PB_DS_COMMON_XML_TEST_REGRESSION_FORMATTER_HPP
+#define PB_DS_COMMON_XML_TEST_REGRESSION_FORMATTER_HPP
+
+#include <string>
+#include <iostream>
+#include <io/xml_test_formatter.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ // Test formatters.
+ struct xml_test_rand_regression_formatter : public xml_test_formatter
+ {
+ // Associative.
+ xml_test_rand_regression_formatter(size_t sd, size_t n, size_t m,
+ double tp, double ip, double ep,
+ double cp, double mp)
+ {
+ std::cout << make_xml_tag("sd", "value", sd);
+ std::cout << make_xml_tag("n", "value", n);
+ std::cout << make_xml_tag("m", "value", m);
+ std::cout << make_xml_tag("tp", "value", tp);
+ std::cout << make_xml_tag("ip", "value", ip);
+ std::cout << make_xml_tag("ep", "value", ep);
+ std::cout << make_xml_tag("cp", "value", cp);
+ std::cout << make_xml_tag("mp", "value", mp);
+ }
+
+ // Priority Queue.
+ xml_test_rand_regression_formatter(size_t sd, size_t n, size_t m,
+ double tp, double ip, double dp,
+ double ep, double cp, double mp)
+ {
+ std::cout << make_xml_tag("sd", "value", sd);
+ std::cout << make_xml_tag("n", "value", n);
+ std::cout << make_xml_tag("m", "value", m);
+ std::cout << make_xml_tag("tp", "value", tp);
+ std::cout << make_xml_tag("ip", "value", ip);
+ std::cout << make_xml_tag("dp", "value", dp);
+ std::cout << make_xml_tag("ep", "value", ep);
+ std::cout << make_xml_tag("cp", "value", cp);
+ std::cout << make_xml_tag("mp", "value", mp);
+ }
+ };
+
+ // Result formatter.
+ struct xml_result_set_regression_formatter : public xml_result_set_formatter
+ {
+ xml_result_set_regression_formatter(const std::string& r_container_name,
+ const std::string& r_container_desc)
+ : xml_result_set_formatter(r_container_name, r_container_desc)
+ {
+ std::cout << detail::make_xml_name_start_tag("progress");
+ std::cout << detail::make_xml_name_start_tag_end_delimiter();
+ }
+
+ ~xml_result_set_regression_formatter()
+ { std::cout << detail::make_xml_name_end_tag("progress"); }
+ };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_COMMON_XML_TEST_REGRESSION_FORMATTER_HPP
diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_load_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_load_trait.hpp
new file mode 100644
index 000000000..b771b8020
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_load_trait.hpp
@@ -0,0 +1,90 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file get_set_load_trait.hpp
+ * Contains traits for a random regression test
+ * for a specific container type.
+ */
+
+#ifndef PB_DS_REGRESSION_TEST_SET_LOAD_TRAIT_HPP
+#define PB_DS_REGRESSION_TEST_SET_LOAD_TRAIT_HPP
+
+#include <ext/pb_ds/assoc_container.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Cntnr, class Tag>
+ struct regression_test_get_set_load_traits
+ {
+ enum
+ {
+ value = false
+ };
+ };
+
+ template<typename Cntnr>
+ struct regression_test_hash_get_set_load_traits
+ {
+ enum
+ {
+ value = Cntnr::resize_policy::trigger_policy::get_set_load
+ };
+ };
+
+ template<typename Cntnr>
+ struct regression_test_get_set_load_traits<
+ Cntnr,
+ __gnu_pbds::cc_hash_tag> : public regression_test_hash_get_set_load_traits<
+ Cntnr>
+ { };
+
+ template<typename Cntnr>
+ struct regression_test_get_set_load_traits<
+ Cntnr,
+ __gnu_pbds::gp_hash_tag> : public regression_test_hash_get_set_load_traits<
+ Cntnr>
+ { };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_REGRESSION_TEST_SET_LOAD_TRAIT_HPP
diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_loads_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_loads_trait.hpp
new file mode 100644
index 000000000..6d7508da8
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/get_set_loads_trait.hpp
@@ -0,0 +1,90 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file get_set_loads_trait.hpp
+ * Contains traits for a random regression test
+ * for a specific container type.
+ */
+
+#ifndef PB_DS_REGRESSION_TEST_SET_LOADS_TRAIT_HPP
+#define PB_DS_REGRESSION_TEST_SET_LOADS_TRAIT_HPP
+
+#include <ext/pb_ds/assoc_container.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Cntnr, class Tag>
+ struct regression_test_get_set_loacontainer_traits
+ {
+ enum
+ {
+ value = false
+ };
+ };
+
+ template<typename Cntnr>
+ struct regression_test_hash_get_set_loacontainer_traits
+ {
+ enum
+ {
+ value = Cntnr::resize_policy::trigger_policy::get_set_loads
+ };
+ };
+
+ template<typename Cntnr>
+ struct regression_test_get_set_loacontainer_traits<
+ Cntnr,
+ __gnu_pbds::cc_hash_tag> : public regression_test_hash_get_set_loacontainer_traits<
+ Cntnr>
+ { };
+
+ template<typename Cntnr>
+ struct regression_test_get_set_loacontainer_traits<
+ Cntnr,
+ __gnu_pbds::gp_hash_tag> : public regression_test_hash_get_set_loacontainer_traits<
+ Cntnr>
+ { };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_REGRESSION_TEST_SET_LOADS_TRAIT_HPP
diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/native_type_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/native_type_trait.hpp
new file mode 100644
index 000000000..38761a177
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/native_type_trait.hpp
@@ -0,0 +1,185 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file native_type_trait.hpp
+ * Contains traits for a random regression test
+ * for a specific container type.
+ */
+
+#ifndef PB_DS_REGRESSION_TEST_NATIVE_TYPE_TRAIT_HPP
+#define PB_DS_REGRESSION_TEST_NATIVE_TYPE_TRAIT_HPP
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Key, class Allocator>
+ struct native_key_type;
+
+ template<typename Allocator>
+ struct native_key_type<
+ basic_type,
+ Allocator>
+ {
+ typedef std::string type;
+
+ static type
+ native_key(typename Allocator::template rebind<
+ basic_type>::other::const_reference r_key)
+ {
+ return (std::string(r_key));
+ }
+ };
+
+ template<typename Hd, class Tl, class Allocator>
+ struct native_key_type<
+ std::pair<
+ Hd,
+ Tl>,
+ Allocator>
+ {
+ typedef typename native_key_type< Hd, Allocator>::type hd_type;
+
+ typedef typename native_key_type< Tl, Allocator>::type tl_type;
+
+ typedef std::pair< hd_type, tl_type> type;
+
+ static type
+ native_key(typename Allocator::template rebind< std::pair<Hd, Tl> >::other::const_reference r_key)
+ {
+ return (std::make_pair(
+ native_key_type<Hd, Allocator>::native_key(r_key.first),
+ native_key_type<Tl, Allocator>::native_key(r_key.second)));
+ }
+ };
+
+ template<typename Native_Key_Type,
+ class Key_Type,
+ class Data_Type,
+ class Allocator>
+ struct native_type_traits_base;
+
+ template<typename Native_Key_Type, class Key_Type, class Allocator>
+ struct native_type_traits_base<
+ Native_Key_Type,
+ Key_Type,
+ basic_type,
+ Allocator>
+ {
+ public:
+ typedef std::map< Native_Key_Type, std::string> type;
+
+ public:
+ static const typename type::key_type&
+ extract_key(typename type::const_reference r_val)
+ {
+ return (r_val.first);
+ }
+
+ static typename type::value_type
+ native_value(typename Allocator::template rebind< std::pair<Key_Type, basic_type> >::other::const_reference r_val)
+ {
+ return (std::make_pair(
+ native_key_type<Key_Type, Allocator>::native_key(r_val.first),
+ std::string(r_val.second)));
+ }
+ };
+
+ template<typename Native_Key_Type, class Key_Type, class Allocator>
+ struct native_type_traits_base<
+ Native_Key_Type,
+ Key_Type,
+ __gnu_pbds::null_mapped_type,
+ Allocator>
+ {
+ public:
+ typedef std::set< Native_Key_Type> type;
+
+ public:
+ static const typename type::key_type&
+ extract_key(typename type::const_reference r_val)
+ {
+ return (r_val);
+ }
+
+ static typename type::value_type
+ native_value(typename Allocator::template rebind<
+ Key_Type>::other::const_reference r_val)
+ {
+ return (native_key_type<Key_Type, Allocator>::native_key(
+ r_val));
+ }
+ };
+
+#define PB_DS_NATIVE_KEY_TYPE_C_DEC \
+ native_key_type< \
+ Key_Type, \
+ Allocator>
+
+#define PB_DS_BASE_C_DEC \
+ native_type_traits_base< \
+ typename PB_DS_NATIVE_KEY_TYPE_C_DEC::type, \
+ Key_Type, \
+ Data_Type, \
+ Allocator>
+
+ template<typename Key_Type, class Data_Type, class Allocator>
+ struct native_type_traits : public PB_DS_BASE_C_DEC
+ {
+ typedef typename PB_DS_BASE_C_DEC::type type;
+
+ typedef typename type::key_type key_type;
+
+ static typename PB_DS_NATIVE_KEY_TYPE_C_DEC::type
+ native_key(typename Allocator::template rebind<
+ Key_Type>::other::const_reference r_key)
+ {
+ return (PB_DS_NATIVE_KEY_TYPE_C_DEC::native_key(r_key));
+ }
+ };
+
+#undef PB_DS_BASE_C_DEC
+
+#undef PB_DS_NATIVE_KEY_TYPE_C_DEC
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_REGRESSION_TEST_NATIVE_TYPE_TRAIT_HPP
diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/node_update_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/node_update_trait.hpp
new file mode 100644
index 000000000..d971c1fb2
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/node_update_trait.hpp
@@ -0,0 +1,124 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file node_update_trait.hpp
+ * Contains traits for a random regression test
+ * for a specific container type.
+ */
+
+#ifndef PB_DS_REGRESSION_TEST_NODE_UPDATOR_TRAIT_HPP
+#define PB_DS_REGRESSION_TEST_NODE_UPDATOR_TRAIT_HPP
+
+#include <ext/pb_ds/assoc_container.hpp>
+#include <common_type/assoc/detail/tree_supports_order_statistics.hpp>
+#include <common_type/assoc/detail/trie_supports_order_statistics.hpp>
+#include <common_type/assoc/detail/trie_supports_prefix_search.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Cntnr, class Tag>
+ struct regression_test_node_update_traits
+ {
+ enum
+ {
+ order_statistics = false,
+ prefix_search = false
+ };
+ };
+
+ template<typename Cntnr>
+ struct regression_test_node_update_traits<
+ Cntnr,
+ __gnu_pbds::pat_trie_tag>
+ {
+ enum
+ {
+ order_statistics =
+ trie_supports_order_statistics<Cntnr>::value,
+ prefix_search =
+ trie_supports_prefix_search<Cntnr>::value
+ };
+ };
+
+ template<typename Cntnr>
+ struct regression_test_node_update_traits<
+ Cntnr,
+ __gnu_pbds::rb_tree_tag>
+ {
+ enum
+ {
+ order_statistics =
+ tree_supports_order_statistics<Cntnr>::value,
+ prefix_search = false
+ };
+ };
+
+ template<typename Cntnr>
+ struct regression_test_node_update_traits<
+ Cntnr,
+ __gnu_pbds::splay_tree_tag>
+ {
+ enum
+ {
+ order_statistics =
+ tree_supports_order_statistics<Cntnr>::value,
+ prefix_search = false
+ };
+ };
+
+ template<typename Cntnr>
+ struct regression_test_node_update_traits<
+ Cntnr,
+ __gnu_pbds::ov_tree_tag>
+ {
+ enum
+ {
+ order_statistics =
+ tree_supports_order_statistics<Cntnr>::value,
+ prefix_search = false
+ };
+ };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_REGRESSION_TEST_NODE_UPDATOR_TRAIT_HPP
diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/resize_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/resize_trait.hpp
new file mode 100644
index 000000000..51e012775
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/resize_trait.hpp
@@ -0,0 +1,90 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file resize_trait.hpp
+ * Contains traits for a random regression test
+ * for a specific container type.
+ */
+
+#ifndef PB_DS_REGRESSION_TEST_RESIZE_TRAIT_HPP
+#define PB_DS_REGRESSION_TEST_RESIZE_TRAIT_HPP
+
+#include <ext/pb_ds/assoc_container.hpp>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ template<typename Cntnr, class Tag>
+ struct regression_test_resize_traits
+ {
+ enum
+ {
+ value = false
+ };
+ };
+
+ template<typename Cntnr>
+ struct regression_test_hash_resize_traits
+ {
+ enum
+ {
+ value = Cntnr::resize_policy::external_size_access
+ };
+ };
+
+ template<typename Cntnr>
+ struct regression_test_resize_traits<
+ Cntnr,
+ __gnu_pbds::cc_hash_tag> : public regression_test_hash_resize_traits<
+ Cntnr>
+ { };
+
+ template<typename Cntnr>
+ struct regression_test_resize_traits<
+ Cntnr,
+ __gnu_pbds::gp_hash_tag> : public regression_test_hash_resize_traits<
+ Cntnr>
+ { };
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_REGRESSION_TEST_RESIZE_TRAIT_HPP
diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/to_string.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/to_string.hpp
new file mode 100644
index 000000000..7a1a2e305
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/to_string.hpp
@@ -0,0 +1,81 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file to_string.hpp
+ * Contains classes for transforming stuff to strings.
+ */
+
+#ifndef PB_DS_REGRESSION_TEST_TO_STRING_HPP
+#define PB_DS_REGRESSION_TEST_TO_STRING_HPP
+
+#include <regression/basic_type.hpp>
+#include <string>
+
+namespace __gnu_pbds
+{
+
+ namespace test
+ {
+
+ namespace detail
+ {
+
+ std::string
+ to_string(const basic_type& r_t)
+ {
+ return (r_t);
+ }
+
+ std::string
+ to_string(const std::string& r_t)
+ {
+ return (r_t);
+ }
+
+ template<typename Hd, class Tl>
+ std::string
+ to_string(const std::pair<Hd, Tl>&r_t)
+ {
+ std::ostringstream ret;
+
+ ret << to_string(r_t.first) << " " << to_string(r_t.second);
+
+ return (ret.str());
+ }
+
+ } // namespace detail
+
+ } // namespace test
+
+} // namespace __gnu_pbds
+
+#endif // #ifndef PB_DS_REGRESSION_TEST_TO_STRING_HPP
diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp
new file mode 100644
index 000000000..a4a768e5e
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp
@@ -0,0 +1,206 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file trait.hpp
+ * Contains traits for a random regression test
+ * for a specific container type.
+ */
+
+#ifndef PB_DS_REGRESSION_TEST_TRAIT_HPP
+#define PB_DS_REGRESSION_TEST_TRAIT_HPP
+
+#include <regression/trait/erase_if_fn.hpp>
+#include <regression/trait/assoc/to_string.hpp>
+#include <regression/trait/assoc/type_trait.hpp>
+#include <regression/trait/assoc/native_type_trait.hpp>
+#include <regression/trait/assoc/resize_trait.hpp>
+#include <regression/trait/assoc/get_set_loads_trait.hpp>
+#include <regression/trait/assoc/get_set_load_trait.hpp>
+#include <regression/trait/assoc/node_update_trait.hpp>
+
+namespace __gnu_pbds
+{
+namespace test
+{
+namespace detail
+{
+
+#define PB_DS_CLASS_T_DEC \
+ template<typename Cntnr>
+
+#define PB_DS_CLASS_C_DEC \
+ regression_test_traits<Cntnr>
+
+#define PB_DS_TYPE_TRAITS_C_DEC \
+ regression_test_type_traits<Cntnr>
+
+#define PB_DS_NATIVE_TYPE_TRAITS_C_DEC \
+ native_type_traits<typename PB_DS_TYPE_TRAITS_C_DEC::key_type, \
+ typename PB_DS_TYPE_TRAITS_C_DEC::mapped_type, \
+ typename Cntnr::allocator_type>
+
+#define PB_DS_RESIZE_TRAITS_C_DEC \
+ regression_test_resize_traits<Cntnr, typename Cntnr::container_category>
+
+#define PB_DS_SET_LOADS_TRAITS_C_DEC \
+ regression_test_get_set_loacontainer_traits<Cntnr, \
+ typename Cntnr::container_category>
+
+#define PB_DS_SET_LOAD_TRAITS_C_DEC \
+ regression_test_get_set_load_traits<Cntnr,typename Cntnr::container_category>
+
+#define PB_DS_NODE_UPDATOR_TRAITS_C_DEC \
+ regression_test_node_update_traits<Cntnr, typename Cntnr::container_category>
+
+ template<typename Cntnr>
+ struct regression_test_traits : private PB_DS_TYPE_TRAITS_C_DEC,
+ private PB_DS_NATIVE_TYPE_TRAITS_C_DEC,
+ private PB_DS_RESIZE_TRAITS_C_DEC,
+ private PB_DS_NODE_UPDATOR_TRAITS_C_DEC,
+ private PB_DS_SET_LOADS_TRAITS_C_DEC,
+ private PB_DS_SET_LOAD_TRAITS_C_DEC
+ {
+ private:
+ typedef PB_DS_NATIVE_TYPE_TRAITS_C_DEC native_type_traits_base;
+ typedef PB_DS_TYPE_TRAITS_C_DEC type_traits_base;
+
+ public:
+ typedef typename Cntnr::value_type value_type;
+ typedef typename Cntnr::const_reference const_reference;
+ typedef typename PB_DS_NATIVE_TYPE_TRAITS_C_DEC::type native_type;
+ typedef typename native_type::value_type native_value_type;
+
+ // Only associative containers.
+ typedef typename Cntnr::key_type key_type;
+ typedef typename Cntnr::const_key_reference const_key_reference;
+ typedef typename native_type::key_type native_key_type;
+
+ enum
+ {
+ resize = PB_DS_RESIZE_TRAITS_C_DEC::value,
+ get_set_loads = PB_DS_SET_LOADS_TRAITS_C_DEC::value,
+ get_set_load = PB_DS_SET_LOAD_TRAITS_C_DEC::value,
+ order_statistics = PB_DS_NODE_UPDATOR_TRAITS_C_DEC::order_statistics,
+ prefix_search = PB_DS_NODE_UPDATOR_TRAITS_C_DEC::prefix_search
+ };
+
+ template<typename T>
+ struct erase_if_fn : public regression_test_erase_if_fn<T>
+ { };
+
+ static size_t
+ erase_if(native_type& r_native_c)
+ {
+ typedef regression_test_erase_if_fn<native_value_type> erase_if_fn;
+ typename native_type::iterator it = r_native_c.begin();
+ size_t num_ersd = 0;
+ while (it != r_native_c.end())
+ if (erase_if_fn()(*it))
+ {
+ ++num_ersd;
+ r_native_c.erase(it);
+ it = r_native_c.begin();
+ }
+ else
+ ++it;
+ return num_ersd;
+ }
+
+ static void
+ print_container(const Cntnr& r_c, std::ostream& r_os)
+ { PB_DS_TYPE_TRAITS_C_DEC::print_container(r_c, r_os); }
+
+ template<typename Gen>
+ static key_type
+ generate_key(Gen& r_gen, size_t max)
+ { return PB_DS_TYPE_TRAITS_C_DEC::generate_key(r_gen, max); }
+
+ template<typename Gen>
+ static value_type
+ generate_value(Gen& r_gen, size_t max)
+ { return PB_DS_TYPE_TRAITS_C_DEC::generate_value(r_gen, max); }
+
+ static const_key_reference
+ extract_key(const_reference r_val)
+ { return type_traits_base::extract_key(r_val); }
+
+ static native_key_type
+ native_key(const_key_reference r_key)
+ { return native_type_traits_base::native_key(r_key); }
+
+ static native_value_type
+ native_value(const_reference r_val)
+ { return native_type_traits_base::native_value(r_val); }
+
+ static const native_key_type&
+ extract_native_key(const native_value_type& r_val)
+ { return native_type_traits_base::extract_key(r_val); }
+
+ static bool
+ cmp(const_reference r_val, const native_value_type& r_native_val)
+ { return val_to_string(r_val) == native_val_to_string(r_native_val); }
+
+ static std::string
+ val_to_string(const_reference r_val)
+ { return to_string(r_val); }
+
+ static std::string
+ key_to_string(const_key_reference r_key)
+ { return to_string(r_key); }
+
+ static std::string
+ native_val_to_string(const native_value_type& r_native_val)
+ { return to_string(r_native_val); }
+
+ static bool
+ prefix_match(const_key_reference r_key, const std::string& r_native_key)
+ {
+ const size_t len = std::min(r_key.length(), r_native_key.length());
+ const std::string substr = r_native_key.substr(0, len);
+ return substr == static_cast<const std::string&>(r_key);
+ }
+ };
+
+#undef PB_DS_TYPE_TRAITS_C_DEC
+#undef PB_DS_NATIVE_TYPE_TRAITS_C_DEC
+#undef PB_DS_RESIZE_TRAITS_C_DEC
+#undef PB_DS_SET_LOADS_TRAITS_C_DEC
+#undef PB_DS_SET_LOAD_TRAITS_C_DEC
+#undef PB_DS_NODE_UPDATOR_TRAITS_C_DEC
+#undef PB_DS_CLASS_T_DEC
+#undef PB_DS_CLASS_C_DEC
+
+} // namespace detail
+} // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/regression/trait/assoc/type_trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/assoc/type_trait.hpp
new file mode 100644
index 000000000..c7ce5f7a3
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/trait/assoc/type_trait.hpp
@@ -0,0 +1,111 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file type_trait.hpp
+ * Contains traits for a random regression test
+ * for a specific container type.
+ */
+
+#ifndef PB_DS_REGRESSION_TEST_TYPE_TRAIT_HPP
+#define PB_DS_REGRESSION_TEST_TYPE_TRAIT_HPP
+
+#include <regression/basic_type.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename Cntnr>
+ struct regression_test_type_traits
+ {
+ typedef Cntnr cntnr;
+ typedef typename cntnr::key_type key_type;
+ typedef typename cntnr::const_key_reference const_key_reference;
+ typedef typename cntnr::value_type value_type;
+ typedef typename cntnr::const_reference const_reference;
+ typedef typename cntnr::mapped_type mapped_type;
+ typedef typename cntnr::const_mapped_reference const_mapped_reference;
+
+ template<typename Gen>
+ static key_type
+ generate_key(Gen& r_gen, size_t max)
+ { return basic_type(r_gen, max); }
+
+ template<typename Gen>
+ static value_type
+ generate_value(Gen& r_gen, size_t max)
+ { return generate_value(r_gen, max, value_type()); }
+
+ static const_key_reference
+ extract_key(const_reference r_val)
+ { return extract_key_imp(r_val); }
+
+ private:
+ typedef typename cntnr::allocator_type::template rebind<basic_type>::other
+ basic_type_rebind;
+
+ typedef typename basic_type_rebind::const_reference basic_type_const_reference;
+
+ typedef typename cntnr::allocator_type::template rebind<std::pair<const basic_type, basic_type> >::other pair_type_rebind;
+ typedef typename pair_type_rebind::const_reference pair_type_const_reference;
+
+ template<typename Gen>
+ static value_type
+ generate_value(Gen& r_gen, size_t max, __gnu_pbds::null_mapped_type)
+ { return basic_type(r_gen, max); }
+
+ template<typename Gen>
+ static value_type
+ generate_value(Gen& r_gen, size_t max, basic_type)
+ { return basic_type(r_gen, max); }
+
+ template<typename Gen>
+ static value_type
+ generate_value(Gen& gen, size_t max,
+ std::pair<const basic_type, basic_type>)
+ { return std::make_pair(basic_type(gen, max), basic_type(gen, max)); }
+
+ static const_key_reference
+ extract_key_imp(basic_type_const_reference r_val)
+ { return r_val; }
+
+ static const_key_reference
+ extract_key_imp(pair_type_const_reference r_val)
+ { return r_val.first; }
+ };
+ } // namespace detail
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/regression/trait/erase_if_fn.hpp b/libstdc++-v3/testsuite/util/regression/trait/erase_if_fn.hpp
new file mode 100644
index 000000000..9903dfeb3
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/trait/erase_if_fn.hpp
@@ -0,0 +1,85 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file erase_if_fn.hpp
+ * Contains traits for a random regression test
+ * for a specific container type.
+ */
+
+#ifndef PB_DS_REGRESSION_TEST_ERASE_IF_FN_HPP
+#define PB_DS_REGRESSION_TEST_ERASE_IF_FN_HPP
+
+#include <functional>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename T>
+ struct regression_test_erase_if_fn
+ : public std::unary_function<T, bool>
+ {
+ private:
+ typedef const T& const_reference;
+
+ public:
+ bool
+ operator()(const_reference r_t) const
+ {
+ return (r_t.length() == 0 ||
+ static_cast<size_t>(*((r_t).begin())) % 2 == 1);
+ }
+ };
+
+ template<typename Hd, class Tl>
+ struct regression_test_erase_if_fn<std::pair<Hd, Tl> >
+ : public std::unary_function<std::pair<Hd, Tl>, bool>
+ {
+ private:
+ typedef const std::pair<Hd, Tl>& const_reference;
+ typedef regression_test_erase_if_fn<Hd> hd_erase_if_fn;
+ typedef regression_test_erase_if_fn<Tl> tl_erase_if_fn;
+
+ public:
+ bool
+ operator()(const_reference r_t) const
+ {
+ return (hd_erase_if_fn()(r_t.first) && tl_erase_if_fn()(r_t.second));
+ }
+ };
+ } // namespace detail
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/regression/trait/priority_queue/trait.hpp b/libstdc++-v3/testsuite/util/regression/trait/priority_queue/trait.hpp
new file mode 100644
index 000000000..f55dbbc99
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/regression/trait/priority_queue/trait.hpp
@@ -0,0 +1,82 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file trait.hpp
+ * Contains traits for a random regression test
+ * for a specific container type.
+ */
+
+#ifndef PB_DS_REGRESSION_TEST_TRAIT_HPP
+#define PB_DS_REGRESSION_TEST_TRAIT_HPP
+
+#include <regression/trait/erase_if_fn.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ template<typename Cntnr>
+ struct regression_test_traits
+ {
+ typedef typename Cntnr::value_type value_type;
+ typedef typename Cntnr::const_reference const_reference;
+ typedef __gnu_pbds::test::native_priority_queue<std::string, true> native_type;
+ typedef typename native_type::value_type native_value_type;
+
+ template<typename T>
+ struct erase_if_fn : public regression_test_erase_if_fn<T>
+ { };
+
+ template<typename Gen>
+ static value_type
+ generate_value(Gen& r_gen, size_t max)
+ { return basic_type(r_gen, max); }
+
+ static native_value_type
+ native_value(const_reference r_val)
+ { return native_value_type(r_val); }
+
+ static bool
+ cmp(const_reference r_val, const native_value_type& r_native_val)
+ { return val_to_string(r_val) == r_native_val; }
+
+ static std::string
+ val_to_string(const_reference r_val)
+ { return std::string(r_val); }
+ };
+ } // namespace detail
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/replacement_memory_operators.h b/libstdc++-v3/testsuite/util/replacement_memory_operators.h
new file mode 100644
index 000000000..b7d3a3b10
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/replacement_memory_operators.h
@@ -0,0 +1,113 @@
+//
+// Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <exception>
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+namespace __gnu_test
+{
+ struct counter_error : public std::exception { };
+
+ struct counter
+ {
+ std::size_t _M_count;
+ bool _M_throw;
+
+ counter() : _M_count(0), _M_throw(true) { }
+
+ ~counter()
+ {
+ if (_M_throw && _M_count != 0)
+ throw counter_error();
+ }
+
+ static void
+ increment() { get()._M_count++; }
+
+ static void
+ decrement() { get()._M_count--; }
+
+ static counter&
+ get()
+ {
+ static counter g;
+ return g;
+ }
+
+ static std::size_t
+ count() { return get()._M_count; }
+
+ static void
+ exceptions(bool __b) { get()._M_throw = __b; }
+ };
+
+ template<typename Alloc, bool uses_global_new>
+ bool
+ check_new(Alloc a = Alloc())
+ {
+ __gnu_test::counter::exceptions(false);
+ a.allocate(10);
+ const bool __b((__gnu_test::counter::count() > 0) == uses_global_new);
+ if (!__b)
+ throw std::logic_error("counter not incremented");
+ return __b;
+ }
+
+ template<typename Alloc, bool uses_global_delete>
+ bool
+ check_delete(Alloc a = Alloc())
+ {
+ __gnu_test::counter::exceptions(false);
+ typename Alloc::pointer p = a.allocate(10);
+ const std::size_t count1 = __gnu_test::counter::count();
+ a.deallocate(p, 10);
+ const std::size_t count2 = __gnu_test::counter::count();
+ const bool __b((count2 < count1) == uses_global_delete);
+ if (!__b)
+ throw std::logic_error("counter not decremented");
+ return __b;
+ }
+} // namespace __gnu_test
+
+void* operator new(std::size_t size) throw(std::bad_alloc)
+{
+ std::printf("operator new is called \n");
+ void* p = std::malloc(size);
+ if (!p)
+ throw std::bad_alloc();
+ __gnu_test::counter::increment();
+ return p;
+}
+
+void operator delete(void* p) throw()
+{
+ std::printf("operator delete is called \n");
+ if (p)
+ {
+ std::free(p);
+ __gnu_test::counter::decrement();
+
+ std::size_t count = __gnu_test::counter::count();
+ if (count == 0)
+ std::printf("All memory released \n");
+ else
+ std::printf("%lu allocations to be released \n", (unsigned long)count);
+ }
+}
diff --git a/libstdc++-v3/testsuite/util/statistic/result_recorder.hpp b/libstdc++-v3/testsuite/util/statistic/result_recorder.hpp
new file mode 100644
index 000000000..fd638e22e
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/statistic/result_recorder.hpp
@@ -0,0 +1,98 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file result_recorder.hpp
+ * Contains a class for recording results
+ */
+
+#ifndef PB_DS_RES_RECORDER_HPP
+#define PB_DS_RES_RECORDER_HPP
+
+#include <statistic/sample_mean.hpp>
+#include <statistic/sample_variance.hpp>
+#include <statistic/sample_mean_confidence_checker.hpp>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ /*
+ * Records results until the probability that the sample mean is 10% away
+ * from the true mean is ~ 0.05.
+ */
+ template<typename Value_Type>
+ class result_recorder
+ {
+ public:
+ typedef Value_Type value_type;
+
+ result_recorder()
+ : m_sample_mean(value_type()), m_sample_var(value_type())
+ { }
+
+ bool
+ add_result(value_type res);
+
+ inline value_type
+ get_sample_mean() const
+ { return m_sample_mean; }
+
+ private:
+ typedef std::list<value_type> list_type;
+
+ list_type m_l;
+ value_type m_sample_mean;
+ value_type m_sample_var;
+ };
+
+
+ template<typename Value_Type>
+ bool
+ result_recorder<Value_Type>::
+ add_result(value_type res)
+ {
+ m_l.push_back(res);
+ m_sample_mean = sample_mean(m_l.begin(), m_l.end());
+ m_sample_var = sample_variance(m_l.begin(), m_l.end(), m_sample_mean);
+
+ size_t dist = std::distance(m_l.begin(), m_l.end());
+ return sample_mean_confidence_checker(m_sample_mean, m_sample_var,
+ dist, 0.1);
+ }
+ } // namespace detail
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/statistic/sample_mean.hpp b/libstdc++-v3/testsuite/util/statistic/sample_mean.hpp
new file mode 100644
index 000000000..8dfdab8e2
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/statistic/sample_mean.hpp
@@ -0,0 +1,69 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file sample_mean.hpp
+ * Contains a function for calculating a sample mean
+ */
+
+#ifndef PB_DS_SAMPLE_MEAN_HPP
+#define PB_DS_SAMPLE_MEAN_HPP
+
+#include <list>
+#include <numeric>
+#include <math.h>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+#define PB_DS_VTYPE typename std::iterator_traits<It>::value_type
+
+ template<typename It>
+ PB_DS_VTYPE
+ sample_mean(It b, It e)
+ {
+ const PB_DS_VTYPE total = std::accumulate(b, e, PB_DS_VTYPE(0));
+ const size_t num = std::distance(b, e);
+ return total / num;
+ }
+
+#undef PB_DS_VTYPE
+
+ } // namespace detail
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/statistic/sample_mean_confidence_checker.hpp b/libstdc++-v3/testsuite/util/statistic/sample_mean_confidence_checker.hpp
new file mode 100644
index 000000000..d63f34bcb
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/statistic/sample_mean_confidence_checker.hpp
@@ -0,0 +1,84 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file sample_mean_confidence_checker.hpp
+ * Contains a function for checking the confidence of a sample mean
+ */
+
+#ifndef PB_DS_SAMPLE_MEAN_CONFIDENCE_CHECKER_HPP
+#define PB_DS_SAMPLE_MEAN_CONFIDENCE_CHECKER_HPP
+
+#include <list>
+#include <numeric>
+#include <math.h>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+ /*
+ * Checks that a sample mean sm is in the relative interval
+ * relative_interval of a true mean (assuming i.i.d. samples),
+ * given a sample variance sv taken over num_samples samples,
+ * with confidence ~ 0.95.
+ *
+ * See "Probability, Random Variables, and Stochastic Processes"
+ * (Third edition) Athanasios Papoulis, Chapter 9.
+ */
+ template<typename Value_Type>
+ bool
+ sample_mean_confidence_checker(Value_Type sm, Value_Type sv,
+ std::size_t num_samples,
+ double relative_interval)
+ {
+ enum
+ {
+ // Ensures that the student-t distribution is approximately normal.
+ min_num_samples = 30
+ };
+
+ if (num_samples < min_num_samples)
+ return (false);
+
+ // This is z_u (normal-dist percentile) for u = 0.975.
+ const Value_Type z = 1.976;
+
+ return (sv / ::sqrt(double(num_samples)) <= relative_interval * sm / z);
+ }
+ } // namespace detail
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/statistic/sample_variance.hpp b/libstdc++-v3/testsuite/util/statistic/sample_variance.hpp
new file mode 100644
index 000000000..ed61d0b05
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/statistic/sample_variance.hpp
@@ -0,0 +1,81 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file sample_variance.hpp
+ * Contains a function for calculating a sample variance
+ */
+
+#ifndef PB_DS_SAMPLE_VAR_HPP
+#define PB_DS_SAMPLE_VAR_HPP
+
+#include <list>
+#include <numeric>
+#include <math.h>
+#include <iterator>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ namespace detail
+ {
+#define PB_DS_VTYPE typename std::iterator_traits<It>::value_type
+
+ template<typename It>
+ PB_DS_VTYPE
+ sample_variance(It b, It e, PB_DS_VTYPE sm)
+ {
+ PB_DS_VTYPE ss = 0;
+ size_t num_res = 0;
+
+ while (b != e)
+ {
+ const PB_DS_VTYPE d =* b - sm;
+ ss += d* d;
+ ++num_res;
+ ++b;
+ }
+
+ if (num_res == 1)
+ return 0;
+
+ return ::sqrt(ss / (num_res - 1));
+ }
+
+#undef PB_DS_VTYPE
+
+ } // namespace detail
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif
+
diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.cc b/libstdc++-v3/testsuite/util/testsuite_abi.cc
new file mode 100644
index 000000000..ea100b681
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_abi.cc
@@ -0,0 +1,563 @@
+// -*- C++ -*-
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+// Free Software Foundation, Inc.
+
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 3, or (at
+// your option) any later version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Benjamin Kosnik <bkoz@redhat.com>
+
+#include "testsuite_abi.h"
+#include <cstdlib>
+#include <sstream>
+#include <fstream>
+#include <iostream>
+#include <vector>
+#include <algorithm>
+
+using namespace std;
+
+void
+symbol::init(string& data)
+{
+ const char delim = ':';
+ const char version_delim = '@';
+ const string::size_type npos = string::npos;
+ string::size_type n = 0;
+
+ // Set the type.
+ if (data.find("FUNC") == 0)
+ type = symbol::function;
+ else if (data.find("OBJECT") == 0)
+ type = symbol::object;
+ else if (data.find("TLS") == 0)
+ type = symbol::tls;
+
+ n = data.find_first_of(delim);
+ if (n != npos)
+ data.erase(data.begin(), data.begin() + n + 1);
+
+ // Iff object or TLS, get size info.
+ if (type == symbol::object || type == symbol::tls)
+ {
+ n = data.find_first_of(delim);
+ if (n != npos)
+ {
+ string objectsize(data.begin(), data.begin() + n);
+ istringstream iss(objectsize);
+ int x;
+ iss >> x;
+ if (!iss.fail())
+ size = x;
+ data.erase(data.begin(), data.begin() + n + 1);
+ }
+ }
+
+ // Set the name and raw_name.
+ raw_name = string(data.begin(), data.end());
+ n = data.find_first_of(version_delim);
+ if (n != npos)
+ {
+ // Found version string.
+ name = string(data.begin(), data.begin() + n);
+ n = data.find_last_of(version_delim);
+ data.erase(data.begin(), data.begin() + n + 1);
+
+ // Set version name.
+ version_name = data;
+ }
+ else
+ {
+ // No versioning info.
+ name = string(data.begin(), data.end());
+ version_status = symbol::none;
+ }
+
+ // Set the demangled name.
+ demangled_name = demangle(name);
+}
+
+void
+symbol::print() const
+{
+ const char tab = '\t';
+ cout << name << endl;
+
+ if (demangled_name != name)
+ cout << demangled_name << endl;
+
+ string vers;
+ switch (version_status)
+ {
+ case none:
+ vers = "none";
+ break;
+ case compatible:
+ vers = "compatible";
+ break;
+ case incompatible:
+ vers = "incompatible";
+ break;
+ case unversioned:
+ vers = "unversioned";
+ break;
+ default:
+ vers = "<default>";
+ }
+ cout << "version status: " << vers << endl;
+
+ if (version_name.size()
+ && (version_status == compatible || version_status == incompatible))
+ cout << version_name << endl;
+
+ string type_string;
+ switch (type)
+ {
+ case function:
+ type_string = "function";
+ break;
+ case object:
+ type_string = "object";
+ break;
+ case tls:
+ type_string = "tls";
+ break;
+ case uncategorized:
+ type_string = "uncategorized";
+ break;
+ default:
+ type_string = "<default>";
+ }
+ cout << "type: " << type_string << endl;
+
+ if (type == object || type == tls)
+ cout << "type size: " << size << endl;
+
+ string status_string;
+ switch (status)
+ {
+ case added:
+ status_string = "added";
+ break;
+ case subtracted:
+ status_string = "subtracted";
+ break;
+ case undesignated:
+ status_string = "undesignated";
+ break;
+ default:
+ status_string = "<default>";
+ }
+ cout << "status: " << status_string << endl;
+
+ cout << endl;
+}
+
+
+bool
+check_version(symbol& test, bool added)
+{
+ // Construct list of compatible versions.
+ typedef std::vector<std::string> compat_list;
+ static compat_list known_versions;
+ if (known_versions.empty())
+ {
+ // NB: First version here must be the default version for this
+ // version of DT_SONAME.
+ known_versions.push_back("GLIBCXX_3.4");
+ known_versions.push_back("GLIBCXX_3.4.1");
+ known_versions.push_back("GLIBCXX_3.4.2");
+ known_versions.push_back("GLIBCXX_3.4.3");
+ known_versions.push_back("GLIBCXX_3.4.4");
+ known_versions.push_back("GLIBCXX_3.4.5");
+ known_versions.push_back("GLIBCXX_3.4.6");
+ known_versions.push_back("GLIBCXX_3.4.7");
+ known_versions.push_back("GLIBCXX_3.4.8");
+ known_versions.push_back("GLIBCXX_3.4.9");
+ known_versions.push_back("GLIBCXX_3.4.10");
+ known_versions.push_back("GLIBCXX_3.4.11");
+ known_versions.push_back("GLIBCXX_3.4.12");
+ known_versions.push_back("GLIBCXX_3.4.13");
+ known_versions.push_back("GLIBCXX_3.4.14");
+ known_versions.push_back("GLIBCXX_3.4.15");
+ known_versions.push_back("GLIBCXX_3.4.16");
+ known_versions.push_back("GLIBCXX_LDBL_3.4");
+ known_versions.push_back("GLIBCXX_LDBL_3.4.7");
+ known_versions.push_back("GLIBCXX_LDBL_3.4.10");
+ known_versions.push_back("CXXABI_1.3");
+ known_versions.push_back("CXXABI_1.3.1");
+ known_versions.push_back("CXXABI_1.3.2");
+ known_versions.push_back("CXXABI_1.3.3");
+ known_versions.push_back("CXXABI_1.3.4");
+ known_versions.push_back("CXXABI_1.3.5");
+ known_versions.push_back("CXXABI_LDBL_1.3");
+ }
+ compat_list::iterator begin = known_versions.begin();
+ compat_list::iterator end = known_versions.end();
+
+ // Check for compatible version.
+ if (test.version_name.size())
+ {
+ compat_list::iterator it1 = find(begin, end, test.version_name);
+ compat_list::iterator it2 = find(begin, end, test.name);
+ if (it1 != end)
+ test.version_status = symbol::compatible;
+ else
+ test.version_status = symbol::incompatible;
+
+ // Check that added symbols aren't added in the base versions.
+ if (added
+ && (test.version_name == known_versions[0]
+ || test.version_name == "CXXABI_1.3"
+ || test.version_name == "GLIBCXX_LDBL_3.4"
+ || test.version_name == "CXXABI_LDBL_1.3"))
+ test.version_status = symbol::incompatible;
+
+ // Check that long double compatibility symbols demangled as
+ // __float128 are put into some _LDBL_ version name.
+ if (added && test.demangled_name.find("__float128") != std::string::npos)
+ {
+ // Has to be in _LDBL_ version name.
+ if (test.version_name.find("_LDBL_") == std::string::npos)
+ test.version_status = symbol::incompatible;
+ }
+
+ // Check for weak label.
+ if (it1 == end && it2 == end)
+ test.version_status = symbol::incompatible;
+
+ // Check that
+ // GLIBCXX_3.4
+ // GLIBCXX_3.4.5
+ // version as compatible
+ // XXX
+ }
+ else
+ {
+ if (added)
+ {
+ // New version labels are ok. The rest are not.
+ compat_list::iterator it2 = find(begin, end, test.name);
+ if (it2 != end)
+ test.version_status = symbol::compatible;
+ else
+ test.version_status = symbol::incompatible;
+ }
+ }
+ return test.version_status == symbol::compatible;
+}
+
+bool
+check_compatible(symbol& lhs, symbol& rhs, bool verbose)
+{
+ bool ret = true;
+ const char tab = '\t';
+
+ // Check to see if symbol_objects are compatible.
+ if (lhs.type != rhs.type)
+ {
+ ret = false;
+ if (verbose)
+ cout << tab << "incompatible types" << endl;
+ }
+
+ if (lhs.name != rhs.name)
+ {
+ ret = false;
+ if (verbose)
+ cout << tab << "incompatible names" << endl;
+ }
+
+ if (lhs.size != rhs.size)
+ {
+ ret = false;
+ if (verbose)
+ {
+ cout << tab << "incompatible sizes" << endl;
+ cout << tab << lhs.size << endl;
+ cout << tab << rhs.size << endl;
+ }
+ }
+
+ if (lhs.version_name != rhs.version_name
+ && !check_version(lhs) && !check_version(rhs))
+ {
+ ret = false;
+ if (verbose)
+ {
+ cout << tab << "incompatible versions" << endl;
+ cout << tab << lhs.version_name << endl;
+ cout << tab << rhs.version_name << endl;
+ }
+ }
+
+ if (verbose)
+ cout << endl;
+
+ return ret;
+}
+
+
+inline bool
+has_symbol(const string& name, const symbols& s) throw()
+{ return s.find(name) != s.end(); }
+
+const symbol&
+get_symbol(const string& name, const symbols& s)
+{
+ symbols::const_iterator i = s.find(name);
+ if (i != s.end())
+ {
+ return i->second;
+ }
+ else
+ {
+ ostringstream os;
+ os << "get_symbol failed for symbol " << name;
+ __throw_logic_error(os.str().c_str());
+ }
+}
+
+void
+examine_symbol(const char* name, const char* file)
+{
+ try
+ {
+ symbols s = create_symbols(file);
+ const symbol& sym = get_symbol(name, s);
+ sym.print();
+ }
+ catch(...)
+ { __throw_exception_again; }
+}
+
+int
+compare_symbols(const char* baseline_file, const char* test_file,
+ bool verbose)
+{
+ // Input both lists of symbols into container.
+ symbols baseline = create_symbols(baseline_file);
+ symbols test = create_symbols(test_file);
+
+ // Sanity check results.
+ if (!baseline.size() || !test.size())
+ {
+ cerr << "Problems parsing the list of exported symbols." << endl;
+ exit(2);
+ }
+
+ // Check to see if any long double compatibility symbols are produced.
+ bool ld_version_found(false);
+ symbols::iterator li(test.begin());
+ while (!ld_version_found && li != test.end())
+ {
+ if (li->second.version_name.find("_LDBL_") != std::string::npos)
+ ld_version_found = true;
+ ++li;
+ }
+
+ // Sort out names.
+ // Assuming all baseline names and test names are both unique w/ no
+ // duplicates.
+ //
+ // The names added to missing_names are baseline names not found in
+ // test names
+ // -> symbols that have been deleted.
+ //
+ // The names added to added_names are test names not in
+ // baseline names
+ // -> symbols that have been added.
+ typedef std::vector<std::string> symbol_names;
+ symbol_names shared_names;
+ symbol_names missing_names;
+ symbol_names added_names;
+ for (li = test.begin(); li != test.end(); ++li)
+ added_names.push_back(li->first);
+
+ for (symbols::iterator i = baseline.begin(); i != baseline.end(); ++i)
+ {
+ string name(i->first);
+ symbol_names::iterator end = added_names.end();
+ symbol_names::iterator it = find(added_names.begin(), end, name);
+ if (it != end)
+ {
+ // Found.
+ shared_names.push_back(name);
+ added_names.erase(it);
+ }
+ else
+ {
+ // Iff no test long double compatibility symbols at all and the symbol
+ // missing is a baseline long double compatibility symbol, skip.
+ string version_name(i->second.version_name);
+ bool base_ld(version_name.find("_LDBL_") != std::string::npos);
+ if (!base_ld || base_ld && ld_version_found)
+ missing_names.push_back(name);
+ }
+ }
+
+ // Fill out list of incompatible symbols.
+ typedef pair<symbol, symbol> symbol_pair;
+ vector<symbol_pair> incompatible;
+
+ // Check missing names for compatibility.
+ for (size_t j = 0; j < missing_names.size(); ++j)
+ {
+ symbol& sbase = baseline[missing_names[j]];
+ sbase.status = symbol::subtracted;
+ incompatible.push_back(symbol_pair(sbase, sbase));
+ }
+
+ // Check shared names for compatibility.
+ const symbol_names::size_type shared_size = shared_names.size();
+ for (size_t k = 0; k < shared_size; ++k)
+ {
+ symbol& sbase = baseline[shared_names[k]];
+ symbol& stest = test[shared_names[k]];
+ stest.status = symbol::existing;
+ if (!check_compatible(sbase, stest))
+ incompatible.push_back(symbol_pair(sbase, stest));
+ }
+
+ // Check added names for compatibility.
+ const symbol_names::size_type added_size = added_names.size();
+ for (size_t l = 0; l < added_size; ++l)
+ {
+ symbol& stest = test[added_names[l]];
+ stest.status = symbol::added;
+ if (!check_version(stest, true))
+ incompatible.push_back(symbol_pair(stest, stest));
+ }
+
+ // Report results.
+ if (verbose && added_names.size())
+ {
+ cout << endl << added_names.size() << " added symbols " << endl;
+ for (size_t j = 0; j < added_names.size() ; ++j)
+ {
+ cout << j << endl;
+ test[added_names[j]].print();
+ }
+ }
+
+ if (verbose && missing_names.size())
+ {
+ cout << endl << missing_names.size() << " missing symbols " << endl;
+ for (size_t j = 0; j < missing_names.size() ; ++j)
+ {
+ cout << j << endl;
+ baseline[missing_names[j]].print();
+ }
+ }
+
+ if (verbose && incompatible.size())
+ {
+ cout << endl << incompatible.size() << " incompatible symbols " << endl;
+ for (size_t j = 0; j < incompatible.size() ; ++j)
+ {
+ // First, print index.
+ cout << j << endl;
+
+ // Second, report name.
+ symbol& sbase = incompatible[j].first;
+ symbol& stest = incompatible[j].second;
+ stest.print();
+
+ // Second, report reason or reasons incompatible.
+ check_compatible(sbase, stest, true);
+ }
+ }
+
+ cout << "\n\t\t=== libstdc++-v3 check-abi Summary ===" << endl;
+ cout << endl;
+ cout << "# of added symbols:\t\t " << added_names.size() << endl;
+ cout << "# of missing symbols:\t\t " << missing_names.size() << endl;
+ cout << "# of incompatible symbols:\t " << incompatible.size() << endl;
+ cout << endl;
+ cout << "using: " << baseline_file << endl;
+
+ return !(missing_names.size() || incompatible.size());
+}
+
+
+symbols
+create_symbols(const char* file)
+{
+ symbols s;
+ ifstream ifs(file);
+ if (ifs.is_open())
+ {
+ // Organize file data into an associated container (symbols) of symbol
+ // objects mapped to mangled names without versioning
+ // information.
+ const string empty;
+ string line = empty;
+ while (getline(ifs, line).good())
+ {
+ symbol tmp;
+ tmp.init(line);
+ s[tmp.name] = tmp;
+ line = empty;
+ }
+ }
+ else
+ {
+ ostringstream os;
+ os << "create_symbols failed for file " << file;
+ __throw_runtime_error(os.str().c_str());
+ }
+ return s;
+}
+
+
+const char*
+demangle(const std::string& mangled)
+{
+ const char* name;
+ if (mangled[0] != '_' || mangled[1] != 'Z')
+ {
+ // This is not a mangled symbol, thus has "C" linkage.
+ name = mangled.c_str();
+ }
+ else
+ {
+ // Use __cxa_demangle to demangle.
+ int status = 0;
+ name = abi::__cxa_demangle(mangled.c_str(), 0, 0, &status);
+ if (!name)
+ {
+ switch (status)
+ {
+ case 0:
+ name = "error code = 0: success";
+ break;
+ case -1:
+ name = "error code = -1: memory allocation failure";
+ break;
+ case -2:
+ name = "error code = -2: invalid mangled name";
+ break;
+ case -3:
+ name = "error code = -3: invalid arguments";
+ break;
+ default:
+ name = "error code unknown - who knows what happened";
+ }
+ }
+ }
+ return name;
+}
+
diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.h b/libstdc++-v3/testsuite/util/testsuite_abi.h
new file mode 100644
index 000000000..bff39903e
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_abi.h
@@ -0,0 +1,99 @@
+// -*- C++ -*-
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Free Software Foundation, Inc.
+
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 3, or (at
+// your option) any later version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// Benjamin Kosnik <bkoz@redhat.com>
+
+#include <string>
+#include <stdexcept>
+#include <vector>
+#include <locale>
+#include <tr1/unordered_map>
+#include <cxxabi.h>
+
+// Encapsulates symbol characteristics.
+struct symbol
+{
+ enum category { function, object, tls, uncategorized };
+ enum designation { existing, added, subtracted, undesignated };
+ enum version { none, compatible, incompatible, unversioned };
+ enum compatibility
+ {
+ compat_type = 1,
+ compat_name = 2,
+ compat_size = 4,
+ compat_version = 8
+ };
+
+ category type;
+ std::string name;
+ std::string raw_name; // Name with versioning info still attached.
+ std::string demangled_name;
+ int size;
+ std::string version_name;
+ version version_status;
+ designation status;
+
+ symbol()
+ : type(uncategorized), size(0), version_status(unversioned),
+ status(undesignated) { }
+
+ symbol(const symbol& other)
+ : type(other.type), name(other.name), demangled_name(other.demangled_name),
+ size(other.size), version_name(other.version_name),
+ version_status(other.version_status), status(other.status) { }
+
+ void
+ print() const;
+
+ void
+ init(std::string& data);
+};
+
+// Map type between symbol names and full symbol info.
+typedef std::tr1::unordered_map<std::string, symbol> symbols;
+
+
+// Check.
+bool
+check_version(symbol& test, bool added = false);
+
+bool
+check_compatible(symbol& lhs, symbol& rhs, bool verbose = false);
+
+
+// Examine.
+bool
+has_symbol(const std::string& mangled, const symbols& list) throw();
+
+const symbol&
+get_symbol(const std::string& mangled, const symbols& list);
+
+extern "C" void
+examine_symbol(const char* name, const char* file);
+
+extern "C" int
+compare_symbols(const char* baseline_file, const char* test_file, bool verb);
+
+
+// Util.
+symbols
+create_symbols(const char* file);
+
+const char*
+demangle(const std::string& mangled);
diff --git a/libstdc++-v3/testsuite/util/testsuite_abi_check.cc b/libstdc++-v3/testsuite/util/testsuite_abi_check.cc
new file mode 100644
index 000000000..d4fea3ae6
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_abi_check.cc
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+
+// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 3, or (at
+// your option) any later version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Benjamin Kosnik <bkoz@redhat.com>
+// Blame subsequent hacks on Loren J. Rittle <ljrittle@acm.org>, Phil
+// Edwards <pme@gcc.gnu.org>, and a cast of dozens at libstdc++@gcc.gnu.org.
+
+#include "testsuite_abi.h"
+#include <iostream>
+#include <cstdlib>
+#include <unistd.h> // for access(2)
+
+int
+main(int argc, char** argv)
+{
+ using namespace std;
+
+ // Get arguments. (Heading towards getopt_long, I can feel it.)
+ string argv1 = argc > 1 ? argv[1] : "";
+ if (argv1 == "--help" || argc < 4)
+ {
+ cerr << "usage: abi_check --check current baseline\n"
+ " --check-verbose current baseline\n"
+ " --examine symbol current\n"
+ " --help\n"
+ "\n"
+ "All arguments are string literals.\n"
+ "CURRENT is a file generated byextract_symvers.\n"
+ "BASELINE is a file from config/abi.\n"
+ "SYMBOL is a mangled name.\n"
+ << endl;
+ exit(1);
+ }
+
+ if (argv1.find("--check") != string::npos)
+ {
+ bool verbose = false;
+ if (argv1 == "--check-verbose")
+ verbose = true;
+
+ // Quick sanity/setup check for arguments.
+ const char* test_file = argv[2];
+ const char* baseline_file = argv[3];
+ if (access(test_file, R_OK) != 0)
+ {
+ cerr << "Cannot read symbols file " << test_file
+ << ", did you forget to build first?" << endl;
+ exit(1);
+ }
+ if (access(baseline_file, R_OK) != 0)
+ {
+ cerr << "Cannot read baseline file " << baseline_file << endl;
+ exit(1);
+ }
+ if (!compare_symbols(baseline_file, test_file, verbose))
+ exit (1);
+ }
+
+ if (argv1 == "--examine")
+ {
+ const char* file = argv[3];
+ if (access(file, R_OK) != 0)
+ {
+ cerr << "Cannot read symbol file " << file << endl;
+ exit(1);
+ }
+ examine_symbol(argv[2], file);
+ }
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.cc b/libstdc++-v3/testsuite/util/testsuite_allocator.cc
new file mode 100644
index 000000000..a5fbc77d2
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.cc
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+// Testing allocator for the C++ library testsuite.
+//
+// Copyright (C) 2002, 2003, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#include <iostream>
+#include <testsuite_allocator.h>
+
+namespace __gnu_test
+{
+ typedef tracker_allocator_counter counter_type;
+
+ counter_type::size_type
+ counter_type::allocationCount_ = 0;
+
+ counter_type::size_type
+ counter_type::deallocationCount_ = 0;
+
+ int counter_type::constructCount_ = 0;
+ int counter_type::destructCount_ = 0;
+
+ bool
+ check_construct_destroy(const char* tag, int expected_c, int expected_d)
+ {
+ bool ret = true;
+ if (counter_type::get_construct_count() != expected_c
+ || counter_type::get_destruct_count() != expected_d)
+ {
+ std::cerr << tag << ": "
+ << " construct = " << counter_type::get_construct_count()
+ << " (should be " << expected_c << "),"
+ << " destroy = " << counter_type::get_destruct_count()
+ << " (should be " << expected_d << ")"
+ << std::endl;
+ ret = false;
+ }
+ return ret;
+ }
+} // namespace __cxx_test
+
diff --git a/libstdc++-v3/testsuite/util/testsuite_allocator.h b/libstdc++-v3/testsuite/util/testsuite_allocator.h
new file mode 100644
index 000000000..a534d8584
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
@@ -0,0 +1,354 @@
+// -*- C++ -*-
+// Testing allocator for the C++ library testsuite.
+//
+// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// This file provides an test instrumentation allocator that can be
+// used to verify allocation functionality of standard library
+// containers. 2002.11.25 smw
+
+#ifndef _GLIBCXX_TESTSUITE_ALLOCATOR_H
+#define _GLIBCXX_TESTSUITE_ALLOCATOR_H
+
+#include <tr1/unordered_map>
+#include <cassert>
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#include <bits/move.h>
+#endif
+
+namespace __gnu_test
+{
+ class tracker_allocator_counter
+ {
+ public:
+ typedef std::size_t size_type;
+
+ static void*
+ allocate(size_type blocksize)
+ {
+ allocationCount_ += blocksize;
+ return ::operator new(blocksize);
+ }
+
+ static void
+ construct() { constructCount_++; }
+
+ static void
+ destroy() { destructCount_++; }
+
+ static void
+ deallocate(void* p, size_type blocksize)
+ {
+ ::operator delete(p);
+ deallocationCount_ += blocksize;
+ }
+
+ static size_type
+ get_allocation_count() { return allocationCount_; }
+
+ static size_type
+ get_deallocation_count() { return deallocationCount_; }
+
+ static int
+ get_construct_count() { return constructCount_; }
+
+ static int
+ get_destruct_count() { return destructCount_; }
+
+ static void
+ reset()
+ {
+ allocationCount_ = 0;
+ deallocationCount_ = 0;
+ constructCount_ = 0;
+ destructCount_ = 0;
+ }
+
+ private:
+ static size_type allocationCount_;
+ static size_type deallocationCount_;
+ static int constructCount_;
+ static int destructCount_;
+ };
+
+ // A simple basic allocator that just forwards to the
+ // tracker_allocator_counter to fulfill memory requests. This class
+ // is templated on the target object type, but tracker isn't.
+ template<class T>
+ class tracker_allocator
+ {
+ private:
+ typedef tracker_allocator_counter counter_type;
+
+ public:
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ template<class U> struct rebind { typedef tracker_allocator<U> other; };
+
+ pointer
+ address(reference value) const
+ { return &value; }
+
+ const_pointer
+ address(const_reference value) const
+ { return &value; }
+
+ tracker_allocator() throw()
+ { }
+
+ tracker_allocator(const tracker_allocator&) throw()
+ { }
+
+ template<class U>
+ tracker_allocator(const tracker_allocator<U>&) throw()
+ { }
+
+ ~tracker_allocator() throw()
+ { }
+
+ size_type
+ max_size() const throw()
+ { return size_type(-1) / sizeof(T); }
+
+ pointer
+ allocate(size_type n, const void* = 0)
+ { return static_cast<pointer>(counter_type::allocate(n * sizeof(T))); }
+
+ void
+ construct(pointer p, const T& value)
+ {
+ ::new ((void *)p) T(value);
+ counter_type::construct();
+ }
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename... Args>
+ void
+ construct(pointer p, Args&&... args)
+ {
+ ::new((void *)p) T(std::forward<Args>(args)...);
+ counter_type::construct();
+ }
+#endif
+
+ void
+ destroy(pointer p)
+ {
+ p->~T();
+ counter_type::destroy();
+ }
+
+ void
+ deallocate(pointer p, size_type num)
+ { counter_type::deallocate(p, num * sizeof(T)); }
+ };
+
+ template<class T1, class T2>
+ bool
+ operator==(const tracker_allocator<T1>&,
+ const tracker_allocator<T2>&) throw()
+ { return true; }
+
+ template<class T1, class T2>
+ bool
+ operator!=(const tracker_allocator<T1>&,
+ const tracker_allocator<T2>&) throw()
+ { return false; }
+
+ bool
+ check_construct_destroy(const char* tag, int expected_c, int expected_d);
+
+ template<typename Alloc>
+ bool
+ check_deallocate_null()
+ {
+ // Let's not core here...
+ Alloc a;
+ a.deallocate(0, 1);
+ a.deallocate(0, 10);
+ return true;
+ }
+
+ template<typename Alloc>
+ bool
+ check_allocate_max_size()
+ {
+ Alloc a;
+ try
+ {
+ a.allocate(a.max_size() + 1);
+ }
+ catch(std::bad_alloc&)
+ {
+ return true;
+ }
+ catch(...)
+ {
+ throw;
+ }
+ throw;
+ }
+
+
+ // A simple allocator which can be constructed endowed of a given
+ // "personality" (an integer), queried in operator== to simulate the
+ // behavior of realworld "unequal" allocators (i.e., not exploiting
+ // the provision in 20.1.5/4, first bullet). A global unordered_map,
+ // filled at allocation time with (pointer, personality) pairs, is
+ // then consulted to enforce the requirements in Table 32 about
+ // deallocation vs allocator equality. Note that this allocator is
+ // swappable, not assignable, consistently with Option 3 of DR 431
+ // (see N1599).
+ struct uneq_allocator_base
+ {
+ typedef std::tr1::unordered_map<void*, int> map_type;
+
+ // Avoid static initialization troubles and/or bad interactions
+ // with tests linking testsuite_allocator.o and playing globally
+ // with operator new/delete.
+ static map_type&
+ get_map()
+ {
+ static map_type alloc_map;
+ return alloc_map;
+ }
+ };
+
+ template<typename Tp>
+ class uneq_allocator
+ : private uneq_allocator_base
+ {
+ public:
+ typedef std::size_t size_type;
+ typedef std::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<typename Tp1>
+ struct rebind
+ { typedef uneq_allocator<Tp1> other; };
+
+ uneq_allocator() throw()
+ : personality(0) { }
+
+ uneq_allocator(int person) throw()
+ : personality(person) { }
+
+ template<typename Tp1>
+ uneq_allocator(const uneq_allocator<Tp1>& b) throw()
+ : personality(b.get_personality()) { }
+
+ int get_personality() const { return personality; }
+
+ pointer
+ address(reference x) const { return &x; }
+
+ const_pointer
+ address(const_reference x) const { return &x; }
+
+ pointer
+ allocate(size_type n, const void* = 0)
+ {
+ if (__builtin_expect(n > this->max_size(), false))
+ std::__throw_bad_alloc();
+
+ pointer p = static_cast<Tp*>(::operator new(n * sizeof(Tp)));
+ try
+ {
+ get_map().insert(map_type::value_type(reinterpret_cast<void*>(p),
+ personality));
+ }
+ catch(...)
+ {
+ ::operator delete(p);
+ __throw_exception_again;
+ }
+ return p;
+ }
+
+ void
+ deallocate(pointer p, size_type)
+ {
+ assert( p );
+
+ map_type::iterator it = get_map().find(reinterpret_cast<void*>(p));
+ assert( it != get_map().end() );
+
+ // Enforce requirements in Table 32 about deallocation vs
+ // allocator equality.
+ assert( it->second == personality );
+
+ get_map().erase(it);
+ ::operator delete(p);
+ }
+
+ size_type
+ max_size() const throw()
+ { return size_type(-1) / sizeof(Tp); }
+
+ void
+ construct(pointer p, const Tp& val)
+ { ::new((void *)p) Tp(val); }
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename... Args>
+ void
+ construct(pointer p, Args&&... args)
+ { ::new((void *)p) Tp(std::forward<Args>(args)...); }
+#endif
+
+ void
+ destroy(pointer p) { p->~Tp(); }
+
+ private:
+ // Not assignable...
+ uneq_allocator&
+ operator=(const uneq_allocator&);
+
+ // ... yet swappable!
+ friend inline void
+ swap(uneq_allocator& a, uneq_allocator& b)
+ { std::swap(a.personality, b.personality); }
+
+ template<typename Tp1>
+ friend inline bool
+ operator==(const uneq_allocator& a, const uneq_allocator<Tp1>& b)
+ { return a.personality == b.personality; }
+
+ template<typename Tp1>
+ friend inline bool
+ operator!=(const uneq_allocator& a, const uneq_allocator<Tp1>& b)
+ { return !(a == b); }
+
+ int personality;
+ };
+} // namespace __gnu_test
+
+#endif // _GLIBCXX_TESTSUITE_ALLOCATOR_H
diff --git a/libstdc++-v3/testsuite/util/testsuite_api.h b/libstdc++-v3/testsuite/util/testsuite_api.h
new file mode 100644
index 000000000..110079040
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_api.h
@@ -0,0 +1,197 @@
+// -*- C++ -*-
+// Exception testing utils for the C++ library testsuite.
+//
+// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#include <exception>
+#include <testsuite_hooks.h>
+
+#ifndef _TESTSUITE_API
+#define _TESTSUITE_API 1
+
+namespace __gnu_test
+{
+ // Checks for virtual public derivation in exception classes.
+ // See:
+ // http://www.boost.org/more/error_handling.html
+ struct bad_non_virtual : virtual public std::exception { };
+
+ template<typename Exception, bool DefaultCons>
+ struct diamond_derivation_base;
+
+ template<typename Exception>
+ struct diamond_derivation_base<Exception, true>
+ {
+ struct diamond_derivation_error
+ : bad_non_virtual, Exception
+ {
+ diamond_derivation_error()
+ : bad_non_virtual(), Exception() { }
+ };
+ };
+
+ template<typename Exception>
+ struct diamond_derivation_base<Exception, false>
+ {
+ struct diamond_derivation_error
+ : bad_non_virtual, Exception
+ {
+ diamond_derivation_error()
+ : bad_non_virtual(), Exception("construct diamond") { }
+ };
+ };
+
+ template<typename Exception, bool DefaultCons>
+ struct diamond_derivation
+ : diamond_derivation_base<Exception, DefaultCons>
+ {
+ typedef diamond_derivation_base<Exception, DefaultCons> base_type;
+ typedef typename base_type::diamond_derivation_error error_type;
+
+ // NB: In the libstdc++-v3 testsuite, all the standard exception
+ // classes (+ a couple of extensions) are checked: since they
+ // all derive *non* virtually from std::exception, the expected
+ // behavior is ambiguity.
+ static void test()
+ {
+ bool test __attribute__((unused)) = true;
+ try
+ { throw error_type(); }
+ catch (std::exception const&)
+ { VERIFY( false ); }
+ catch (...)
+ { VERIFY( true ); }
+ }
+ };
+
+ // Testing type requirements for template arguments.
+ struct NonDefaultConstructible
+ {
+ NonDefaultConstructible(int) { }
+ NonDefaultConstructible(const NonDefaultConstructible&) { }
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ // For std::iota.
+ NonDefaultConstructible&
+ operator++()
+ { return *this; }
+#endif
+ };
+
+ // See: 20.1.1 Template argument requirements.
+ inline bool
+ operator==(const NonDefaultConstructible&, const NonDefaultConstructible&)
+ { return false; }
+
+ inline bool
+ operator<(const NonDefaultConstructible&, const NonDefaultConstructible&)
+ { return false; }
+
+ // For 23 unordered_* requirements.
+ struct NonDefaultConstructible_hash
+ {
+ std::size_t
+ operator()(NonDefaultConstructible) const
+ { return 1; }
+ };
+
+ // For 26 numeric algorithms requirements, need addable,
+ // subtractable, multiplicable.
+ inline NonDefaultConstructible
+ operator+(const NonDefaultConstructible& lhs,
+ const NonDefaultConstructible& rhs)
+ { return NonDefaultConstructible(1); }
+
+ inline NonDefaultConstructible
+ operator-(const NonDefaultConstructible& lhs,
+ const NonDefaultConstructible& rhs)
+ { return NonDefaultConstructible(1); }
+
+ inline NonDefaultConstructible
+ operator*(const NonDefaultConstructible& lhs,
+ const NonDefaultConstructible& rhs)
+ { return NonDefaultConstructible(1); }
+
+ // Like unary_function, but takes no argument. (ie, void).
+ // Used for generator template parameter.
+ template<typename _Result>
+ struct void_function
+ {
+ typedef _Result result_type;
+
+ result_type
+ operator()() const
+ { return result_type(); }
+ };
+
+ template<>
+ struct void_function<NonDefaultConstructible>
+ {
+ typedef NonDefaultConstructible result_type;
+
+ result_type
+ operator()() const
+ { return result_type(2); }
+ };
+
+ // For std::addressof, etc.
+ struct OverloadedAddressAux { };
+
+ struct OverloadedAddress
+ {
+ OverloadedAddressAux
+ operator&() const { return OverloadedAddressAux(); }
+ };
+
+ inline bool
+ operator<(const OverloadedAddress&, const OverloadedAddress&)
+ { return false; }
+
+ inline bool
+ operator==(const OverloadedAddress&, const OverloadedAddress&)
+ { return false; }
+
+ struct OverloadedAddress_hash
+ {
+ std::size_t
+ operator()(const OverloadedAddress&) const
+ { return 1; }
+ };
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ struct NonCopyConstructible
+ {
+ NonCopyConstructible() : num(-1) { }
+
+ NonCopyConstructible(NonCopyConstructible&& other)
+ : num(other.num)
+ { other.num = 0; }
+
+ NonCopyConstructible(const NonCopyConstructible&) = delete;
+
+ operator int() { return num; }
+
+ private:
+ int num;
+ };
+#endif
+
+}
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/testsuite_character.cc b/libstdc++-v3/testsuite/util/testsuite_character.cc
new file mode 100644
index 000000000..dba37c96d
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_character.cc
@@ -0,0 +1,186 @@
+// -*- C++ -*-
+
+// Utility subroutines for the C++ library testsuite.
+//
+// Copyright (C) 2002, 2003, 2004, 2005, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#include <testsuite_character.h>
+
+namespace std
+{
+ locale::id
+ codecvt<__gnu_test::pod_uchar, char, __gnu_test::pod_state>::id;
+
+ locale::id
+ ctype<__gnu_test::pod_uchar>::id;
+
+ locale::id
+ numpunct<__gnu_test::pod_uint>::id;
+
+ locale::id
+ moneypunct<__gnu_test::pod_uint>::id;
+
+ // Member specializations for the existing facet classes.
+ // NB: This isn't especially portable. Perhaps a better way would be
+ // to just specialize all of numpunct and ctype.
+ using __gnu_test::pod_ushort;
+ typedef pod_ushort::value_type value_type;
+
+ template<>
+ bool
+ ctype<pod_ushort>::
+ do_is(mask, char_type) const { return true; }
+
+ template<>
+ const pod_ushort*
+ ctype<pod_ushort>::
+ do_is(const char_type* __lo, const char_type*, mask*) const
+ { return __lo; }
+
+ template<>
+ const pod_ushort*
+ ctype<pod_ushort>::
+ do_scan_is(mask, const char_type* __lo, const char_type*) const
+ { return __lo; }
+
+ template<>
+ const pod_ushort*
+ ctype<pod_ushort>::
+ do_scan_not(mask, const char_type* __lo, const char_type*) const
+ { return __lo; }
+
+ template<>
+ pod_ushort
+ ctype<pod_ushort>::
+ do_toupper(char_type __c) const
+ { return __c; }
+
+ template<>
+ const pod_ushort*
+ ctype<pod_ushort>::
+ do_toupper(char_type*, const char_type* __hi) const
+ { return __hi; }
+
+ template<>
+ pod_ushort
+ ctype<pod_ushort>::
+ do_tolower(char_type __c) const
+ { return __c; }
+
+ template<>
+ const pod_ushort*
+ ctype<pod_ushort>::
+ do_tolower(char_type*, const char_type* __hi) const
+ { return __hi; }
+
+ template<>
+ pod_ushort
+ ctype<pod_ushort>::
+ do_widen(char __c) const
+ {
+ char_type ret = { value_type(__c) };
+ return ret;
+ }
+
+ template<>
+ const char*
+ ctype<pod_ushort>::
+ do_widen(const char* __lo, const char* __hi, char_type* __dest) const
+ {
+ while (__lo < __hi)
+ {
+ *__dest = this->do_widen(*__lo);
+ ++__lo;
+ ++__dest;
+ }
+ return __hi;
+ }
+
+ template<>
+ char
+ ctype<pod_ushort>::
+ do_narrow(char_type __wc, char) const
+ { return static_cast<char>(__wc.value); }
+
+ template<>
+ const pod_ushort*
+ ctype<pod_ushort>::
+ do_narrow(const pod_ushort* __lo, const pod_ushort* __hi,
+ char, char* __dest) const
+ {
+ while (__lo < __hi)
+ {
+ *__dest = this->do_narrow(*__lo, char());
+ ++__lo;
+ ++__dest;
+ }
+ return __hi;
+ }
+
+ template<>
+ ctype<pod_ushort>::~ctype() { }
+
+ template<>
+ void
+ numpunct<pod_ushort>::_M_initialize_numpunct(__c_locale)
+ {
+ if (!_M_data)
+ _M_data = new __numpunct_cache<pod_ushort>;
+
+ _M_data->_M_grouping = "";
+ _M_data->_M_use_grouping = false;
+
+ _M_data->_M_decimal_point.value = value_type('.');
+ _M_data->_M_thousands_sep.value = value_type(',');
+
+ for (size_t i = 0; i < __num_base::_S_oend; ++i)
+ {
+ value_type v = __num_base::_S_atoms_out[i];
+ _M_data->_M_atoms_out[i].value = v;
+ }
+ _M_data->_M_atoms_out[__num_base::_S_oend] = pod_ushort();
+
+ for (size_t j = 0; j < __num_base::_S_iend; ++j)
+ _M_data->_M_atoms_in[j].value = value_type(__num_base::_S_atoms_in[j]);
+ _M_data->_M_atoms_in[__num_base::_S_iend] = pod_ushort();
+
+ // "true"
+ pod_ushort* __truename = new pod_ushort[4 + 1];
+ __truename[0].value = value_type('t');
+ __truename[1].value = value_type('r');
+ __truename[2].value = value_type('u');
+ __truename[3].value = value_type('e');
+ __truename[4] = pod_ushort();
+ _M_data->_M_truename = __truename;
+
+ // "false"
+ pod_ushort* __falsename = new pod_ushort[5 + 1];
+ __falsename[0].value = value_type('f');
+ __falsename[1].value = value_type('a');
+ __falsename[2].value = value_type('l');
+ __falsename[3].value = value_type('s');
+ __falsename[4].value = value_type('e');
+ __falsename[5] = pod_ushort();
+ _M_data->_M_falsename = __falsename;
+ }
+
+ template<>
+ numpunct<pod_ushort>::~numpunct()
+ { delete _M_data; }
+} // namespace std
diff --git a/libstdc++-v3/testsuite/util/testsuite_character.h b/libstdc++-v3/testsuite/util/testsuite_character.h
new file mode 100644
index 000000000..ceda1f512
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_character.h
@@ -0,0 +1,570 @@
+// -*- C++ -*-
+
+// Testing character type and state type with char_traits and codecvt
+// specializations for the C++ library testsuite.
+//
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#ifndef _GLIBCXX_TESTSUITE_CHARACTER_H
+#define _GLIBCXX_TESTSUITE_CHARACTER_H
+
+#include <climits>
+#include <string> // for char_traits
+#include <locale> // for codecvt
+#include <algorithm> // for transform
+#include <ext/pod_char_traits.h>
+
+namespace __gnu_test
+{
+ struct pod_int
+ {
+ int value;
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ // For std::iota.
+ pod_int&
+ operator++()
+ {
+ ++value;
+ return *this;
+ }
+#endif
+ };
+
+ // For 20.1 requirements for instantiable type: equality comparable
+ // and less than comparable.
+ inline bool
+ operator==(const pod_int& lhs, const pod_int& rhs)
+ { return lhs.value == rhs.value; }
+
+ inline bool
+ operator<(const pod_int& lhs, const pod_int& rhs)
+ { return lhs.value < rhs.value; }
+
+ // For 26 numeric algorithms requirements, need addable,
+ // subtractable, multiplicable.
+ inline pod_int
+ operator+(const pod_int& lhs, const pod_int& rhs)
+ {
+ pod_int ret = { lhs.value + rhs.value };
+ return ret;
+ }
+
+ inline pod_int
+ operator-(const pod_int& lhs, const pod_int& rhs)
+ {
+ pod_int ret = { lhs.value - rhs.value };
+ return ret;
+ }
+
+ inline pod_int
+ operator*(const pod_int& lhs, const pod_int& rhs)
+ {
+ pod_int ret = { lhs.value * rhs.value };
+ return ret;
+ }
+
+ struct pod_state
+ {
+ unsigned long value;
+ };
+
+ inline bool
+ operator==(const pod_state& lhs, const pod_state& rhs)
+ { return lhs.value == rhs.value; }
+
+ inline bool
+ operator<(const pod_state& lhs, const pod_state& rhs)
+ { return lhs.value < rhs.value; }
+
+ // Alternate character types.
+ using __gnu_cxx::character;
+ typedef character<unsigned char, pod_int, pod_state> pod_char;
+ typedef character<unsigned char, unsigned int, pod_state> pod_uchar;
+ typedef character<unsigned short, unsigned int> pod_ushort;
+ typedef character<unsigned int, unsigned long> pod_uint;
+}
+
+namespace __gnu_cxx
+{
+ // Specializations.
+ // pod_char
+ template<>
+ template<typename V2>
+ inline __gnu_test::pod_char::char_type
+ __gnu_test::pod_char::char_type::from(const V2& v)
+ {
+ char_type ret = { static_cast<value_type>(v.value) };
+ return ret;
+ }
+
+ template<>
+ template<typename V2>
+ inline V2
+ __gnu_test::pod_char::char_type::to(const char_type& c)
+ {
+ V2 ret = { c.value };
+ return ret;
+ }
+
+ template<>
+ template<typename V2>
+ inline __gnu_test::pod_uchar::char_type
+ __gnu_test::pod_uchar::char_type::from(const V2& v)
+ {
+ char_type ret;
+ ret.value = (v >> 5);
+ return ret;
+ }
+
+ template<>
+ template<typename V2>
+ inline V2
+ __gnu_test::pod_uchar::char_type::to(const char_type& c)
+ { return static_cast<V2>(c.value << 5); }
+} // namespace __gnu_test
+
+namespace std
+{
+ // codecvt specialization
+ //
+ // The conversion performed by the specialization is not supposed to
+ // be useful, rather it has been designed to demonstrate the
+ // essential features of stateful conversions:
+ // * Number and value of bytes for each internal character depends on the
+ // state in addition to the character itself.
+ // * Unshift produces an unshift sequence and resets the state. On input
+ // the unshift sequence causes the state to be reset.
+ //
+ // The conversion for output is as follows:
+ // 1. Calculate the value tmp by xor-ing the state and the internal
+ // character
+ // 2. Split tmp into either two or three bytes depending on the value of
+ // state. Output those bytes.
+ // 3. tmp becomes the new value of state.
+ template<>
+ class codecvt<__gnu_test::pod_uchar, char, __gnu_test::pod_state>
+ : public __codecvt_abstract_base<__gnu_test::pod_uchar, char,
+ __gnu_test::pod_state>
+ {
+ public:
+ typedef codecvt_base::result result;
+ typedef __gnu_test::pod_uchar intern_type;
+ typedef char extern_type;
+ typedef __gnu_test::pod_state state_type;
+ typedef __codecvt_abstract_base<intern_type, extern_type, state_type>
+ base_type;
+
+ explicit codecvt(size_t refs = 0) : base_type(refs)
+ { }
+
+ static locale::id id;
+
+ protected:
+ ~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_limit,
+ extern_type*& to_next) const
+ {
+ while (from < from_end && to < to_limit)
+ {
+ unsigned char tmp = (state.value ^ from->value);
+ if (state.value & 0x8)
+ {
+ if (to >= to_limit - 2)
+ break;
+ *to++ = (tmp & 0x7);
+ *to++ = ((tmp >> 3) & 0x7);
+ *to++ = ((tmp >> 6) & 0x3);
+ }
+ else
+ {
+ if (to >= to_limit - 1)
+ break;
+ *to++ = (tmp & 0xf);
+ *to++ = ((tmp >> 4) & 0xf);
+ }
+ state.value = tmp;
+ ++from;
+ }
+
+ from_next = from;
+ to_next = to;
+ return (from < from_end) ? partial : ok;
+ }
+
+ 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_limit,
+ intern_type*& to_next) const
+ {
+ while (from < from_end && to < to_limit)
+ {
+ unsigned char c = *from;
+ if (c & 0xc0)
+ {
+ // Unshift sequence
+ state.value &= c;
+ ++from;
+ continue;
+ }
+
+ unsigned char tmp;
+ if (state.value & 0x8)
+ {
+ if (from >= from_end - 2)
+ break;
+ tmp = (*from++ & 0x7);
+ tmp |= ((*from++ << 3) & 0x38);
+ tmp |= ((*from++ << 6) & 0xc0);
+ }
+ else
+ {
+ if (from >= from_end - 1)
+ break;
+ tmp = (*from++ & 0xf);
+ tmp |= ((*from++ << 4) & 0xf0);
+ }
+ to->value = (tmp ^ state.value);
+ state.value = tmp;
+ ++to;
+ }
+
+ from_next = from;
+ to_next = to;
+ return (from < from_end) ? partial : ok;
+ }
+
+ virtual result
+ do_unshift(state_type& state, extern_type* to, extern_type* to_limit,
+ extern_type*& to_next) const
+ {
+ for (unsigned int i = 0; i < CHAR_BIT; ++i)
+ {
+ unsigned int mask = (1 << i);
+ if (state.value & mask)
+ {
+ if (to == to_limit)
+ {
+ to_next = to;
+ return partial;
+ }
+
+ state.value &= ~mask;
+ *to++ = static_cast<unsigned char>(~mask);
+ }
+ }
+
+ to_next = to;
+ return state.value == 0 ? ok : error;
+ }
+
+ virtual int
+ do_encoding() const throw()
+ { return -1; }
+
+ virtual bool
+ do_always_noconv() const throw()
+ { return false; }
+
+ virtual int
+ do_length(state_type& state, const extern_type* from,
+ const extern_type* end, size_t max) const
+ {
+ const extern_type* beg = from;
+ while (from < end)
+ {
+ unsigned char c = *from;
+ if (c & 0xc0)
+ {
+ // Unshift sequence
+ state.value &= c;
+ ++from;
+ continue;
+ }
+
+ if (max == 0) break;
+
+ unsigned char tmp;
+ if (state.value & 0x8)
+ {
+ if (from >= end - 2)
+ break;
+ tmp = (*from++ & 0x7);
+ tmp |= ((*from++ << 3) & 0x38);
+ tmp |= ((*from++ << 6) & 0xc0);
+ }
+ else
+ {
+ if (from >= end - 1)
+ break;
+ tmp = (*from++ & 0xf);
+ tmp |= ((*from++ << 4) & 0xf0);
+ }
+ state.value = tmp;
+ --max;
+ }
+ return from - beg;
+ }
+
+ // Maximum 8 bytes unshift sequence followed by max 3 bytes for
+ // one character.
+ virtual int
+ do_max_length() const throw()
+ { return 11; }
+ };
+
+ template<>
+ class ctype<__gnu_test::pod_uchar>
+ : public __ctype_abstract_base<__gnu_test::pod_uchar>
+ {
+ public:
+ typedef __gnu_test::pod_uchar char_type;
+
+ explicit ctype(size_t refs = 0)
+ : __ctype_abstract_base<__gnu_test::pod_uchar>(refs) { }
+
+ static locale::id id;
+
+ protected:
+ ~ctype()
+ { }
+
+ virtual bool
+ do_is(mask, char_type) const
+ { return false; }
+
+ virtual const char_type*
+ do_is(const char_type* low, const char_type* high, mask* vec) const
+ {
+ fill_n(vec, high - low, mask());
+ return high;
+ }
+
+ virtual const char_type*
+ do_scan_is(mask, const char_type*, const char_type* high) const
+ { return high; }
+
+ virtual const char_type*
+ do_scan_not(mask, const char_type* low, const char_type*) const
+ { return low; }
+
+ virtual char_type
+ do_toupper(char_type c) const
+ { return c; }
+
+ virtual const char_type*
+ do_toupper(char_type*, const char_type* high) const
+ { return high; }
+
+ virtual char_type
+ do_tolower(char_type c) const
+ { return c; }
+
+ virtual const char_type*
+ do_tolower(char_type*, const char_type* high) const
+ { return high; }
+
+ virtual char_type
+ do_widen(char c) const
+ { return __gnu_test::pod_uchar::from<char>(c); }
+
+ virtual const char*
+ do_widen(const char* low, const char* high, char_type* dest) const
+ {
+ transform(low, high, dest, &__gnu_test::pod_uchar::from<char>);
+ return high;
+ }
+
+ virtual char
+ do_narrow(char_type, char dfault) const
+ { return dfault; }
+
+ virtual const char_type*
+ do_narrow(const char_type* low, const char_type* high,
+ char dfault, char* dest) const
+ {
+ fill_n(dest, high - low, dfault);
+ return high;
+ }
+ };
+
+ // numpunct specializations
+ template<>
+ class numpunct<__gnu_test::pod_uint>
+ : public locale::facet
+ {
+ public:
+ typedef __gnu_test::pod_uint char_type;
+ typedef basic_string<char_type> string_type;
+
+ static locale::id id;
+
+ explicit
+ numpunct(size_t refs = 0)
+ : locale::facet(refs)
+ { }
+
+ char_type
+ decimal_point() const
+ { return this->do_decimal_point(); }
+
+ char_type
+ thousands_sep() const
+ { return this->do_thousands_sep(); }
+
+ string
+ grouping() const
+ { return this->do_grouping(); }
+
+ string_type
+ truename() const
+ { return this->do_truename(); }
+
+ string_type
+ falsename() const
+ { return this->do_falsename(); }
+
+ protected:
+ ~numpunct()
+ { }
+
+ virtual char_type
+ do_decimal_point() const
+ { return char_type(); }
+
+ virtual char_type
+ do_thousands_sep() const
+ { return char_type(); }
+
+ virtual string
+ do_grouping() const
+ { return string(); }
+
+ virtual string_type
+ do_truename() const
+ { return string_type(); }
+
+ virtual string_type
+ do_falsename() const
+ { return string_type(); }
+ };
+
+ template<>
+ class moneypunct<__gnu_test::pod_uint>
+ : public locale::facet, public money_base
+ {
+ public:
+ typedef __gnu_test::pod_uint char_type;
+ typedef basic_string<char_type> string_type;
+
+ static locale::id id;
+ static const bool intl = false;
+
+ explicit
+ moneypunct(size_t refs = 0)
+ : locale::facet(refs)
+ { }
+
+ char_type
+ decimal_point() const
+ { return this->do_decimal_point(); }
+
+ char_type
+ thousands_sep() const
+ { return this->do_thousands_sep(); }
+
+ string
+ grouping() const
+ { return this->do_grouping(); }
+
+ string_type
+ curr_symbol() const
+ { return this->do_curr_symbol(); }
+
+ string_type
+ positive_sign() const
+ { return this->do_positive_sign(); }
+
+ string_type
+ negative_sign() const
+ { return this->do_negative_sign(); }
+
+ int
+ frac_digits() const
+ { return this->do_frac_digits(); }
+
+ pattern
+ pos_format() const
+ { return this->do_pos_format(); }
+
+ pattern
+ neg_format() const
+ { return this->do_neg_format(); }
+
+ protected:
+ ~moneypunct()
+ { }
+
+ virtual char_type
+ do_decimal_point() const
+ { return char_type(); }
+
+ virtual char_type
+ do_thousands_sep() const
+ { return char_type(); }
+
+ virtual string
+ do_grouping() const
+ { return string(); }
+
+ virtual string_type
+ do_curr_symbol() const
+ { return string_type(); }
+
+ string_type
+ do_positive_sign() const
+ { return string_type(); }
+
+ string_type
+ do_negative_sign() const
+ { return string_type(); }
+
+ int
+ do_frac_digits() const
+ { return 0; }
+
+ pattern
+ do_pos_format() const
+ { return pattern(); }
+
+ pattern
+ do_neg_format() const
+ { return pattern(); }
+ };
+} // namespace std
+
+#endif // _GLIBCXX_TESTSUITE_CHARACTER_H
+
diff --git a/libstdc++-v3/testsuite/util/testsuite_common_types.h b/libstdc++-v3/testsuite/util/testsuite_common_types.h
new file mode 100644
index 000000000..a4f59ac2a
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_common_types.h
@@ -0,0 +1,833 @@
+// -*- C++ -*-
+// typelist for the C++ library testsuite.
+//
+// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#ifndef _TESTSUITE_COMMON_TYPES_H
+#define _TESTSUITE_COMMON_TYPES_H 1
+
+#include <ext/typelist.h>
+
+#include <ext/new_allocator.h>
+#include <ext/malloc_allocator.h>
+#include <ext/mt_allocator.h>
+#include <ext/bitmap_allocator.h>
+#include <ext/pool_allocator.h>
+
+#include <algorithm>
+
+#include <vector>
+#include <list>
+#include <deque>
+#include <string>
+#include <limits>
+
+#include <map>
+#include <set>
+#include <tr1/functional>
+#include <tr1/unordered_map>
+#include <tr1/unordered_set>
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#include <atomic>
+#include <type_traits>
+#endif
+
+namespace __gnu_test
+{
+ using __gnu_cxx::typelist::node;
+ using __gnu_cxx::typelist::transform;
+ using __gnu_cxx::typelist::append;
+
+ // All the allocators to test.
+ template<typename Tp, bool Thread>
+ struct allocator_policies
+ {
+ typedef Tp value_type;
+ typedef __gnu_cxx::new_allocator<Tp> a1;
+ typedef __gnu_cxx::malloc_allocator<Tp> a2;
+ typedef __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, Thread> pool_policy;
+ typedef __gnu_cxx::__mt_alloc<Tp, pool_policy> a3;
+ typedef __gnu_cxx::bitmap_allocator<Tp> a4;
+ typedef __gnu_cxx::__pool_alloc<Tp> a5;
+ typedef node<_GLIBCXX_TYPELIST_CHAIN5(a1, a2, a3, a4, a5)> type;
+ };
+
+ // Typelists for vector, string, list, deque.
+ // XXX should just use template templates
+ template<typename Tp, bool Thread>
+ struct vectors
+ {
+ typedef Tp value_type;
+
+ template<typename Tl>
+ struct vector_shell
+ {
+ typedef Tl allocator_type;
+ typedef std::vector<value_type, allocator_type> type;
+ };
+
+ typedef allocator_policies<value_type, Thread> allocator_types;
+ typedef typename allocator_types::type allocator_typelist;
+ typedef typename transform<allocator_typelist, vector_shell>::type type;
+ };
+
+ template<typename Tp, bool Thread>
+ struct lists
+ {
+ typedef Tp value_type;
+
+ template<typename Tl>
+ struct list_shell
+ {
+ typedef Tl allocator_type;
+ typedef std::list<value_type, allocator_type> type;
+ };
+
+ typedef allocator_policies<value_type, Thread> allocator_types;
+ typedef typename allocator_types::type allocator_typelist;
+ typedef typename transform<allocator_typelist, list_shell>::type type;
+ };
+
+ template<typename Tp, bool Thread>
+ struct deques
+ {
+ typedef Tp value_type;
+
+ template<typename Tl>
+ struct deque_shell
+ {
+ typedef Tl allocator_type;
+ typedef std::deque<value_type, allocator_type> type;
+ };
+
+ typedef allocator_policies<value_type, Thread> allocator_types;
+ typedef typename allocator_types::type allocator_typelist;
+ typedef typename transform<allocator_typelist, deque_shell>::type type;
+ };
+
+ template<typename Tp, bool Thread>
+ struct strings
+ {
+ typedef Tp value_type;
+
+ template<typename Tl>
+ struct string_shell
+ {
+ typedef Tl allocator_type;
+ typedef std::char_traits<value_type> traits_type;
+ typedef std::basic_string<value_type, traits_type, allocator_type> type;
+ };
+
+ typedef allocator_policies<value_type, Thread> allocator_types;
+ typedef typename allocator_types::type allocator_typelist;
+ typedef typename transform<allocator_typelist, string_shell>::type type;
+ };
+
+ // A typelist of vector, list, deque, and string all instantiated
+ // with each of the allocator policies.
+ template<typename Tp, bool Thread>
+ struct sequence_containers
+ {
+ typedef Tp value_type;
+
+ typedef typename vectors<value_type, Thread>::type vector_typelist;
+ typedef typename lists<value_type, Thread>::type list_typelist;
+ typedef typename deques<value_type, Thread>::type deque_typelist;
+ typedef typename strings<value_type, Thread>::type string_typelist;
+
+ typedef typename append<vector_typelist, list_typelist>::type a1;
+ typedef typename append<deque_typelist, string_typelist>::type a2;
+ typedef typename append<a1, a2>::type type;
+ };
+
+ // Typelists for map, set, unordered_set, unordered_map.
+ template<typename Tp, bool Thread>
+ struct maps
+ {
+ typedef Tp value_type;
+ typedef Tp key_type;
+ typedef std::pair<const key_type, value_type> pair_type;
+ typedef std::less<key_type> compare_function;
+
+ template<typename Tl>
+ struct container
+ {
+ typedef Tl allocator_type;
+ typedef std::map<key_type, value_type, compare_function, allocator_type> type;
+ };
+
+ typedef allocator_policies<pair_type, Thread> allocator_types;
+ typedef typename allocator_types::type allocator_typelist;
+ typedef typename transform<allocator_typelist, container>::type type;
+ };
+
+ template<typename Tp, bool Thread>
+ struct unordered_maps
+ {
+ typedef Tp value_type;
+ typedef Tp key_type;
+ typedef std::pair<const key_type, value_type> pair_type;
+ typedef std::tr1::hash<key_type> hash_function;
+ typedef std::equal_to<key_type> equality_function;
+
+ template<typename Tl>
+ struct container
+ {
+ typedef Tl allocator_type;
+ typedef std::tr1::unordered_map<key_type, value_type, hash_function, equality_function, allocator_type> type;
+ };
+
+ typedef allocator_policies<pair_type, Thread> allocator_types;
+ typedef typename allocator_types::type allocator_typelist;
+ typedef typename transform<allocator_typelist, container>::type type;
+ };
+
+ template<typename Tp, bool Thread>
+ struct sets
+ {
+ typedef Tp value_type;
+ typedef Tp key_type;
+ typedef std::less<key_type> compare_function;
+
+ template<typename Tl>
+ struct container
+ {
+ typedef Tl allocator_type;
+ typedef std::set<key_type, compare_function, allocator_type> type;
+ };
+
+ typedef allocator_policies<key_type, Thread> allocator_types;
+ typedef typename allocator_types::type allocator_typelist;
+ typedef typename transform<allocator_typelist, container>::type type;
+ };
+
+ template<typename Tp, bool Thread>
+ struct unordered_sets
+ {
+ typedef Tp value_type;
+ typedef Tp key_type;
+ typedef std::tr1::hash<key_type> hash_function;
+ typedef std::equal_to<key_type> equality_function;
+
+ template<typename Tl>
+ struct container
+ {
+ typedef Tl allocator_type;
+ typedef std::tr1::unordered_set<key_type, hash_function, equality_function, allocator_type> type;
+ };
+
+ typedef allocator_policies<key_type, Thread> allocator_types;
+ typedef typename allocator_types::type allocator_typelist;
+ typedef typename transform<allocator_typelist, container>::type type;
+ };
+
+
+ // A typelist of all associated container types, with each of the
+ // allocator policies.
+ template<typename Tp, bool Thread>
+ struct associative_containers
+ {
+ typedef Tp value_type;
+
+ typedef typename maps<value_type, Thread>::type map_typelist;
+ typedef typename sets<value_type, Thread>::type set_typelist;
+ typedef typename unordered_maps<value_type, Thread>::type unordered_map_typelist;
+ typedef typename unordered_sets<value_type, Thread>::type unordered_set_typelist;
+
+ typedef typename append<map_typelist, unordered_map_typelist>::type a1;
+ typedef typename append<set_typelist, unordered_set_typelist>::type a2;
+ typedef typename append<a1, a2>::type type;
+ };
+
+ // A typelist of all integral types.
+ struct integral_types
+ {
+ typedef bool a1;
+ typedef char a2;
+ typedef signed char a3;
+ typedef unsigned char a4;
+ typedef short a5;
+ typedef unsigned short a6;
+ typedef int a7;
+ typedef unsigned int a8;
+ typedef long a9;
+ typedef unsigned long a10;
+ typedef long long a11;
+ typedef unsigned long long a12;
+ typedef wchar_t a13;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ typedef char16_t a14;
+ typedef char32_t a15;
+
+ typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13, a14, a15)> type;
+#else
+ typedef node<_GLIBCXX_TYPELIST_CHAIN13(a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13)> type;
+#endif
+ };
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ struct atomic_integrals_no_bool
+ {
+ typedef std::atomic_char a2;
+ typedef std::atomic_schar a3;
+ typedef std::atomic_uchar a4;
+ typedef std::atomic_short a5;
+ typedef std::atomic_ushort a6;
+ typedef std::atomic_int a7;
+ typedef std::atomic_uint a8;
+ typedef std::atomic_long a9;
+ typedef std::atomic_ulong a10;
+ typedef std::atomic_llong a11;
+ typedef std::atomic_ullong a12;
+ typedef std::atomic_wchar_t a13;
+ typedef std::atomic_char16_t a14;
+ typedef std::atomic_char32_t a15;
+
+ typedef node<_GLIBCXX_TYPELIST_CHAIN14(a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13, a14, a15)> type;
+ };
+
+ struct atomic_integrals
+ {
+ typedef std::atomic_bool a1;
+ typedef std::atomic_char a2;
+ typedef std::atomic_schar a3;
+ typedef std::atomic_uchar a4;
+ typedef std::atomic_short a5;
+ typedef std::atomic_ushort a6;
+ typedef std::atomic_int a7;
+ typedef std::atomic_uint a8;
+ typedef std::atomic_long a9;
+ typedef std::atomic_ulong a10;
+ typedef std::atomic_llong a11;
+ typedef std::atomic_ullong a12;
+ typedef std::atomic_wchar_t a13;
+ typedef std::atomic_char16_t a14;
+ typedef std::atomic_char32_t a15;
+
+ typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13, a14, a15)> type;
+ };
+
+
+ template<typename Tp>
+ struct atomics
+ {
+ typedef Tp value_type;
+ typedef std::atomic<value_type> type;
+ };
+
+ typedef transform<integral_types::type, atomics>::type atomics_tl;
+#endif
+
+ template<typename Tp>
+ struct numeric_limits
+ {
+ typedef Tp value_type;
+ typedef std::numeric_limits<value_type> type;
+ };
+
+ typedef transform<integral_types::type, numeric_limits>::type limits_tl;
+
+ struct has_increment_operators
+ {
+ template<typename _Tp>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ {
+ _Tp a;
+ ++a; // prefix
+ a++; // postfix
+ a += a;
+ }
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+ struct has_decrement_operators
+ {
+ template<typename _Tp>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ {
+ _Tp a;
+ --a; // prefix
+ a--; // postfix
+ a -= a;
+ }
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _Tp>
+ void
+ constexpr_bitwise_operators()
+ {
+ constexpr _Tp a = _Tp();
+ constexpr _Tp b = _Tp();
+ constexpr _Tp c1 __attribute__((unused)) = a | b;
+ constexpr _Tp c2 __attribute__((unused)) = a & b;
+ constexpr _Tp c3 __attribute__((unused)) = a ^ b;
+ constexpr _Tp c4 __attribute__((unused)) = ~b;
+ }
+#endif
+
+ template<typename _Tp>
+ void
+ bitwise_operators()
+ {
+ _Tp a = _Tp();
+ _Tp b = _Tp();
+ a | b;
+ a & b;
+ a ^ b;
+ ~b;
+ }
+
+ template<typename _Tp>
+ void
+ bitwise_assignment_operators()
+ {
+ _Tp a = _Tp();
+ _Tp b = _Tp();
+ a |= b; // set
+ a &= ~b; // clear
+ a ^= b;
+ }
+
+ // 17.3.2.1.2 - Bitmask types [lib.bitmask.types]
+ // bitmask_operators
+ template<typename _BitmTp>
+ void
+ bitmask_operators()
+ {
+ bitwise_operators<_BitmTp>();
+ bitwise_assignment_operators<_BitmTp>();
+ }
+
+ struct has_bitwise_operators
+ {
+ template<typename _Tp>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ {
+ a |= b; // set
+ a &= ~b; // clear
+ a ^= b;
+ }
+ _Tp a;
+ _Tp b;
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+
+ struct constexpr_comparison_eq_ne
+ {
+ template<typename _Tp1, typename _Tp2 = _Tp1>
+ void
+ operator()()
+ {
+ static_assert(_Tp1() == _Tp2(), "eq");
+ static_assert(!(_Tp1() != _Tp2()), "ne");
+ }
+ };
+
+ struct constexpr_comparison_operators
+ {
+ template<typename _Tp>
+ void
+ operator()()
+ {
+ static_assert(!(_Tp() < _Tp()), "less");
+ static_assert(_Tp() <= _Tp(), "leq");
+ static_assert(!(_Tp() > _Tp()), "more");
+ static_assert(_Tp() >= _Tp(), "meq");
+ static_assert(_Tp() == _Tp(), "eq");
+ static_assert(!(_Tp() != _Tp()), "ne");
+ }
+ };
+
+ // Generator to test standard layout
+ struct has_trivial_cons_dtor
+ {
+ template<typename _Tp>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ {
+ typedef std::has_trivial_default_constructor<_Tp> ctor_p;
+ static_assert(ctor_p::value, "default constructor not trivial");
+
+ typedef std::has_trivial_destructor<_Tp> dtor_p;
+ static_assert(dtor_p::value, "destructor not trivial");
+ }
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+ struct standard_layout
+ {
+ template<typename _Tp>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ {
+ typedef std::is_standard_layout<_Tp> standard_layout_p;
+ static_assert(standard_layout_p::value, "not standard_layout");
+ }
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+#endif
+
+ // Generator to test base class
+ struct has_required_base_class
+ {
+ template<typename _TBase, typename _TDerived>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ {
+ const _TDerived& obj = __a;
+ const _TBase* base __attribute__((unused)) = &obj;
+ }
+
+ _TDerived __a;
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+ // Generator to test assignment operator.
+ struct assignable
+ {
+ template<typename _Tp>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ { __v1 = __v2; }
+
+ _Tp __v1;
+ _Tp __v2;
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+ // Generator to test default constructor.
+ struct default_constructible
+ {
+ template<typename _Tp>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ { _Tp __v __attribute__((unused)); }
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+ // Generator to test copy constructor.
+ struct copy_constructible
+ {
+ template<typename _Tp>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ { _Tp __v2(__v1); }
+
+ _Tp __v1;
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+ // Generator to test direct initialization, single value constructor.
+ struct single_value_constructible
+ {
+ template<typename _Ttype, typename _Tvalue>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ { _Ttype __v(__a); }
+
+ _Tvalue __a;
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ // Generator to test default constructor.
+ struct constexpr_default_constructible
+ {
+ template<typename _Tp, bool _IsLitp = std::is_literal_type<_Tp>::value>
+ struct _Concept;
+
+ // NB: _Tp must be a literal type.
+ // Have to have user-defined default ctor for this to work.
+ template<typename _Tp>
+ struct _Concept<_Tp, true>
+ {
+ void __constraint()
+ { constexpr _Tp __obj; }
+ };
+
+ // Non-literal type, declare local static and verify no
+ // constructors generated for _Tp within the translation unit.
+ template<typename _Tp>
+ struct _Concept<_Tp, false>
+ {
+ void __constraint()
+ { static _Tp __obj; }
+ };
+
+ template<typename _Tp>
+ void
+ operator()()
+ {
+ _Concept<_Tp> c;
+ c.__constraint();
+ }
+ };
+
+ // Generator to test defaulted default constructor.
+ struct constexpr_defaulted_default_constructible
+ {
+ template<typename _Tp>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ { constexpr _Tp __v __attribute__((unused)) { }; }
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+ struct constexpr_single_value_constructible
+ {
+ template<typename _Ttesttype, typename _Tvaluetype,
+ bool _IsLitp = std::is_literal_type<_Ttesttype>::value>
+ struct _Concept;
+
+ // NB: _Tvaluetype and _Ttesttype must be literal types.
+ // Additional constraint on _Tvaluetype needed. Either assume
+ // user-defined default ctor as per
+ // constexpr_default_constructible and provide no initializer,
+ // provide an initializer, or assume empty-list init-able. Choose
+ // the latter.
+ template<typename _Ttesttype, typename _Tvaluetype>
+ struct _Concept<_Ttesttype, _Tvaluetype, true>
+ {
+ void __constraint()
+ {
+ constexpr _Tvaluetype __v { };
+ constexpr _Ttesttype __obj(__v);
+ }
+ };
+
+ template<typename _Ttesttype, typename _Tvaluetype>
+ struct _Concept<_Ttesttype, _Tvaluetype, false>
+ {
+ void __constraint()
+ {
+ const _Tvaluetype __v { };
+ static _Ttesttype __obj(__v);
+ }
+ };
+
+ template<typename _Ttesttype, typename _Tvaluetype>
+ void
+ operator()()
+ {
+ _Concept<_Ttesttype, _Tvaluetype> c;
+ c.__constraint();
+ }
+ };
+#endif
+
+ // Generator to test direct list initialization
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ struct direct_list_initializable
+ {
+ template<typename _Ttype, typename _Tvalue>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ {
+ _Ttype __v1 { }; // default ctor
+ _Ttype __v2 { __a }; // single-argument ctor
+ }
+
+ _Tvalue __a;
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+#endif
+
+ // Generator to test copy list initialization, aggregate initialization
+ struct copy_list_initializable
+ {
+ template<typename _Ttype, typename _Tvalue>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ { _Ttype __v __attribute__((unused)) = {__a}; }
+
+ _Tvalue __a;
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+ // Generator to test integral conversion operator
+ struct integral_convertable
+ {
+ template<typename _Ttype, typename _Tvalue>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ {
+ _Tvalue __v0(0);
+ _Tvalue __v1(1);
+ _Ttype __a(__v1);
+ __v0 = __a;
+
+ bool test __attribute__((unused)) = true;
+ VERIFY( __v1 == __v0 );
+ }
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+
+ // Generator to test integral assignment operator
+ struct integral_assignable
+ {
+ template<typename _Ttype, typename _Tvalue>
+ void
+ operator()()
+ {
+ struct _Concept
+ {
+ void __constraint()
+ {
+ _Tvalue __v0(0);
+ _Tvalue __v1(1);
+ _Ttype __a(__v0);
+ __a = __v1;
+ _Tvalue __vr = __a;
+
+ bool test __attribute__((unused)) = true;
+ VERIFY( __v1 == __vr );
+ }
+ };
+
+ void (_Concept::*__x)() __attribute__((unused))
+ = &_Concept::__constraint;
+ }
+ };
+} // namespace __gnu_test
+#endif
diff --git a/libstdc++-v3/testsuite/util/testsuite_container_traits.h b/libstdc++-v3/testsuite/util/testsuite_container_traits.h
new file mode 100644
index 000000000..4d8ff997a
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_container_traits.h
@@ -0,0 +1,260 @@
+// -*- C++ -*-
+
+// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#ifndef _GLIBCXX_TESTSUITE_CONTAINER_TRAITS_H
+#define _GLIBCXX_TESTSUITE_CONTAINER_TRAITS_H
+
+#include <bits/stdc++.h>
+#include <ext/vstring.h>
+
+namespace __gnu_test
+{
+ // Container traits.
+ // Base class with default false values for all traits.
+ struct traits_base
+ {
+ // Type, nested type, and typedef related traits.
+ typedef std::false_type is_container;
+ typedef std::false_type is_adaptor;
+ typedef std::false_type is_reversible;
+ typedef std::false_type is_allocator_aware;
+ typedef std::false_type is_associative;
+ typedef std::false_type is_unordered;
+ typedef std::false_type is_mapped;
+
+ typedef std::false_type has_erase;
+ typedef std::false_type has_erase_after;
+ typedef std::false_type has_throwing_erase;
+ typedef std::false_type has_insert;
+ typedef std::false_type has_insert_after;
+ typedef std::false_type has_push_pop;
+ typedef std::false_type has_size_type_constructor;
+ };
+
+ // Primary template does nothing. Specialize on each type under
+ // test, derive off of traits_base and just add the true traits.
+ template<typename _Tp>
+ struct traits;
+
+ // Specialize for each container.
+ template<typename _Tp, size_t _Np>
+ struct traits<std::array<_Tp, _Np>> : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_reversible;
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct traits<std::deque<_Tp1, _Tp2>> : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_reversible;
+ typedef std::true_type is_allocator_aware;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_throwing_erase;
+ typedef std::true_type has_insert;
+ typedef std::true_type has_push_pop;
+ typedef std::true_type has_size_type_constructor;
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct traits<std::forward_list<_Tp1, _Tp2>> : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_allocator_aware;
+
+ typedef std::true_type has_erase_after;
+ typedef std::true_type has_insert_after;
+ typedef std::true_type has_push_pop;
+ typedef std::true_type has_size_type_constructor;
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct traits<std::list<_Tp1, _Tp2>> : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_reversible;
+ typedef std::true_type is_allocator_aware;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_insert;
+ typedef std::true_type has_push_pop;
+ typedef std::true_type has_size_type_constructor;
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct traits<std::vector<_Tp1, _Tp2>> : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_reversible;
+ typedef std::true_type is_allocator_aware;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_throwing_erase;
+ typedef std::true_type has_insert;
+ typedef std::true_type has_size_type_constructor;
+ };
+
+ template<typename _Tp1, typename _Tp2, typename _Tp3>
+ struct traits<std::basic_string<_Tp1, _Tp2, _Tp3>> : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_reversible;
+ typedef std::true_type is_allocator_aware;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_insert;
+ };
+
+ template<typename _Tp1, typename _Tp2, typename _Tp3,
+ template <typename, typename, typename> class _Tp4>
+ struct traits<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>>
+ : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_reversible;
+ typedef std::true_type is_allocator_aware;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_insert;
+ };
+
+ template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
+ struct traits<std::map<_Tp1, _Tp2, _Tp3, _Tp4>> : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_reversible;
+ typedef std::true_type is_allocator_aware;
+ typedef std::true_type is_associative;
+ typedef std::true_type is_mapped;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_insert;
+ };
+
+ template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
+ struct traits<std::multimap<_Tp1, _Tp2, _Tp3, _Tp4>> : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_reversible;
+ typedef std::true_type is_allocator_aware;
+ typedef std::true_type is_associative;
+ typedef std::true_type is_mapped;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_insert;
+ };
+
+ template<typename _Tp1, typename _Tp2, typename _Tp3>
+ struct traits<std::set<_Tp1, _Tp2, _Tp3>> : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_reversible;
+ typedef std::true_type is_allocator_aware;
+ typedef std::true_type is_associative;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_insert;
+ };
+
+ template<typename _Tp1, typename _Tp2, typename _Tp3>
+ struct traits<std::multiset<_Tp1, _Tp2, _Tp3>> : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_reversible;
+ typedef std::true_type is_allocator_aware;
+ typedef std::true_type is_associative;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_insert;
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct traits<std::priority_queue<_Tp1, _Tp2>> : public traits_base
+ {
+ typedef std::true_type is_adaptor;
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct traits<std::queue<_Tp1, _Tp2>> : public traits_base
+ {
+ typedef std::true_type is_adaptor;
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct traits<std::stack<_Tp1, _Tp2> > : public traits_base
+ {
+ typedef std::true_type is_adaptor;
+ };
+
+ template<typename _Tp1, typename _Tp2, typename _Tp3,
+ typename _Tp4, typename _Tp5>
+ struct traits<std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>>
+ : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_allocator_aware;
+ typedef std::true_type is_unordered;
+ typedef std::true_type is_mapped;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_insert;
+ };
+
+ template<typename _Tp1, typename _Tp2, typename _Tp3,
+ typename _Tp4, typename _Tp5>
+ struct traits<std::unordered_multimap<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>>
+ : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_allocator_aware;
+ typedef std::true_type is_unordered;
+ typedef std::true_type is_mapped;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_insert;
+ };
+
+ template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
+ struct traits<std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4>>
+ : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_allocator_aware;
+ typedef std::true_type is_unordered;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_insert;
+ };
+
+ template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4>
+ struct traits<std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4>>
+ : public traits_base
+ {
+ typedef std::true_type is_container;
+ typedef std::true_type is_allocator_aware;
+ typedef std::true_type is_unordered;
+
+ typedef std::true_type has_erase;
+ typedef std::true_type has_insert;
+ };
+} // namespace __gnu_test
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/testsuite_containers.h b/libstdc++-v3/testsuite/util/testsuite_containers.h
new file mode 100644
index 000000000..24133cdc5
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_containers.h
@@ -0,0 +1,229 @@
+// -*- C++ -*-
+
+// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#ifndef _GLIBCXX_TESTSUITE_CONTAINERS_H
+#define _GLIBCXX_TESTSUITE_CONTAINERS_H
+
+#include <cassert>
+#include <testsuite_container_traits.h>
+
+// Container requirement testing.
+namespace __gnu_test
+{
+ // Compile-time typedef testing.
+ template<typename _Tp, bool _Bt = traits<_Tp>::is_container::value>
+ struct basic_types
+ {
+ // Base container requirements (table 80)
+ typedef _Tp test_type;
+ typedef typename test_type::value_type value_type;
+ typedef typename test_type::pointer pointer;
+ typedef typename test_type::const_pointer const_pointer;
+ typedef typename test_type::reference reference;
+ typedef typename test_type::const_reference const_reference;
+ typedef typename test_type::iterator iterator;
+ typedef typename test_type::const_iterator const_iterator;
+ typedef typename test_type::size_type size_type;
+ typedef typename test_type::difference_type difference_type;
+ };
+
+ // Conditional typedef testing, positive.
+ template<typename _Tp, bool _Bt = traits<_Tp>::is_reversible::value>
+ struct reversible_types
+ {
+ // Reversible container requirements (table 81)
+ typedef _Tp test_type;
+ typedef typename test_type::reverse_iterator reverse_iterator;
+ typedef typename test_type::const_reverse_iterator const_reverse_iterator;
+ };
+
+ template<typename _Tp, bool _Bt = traits<_Tp>::is_allocator_aware::value>
+ struct allocator_aware_types
+ {
+ // Allocator-aware requirements (table 82)
+ typedef _Tp test_type;
+ typedef typename test_type::allocator_type allocator_type;
+ };
+
+ template<typename _Tp, bool _Bt = traits<_Tp>::is_associative::value>
+ struct associative_types
+ {
+ // Associative container requirements (table 85)
+ typedef _Tp test_type;
+ typedef typename test_type::key_type key_type;
+ typedef typename test_type::key_compare key_compare;
+ typedef typename test_type::value_compare value_compare;
+ };
+
+ template<typename _Tp, bool = traits<_Tp>::is_unordered::value>
+ struct unordered_types
+ {
+ // Unordered associative container requirements (table 87)
+ typedef _Tp test_type;
+ typedef typename test_type::key_type key_type;
+ typedef typename test_type::hasher hasher;
+ typedef typename test_type::key_equal key_equal;
+ typedef typename test_type::local_iterator local_iterator;
+ typedef typename test_type::const_local_iterator const_local_iterator;
+ };
+
+ template<typename _Tp, bool _Bt = traits<_Tp>::is_mapped::value>
+ struct mapped_types
+ {
+ typedef _Tp test_type;
+ typedef typename test_type::mapped_type mapped_type;
+ };
+
+ template<typename _Tp, bool = traits<_Tp>::is_adaptor::value>
+ struct adaptor_types
+ {
+ // Container adaptor requirements.
+ typedef _Tp test_type;
+ typedef typename test_type::value_type value_type;
+ typedef typename test_type::reference reference;
+ typedef typename test_type::const_reference const_reference;
+ typedef typename test_type::size_type size_type;
+ typedef typename test_type::container_type container_type;
+ };
+
+ // Conditional typedef testing, negative.
+ template<typename _Tp>
+ struct basic_types<_Tp, false> { };
+
+ template<typename _Tp>
+ struct adaptor_types<_Tp, false> { };
+
+ template<typename _Tp>
+ struct reversible_types<_Tp, false> { };
+
+ template<typename _Tp>
+ struct allocator_aware_types<_Tp, false> { };
+
+ template<typename _Tp>
+ struct associative_types<_Tp, false> { };
+
+ template<typename _Tp>
+ struct unordered_types<_Tp, false> { };
+
+ template<typename _Tp>
+ struct mapped_types<_Tp, false> { };
+
+ // Primary template.
+ template<typename _Tp>
+ struct types
+ : basic_types<_Tp>, adaptor_types<_Tp>, reversible_types<_Tp>,
+ allocator_aware_types<_Tp>, associative_types<_Tp>,
+ unordered_types<_Tp>, mapped_types<_Tp>
+ { };
+
+
+ // Run-time test for constant_iterator requirements.
+ template<typename _Tp, bool = traits<_Tp>::is_allocator_aware::value>
+ struct populate
+ {
+ populate(_Tp& container)
+ {
+ // Avoid uninitialized warnings, requires DefaultContructible.
+ typedef typename _Tp::value_type value_type;
+ container.insert(container.begin(), value_type());
+ container.insert(container.begin(), value_type());
+ }
+ };
+
+ template<typename _Tp>
+ struct populate<_Tp, false>
+ {
+ populate(_Tp& container) { }
+ };
+
+ template<typename _Tp, bool = traits<_Tp>::is_reversible::value>
+ struct reverse_members
+ {
+ reverse_members(_Tp& container)
+ {
+ assert( container.crbegin() == container.rbegin() );
+ assert( container.crend() == container.rend() );
+ assert( container.crbegin() != container.crend() );
+ }
+ };
+
+ template<typename _Tp>
+ struct reverse_members<_Tp, false>
+ {
+ reverse_members(_Tp& container) { }
+ };
+
+ // DR 691.
+ template<typename _Tp, bool = traits<_Tp>::is_unordered::value>
+ struct forward_members_unordered
+ {
+ forward_members_unordered(typename _Tp::value_type& v)
+ {
+ typedef _Tp test_type;
+ test_type container;
+ container.insert(v);
+ assert( container.cbegin(0) == container.begin(0) );
+ assert( container.cend(0) == container.end(0) );
+ const typename test_type::size_type bn = container.bucket(1);
+ assert( container.cbegin(bn) != container.cend(bn) );
+ }
+ };
+
+ template<typename _Tp>
+ struct forward_members_unordered<_Tp, false>
+ {
+ forward_members_unordered(_Tp& container) { }
+ };
+
+ template<typename _Tp>
+ struct citerator
+ {
+ typedef _Tp test_type;
+ typedef traits<test_type> traits_type;
+ typedef typename test_type::value_type value_type;
+
+ static test_type _S_container;
+
+ // Unconditional.
+ struct forward_members
+ {
+ forward_members()
+ {
+ assert( _S_container.cbegin() == _S_container.begin() );
+ assert( _S_container.cend() == _S_container.end() );
+ assert( _S_container.cbegin() != _S_container.cend() );
+ }
+ };
+
+ // Run test.
+ citerator()
+ {
+ populate<test_type> p(_S_container);
+ forward_members m1;
+ reverse_members<test_type> m2(_S_container);
+ }
+ };
+
+ template<typename _Tp>
+ _Tp citerator<_Tp>::_S_container;
+
+
+} // namespace __gnu_test
+
+#endif
diff --git a/libstdc++-v3/testsuite/util/testsuite_error.h b/libstdc++-v3/testsuite/util/testsuite_error.h
new file mode 100644
index 000000000..c2bfed737
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_error.h
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+// Error handling utils for the C++ library testsuite.
+//
+// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#include <string>
+#include <testsuite_hooks.h>
+
+#ifndef _TESTSUITE_ERROR_H
+#define _TESTSUITE_ERROR_H 1
+
+namespace __gnu_test
+{
+ struct test_category : public std::error_category
+ {
+ test_category() {}
+
+ virtual const char*
+ name() const
+ {
+ const char* s = "__gnu_test::test_category";
+ return s;
+ }
+
+ virtual std::string
+ message(int) const
+ { return std::string("message to be determined"); }
+ };
+
+ struct test_derived_category : public test_category
+ {
+ test_derived_category() {}
+
+ virtual const char*
+ name() const
+ {
+ const char* s = "__gnu_test::test_derived_category";
+ return s;
+ }
+ };
+
+}
+#endif
diff --git a/libstdc++-v3/testsuite/util/testsuite_greedy_ops.h b/libstdc++-v3/testsuite/util/testsuite_greedy_ops.h
new file mode 100644
index 000000000..8dcbfdb84
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_greedy_ops.h
@@ -0,0 +1,58 @@
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+namespace greedy_ops
+{
+ struct X
+ { };
+
+ template<typename T>
+ X operator==(T, T)
+ { return X(); }
+
+ template<typename T>
+ X operator!=(T, T)
+ { return X(); }
+
+ template<typename T>
+ X operator<(T, T)
+ { return X(); }
+
+ template<typename T>
+ X operator<=(T, T)
+ { return X(); }
+
+ template<typename T>
+ X operator>(T, T)
+ { return X(); }
+
+ template<typename T>
+ X operator>=(T, T)
+ { return X(); }
+
+ template<typename T>
+ X operator-(T, T)
+ { return X(); }
+ /*
+ template<typename T>
+ T operator+(std::size_t, T)
+ { return T(); }
+ */
+ template<typename T>
+ T operator+(T, std::size_t)
+ { return T(); }
+}
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.cc b/libstdc++-v3/testsuite/util/testsuite_hooks.cc
new file mode 100644
index 000000000..1ead34851
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.cc
@@ -0,0 +1,326 @@
+// -*- C++ -*-
+
+// Utility subroutines for the C++ library testsuite.
+//
+// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#include <testsuite_hooks.h>
+
+#ifdef _GLIBCXX_RES_LIMITS
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
+
+#include <list>
+#include <string>
+#include <stdexcept>
+#include <clocale>
+#include <cstdlib>
+#include <locale>
+#include <cxxabi.h>
+
+// If we have <sys/types.h>, <sys/ipc.h>, and <sys/sem.h>, then assume
+// that System V semaphores are available.
+#if defined(_GLIBCXX_HAVE_SYS_TYPES_H) \
+ && defined(_GLIBCXX_HAVE_SYS_IPC_H) \
+ && defined(_GLIBCXX_HAVE_SYS_SEM_H)
+#define _GLIBCXX_SYSV_SEM
+#endif
+
+#ifdef _GLIBCXX_SYSV_SEM
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#endif
+
+namespace __gnu_test
+{
+#ifdef _GLIBCXX_RES_LIMITS
+ void
+ set_memory_limits(float size)
+ {
+ struct rlimit r;
+ // Cater to the absence of rlim_t.
+ __typeof__ (r.rlim_cur) limit = (__typeof__ (r.rlim_cur))(size * 1048576);
+
+ // Heap size, seems to be common.
+#if _GLIBCXX_HAVE_LIMIT_DATA
+ getrlimit(RLIMIT_DATA, &r);
+ r.rlim_cur = limit;
+ setrlimit(RLIMIT_DATA, &r);
+#endif
+
+ // Resident set size.
+#if _GLIBCXX_HAVE_LIMIT_RSS
+ getrlimit(RLIMIT_RSS, &r);
+ r.rlim_cur = limit;
+ setrlimit(RLIMIT_RSS, &r);
+#endif
+
+ // Mapped memory (brk + mmap).
+#if _GLIBCXX_HAVE_LIMIT_VMEM
+ getrlimit(RLIMIT_VMEM, &r);
+ r.rlim_cur = limit;
+ setrlimit(RLIMIT_VMEM, &r);
+#endif
+
+ // Virtual memory. On x86_64-linux, the default is -z
+ // max-page-size=0x200000 which means up to 2MB of address space
+ // are accounted for PROT_NONE mappings between text and data
+ // segments of each shared library. There are 4 shared libs
+ // involved in addition to the dynamic linker, maybe 5 if libgomp
+ // is being used as well. Use at least 20MB address space limit.
+#if defined(__x86_64__) && defined(__linux__)
+ if (limit < 20971520)
+ limit = 20971520;
+#endif
+
+ // On HP-UX 11.23, a trivial C++ program that sets RLIMIT_AS to
+ // anything less than 128MB cannot "malloc" even 1K of memory.
+ // Therefore, we skip RLIMIT_AS on HP-UX.
+#if _GLIBCXX_HAVE_LIMIT_AS && !defined(__hpux__)
+ getrlimit(RLIMIT_AS, &r);
+ r.rlim_cur = limit;
+ setrlimit(RLIMIT_AS, &r);
+#endif
+ }
+
+#else
+ void
+ set_memory_limits(float) { }
+#endif
+
+#ifdef _GLIBCXX_RES_LIMITS
+ void
+ set_file_limit(unsigned long size)
+ {
+#if _GLIBCXX_HAVE_LIMIT_FSIZE
+ struct rlimit r;
+ // Cater to the absence of rlim_t.
+ __typeof__ (r.rlim_cur) limit = (__typeof__ (r.rlim_cur))(size);
+
+ getrlimit(RLIMIT_FSIZE, &r);
+ r.rlim_cur = limit;
+ setrlimit(RLIMIT_FSIZE, &r);
+#endif
+ }
+
+#else
+ void
+ set_file_limit(unsigned long) { }
+#endif
+
+ void
+ verify_demangle(const char* mangled, const char* wanted)
+ {
+ int status = 0;
+ const char* s = abi::__cxa_demangle(mangled, 0, 0, &status);
+ if (!s)
+ {
+ switch (status)
+ {
+ case 0:
+ s = "error code = 0: success";
+ break;
+ case -1:
+ s = "error code = -1: memory allocation failure";
+ break;
+ case -2:
+ s = "error code = -2: invalid mangled name";
+ break;
+ case -3:
+ s = "error code = -3: invalid arguments";
+ break;
+ default:
+ s = "error code unknown - who knows what happened";
+ }
+ }
+
+ std::string w(wanted);
+ if (w != s)
+ std::__throw_runtime_error(s);
+ }
+
+ void
+ run_tests_wrapped_locale(const char* name, const func_callback& l)
+ {
+ using namespace std;
+
+ // Set the global locale.
+ locale loc_name = locale(name);
+ locale orig = locale::global(loc_name);
+
+ const char* res = setlocale(LC_ALL, name);
+ if (res)
+ {
+ string preLC_ALL = res;
+ const func_callback::test_type* tests = l.tests();
+ for (int i = 0; i < l.size(); ++i)
+ (*tests[i])();
+ string postLC_ALL= setlocale(LC_ALL, 0);
+ VERIFY( preLC_ALL == postLC_ALL );
+ }
+ else
+ {
+ string s("LC_ALL for ");
+ s += name;
+ __throw_runtime_error(s.c_str());
+ }
+ }
+
+ void
+ run_tests_wrapped_env(const char* name, const char* env,
+ const func_callback& l)
+ {
+ using namespace std;
+
+#ifdef _GLIBCXX_HAVE_SETENV
+ // Set the global locale.
+ locale loc_name = locale(name);
+ locale orig = locale::global(loc_name);
+
+ // Set environment variable env to value in name.
+ const char* oldENV = getenv(env);
+ if (!setenv(env, name, 1))
+ {
+ const func_callback::test_type* tests = l.tests();
+ for (int i = 0; i < l.size(); ++i)
+ (*tests[i])();
+ setenv(env, oldENV ? oldENV : "", 1);
+ }
+ else
+ {
+ string s(env);
+ s += string(" to ");
+ s += string(name);
+ __throw_runtime_error(s.c_str());
+ }
+#endif
+ }
+
+ object_counter::size_type object_counter::count = 0;
+ unsigned int copy_constructor::count_ = 0;
+ unsigned int copy_constructor::throw_on_ = 0;
+ unsigned int assignment_operator::count_ = 0;
+ unsigned int assignment_operator::throw_on_ = 0;
+ unsigned int destructor::_M_count = 0;
+ int copy_tracker::next_id_ = 0;
+
+#ifdef _GLIBCXX_SYSV_SEM
+ // This union is not declared in system headers. Instead, it must
+ // be defined by user programs.
+ union semun
+ {
+ int val;
+ struct semid_ds *buf;
+ unsigned short *array;
+ };
+#endif
+
+ semaphore::semaphore()
+ {
+#ifdef _GLIBCXX_SYSV_SEM
+ // Remeber the PID for the process that created the semaphore set
+ // so that only one process will destroy the set.
+ pid_ = getpid();
+
+ // GLIBC does not define SEM_R and SEM_A.
+#ifndef SEM_R
+#define SEM_R 0400
+#endif
+
+#ifndef SEM_A
+#define SEM_A 0200
+#endif
+
+ // Get a semaphore set with one semaphore.
+ sem_set_ = semget(IPC_PRIVATE, 1, SEM_R | SEM_A);
+ if (sem_set_ == -1)
+ std::__throw_runtime_error("could not obtain semaphore set");
+
+ // Initialize the semaphore.
+ union semun val;
+ val.val = 0;
+ if (semctl(sem_set_, 0, SETVAL, val) == -1)
+ std::__throw_runtime_error("could not initialize semaphore");
+#else
+ // There are no semaphores on this system. We have no way to mark
+ // a test as "unsupported" at runtime, so we just exit, pretending
+ // that the test passed.
+ exit(0);
+#endif
+ }
+
+ semaphore::~semaphore()
+ {
+#ifdef _GLIBCXX_SYSV_SEM
+ union semun val;
+ val.val = 0; // Avoid uninitialized variable warning.
+ // Destroy the semaphore set only in the process that created it.
+ if (pid_ == getpid())
+ semctl(sem_set_, 0, IPC_RMID, val);
+#endif
+ }
+
+ void
+ semaphore::signal()
+ {
+#ifdef _GLIBCXX_SYSV_SEM
+ struct sembuf op[1] =
+ {
+ { 0, 1, 0 }
+ };
+ if (semop(sem_set_, op, 1) == -1)
+ std::__throw_runtime_error("could not signal semaphore");
+#endif
+ }
+
+ void
+ semaphore::wait()
+ {
+#ifdef _GLIBCXX_SYSV_SEM
+ struct sembuf op[1] =
+ {
+ { 0, -1, SEM_UNDO }
+ };
+ if (semop(sem_set_, op, 1) == -1)
+ std::__throw_runtime_error("could not wait for semaphore");
+#endif
+ }
+
+ // For use in 22_locale/time_get and time_put.
+ std::tm
+ test_tm(int sec, int min, int hour, int mday, int mon,
+ int year, int wday, int yday, int isdst)
+ {
+ static std::tm tmp;
+ tmp.tm_sec = sec;
+ tmp.tm_min = min;
+ tmp.tm_hour = hour;
+ tmp.tm_mday = mday;
+ tmp.tm_mon = mon;
+ tmp.tm_year = year;
+ tmp.tm_wday = wday;
+ tmp.tm_yday = yday;
+ tmp.tm_isdst = isdst;
+ return tmp;
+ }
+} // namespace __gnu_test
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h
new file mode 100644
index 000000000..fe41b1cb3
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h
@@ -0,0 +1,345 @@
+// -*- C++ -*-
+// Utility subroutines for the C++ library testsuite.
+//
+// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+// 2009, 2010
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// This file provides the following:
+//
+// 1) VERIFY(), via _GLIBCXX_ASSERT, from Brent Verner <brent@rcfile.org>.
+// This file is included in the various testsuite programs to provide
+// #define(able) assert() behavior for debugging/testing. It may be
+// a suitable location for other furry woodland creatures as well.
+//
+// 2) set_memory_limits()
+// set_memory_limits() uses setrlimit() to restrict dynamic memory
+// allocation. We provide a default memory limit if none is passed by the
+// calling application. The argument to set_memory_limits() is the
+// limit in megabytes (a floating-point number). If _GLIBCXX_RES_LIMITS is
+// not #defined before including this header, then no limiting is attempted.
+//
+// 3) object_counter
+// This is a POD with a static data member, object_counter::count,
+// which starts at zero, increments on instance construction, and decrements
+// on instance destruction. "assert_count(n)" can be called to VERIFY()
+// that the count equals N.
+//
+// 4) copy_tracker, from Stephen M. Webb <stephen@bregmasoft.com>.
+// A class with nontrivial ctor/dtor that provides the ability to track the
+// number of copy ctors and dtors, and will throw on demand during copy.
+
+#ifndef _GLIBCXX_TESTSUITE_HOOKS_H
+#define _GLIBCXX_TESTSUITE_HOOKS_H
+
+#include <bits/c++config.h>
+#include <bits/functexcept.h>
+#include <ctime>
+
+#ifdef _GLIBCXX_HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef _GLIBCXX_ASSERT
+# include <cassert>
+# define VERIFY(fn) assert(fn)
+#else
+# define VERIFY(fn) test &= bool(fn)
+#endif
+
+#ifdef _GLIBCXX_HAVE_UNISTD_H
+# include <unistd.h>
+#else
+# define unlink(x)
+#endif
+
+namespace __gnu_test
+{
+ // All macros are defined in GLIBCXX_CONFIGURE_TESTSUITE and imported
+ // from c++config.h
+
+ // Set memory limits if possible, if not set to 0.
+#ifndef _GLIBCXX_RES_LIMITS
+# define MEMLIMIT_MB 0
+#else
+# ifndef MEMLIMIT_MB
+# define MEMLIMIT_MB 16.0
+# endif
+#endif
+ extern void
+ set_memory_limits(float __size = MEMLIMIT_MB);
+
+ extern void
+ set_file_limit(unsigned long __size);
+
+ // Check mangled name demangles (using __cxa_demangle) as expected.
+ void
+ verify_demangle(const char* mangled, const char* wanted);
+
+ // Simple callback structure for variable numbers of tests (all with
+ // same signature). Assume all unit tests are of the signature
+ // void test01();
+ class func_callback
+ {
+ public:
+ typedef void (*test_type) (void);
+
+ private:
+ int _M_size;
+ test_type _M_tests[15];
+
+ func_callback&
+ operator=(const func_callback&);
+
+ func_callback(const func_callback&);
+
+ public:
+ func_callback(): _M_size(0) { }
+
+ int
+ size() const { return _M_size; }
+
+ const test_type*
+ tests() const { return _M_tests; }
+
+ void
+ push_back(test_type test)
+ {
+ _M_tests[_M_size] = test;
+ ++_M_size;
+ }
+ };
+
+
+ // Run select unit tests after setting global locale.
+ void
+ run_tests_wrapped_locale(const char*, const func_callback&);
+
+ // Run select unit tests after setting environment variables.
+ void
+ run_tests_wrapped_env(const char*, const char*, const func_callback&);
+
+ // Counting.
+ struct object_counter
+ {
+ // Specifically and glaringly-obviously marked 'signed' so that
+ // when COUNT mistakenly goes negative, we can track the patterns
+ // of deletions more easily.
+ typedef signed int size_type;
+ static size_type count;
+ object_counter() { ++count; }
+ object_counter (const object_counter&) { ++count; }
+ ~object_counter() { --count; }
+ };
+
+#define assert_count(n) VERIFY(__gnu_test::object_counter::count == n)
+
+ // A (static) class for counting copy constructors and possibly throwing an
+ // exception on a desired count.
+ class copy_constructor
+ {
+ public:
+ static unsigned int
+ count() { return count_; }
+
+ static void
+ mark_call()
+ {
+ count_++;
+ if (count_ == throw_on_)
+ std::__throw_runtime_error("copy_constructor::mark_call");
+ }
+
+ static void
+ reset()
+ {
+ count_ = 0;
+ throw_on_ = 0;
+ }
+
+ static void
+ throw_on(unsigned int count) { throw_on_ = count; }
+
+ private:
+ static unsigned int count_;
+ static unsigned int throw_on_;
+ };
+
+ // A (static) class for counting assignment operator calls and
+ // possibly throwing an exception on a desired count.
+ class assignment_operator
+ {
+ public:
+ static unsigned int
+ count() { return count_; }
+
+ static void
+ mark_call()
+ {
+ count_++;
+ if (count_ == throw_on_)
+ std::__throw_runtime_error("assignment_operator::mark_call");
+ }
+
+ static void
+ reset()
+ {
+ count_ = 0;
+ throw_on_ = 0;
+ }
+
+ static void
+ throw_on(unsigned int count) { throw_on_ = count; }
+
+ private:
+ static unsigned int count_;
+ static unsigned int throw_on_;
+ };
+
+ // A (static) class for tracking calls to an object's destructor.
+ class destructor
+ {
+ public:
+ static unsigned int
+ count() { return _M_count; }
+
+ static void
+ mark_call() { _M_count++; }
+
+ static void
+ reset() { _M_count = 0; }
+
+ private:
+ static unsigned int _M_count;
+ };
+
+ // An class of objects that can be used for validating various
+ // behaviours and guarantees of containers and algorithms defined in
+ // the standard library.
+ class copy_tracker
+ {
+ public:
+ // Creates a copy-tracking object with the given ID number. If
+ // "throw_on_copy" is set, an exception will be thrown if an
+ // attempt is made to copy this object.
+ copy_tracker(int id = next_id_--, bool throw_on_copy = false)
+ : id_(id) , throw_on_copy_(throw_on_copy) { }
+
+ // Copy-constructs the object, marking a call to the copy
+ // constructor and forcing an exception if indicated.
+ copy_tracker(const copy_tracker& rhs)
+ : id_(rhs.id()), throw_on_copy_(rhs.throw_on_copy_)
+ {
+ if (throw_on_copy_)
+ copy_constructor::throw_on(copy_constructor::count() + 1);
+ copy_constructor::mark_call();
+ }
+
+ // Assigns the value of another object to this one, tracking the
+ // number of times this member function has been called and if the
+ // other object is supposed to throw an exception when it is
+ // copied, well, make it so.
+ copy_tracker&
+ operator=(const copy_tracker& rhs)
+ {
+ id_ = rhs.id();
+ if (rhs.throw_on_copy_)
+ assignment_operator::throw_on(assignment_operator::count() + 1);
+ assignment_operator::mark_call();
+ return *this;
+ }
+
+ ~copy_tracker()
+ { destructor::mark_call(); }
+
+ int
+ id() const { return id_; }
+
+ static void
+ reset()
+ {
+ copy_constructor::reset();
+ assignment_operator::reset();
+ destructor::reset();
+ }
+
+ private:
+ int id_;
+ const bool throw_on_copy_;
+ static int next_id_;
+ };
+
+ inline bool
+ operator==(const copy_tracker& lhs, const copy_tracker& rhs)
+ { return lhs.id() == rhs.id(); }
+
+ inline bool
+ operator<(const copy_tracker& lhs, const copy_tracker& rhs)
+ { return lhs.id() < rhs.id(); }
+
+ // Class for checking required type conversions, implicit and
+ // explicit for given library data structures.
+ template<typename _Container>
+ struct conversion
+ {
+ typedef typename _Container::const_iterator const_iterator;
+
+ // Implicit conversion iterator to const_iterator.
+ static const_iterator
+ iterator_to_const_iterator()
+ {
+ _Container v;
+ const_iterator it = v.begin();
+ const_iterator end = v.end();
+ return it == end ? v.end() : it;
+ }
+ };
+
+ // A binary semaphore for use across multiple processes.
+ class semaphore
+ {
+ public:
+ // Creates a binary semaphore. The semaphore is initially in the
+ // unsignaled state.
+ semaphore();
+
+ // Destroy the semaphore.
+ ~semaphore();
+
+ // Signal the semaphore. If there are processes blocked in
+ // "wait", exactly one will be permitted to proceed.
+ void signal();
+
+ // Wait until the semaphore is signaled.
+ void wait();
+
+ private:
+ int sem_set_;
+
+ pid_t pid_;
+ };
+
+ // For use in 22_locale/time_get and time_put.
+ std::tm test_tm(int sec, int min, int hour, int mday, int mon,
+ int year, int wday, int yday, int isdst);
+
+} // namespace __gnu_test
+
+#endif // _GLIBCXX_TESTSUITE_HOOKS_H
+
diff --git a/libstdc++-v3/testsuite/util/testsuite_io.h b/libstdc++-v3/testsuite/util/testsuite_io.h
new file mode 100644
index 000000000..681448aa5
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_io.h
@@ -0,0 +1,319 @@
+// -*- C++ -*-
+// Testing streambuf/filebuf/stringbuf for the C++ library testsuite.
+//
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#ifndef _GLIBCXX_TESTSUITE_IO_H
+#define _GLIBCXX_TESTSUITE_IO_H
+
+#include <ios>
+
+namespace __gnu_test
+{
+ // Used to verify the constraints/requirements on get and put areas
+ // as defined in
+ // 27.5.1 - Stream buffer requirements: get and put areas
+ // 27.8.1.1 - Template class basic_filebuf p 3
+ // If the file is not open (ios_base::in) -> input seq. cannot be read
+ // If the file is not open (ios_base::out) -> output seq. cannot be written
+ // Joint file position
+ // 27.8.1.4 - Overridden virtual functions p9
+ // If unbuffered, pbase == pptr == NULL
+ // 27.7.1.1 - Basic_stringbuf constructors p 1
+ // 27.8.1.2 - Basic_filebuf constructors p 1
+ // ... , initializing the base class with basic_streambuf() 27.5.2.1
+ template<typename T>
+ class constraint_buf
+ : public T
+ {
+ public:
+ bool
+ write_position()
+ {
+ bool one = this->pptr() != 0;
+ bool two = this->pptr() < this->epptr();
+ return one && two;
+ }
+
+ bool
+ read_position()
+ {
+ bool one = this->gptr() != 0;
+ bool two = this->gptr() < this->egptr();
+ return one && two;
+ }
+
+ bool
+ unbuffered()
+ {
+ bool one = this->pbase() == 0;
+ bool two = this->pptr() == 0;
+ return one && two;
+ }
+
+ bool
+ check_pointers()
+ {
+ bool one = this->eback() == 0;
+ bool two = this->gptr() == 0;
+ bool three = this->egptr() == 0;
+
+ bool four = this->pbase() == 0;
+ bool five = this->pptr() == 0;
+ bool six = this->epptr() == 0;
+ return one && two && three && four && five && six;
+ }
+ };
+
+ typedef constraint_buf<std::streambuf> constraint_streambuf;
+ typedef constraint_buf<std::filebuf> constraint_filebuf;
+ typedef constraint_buf<std::stringbuf> constraint_stringbuf;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ typedef constraint_buf<std::wstreambuf> constraint_wstreambuf;
+ typedef constraint_buf<std::wfilebuf> constraint_wfilebuf;
+ typedef constraint_buf<std::wstringbuf> constraint_wstringbuf;
+#endif
+
+ // Used to check if basic_streambuf::pubsync() has been called.
+ // This is useful for checking if a function creates [io]stream::sentry
+ // objects, since the sentry constructors call tie()->flush().
+ template<typename T>
+ class sync_buf
+ : public T
+ {
+ private:
+ bool m_sync_called;
+
+ public:
+ sync_buf()
+ : m_sync_called(false)
+ { }
+
+ bool sync_called() const
+ { return m_sync_called; }
+
+ protected:
+ int sync()
+ {
+ m_sync_called = true;
+ return 0;
+ }
+ };
+
+ typedef sync_buf<std::streambuf> sync_streambuf;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ typedef sync_buf<std::wstreambuf> sync_wstreambuf;
+#endif
+
+ // Throws on all overflow and underflow calls.
+ struct underflow_error: std::exception { };
+ struct overflow_error: std::exception { };
+ struct positioning_error: std::exception { };
+
+ template<typename T>
+ struct fail_buf
+ : public T
+ {
+ typedef typename T::char_type char_type;
+ typedef typename T::int_type int_type;
+ typedef typename T::off_type off_type;
+ typedef typename T::pos_type pos_type;
+
+ private:
+ char_type p[2];
+
+ public:
+ fail_buf()
+ {
+ p[0] = char_type('s');
+ p[1] = char_type();
+ setg(p, p, p + 1);
+ }
+
+ virtual int_type underflow()
+ {
+ throw underflow_error();
+ return int_type();
+ }
+
+ virtual int_type uflow()
+ {
+ throw underflow_error();
+ return int_type();
+ }
+
+ virtual int_type
+ overflow(int_type)
+ {
+ throw overflow_error();
+ return int_type();
+ }
+
+ virtual pos_type
+ seekoff(off_type, std::ios_base::seekdir, std::ios_base::openmode)
+ {
+ throw positioning_error();
+ return pos_type(off_type(-1));
+ }
+
+ virtual pos_type
+ seekpos(pos_type, std::ios_base::openmode)
+ {
+ throw positioning_error();
+ return pos_type(off_type(-1));
+ }
+
+ virtual int
+ sync()
+ {
+ throw positioning_error();
+ return 0;
+ }
+ };
+
+ typedef fail_buf<std::streambuf> fail_streambuf;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ typedef fail_buf<std::wstreambuf> fail_wstreambuf;
+#endif
+
+ // Facets that throw an exception for every virtual function.
+ struct facet_error: std::exception { };
+
+ template<typename T>
+ class fail_num_get
+ : public std::num_get<T>
+ {
+ typedef std::ios_base ios_base;
+ typedef typename std::num_get<T>::iter_type iter_type;
+
+ protected:
+ iter_type
+ do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const
+ { throw facet_error(); return iter_type(); }
+
+ virtual iter_type
+ do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const
+ { throw facet_error(); return iter_type(); }
+
+ virtual iter_type
+ do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
+ unsigned short&) const
+ { throw facet_error(); return iter_type(); }
+
+ virtual iter_type
+ do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
+ unsigned int&) const
+ { throw facet_error(); return iter_type(); }
+
+ virtual iter_type
+ do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
+ unsigned long&) const
+ { throw facet_error(); return iter_type(); }
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ virtual iter_type
+ do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
+ long long&) const
+ { throw facet_error(); return iter_type(); }
+
+ virtual iter_type
+ do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
+ unsigned long long&) const
+ { throw facet_error(); return iter_type(); }
+#endif
+
+ virtual iter_type
+ do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
+ float&) const
+ { throw facet_error(); return iter_type(); }
+
+ virtual iter_type
+ do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
+ double&) const
+ { throw facet_error(); return iter_type(); }
+
+ virtual iter_type
+ do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
+ long double&) const
+ { throw facet_error(); return iter_type(); }
+
+ virtual iter_type
+ do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
+ void*&) const
+ { throw facet_error(); return iter_type(); }
+ };
+
+ typedef fail_num_get<char> fail_num_get_char;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ typedef fail_num_get<wchar_t> fail_num_get_wchar_t;
+#endif
+
+ template<typename T>
+ class fail_num_put
+ : public std::num_put<T>
+ {
+ typedef std::ios_base ios_base;
+ typedef typename std::num_put<T>::iter_type iter_type;
+ typedef typename std::num_put<T>::char_type char_type;
+
+ protected:
+ iter_type
+ do_put(iter_type, ios_base&, char_type, bool) const
+ { throw facet_error(); return iter_type(0); }
+
+ virtual iter_type
+ do_put(iter_type, ios_base&, char_type, long) const
+ { throw facet_error(); return iter_type(0); }
+
+ virtual iter_type
+ do_put(iter_type, ios_base&, char_type, unsigned long) const
+ { throw facet_error(); return iter_type(0); }
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ virtual iter_type
+ do_put(iter_type, ios_base&, char_type, long long) const
+ { throw facet_error(); return iter_type(0); }
+
+ virtual iter_type
+ do_put(iter_type, ios_base&, char_type, unsigned long long) const
+ { throw facet_error(); return iter_type(0); }
+#endif
+
+ virtual iter_type
+ do_put(iter_type, ios_base&, char_type, double) const
+ { throw facet_error(); return iter_type(0); }
+
+ virtual iter_type
+ do_put(iter_type, ios_base&, char_type, long double) const
+ { throw facet_error(); return iter_type(0); }
+
+ virtual iter_type
+ do_put(iter_type, ios_base&, char_type, const void*) const
+ { throw facet_error(); return iter_type(0); }
+ };
+
+ typedef fail_num_put<char> fail_num_put_char;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ typedef fail_num_put<wchar_t> fail_num_put_wchar_t;
+#endif
+} // namespace __gnu_test
+
+#endif // _GLIBCXX_TESTSUITE_IO_H
+
diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h
new file mode 100644
index 000000000..d815b6c57
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h
@@ -0,0 +1,552 @@
+// -*- C++ -*-
+// Iterator Wrappers for the C++ library testsuite.
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// This file provides the following:
+//
+// input_iterator_wrapper, output_iterator_wrapper
+// forward_iterator_wrapper, bidirectional_iterator_wrapper and
+// random_access_wrapper, which attempt to exactly perform the requirements
+// of these types of iterators. These are constructed from the class
+// test_container, which is given two pointers to T and an iterator type.
+
+#include <testsuite_hooks.h>
+#include <bits/stl_iterator_base_types.h>
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#include <bits/move.h>
+#endif
+
+#ifndef _TESTSUITE_ITERATORS
+#define _TESTSUITE_ITERATORS
+
+#ifdef DISABLE_ITERATOR_DEBUG
+#define ITERATOR_VERIFY(x)
+#else
+#define ITERATOR_VERIFY(x) VERIFY(x)
+#endif
+
+namespace __gnu_test
+{
+ /**
+ * @brief Simple container for holding two pointers.
+ *
+ * Note that input_iterator_wrapper changes first to denote
+ * how the valid range of == , ++, etc. change as the iterators are used.
+ */
+ template<typename T>
+ struct BoundsContainer
+ {
+ T* first;
+ T* last;
+ BoundsContainer(T* _first, T* _last) : first(_first), last(_last)
+ { }
+ };
+
+ // Simple container for holding state of a set of output iterators.
+ template<typename T>
+ struct OutputContainer : public BoundsContainer<T>
+ {
+ T* incrementedto;
+ bool* writtento;
+ OutputContainer(T* _first, T* _last)
+ : BoundsContainer<T>(_first, _last), incrementedto(_first)
+ {
+ writtento = new bool[this->last - this->first];
+ for(int i = 0; i < this->last - this->first; i++)
+ writtento[i] = false;
+ }
+
+ ~OutputContainer()
+ { delete[] writtento; }
+ };
+
+ // Produced by output_iterator to allow limited writing to pointer
+ template<class T>
+ class WritableObject
+ {
+ T* ptr;
+
+ public:
+ OutputContainer<T>* SharedInfo;
+ WritableObject(T* ptr_in,OutputContainer<T>* SharedInfo_in):
+ ptr(ptr_in), SharedInfo(SharedInfo_in)
+ { }
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<class U>
+ void
+ operator=(U&& new_val)
+ {
+ ITERATOR_VERIFY(SharedInfo->writtento[ptr - SharedInfo->first] == 0);
+ SharedInfo->writtento[ptr - SharedInfo->first] = 1;
+ *ptr = std::forward<U>(new_val);
+ }
+#else
+ template<class U>
+ void
+ operator=(const U& new_val)
+ {
+ ITERATOR_VERIFY(SharedInfo->writtento[ptr - SharedInfo->first] == 0);
+ SharedInfo->writtento[ptr - SharedInfo->first] = 1;
+ *ptr = new_val;
+ }
+#endif
+ };
+
+ /**
+ * @brief output_iterator wrapper for pointer
+ *
+ * This class takes a pointer and wraps it to provide exactly
+ * the requirements of a output_iterator. It should not be
+ * instansiated directly, but generated from a test_container
+ */
+ template<class T>
+ struct output_iterator_wrapper
+ : public std::iterator<std::output_iterator_tag, T, std::ptrdiff_t, T*, T&>
+ {
+ typedef OutputContainer<T> ContainerType;
+ T* ptr;
+ ContainerType* SharedInfo;
+
+ output_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in)
+ : ptr(_ptr), SharedInfo(SharedInfo_in)
+ {
+ ITERATOR_VERIFY(ptr >= SharedInfo->first && ptr <= SharedInfo->last);
+ }
+
+ output_iterator_wrapper(const output_iterator_wrapper& in)
+ : ptr(in.ptr), SharedInfo(in.SharedInfo)
+ { }
+
+ WritableObject<T>
+ operator*() const
+ {
+ ITERATOR_VERIFY(ptr < SharedInfo->last);
+ ITERATOR_VERIFY(SharedInfo->writtento[ptr - SharedInfo->first] == false);
+ return WritableObject<T>(ptr, SharedInfo);
+ }
+
+ output_iterator_wrapper&
+ operator=(const output_iterator_wrapper& in)
+ {
+ ptr = in.ptr;
+ SharedInfo = in.SharedInfo;
+ return *this;
+ }
+
+ output_iterator_wrapper&
+ operator++()
+ {
+ ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last);
+ ITERATOR_VERIFY(ptr>=SharedInfo->incrementedto);
+ ptr++;
+ SharedInfo->incrementedto=ptr;
+ return *this;
+ }
+
+ output_iterator_wrapper
+ operator++(int)
+ {
+ output_iterator_wrapper<T> tmp = *this;
+ ++*this;
+ return tmp;
+ }
+
+ };
+
+ /**
+ * @brief input_iterator wrapper for pointer
+ *
+ * This class takes a pointer and wraps it to provide exactly
+ * the requirements of a input_iterator. It should not be
+ * instansiated directly, but generated from a test_container
+ */
+ template<class T>
+ class input_iterator_wrapper
+ : public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T&>
+ {
+ protected:
+ input_iterator_wrapper()
+ { }
+
+ public:
+ typedef BoundsContainer<T> ContainerType;
+ T* ptr;
+ ContainerType* SharedInfo;
+
+ input_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in)
+ : ptr(_ptr), SharedInfo(SharedInfo_in)
+ { ITERATOR_VERIFY(ptr >= SharedInfo->first && ptr <= SharedInfo->last); }
+
+ input_iterator_wrapper(const input_iterator_wrapper& in)
+ : ptr(in.ptr), SharedInfo(in.SharedInfo)
+ { }
+
+ bool
+ operator==(const input_iterator_wrapper& in) const
+ {
+ ITERATOR_VERIFY(SharedInfo && SharedInfo == in.SharedInfo);
+ ITERATOR_VERIFY(ptr>=SharedInfo->first && in.ptr>=SharedInfo->first);
+ return ptr == in.ptr;
+ }
+
+ bool
+ operator!=(const input_iterator_wrapper& in) const
+ {
+ return !(*this == in);
+ }
+
+ T&
+ operator*() const
+ {
+ ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last);
+ ITERATOR_VERIFY(ptr >= SharedInfo->first);
+ return *ptr;
+ }
+
+ T*
+ operator->() const
+ {
+ return &**this;
+ }
+
+ input_iterator_wrapper&
+ operator=(const input_iterator_wrapper& in)
+ {
+ ptr = in.ptr;
+ SharedInfo = in.SharedInfo;
+ return *this;
+ }
+
+ input_iterator_wrapper&
+ operator++()
+ {
+ ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last);
+ ITERATOR_VERIFY(ptr>=SharedInfo->first);
+ ptr++;
+ SharedInfo->first=ptr;
+ return *this;
+ }
+
+ void
+ operator++(int)
+ {
+ ++*this;
+ }
+ };
+
+
+ /**
+ * @brief forward_iterator wrapper for pointer
+ *
+ * This class takes a pointer and wraps it to provide exactly
+ * the requirements of a forward_iterator. It should not be
+ * instansiated directly, but generated from a test_container
+ */
+ template<class T>
+ struct forward_iterator_wrapper : public input_iterator_wrapper<T>
+ {
+ typedef BoundsContainer<T> ContainerType;
+ typedef std::forward_iterator_tag iterator_category;
+ forward_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in)
+ : input_iterator_wrapper<T>(_ptr, SharedInfo_in)
+ { }
+
+ forward_iterator_wrapper(const forward_iterator_wrapper& in)
+ : input_iterator_wrapper<T>(in)
+ { }
+
+ forward_iterator_wrapper()
+ {
+ this->ptr = 0;
+ this->SharedInfo = 0;
+ }
+
+ T&
+ operator*() const
+ {
+ ITERATOR_VERIFY(this->SharedInfo && this->ptr < this->SharedInfo->last);
+ return *(this->ptr);
+ }
+
+ T*
+ operator->() const
+ { return &**this; }
+
+ forward_iterator_wrapper&
+ operator++()
+ {
+ ITERATOR_VERIFY(this->SharedInfo && this->ptr < this->SharedInfo->last);
+ this->ptr++;
+ return *this;
+ }
+
+ forward_iterator_wrapper
+ operator++(int)
+ {
+ forward_iterator_wrapper<T> tmp = *this;
+ ++*this;
+ return tmp;
+ }
+ };
+
+ /**
+ * @brief bidirectional_iterator wrapper for pointer
+ *
+ * This class takes a pointer and wraps it to provide exactly
+ * the requirements of a forward_iterator. It should not be
+ * instansiated directly, but generated from a test_container
+ */
+ template<class T>
+ struct bidirectional_iterator_wrapper : public forward_iterator_wrapper<T>
+ {
+ typedef BoundsContainer<T> ContainerType;
+ typedef std::bidirectional_iterator_tag iterator_category;
+ bidirectional_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in)
+ : forward_iterator_wrapper<T>(_ptr, SharedInfo_in)
+ { }
+
+ bidirectional_iterator_wrapper(const bidirectional_iterator_wrapper& in)
+ : forward_iterator_wrapper<T>(in)
+ { }
+
+ bidirectional_iterator_wrapper(): forward_iterator_wrapper<T>()
+ { }
+
+ bidirectional_iterator_wrapper&
+ operator=(const bidirectional_iterator_wrapper& in)
+ {
+ this->ptr = in.ptr;
+ this->SharedInfo = in.SharedInfo;
+ return *this;
+ }
+
+ bidirectional_iterator_wrapper&
+ operator++()
+ {
+ ITERATOR_VERIFY(this->SharedInfo && this->ptr < this->SharedInfo->last);
+ this->ptr++;
+ return *this;
+ }
+
+ bidirectional_iterator_wrapper
+ operator++(int)
+ {
+ bidirectional_iterator_wrapper<T> tmp = *this;
+ ++*this;
+ return tmp;
+ }
+
+ bidirectional_iterator_wrapper&
+ operator--()
+ {
+ ITERATOR_VERIFY(this->SharedInfo && this->ptr > this->SharedInfo->first);
+ this->ptr--;
+ return *this;
+ }
+
+ bidirectional_iterator_wrapper
+ operator--(int)
+ {
+ bidirectional_iterator_wrapper<T> tmp = *this;
+ --*this;
+ return tmp;
+ }
+ };
+
+ /**
+ * @brief random_access_iterator wrapper for pointer
+ *
+ * This class takes a pointer and wraps it to provide exactly
+ * the requirements of a forward_iterator. It should not be
+ * instansiated directly, but generated from a test_container
+ */
+ template<class T>
+ struct random_access_iterator_wrapper
+ : public bidirectional_iterator_wrapper<T>
+ {
+ typedef BoundsContainer<T> ContainerType;
+ typedef std::random_access_iterator_tag iterator_category;
+ random_access_iterator_wrapper(T* _ptr, ContainerType* SharedInfo_in)
+ : bidirectional_iterator_wrapper<T>(_ptr, SharedInfo_in)
+ { }
+
+ random_access_iterator_wrapper(const random_access_iterator_wrapper<T>& in)
+ : bidirectional_iterator_wrapper<T>(in)
+ { }
+
+ random_access_iterator_wrapper():bidirectional_iterator_wrapper<T>()
+ { }
+
+ random_access_iterator_wrapper&
+ operator=(const random_access_iterator_wrapper& in)
+ {
+ this->ptr = in.ptr;
+ this->SharedInfo = in.SharedInfo;
+ return *this;
+ }
+
+ random_access_iterator_wrapper&
+ operator++()
+ {
+ ITERATOR_VERIFY(this->SharedInfo && this->ptr < this->SharedInfo->last);
+ this->ptr++;
+ return *this;
+ }
+
+ random_access_iterator_wrapper
+ operator++(int)
+ {
+ random_access_iterator_wrapper<T> tmp = *this;
+ ++*this;
+ return tmp;
+ }
+
+ random_access_iterator_wrapper&
+ operator--()
+ {
+ ITERATOR_VERIFY(this->SharedInfo && this->ptr > this->SharedInfo->first);
+ this->ptr--;
+ return *this;
+ }
+
+ random_access_iterator_wrapper
+ operator--(int)
+ {
+ random_access_iterator_wrapper<T> tmp = *this;
+ --*this;
+ return tmp;
+ }
+
+ random_access_iterator_wrapper&
+ operator+=(std::ptrdiff_t n)
+ {
+ if(n > 0)
+ {
+ ITERATOR_VERIFY(n <= this->SharedInfo->last - this->ptr);
+ this->ptr += n;
+ }
+ else
+ {
+ ITERATOR_VERIFY(n <= this->ptr - this->SharedInfo->first);
+ this->ptr += n;
+ }
+ return *this;
+ }
+
+ random_access_iterator_wrapper&
+ operator-=(std::ptrdiff_t n)
+ { return *this += -n; }
+
+ random_access_iterator_wrapper
+ operator-(std::ptrdiff_t n) const
+ {
+ random_access_iterator_wrapper<T> tmp = *this;
+ return tmp -= n;
+ }
+
+ std::ptrdiff_t
+ operator-(const random_access_iterator_wrapper<T>& in) const
+ {
+ ITERATOR_VERIFY(this->SharedInfo == in.SharedInfo);
+ return this->ptr - in.ptr;
+ }
+
+ T&
+ operator[](std::ptrdiff_t n) const
+ { return *(*this + n); }
+
+ bool
+ operator<(const random_access_iterator_wrapper<T>& in) const
+ {
+ ITERATOR_VERIFY(this->SharedInfo == in.SharedInfo);
+ return this->ptr < in.ptr;
+ }
+
+ bool
+ operator>(const random_access_iterator_wrapper<T>& in) const
+ {
+ return in < *this;
+ }
+
+ bool
+ operator>=(const random_access_iterator_wrapper<T>& in) const
+ {
+ return !(*this < in);
+ }
+
+ bool
+ operator<=(const random_access_iterator_wrapper<T>& in) const
+ {
+ return !(*this > in);
+ }
+ };
+
+ template<typename T>
+ random_access_iterator_wrapper<T>
+ operator+(random_access_iterator_wrapper<T> it, std::ptrdiff_t n)
+ { return it += n; }
+
+ template<typename T>
+ random_access_iterator_wrapper<T>
+ operator+(std::ptrdiff_t n, random_access_iterator_wrapper<T> it)
+ { return it += n; }
+
+
+ /**
+ * @brief A container-type class for holding iterator wrappers
+ * test_container takes two parameters, a class T and an iterator
+ * wrapper templated by T (for example forward_iterator_wrapper<T>.
+ * It takes two pointers representing a range and presents them as
+ * a container of iterators.
+ */
+ template <class T, template<class T> class ItType>
+ struct test_container
+ {
+ typename ItType<T>::ContainerType bounds;
+ test_container(T* _first, T* _last):bounds(_first, _last)
+ { }
+
+ ItType<T>
+ it(int pos)
+ {
+ ITERATOR_VERIFY(pos >= 0 && pos <= (bounds.last - bounds.first));
+ return ItType<T>(bounds.first + pos, &bounds);
+ }
+
+ ItType<T>
+ it(T* pos)
+ {
+ ITERATOR_VERIFY(pos >= bounds.first && pos <= bounds.last);
+ return ItType<T>(pos, &bounds);
+ }
+
+ ItType<T>
+ begin()
+ { return it(bounds.first); }
+
+ ItType<T>
+ end()
+ { return it(bounds.last); }
+ };
+}
+#endif
diff --git a/libstdc++-v3/testsuite/util/testsuite_performance.h b/libstdc++-v3/testsuite/util/testsuite_performance.h
new file mode 100644
index 000000000..61efd042d
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_performance.h
@@ -0,0 +1,485 @@
+// -*- C++ -*-
+// Testing performance utilities for the C++ library testsuite.
+//
+// Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#ifndef _GLIBCXX_PERFORMANCE_H
+#define _GLIBCXX_PERFORMANCE_H
+
+#include <sys/times.h>
+#include <sys/resource.h>
+#include <cstdlib>
+#include <cstring>
+#include <string>
+#include <fstream>
+#include <iomanip>
+#include <typeinfo>
+#include <stdexcept>
+#include <sstream>
+#include <cxxabi.h>
+#include <testsuite_common_types.h>
+
+#ifdef __linux__
+#include <malloc.h>
+#elif defined (__FreeBSD__)
+extern "C"
+{
+ struct mallinfo
+ {
+ int uordblks;
+ int hblkhd;
+ };
+
+ struct mallinfo
+ mallinfo(void)
+ {
+ struct mallinfo m = { (((std::size_t) sbrk (0) + 1023) / 1024), 0 };
+ return m;
+ }
+}
+#elif !defined (__hpux__)
+extern "C"
+{
+ struct mallinfo
+ {
+ int uordblks;
+ int hblkhd;
+ };
+
+ struct mallinfo empty = { 0, 0 };
+
+ struct mallinfo
+ mallinfo(void)
+ { return empty; }
+}
+#endif
+
+namespace __gnu_test
+{
+ class time_counter
+ {
+ private:
+ clock_t elapsed_begin;
+ clock_t elapsed_end;
+ tms tms_begin;
+ tms tms_end;
+
+ public:
+ explicit
+ time_counter() : elapsed_begin(), elapsed_end(), tms_begin(), tms_end()
+ { }
+
+ void
+ clear() throw()
+ {
+ elapsed_begin = clock_t();
+ elapsed_end = clock_t();
+ tms_begin = tms();
+ tms_end = tms();
+ }
+
+ void
+ start()
+ {
+ this->clear();
+ elapsed_begin = times(&tms_begin);
+ const clock_t err = clock_t(-1);
+ if (elapsed_begin == err)
+ std::__throw_runtime_error("time_counter::start");
+ }
+
+ void
+ stop()
+ {
+ elapsed_end = times(&tms_end);
+ const clock_t err = clock_t(-1);
+ if (elapsed_end == err)
+ std::__throw_runtime_error("time_counter::stop");
+ }
+
+ std::size_t
+ real_time() const
+ { return elapsed_end - elapsed_begin; }
+
+ std::size_t
+ user_time() const
+ { return tms_end.tms_utime - tms_begin.tms_utime; }
+
+ std::size_t
+ system_time() const
+ { return tms_end.tms_stime - tms_begin.tms_stime; }
+ };
+
+ class resource_counter
+ {
+ int who;
+ rusage rusage_begin;
+ rusage rusage_end;
+ struct mallinfo allocation_begin;
+ struct mallinfo allocation_end;
+
+ public:
+ resource_counter(int i = RUSAGE_SELF) : who(i)
+ { this->clear(); }
+
+ void
+ clear() throw()
+ {
+ memset(&rusage_begin, 0, sizeof(rusage_begin));
+ memset(&rusage_end, 0, sizeof(rusage_end));
+ memset(&allocation_begin, 0, sizeof(allocation_begin));
+ memset(&allocation_end, 0, sizeof(allocation_end));
+ }
+
+ void
+ start()
+ {
+ if (getrusage(who, &rusage_begin) != 0 )
+ memset(&rusage_begin, 0, sizeof(rusage_begin));
+ malloc(0); // Needed for some implementations.
+ allocation_begin = mallinfo();
+ }
+
+ void
+ stop()
+ {
+ if (getrusage(who, &rusage_end) != 0 )
+ memset(&rusage_end, 0, sizeof(rusage_end));
+ allocation_end = mallinfo();
+ }
+
+ int
+ allocated_memory() const
+ { return ((allocation_end.uordblks - allocation_begin.uordblks)
+ + (allocation_end.hblkhd - allocation_begin.hblkhd)); }
+
+ long
+ hard_page_fault() const
+ { return rusage_end.ru_majflt - rusage_begin.ru_majflt; }
+
+ long
+ swapped() const
+ { return rusage_end.ru_nswap - rusage_begin.ru_nswap; }
+ };
+
+ inline void
+ start_counters(time_counter& t, resource_counter& r)
+ {
+ t.start();
+ r.start();
+ }
+
+ inline void
+ stop_counters(time_counter& t, resource_counter& r)
+ {
+ t.stop();
+ r.stop();
+ }
+
+ inline void
+ clear_counters(time_counter& t, resource_counter& r)
+ {
+ t.clear();
+ r.clear();
+ }
+
+ void
+ report_performance(const std::string file, const std::string comment,
+ const time_counter& t, const resource_counter& r)
+ {
+ const char space = ' ';
+ const char tab = '\t';
+ const char* name = "libstdc++-performance.sum";
+ std::string::const_iterator i = file.begin() + file.find_last_of('/') + 1;
+ std::string testname(i, file.end());
+
+ std::ofstream out(name, std::ios_base::app);
+
+#ifdef __GTHREADS
+ if (__gthread_active_p())
+ testname.append("-thread");
+#endif
+
+ out.setf(std::ios_base::left);
+ out << std::setw(25) << testname << tab;
+ out << std::setw(25) << comment << tab;
+
+ out.setf(std::ios_base::right);
+ out << std::setw(4) << t.real_time() << "r" << space;
+ out << std::setw(4) << t.user_time() << "u" << space;
+ out << std::setw(4) << t.system_time() << "s" << space;
+ out << std::setw(8) << r.allocated_memory() << "mem" << space;
+ out << std::setw(4) << r.hard_page_fault() << "pf" << space;
+
+ out << std::endl;
+ out.close();
+ }
+
+ void
+ report_header(const std::string file, const std::string header)
+ {
+ const char space = ' ';
+ const char tab = '\t';
+ const char* name = "libstdc++-performance.sum";
+ std::string::const_iterator i = file.begin() + file.find_last_of('/') + 1;
+ std::string testname(i, file.end());
+
+ std::ofstream out(name, std::ios_base::app);
+
+#ifdef __GTHREADS
+ if (__gthread_active_p ())
+ testname.append("-thread");
+#endif
+
+ out.setf(std::ios_base::left);
+ out << std::setw(25) << testname << tab;
+ out << std::setw(40) << header << tab;
+
+ out << std::endl;
+ out.close();
+ }
+} // namespace __gnu_test
+
+
+// Ah, we wish it wasn't so...
+bool first_container = false;
+extern const char* filename;
+
+typedef std::string::size_type (*callback_type) (std::string&);
+
+template<typename Container, int Iter, bool Thread>
+ void
+ write_viz_container(callback_type find_container, const char* filename)
+ {
+ typedef std::string string;
+
+ // Create title.
+ {
+ const char ws(' ');
+ std::ostringstream title;
+
+ std::string titlename(filename);
+ std::string::size_type n = titlename.find('.');
+ if (n != string::npos)
+ titlename = std::string(titlename.begin(), titlename.begin() + n);
+
+ title << titlename;
+ title << ws;
+ title << Iter;
+ title << ws;
+#if 0
+ title << "thread<";
+ std::boolalpha(title);
+ title << Thread;
+ title << '>';
+#endif
+
+ titlename += ".title";
+ std::ofstream titlefile(titlename.c_str());
+ if (!titlefile.good())
+ throw std::runtime_error("write_viz_data cannot open titlename");
+ titlefile << title.str() << std::endl;
+ }
+
+ // Create compressed type name.
+ Container obj;
+ int status;
+ std::string type(abi::__cxa_demangle(typeid(obj).name(), 0, 0, &status));
+
+ // Extract fully-qualified typename.
+ // Assumes "set" or "map" are uniquely determinate.
+ string::iterator beg = type.begin();
+ string::iterator end;
+ string::size_type n = (*find_container)(type);
+
+ // Find start of fully-qualified name.
+ // Assume map, find end.
+ string::size_type nend = type.find('<', n);
+ if (nend != string::npos)
+ end = type.begin() + nend;
+
+ string compressed_type;
+ compressed_type += '"';
+ compressed_type += string(beg, end);
+ compressed_type += '<';
+#if 0
+ typename Container::key_type v;
+ compressed_type += typeid(v).name();
+#else
+ compressed_type += "int";
+#endif
+ compressed_type += ", A>";
+
+ // XXX
+ if (Thread == true)
+ compressed_type += " thread";
+ compressed_type += '"';
+
+ std::ofstream file(filename, std::ios_base::app);
+ if (!file.good())
+ throw std::runtime_error("write_viz_data cannot open filename");
+
+ file << compressed_type;
+ first_container = false;
+ }
+
+
+void
+write_viz_data(__gnu_test::time_counter& time, const char* filename)
+{
+ std::ofstream file(filename, std::ios_base::app);
+ if (!file.good())
+ throw std::runtime_error("write_viz_data cannot open filename");
+
+ // Print out score in appropriate column.
+ const char tab('\t');
+ int score = time.real_time();
+ file << tab << score;
+}
+
+void
+write_viz_endl(const char* filename)
+{
+ std::ofstream file(filename, std::ios_base::app);
+ if (!file.good())
+ throw std::runtime_error("write_viz_endl cannot open filename");
+ file << std::endl;
+}
+
+
+// Function template, function objects for the tests.
+template<typename TestType>
+ struct value_type : public std::pair<const TestType, TestType>
+ {
+ inline value_type& operator++()
+ {
+ ++this->second;
+ return *this;
+ }
+
+ inline operator TestType() const { return this->second; }
+ };
+
+template<typename Container, int Iter>
+ void
+ do_loop();
+
+template<typename Container, int Iter>
+ void*
+ do_thread(void* p = 0)
+ {
+ do_loop<Container, Iter>();
+ return p;
+ }
+
+template<typename Container, int Iter, bool Thread>
+ void
+ test_container(const char* filename)
+ {
+ using namespace __gnu_test;
+ time_counter time;
+ resource_counter resource;
+ {
+ start_counters(time, resource);
+ if (!Thread)
+ {
+ // No threads, so run 4x.
+ do_loop<Container, Iter * 4>();
+ }
+ else
+ {
+#if defined (_GLIBCXX_GCC_GTHR_POSIX_H) && !defined (NOTHREAD)
+ pthread_t t1, t2, t3, t4;
+ pthread_create(&t1, 0, &do_thread<Container, Iter>, 0);
+ pthread_create(&t2, 0, &do_thread<Container, Iter>, 0);
+ pthread_create(&t3, 0, &do_thread<Container, Iter>, 0);
+ pthread_create(&t4, 0, &do_thread<Container, Iter>, 0);
+
+ pthread_join(t1, 0);
+ pthread_join(t2, 0);
+ pthread_join(t3, 0);
+ pthread_join(t4, 0);
+#endif
+ }
+ stop_counters(time, resource);
+
+ // Detailed text data.
+ Container obj;
+ int status;
+ std::ostringstream comment;
+ comment << "type: " << abi::__cxa_demangle(typeid(obj).name(),
+ 0, 0, &status);
+ report_header(filename, comment.str());
+ report_performance("", "", time, resource);
+
+ // Detailed data for visualization.
+ std::string vizfilename(filename);
+ vizfilename += ".dat";
+ write_viz_data(time, vizfilename.c_str());
+ }
+ }
+
+template<bool Thread>
+ struct test_sequence
+ {
+ test_sequence(const char* filename) : _M_filename(filename) { }
+
+ template<class Container>
+ void
+ operator()(Container)
+ {
+ const int i = 20000;
+ test_container<Container, i, Thread>(_M_filename);
+ }
+
+ private:
+ const char* _M_filename;
+ };
+
+
+inline std::string::size_type
+sequence_find_container(std::string& type)
+{
+ const std::string::size_type npos = std::string::npos;
+ std::string::size_type n1 = type.find("vector");
+ std::string::size_type n2 = type.find("list");
+ std::string::size_type n3 = type.find("deque");
+ std::string::size_type n4 = type.find("string");
+
+ if (n1 != npos || n2 != npos || n3 != npos || n4 != npos)
+ return std::min(std::min(n1, n2), std::min(n3, n4));
+ else
+ throw std::runtime_error("sequence_find_container not found");
+}
+
+inline std::string::size_type
+associative_find_container(std::string& type)
+{
+ using std::string;
+ string::size_type n1 = type.find("map");
+ string::size_type n2 = type.find("set");
+ if (n1 != string::npos || n2 != string::npos)
+ return std::min(n1, n2);
+ else
+ throw std::runtime_error("associative_find_container not found");
+}
+
+#endif // _GLIBCXX_PERFORMANCE_H
+
diff --git a/libstdc++-v3/testsuite/util/testsuite_rng.h b/libstdc++-v3/testsuite/util/testsuite_rng.h
new file mode 100644
index 000000000..73b909e1e
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_rng.h
@@ -0,0 +1,97 @@
+// -*- C++ -*-
+
+// Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License as published by the Free Software
+// Foundation; either version 3, or (at your option) any later
+// version.
+
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
+
+// Permission to use, copy, modify, sell, and distribute this software
+// is hereby granted without fee, provided that the above copyright
+// notice appears in all copies, and that both that copyright notice
+// and this permission notice appear in supporting documentation. None
+// of the above authors, nor IBM Haifa Research Laboratories, make any
+// representation about the suitability of this software for any
+// purpose. It is provided "as is" without express or implied
+// warranty.
+
+/**
+ * @file testsuite_rng.h
+ */
+
+#ifndef _GLIBCXX_TESTSUITE_RNG_H
+#define _GLIBCXX_TESTSUITE_RNG_H
+
+#include <ctime>
+#include <climits>
+#include <debug/debug.h>
+#include <tr1/random>
+
+namespace __gnu_pbds
+{
+ namespace test
+ {
+ class twister_rand_gen
+ {
+ public:
+ twister_rand_gen(unsigned int seed =
+ static_cast<unsigned int>(std::time(0)))
+ : m_base_generator(seed)
+ {
+ // Do nothing.
+ }
+
+ void
+ init(unsigned int seed)
+ { m_base_generator.seed(seed); }
+
+ static unsigned int
+ get_time_determined_seed()
+ { return(static_cast<unsigned int>(std::time(0))); }
+
+ unsigned long
+ get_unsigned_long(unsigned long min = 0,
+ unsigned long max = UINT_MAX - 1)
+ {
+ _GLIBCXX_DEBUG_ASSERT(max >= min);
+ const double prob = get_prob();
+ const unsigned long r = (unsigned long)((max - min + 1) * prob) + min;
+ _GLIBCXX_DEBUG_ASSERT(r <= max);
+ return r;
+ }
+
+ double
+ get_prob()
+ {
+ const double min = m_base_generator.min();
+ const double max = m_base_generator.max();
+ const double range = static_cast<const double>(max - min);
+ const double res = static_cast<const double>(m_base_generator() - min);
+ const double ret = res / range;
+ _GLIBCXX_DEBUG_ASSERT(ret >= 0 && ret <= 1);
+ return ret;
+ }
+
+ private:
+ typedef std::tr1::mt19937 base_generator_t;
+
+ base_generator_t m_base_generator;
+ };
+ } // namespace test
+} // namespace __gnu_pbds
+
+#endif // #ifndef _GLIBCXX_TESTSUITE_RNG_H
diff --git a/libstdc++-v3/testsuite/util/testsuite_rvalref.h b/libstdc++-v3/testsuite/util/testsuite_rvalref.h
new file mode 100644
index 000000000..7725e580a
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_rvalref.h
@@ -0,0 +1,267 @@
+// -*- C++ -*-
+// Testing utilities for the rvalue reference.
+//
+// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#ifndef _GLIBCXX_TESTSUITE_RVALREF_H
+#define _GLIBCXX_TESTSUITE_RVALREF_H 1
+
+#include <testsuite_hooks.h>
+#include <bits/functional_hash.h>
+
+namespace __gnu_test
+{
+ // This class is designed to test libstdc++'s template-based rvalue
+ // reference support. It should fail at compile-time if there is an
+ // attempt to copy it.
+ struct rvalstruct
+ {
+ int val;
+ bool valid;
+
+ rvalstruct() : val(0), valid(true)
+ { }
+
+ rvalstruct(int inval) : val(inval), valid(true)
+ { }
+
+ rvalstruct&
+ operator=(int newval)
+ {
+ val = newval;
+ valid = true;
+ return *this;
+ }
+
+ rvalstruct(const rvalstruct&) = delete;
+
+ rvalstruct(rvalstruct&& in)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( in.valid == true );
+ val = in.val;
+ in.valid = false;
+ valid = true;
+ }
+
+ rvalstruct&
+ operator=(const rvalstruct&) = delete;
+
+ rvalstruct&
+ operator=(rvalstruct&& in)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( this != &in );
+ VERIFY( in.valid == true );
+ val = in.val;
+ in.valid = false;
+ valid = true;
+ return *this;
+ }
+ };
+
+ inline bool
+ operator==(const rvalstruct& lhs, const rvalstruct& rhs)
+ { return lhs.val == rhs.val; }
+
+ inline bool
+ operator<(const rvalstruct& lhs, const rvalstruct& rhs)
+ { return lhs.val < rhs.val; }
+
+ void
+ swap(rvalstruct& lhs, rvalstruct& rhs)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( lhs.valid && rhs.valid );
+ int temp = lhs.val;
+ lhs.val = rhs.val;
+ rhs.val = temp;
+ }
+
+ // This is a moveable class which copies how many times it is copied.
+ // This is mainly of use in the containers, where the an element inserted
+ // into a container has to be copied once to get there, but we want to check
+ // nothing else is copied.
+ struct copycounter
+ {
+ static int copycount;
+ int val;
+ bool valid;
+
+ copycounter() : val(0), valid(true)
+ { }
+
+ copycounter(int inval) : val(inval), valid(true)
+ { }
+
+ copycounter(const copycounter& in) : val(in.val), valid(true)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( in.valid == true );
+ ++copycount;
+ }
+
+ copycounter(copycounter&& in)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( in.valid == true );
+ val = in.val;
+ in.valid = false;
+ valid = true;
+ }
+
+ copycounter&
+ operator=(int newval)
+ {
+ val = newval;
+ valid = true;
+ return *this;
+ }
+
+ bool
+ operator=(const copycounter& in)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( in.valid == true );
+ ++copycount;
+ val = in.val;
+ valid = true;
+ return true;
+ }
+
+ copycounter&
+ operator=(copycounter&& in)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY(in.valid == true);
+ val = in.val;
+ in.valid = false;
+ valid = true;
+ return *this;
+ }
+
+ ~copycounter()
+ { valid = false; }
+ };
+
+ int copycounter::copycount = 0;
+
+ inline bool
+ operator==(const copycounter& lhs, const copycounter& rhs)
+ { return lhs.val == rhs.val; }
+
+ inline bool
+ operator<(const copycounter& lhs, const copycounter& rhs)
+ { return lhs.val < rhs.val; }
+
+ inline void
+ swap(copycounter& lhs, copycounter& rhs)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( lhs.valid && rhs.valid );
+ int temp = lhs.val;
+ lhs.val = rhs.val;
+ rhs.val = temp;
+ }
+
+ // In the occasion of libstdc++/48038.
+ struct rvalstruct_compare_by_value
+ {
+ int val;
+ bool ok;
+
+ rvalstruct_compare_by_value(int v)
+ : val(v), ok(true) { }
+
+ rvalstruct_compare_by_value(const rvalstruct_compare_by_value& rh)
+ : val(rh.val), ok(rh.ok)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY(rh.ok);
+ }
+
+ rvalstruct_compare_by_value&
+ operator=(const rvalstruct_compare_by_value& rh)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( rh.ok );
+ val = rh.val;
+ ok = rh.ok;
+ return *this;
+ }
+
+ rvalstruct_compare_by_value(rvalstruct_compare_by_value&& rh)
+ : val(rh.val), ok(rh.ok)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( rh.ok );
+ rh.ok = false;
+ }
+
+ rvalstruct_compare_by_value&
+ operator=(rvalstruct_compare_by_value&& rh)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( rh.ok );
+ val = rh.val;
+ ok = rh.ok;
+ rh.ok = false;
+ return *this;
+ }
+ };
+
+ inline bool
+ operator<(rvalstruct_compare_by_value lh,
+ rvalstruct_compare_by_value rh)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( rh.ok );
+ VERIFY( lh.ok );
+ return lh.val < rh.val;
+ }
+
+ inline bool
+ order(rvalstruct_compare_by_value lh,
+ rvalstruct_compare_by_value rh)
+ {
+ bool test __attribute__((unused)) = true;
+ VERIFY( rh.ok );
+ VERIFY( lh.ok );
+ return lh.val < rh.val;
+ }
+
+} // namespace __gnu_test
+
+namespace std
+{
+ /// std::hash specialization for __gnu_test::rvalstruct.
+ template<>
+ struct hash<__gnu_test::rvalstruct>
+ {
+ typedef size_t result_type;
+ typedef __gnu_test::rvalstruct argument_type;
+
+ size_t
+ operator()(const __gnu_test::rvalstruct& __rvs) const
+ { return __rvs.val; }
+ };
+}
+
+#endif // _GLIBCXX_TESTSUITE_TR1_H
diff --git a/libstdc++-v3/testsuite/util/testsuite_shared.cc b/libstdc++-v3/testsuite/util/testsuite_shared.cc
new file mode 100644
index 000000000..4999da43d
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_shared.cc
@@ -0,0 +1,72 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string>
+#include <stdexcept>
+#include <iostream>
+#include <sstream>
+#include <ext/mt_allocator.h>
+#include <bits/functexcept.h>
+
+// libstdc++/22309
+extern "C" void
+try_allocation()
+{
+ typedef char value_t;
+
+ typedef __gnu_cxx::__mt_alloc<value_t> allocator_t;
+
+ typedef std::char_traits<value_t> traits_t;
+ typedef std::basic_string<value_t, traits_t, allocator_t> string_t;
+
+ string_t s;
+ s += "west beach, indiana dunes";
+}
+
+// libstdc++/23591
+extern "C" void
+try_throw_exception()
+{
+ try
+ {
+ std::__throw_bad_exception();
+ }
+ catch (const std::exception& e)
+ { }
+}
+
+extern "C" void
+try_function_random_fail()
+{
+ long seed = lrand48();
+ if (seed < 2000)
+ seed = 2000;
+
+ {
+ std::ostringstream s;
+ s << "random_throw, seed: " << seed << std::endl;
+ std::cout << s.str();
+ }
+
+ while (--seed > 0)
+ {
+ try_throw_exception();
+ }
+
+ // Randomly throw. See if other threads cleanup.
+ std::__throw_bad_exception();
+}
diff --git a/libstdc++-v3/testsuite/util/testsuite_tr1.h b/libstdc++-v3/testsuite/util/testsuite_tr1.h
new file mode 100644
index 000000000..6a48a309e
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_tr1.h
@@ -0,0 +1,288 @@
+// -*- C++ -*-
+// Testing utilities for the tr1 testsuite.
+//
+// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#ifndef _GLIBCXX_TESTSUITE_TR1_H
+#define _GLIBCXX_TESTSUITE_TR1_H
+
+#include <ext/type_traits.h>
+
+namespace __gnu_test
+{
+ // For tr1/type_traits.
+ template<template<typename> class Category, typename Type>
+ bool
+ test_category(bool value)
+ {
+ bool ret = true;
+ ret &= Category<Type>::value == value;
+ ret &= Category<const Type>::value == value;
+ ret &= Category<volatile Type>::value == value;
+ ret &= Category<const volatile Type>::value == value;
+ ret &= Category<Type>::type::value == value;
+ ret &= Category<const Type>::type::value == value;
+ ret &= Category<volatile Type>::type::value == value;
+ ret &= Category<const volatile Type>::type::value == value;
+ return ret;
+ }
+
+ template<template<typename> class Property, typename Type>
+ bool
+ test_property(typename Property<Type>::value_type value)
+ {
+ bool ret = true;
+ ret &= Property<Type>::value == value;
+ ret &= Property<Type>::type::value == value;
+ return ret;
+ }
+
+ // For testing tr1/type_traits/extent, which has a second template
+ // parameter.
+ template<template<typename, unsigned> class Property,
+ typename Type, unsigned Uint>
+ bool
+ test_property(typename Property<Type, Uint>::value_type value)
+ {
+ bool ret = true;
+ ret &= Property<Type, Uint>::value == value;
+ ret &= Property<Type, Uint>::type::value == value;
+ return ret;
+ }
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<template<typename...> class Property, typename... Types>
+ bool
+ test_property(typename Property<Types...>::value_type value)
+ {
+ bool ret = true;
+ ret &= Property<Types...>::value == value;
+ ret &= Property<Types...>::type::value == value;
+ return ret;
+ }
+#endif
+
+ template<template<typename, typename> class Relationship,
+ typename Type1, typename Type2>
+ bool
+ test_relationship(bool value)
+ {
+ bool ret = true;
+ ret &= Relationship<Type1, Type2>::value == value;
+ ret &= Relationship<Type1, Type2>::type::value == value;
+ return ret;
+ }
+
+ // Test types.
+ class ClassType { };
+ typedef const ClassType cClassType;
+ typedef volatile ClassType vClassType;
+ typedef const volatile ClassType cvClassType;
+
+ class DerivedType : public ClassType { };
+
+ enum EnumType { e0 };
+
+ struct ConvType
+ { operator int() const; };
+
+ class AbstractClass
+ {
+ virtual void rotate(int) = 0;
+ };
+
+ class PolymorphicClass
+ {
+ virtual void rotate(int);
+ };
+
+ class DerivedPolymorphic : public PolymorphicClass { };
+
+ class VirtualDestructorClass
+ {
+ virtual ~VirtualDestructorClass();
+ };
+
+ union UnionType { };
+
+ class IncompleteClass;
+
+ struct ExplicitClass
+ {
+ ExplicitClass(double&);
+ explicit ExplicitClass(int&);
+ ExplicitClass(double&, int&, double&);
+ };
+
+ struct NothrowExplicitClass
+ {
+ NothrowExplicitClass(double&) throw();
+ explicit NothrowExplicitClass(int&) throw();
+ NothrowExplicitClass(double&, int&, double&) throw();
+ };
+
+ struct ThrowExplicitClass
+ {
+ ThrowExplicitClass(double&) throw(int);
+ explicit ThrowExplicitClass(int&) throw(int);
+ ThrowExplicitClass(double&, int&, double&) throw(int);
+ };
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ struct NoexceptExplicitClass
+ {
+ NoexceptExplicitClass(double&) noexcept(true);
+ explicit NoexceptExplicitClass(int&) noexcept(true);
+ NoexceptExplicitClass(double&, int&, double&) noexcept(true);
+ };
+
+ struct ExceptExplicitClass
+ {
+ ExceptExplicitClass(double&) noexcept(false);
+ explicit ExceptExplicitClass(int&) noexcept(false);
+ ExceptExplicitClass(double&, int&, double&) noexcept(false);
+ };
+#endif
+
+ struct NType // neither trivial nor standard-layout
+ {
+ int i;
+ int j;
+ virtual ~NType();
+ };
+
+ struct TType // trivial but not standard-layout
+ {
+ int i;
+ private:
+ int j;
+ };
+
+ struct SLType // standard-layout but not trivial
+ {
+ int i;
+ int j;
+ ~SLType();
+ };
+
+ struct PODType // both trivial and standard-layout
+ {
+ int i;
+ int j;
+ };
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ struct LType // literal type
+ {
+ int _M_i;
+
+ constexpr LType(int __i) : _M_i(__i) { }
+ };
+
+ struct LTypeDerived : public LType
+ {
+ constexpr LTypeDerived(int __i) : LType(__i) { }
+ };
+
+ struct NLType // not literal type
+ {
+ int _M_i;
+
+ NLType() : _M_i(0) { }
+
+ constexpr NLType(int __i) : _M_i(__i) { }
+
+ NLType(const NLType& __other) : _M_i(__other._M_i) { }
+
+ ~NLType() { _M_i = 0; }
+ };
+#endif
+
+ int truncate_float(float x) { return (int)x; }
+ long truncate_double(double x) { return (long)x; }
+
+ struct do_truncate_float_t
+ {
+ do_truncate_float_t()
+ {
+ ++live_objects;
+ }
+
+ do_truncate_float_t(const do_truncate_float_t&)
+ {
+ ++live_objects;
+ }
+
+ ~do_truncate_float_t()
+ {
+ --live_objects;
+ }
+
+ int operator()(float x) { return (int)x; }
+
+ static int live_objects;
+ };
+
+ int do_truncate_float_t::live_objects = 0;
+
+ struct do_truncate_double_t
+ {
+ do_truncate_double_t()
+ {
+ ++live_objects;
+ }
+
+ do_truncate_double_t(const do_truncate_double_t&)
+ {
+ ++live_objects;
+ }
+
+ ~do_truncate_double_t()
+ {
+ --live_objects;
+ }
+
+ long operator()(double x) { return (long)x; }
+
+ static int live_objects;
+ };
+
+ int do_truncate_double_t::live_objects = 0;
+
+ struct X
+ {
+ int bar;
+
+ int foo() { return 1; }
+ int foo_c() const { return 2; }
+ int foo_v() volatile { return 3; }
+ int foo_cv() const volatile { return 4; }
+ };
+
+ // For use in 8_c_compatibility.
+ template<typename R, typename T>
+ typename __gnu_cxx::__enable_if<std::__are_same<R, T>::__value,
+ bool>::__type
+ check_ret_type(T)
+ { return true; }
+
+} // namespace __gnu_test
+
+#endif // _GLIBCXX_TESTSUITE_TR1_H
diff --git a/libstdc++-v3/testsuite/util/thread/all.h b/libstdc++-v3/testsuite/util/thread/all.h
new file mode 100644
index 000000000..935570ecc
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/thread/all.h
@@ -0,0 +1,62 @@
+// -*- C++ -*-
+// Utilities for testing threads for the C++ library testsuite.
+//
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+#ifndef _GLIBCXX_TESTSUITE_THREAD_H
+#define _GLIBCXX_TESTSUITE_THREAD_H
+
+#include <sstream>
+#include <stdexcept>
+#include <type_traits>
+
+// C++0x only.
+namespace __gnu_test
+{
+ // Assume _Tp::native_handle_type.
+ // Check C++ to native_handle_type characteristics: size and alignment.
+ template<typename _Tp>
+ void
+ compare_type_to_native_type()
+ {
+ typedef _Tp test_type;
+
+ // Remove possible pointer type.
+ typedef typename test_type::native_handle_type native_handle;
+ typedef typename std::remove_pointer<native_handle>::type native_type;
+
+ int st = sizeof(test_type);
+ int snt = sizeof(native_type);
+ int at = __alignof__(test_type);
+ int ant = __alignof__(native_type);
+ if (st != snt || at != ant)
+ {
+ std::ostringstream s;
+ s << std::endl;
+ s << "size of _Tp: " << st << std::endl;
+ s << "alignment of _Tp: " << st << std::endl;
+ s << "size of *(_Tp::native_handle_type): " << snt << std::endl;
+ s << "alignment of *(_Tp::native_handle_type): " << snt << std::endl;
+ throw std::runtime_error(s.str());
+ }
+ }
+} // namespace __gnu_test
+
+#endif // _GLIBCXX_TESTSUITE_THREAD_H
+