]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/util/regression/trait/assoc/type_trait.hpp
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / regression / trait / assoc / type_trait.hpp
CommitLineData
4569a895
AT
1// -*- C++ -*-
2
7adcbafe 3// Copyright (C) 2005-2022 Free Software Foundation, Inc.
4569a895
AT
4//
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
748086b7 8// Foundation; either version 3, or (at your option) any later
4569a895
AT
9// version.
10
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.
15
16// You should have received a copy of the GNU General Public License
748086b7
JJ
17// along with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
19
4569a895
AT
20
21// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
22
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
30// warranty.
31
32/**
33 * @file type_trait.hpp
2e3f9c21 34 * Contains traits for a random regression test
4569a895
AT
35 * for a specific container type.
36 */
37
38#ifndef PB_DS_REGRESSION_TEST_TYPE_TRAIT_HPP
39#define PB_DS_REGRESSION_TEST_TYPE_TRAIT_HPP
40
41#include <regression/basic_type.hpp>
42
5e11f978 43namespace __gnu_pbds
4569a895 44{
4569a895
AT
45 namespace test
46 {
4569a895
AT
47 namespace detail
48 {
4569a895
AT
49 template<typename Cntnr>
50 struct regression_test_type_traits
51 {
4569a895 52 typedef Cntnr cntnr;
4569a895 53 typedef typename cntnr::key_type key_type;
a345e45d 54 typedef typename cntnr::key_const_reference key_const_reference;
4569a895 55 typedef typename cntnr::value_type value_type;
4569a895 56 typedef typename cntnr::const_reference const_reference;
4569a895 57 typedef typename cntnr::mapped_type mapped_type;
a345e45d 58 typedef typename cntnr::mapped_const_reference mapped_const_reference;
4569a895 59
4569a895
AT
60 template<typename Gen>
61 static key_type
62 generate_key(Gen& r_gen, size_t max)
3441f106 63 { return basic_type(r_gen, max); }
4569a895
AT
64
65 template<typename Gen>
66 static value_type
67 generate_value(Gen& r_gen, size_t max)
3441f106 68 { return generate_value(r_gen, max, value_type()); }
4569a895 69
a345e45d 70 static key_const_reference
4569a895 71 extract_key(const_reference r_val)
3441f106 72 { return extract_key_imp(r_val); }
4569a895
AT
73
74 private:
b67758fe 75 typedef typename cntnr::allocator_type::template rebind<basic_type>::other
3441f106 76 basic_type_rebind;
f92ab29f 77
3441f106
BK
78 typedef typename basic_type_rebind::const_reference basic_type_const_reference;
79
81ff169c 80 typedef typename cntnr::allocator_type::template rebind<std::pair<const basic_type, basic_type> >::other pair_type_rebind;
3441f106 81 typedef typename pair_type_rebind::const_reference pair_type_const_reference;
4569a895 82
4569a895
AT
83 template<typename Gen>
84 static value_type
a345e45d 85 generate_value(Gen& r_gen, size_t max, __gnu_pbds::null_type)
3441f106 86 { return basic_type(r_gen, max); }
4569a895
AT
87
88 template<typename Gen>
89 static value_type
3441f106
BK
90 generate_value(Gen& r_gen, size_t max, basic_type)
91 { return basic_type(r_gen, max); }
4569a895
AT
92
93 template<typename Gen>
94 static value_type
f92ab29f 95 generate_value(Gen& gen, size_t max,
3441f106
BK
96 std::pair<const basic_type, basic_type>)
97 { return std::make_pair(basic_type(gen, max), basic_type(gen, max)); }
4569a895 98
a345e45d 99 static key_const_reference
4569a895 100 extract_key_imp(basic_type_const_reference r_val)
3441f106 101 { return r_val; }
4569a895 102
a345e45d 103 static key_const_reference
3441f106
BK
104 extract_key_imp(pair_type_const_reference r_val)
105 { return r_val.first; }
4569a895 106 };
4569a895 107 } // namespace detail
4569a895 108 } // namespace test
5e11f978 109} // namespace __gnu_pbds
4569a895 110
f92ab29f 111#endif