3 // Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 3, or (at your option) any later
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
23 // Permission to use, copy, modify, sell, and distribute this software
24 // is hereby granted without fee, provided that the above copyright
25 // notice appears in all copies, and that both that copyright notice
26 // and this permission notice appear in supporting documentation. None
27 // of the above authors, nor IBM Haifa Research Laboratories, make any
28 // representation about the suitability of this software for any
29 // purpose. It is provided "as is" without express or implied
33 * @file type_trait.hpp
34 * Contains traits for a random regression test
35 * for a specific container type.
38 #ifndef PB_DS_REGRESSION_TEST_TYPE_TRAIT_HPP
39 #define PB_DS_REGRESSION_TEST_TYPE_TRAIT_HPP
41 #include <regression/basic_type.hpp>
49 template<typename Cntnr>
50 struct regression_test_type_traits
53 typedef typename cntnr::key_type key_type;
54 typedef typename cntnr::key_const_reference key_const_reference;
55 typedef typename cntnr::value_type value_type;
56 typedef typename cntnr::const_reference const_reference;
57 typedef typename cntnr::mapped_type mapped_type;
58 typedef typename cntnr::mapped_const_reference mapped_const_reference;
60 template<typename Gen>
62 generate_key(Gen& r_gen, size_t max)
63 { return basic_type(r_gen, max); }
65 template<typename Gen>
67 generate_value(Gen& r_gen, size_t max)
68 { return generate_value(r_gen, max, value_type()); }
70 static key_const_reference
71 extract_key(const_reference r_val)
72 { return extract_key_imp(r_val); }
75 typedef typename cntnr::allocator_type::template rebind<basic_type>::other
78 typedef typename basic_type_rebind::const_reference basic_type_const_reference;
80 typedef typename cntnr::allocator_type::template rebind<std::pair<const basic_type, basic_type> >::other pair_type_rebind;
81 typedef typename pair_type_rebind::const_reference pair_type_const_reference;
83 template<typename Gen>
85 generate_value(Gen& r_gen, size_t max, __gnu_pbds::null_type)
86 { return basic_type(r_gen, max); }
88 template<typename Gen>
90 generate_value(Gen& r_gen, size_t max, basic_type)
91 { return basic_type(r_gen, max); }
93 template<typename Gen>
95 generate_value(Gen& gen, size_t max,
96 std::pair<const basic_type, basic_type>)
97 { return std::make_pair(basic_type(gen, max), basic_type(gen, max)); }
99 static key_const_reference
100 extract_key_imp(basic_type_const_reference r_val)
103 static key_const_reference
104 extract_key_imp(pair_type_const_reference r_val)
105 { return r_val.first; }
107 } // namespace detail
109 } // namespace __gnu_pbds