]> 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
36fed23c 1// -*- C++ -*-
2
fbd26352 3// Copyright (C) 2005-2019 Free Software Foundation, Inc.
36fed23c 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
6bc9506f 8// Foundation; either version 3, or (at your option) any later
36fed23c 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
6bc9506f 17// along with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
19
36fed23c 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
2661beb5 34 * Contains traits for a random regression test
36fed23c 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
b34535d7 43namespace __gnu_pbds
36fed23c 44{
36fed23c 45 namespace test
46 {
36fed23c 47 namespace detail
48 {
36fed23c 49 template<typename Cntnr>
50 struct regression_test_type_traits
51 {
36fed23c 52 typedef Cntnr cntnr;
36fed23c 53 typedef typename cntnr::key_type key_type;
4f4a327e 54 typedef typename cntnr::key_const_reference key_const_reference;
36fed23c 55 typedef typename cntnr::value_type value_type;
36fed23c 56 typedef typename cntnr::const_reference const_reference;
36fed23c 57 typedef typename cntnr::mapped_type mapped_type;
4f4a327e 58 typedef typename cntnr::mapped_const_reference mapped_const_reference;
36fed23c 59
36fed23c 60 template<typename Gen>
61 static key_type
62 generate_key(Gen& r_gen, size_t max)
ce8b0a77 63 { return basic_type(r_gen, max); }
36fed23c 64
65 template<typename Gen>
66 static value_type
67 generate_value(Gen& r_gen, size_t max)
ce8b0a77 68 { return generate_value(r_gen, max, value_type()); }
36fed23c 69
4f4a327e 70 static key_const_reference
36fed23c 71 extract_key(const_reference r_val)
ce8b0a77 72 { return extract_key_imp(r_val); }
36fed23c 73
74 private:
09349009 75 typedef typename cntnr::allocator_type::template rebind<basic_type>::other
ce8b0a77 76 basic_type_rebind;
33b7ef52 77
ce8b0a77 78 typedef typename basic_type_rebind::const_reference basic_type_const_reference;
79
9376868b 80 typedef typename cntnr::allocator_type::template rebind<std::pair<const basic_type, basic_type> >::other pair_type_rebind;
ce8b0a77 81 typedef typename pair_type_rebind::const_reference pair_type_const_reference;
36fed23c 82
36fed23c 83 template<typename Gen>
84 static value_type
4f4a327e 85 generate_value(Gen& r_gen, size_t max, __gnu_pbds::null_type)
ce8b0a77 86 { return basic_type(r_gen, max); }
36fed23c 87
88 template<typename Gen>
89 static value_type
ce8b0a77 90 generate_value(Gen& r_gen, size_t max, basic_type)
91 { return basic_type(r_gen, max); }
36fed23c 92
93 template<typename Gen>
94 static value_type
33b7ef52 95 generate_value(Gen& gen, size_t max,
ce8b0a77 96 std::pair<const basic_type, basic_type>)
97 { return std::make_pair(basic_type(gen, max), basic_type(gen, max)); }
36fed23c 98
4f4a327e 99 static key_const_reference
36fed23c 100 extract_key_imp(basic_type_const_reference r_val)
ce8b0a77 101 { return r_val; }
36fed23c 102
4f4a327e 103 static key_const_reference
ce8b0a77 104 extract_key_imp(pair_type_const_reference r_val)
105 { return r_val.first; }
36fed23c 106 };
36fed23c 107 } // namespace detail
36fed23c 108 } // namespace test
b34535d7 109} // namespace __gnu_pbds
36fed23c 110
33b7ef52 111#endif