Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / include / ext / pb_assoc / detail / types_traits.hpp
blob130242c10767484d20f4293f1c25fbbbca1ab743
1 // -*- C++ -*-
3 // Copyright (C) 2005 Free Software Foundation, Inc.
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
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
32 // Permission to use, copy, modify, sell, and distribute this software
33 // is hereby granted without fee, provided that the above copyright
34 // notice appears in all copies, and that both that copyright notice and
35 // this permission notice appear in supporting documentation. None of
36 // the above authors, nor IBM Haifa Research Laboratories, make any
37 // representation about the suitability of this software for any
38 // purpose. It is provided "as is" without express or implied warranty.
40 /**
41 * @file types_traits.hpp
42 * Contains a traits class of types used by containers.
45 #ifndef TYPES_TRAITS_HPP
46 #define TYPES_TRAITS_HPP
48 #include <ext/pb_assoc/data_type.hpp>
49 #include <ext/pb_assoc/detail/type_utils.hpp>
50 #include <utility>
52 namespace pb_assoc
55 namespace detail
58 template<typename Data, class Allocator>
59 struct basic_data_types_traits
62 public:
64 typedef
65 typename Allocator::template rebind<
66 Data>::other::value_type
67 data_type;
69 typedef
70 typename Allocator::template rebind<
71 Data>::other::pointer
72 data_pointer;
74 typedef
75 typename Allocator::template rebind<
76 Data>::other::const_pointer
77 const_data_pointer;
79 typedef
80 typename Allocator::template rebind<
81 Data>::other::reference
82 data_reference;
84 typedef
85 typename Allocator::template rebind<
86 Data>::other::const_reference
87 const_data_reference;
91 template<typename Data, class Allocator>
92 struct data_types_traits : public basic_data_types_traits<
93 Data,
94 Allocator>
97 public:
99 typedef Data given_data_type;
103 #define PB_ASSOC_CLASS_T_DEC \
104 template<class Allocator>
106 #define PB_ASSOC_CLASS_C_DEC \
107 data_types_traits< \
108 null_data_type, \
109 Allocator>
111 template<class Allocator>
112 struct data_types_traits<
113 null_data_type,
114 Allocator> : public basic_data_types_traits<
115 null_data_type,
116 Allocator>
119 public:
121 typedef null_data_type given_data_type;
125 #undef PB_ASSOC_CLASS_T_DEC
127 #undef PB_ASSOC_CLASS_C_DEC
129 template<class Cntnr, class Allocator>
130 struct data_types_traits<
131 compound_data_type<
132 Cntnr>,
133 Allocator> : public basic_data_types_traits<
134 Cntnr,
135 Allocator>
138 public:
140 typedef compound_data_type< Cntnr> given_data_type;
144 #define PB_ASSOC_CLASS_T_DEC \
145 template<typename Key, typename Data>
147 #define PB_ASSOC_CLASS_C_DEC \
148 exception_throw_types_traits< \
149 Key, \
150 Data>
152 template<typename Key, typename Data>
153 struct exception_throw_types_traits
156 public:
158 typedef int_to_type<false> no_throw_copies_false_indicator;
160 typedef int_to_type<true> no_throw_copies_true_indicator;
162 private:
163 enum
165 key_no_throw = is_simple_type<Key>::value,
166 data_no_throw = is_same_type<Data, null_data_type>::value ||
167 is_simple_type<Data>::value,
168 no_throw_copies = key_no_throw&& data_no_throw
171 typedef int_to_type<no_throw_copies> no_throw_copies_t;
173 public:
174 static no_throw_copies_t s_no_throw_copies_indicator;
177 PB_ASSOC_CLASS_T_DEC
178 typename PB_ASSOC_CLASS_C_DEC::no_throw_copies_t
179 PB_ASSOC_CLASS_C_DEC::s_no_throw_copies_indicator;
181 #undef PB_ASSOC_CLASS_T_DEC
183 #undef PB_ASSOC_CLASS_C_DEC
185 template<typename Key, typename Data, class Allocator>
186 struct value_types_traits
189 public:
191 typedef
192 typename Allocator::template rebind<
193 std::pair<const Key, Data> >::other
194 value_type_allocator;
196 typedef typename value_type_allocator::value_type value_type;
198 typedef typename value_type_allocator::pointer pointer;
200 typedef typename value_type_allocator::const_pointer const_pointer;
202 typedef typename value_type_allocator::reference reference;
204 typedef typename value_type_allocator::const_reference const_reference;
208 template<typename Key, class Allocator>
209 struct value_types_traits<
210 Key,
211 null_data_type,
212 Allocator>
215 public:
217 typedef
218 typename Allocator::template rebind<
219 Key>::other
220 value_type_allocator;
222 typedef typename value_type_allocator::value_type value_type;
224 typedef typename value_type_allocator::const_pointer pointer;
226 typedef typename value_type_allocator::const_pointer const_pointer;
228 typedef typename value_type_allocator::const_reference reference;
230 typedef typename value_type_allocator::const_reference const_reference;
234 template<typename Key, class Cntnr, class Allocator>
235 struct value_types_traits<
236 Key,
237 compound_data_type<
238 Cntnr>,
239 Allocator>
241 private:
243 typedef
244 typename Allocator::template rebind<
245 std::pair<const Key, Cntnr> >::other
246 value_type_allocator;
248 public:
250 typedef typename value_type_allocator::value_type value_type;
252 typedef typename value_type_allocator::pointer pointer;
254 typedef typename value_type_allocator::const_pointer const_pointer;
256 typedef typename value_type_allocator::reference reference;
258 typedef typename value_type_allocator::const_reference const_reference;
262 template<typename Key, typename Data, class Allocator>
263 struct types_traits : public data_types_traits<
264 Data,
265 Allocator>,
266 public value_types_traits<
267 Key,
268 Data,
269 Allocator>,
270 public exception_throw_types_traits<
271 Key,
272 Data>
275 public:
277 typedef typename Allocator::template rebind<Key>::other key_allocator;
279 typedef typename key_allocator::value_type key_type;
281 typedef typename key_allocator::pointer key_pointer;
283 typedef typename key_allocator::const_pointer const_key_pointer;
285 typedef typename key_allocator::reference key_reference;
287 typedef typename key_allocator::const_reference const_key_reference;
291 } // namespace detail
293 } // namespace pb_assoc
295 #endif // #ifndef TYPES_TRAITS_HPP