OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [include/] [ext/] [pb_assoc/] [detail/] [types_traits.hpp] - Blame information for rev 17

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 jlechner
// -*- C++ -*-
2
 
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.
10
 
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.
15
 
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.
20
 
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.
29
 
30
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
31
 
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.
39
 
40
/**
41
 * @file types_traits.hpp
42
 * Contains a traits class of types used by containers.
43
 */
44
 
45
#ifndef TYPES_TRAITS_HPP
46
#define TYPES_TRAITS_HPP
47
 
48
#include <ext/pb_assoc/data_type.hpp>
49
#include <ext/pb_assoc/detail/type_utils.hpp>
50
#include <utility>
51
 
52
namespace pb_assoc
53
{
54
 
55
  namespace detail
56
  {
57
 
58
    template<typename Data, class Allocator>
59
    struct basic_data_types_traits
60
    {
61
 
62
    public:
63
 
64
      typedef
65
      typename Allocator::template rebind<
66
        Data>::other::value_type
67
      data_type;
68
 
69
      typedef
70
      typename Allocator::template rebind<
71
        Data>::other::pointer
72
      data_pointer;
73
 
74
      typedef
75
      typename Allocator::template rebind<
76
        Data>::other::const_pointer
77
      const_data_pointer;
78
 
79
      typedef
80
      typename Allocator::template rebind<
81
        Data>::other::reference
82
      data_reference;
83
 
84
      typedef
85
      typename Allocator::template rebind<
86
        Data>::other::const_reference
87
      const_data_reference;
88
 
89
    };
90
 
91
    template<typename Data, class Allocator>
92
    struct data_types_traits : public basic_data_types_traits<
93
      Data,
94
      Allocator>
95
    {
96
 
97
    public:
98
 
99
      typedef Data given_data_type;
100
 
101
    };
102
 
103
#define PB_ASSOC_CLASS_T_DEC \
104
        template<class Allocator>
105
 
106
#define PB_ASSOC_CLASS_C_DEC \
107
        data_types_traits< \
108
                        null_data_type, \
109
                        Allocator>
110
 
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>
117
    {
118
 
119
    public:
120
 
121
      typedef null_data_type given_data_type;
122
 
123
    };
124
 
125
#undef PB_ASSOC_CLASS_T_DEC
126
 
127
#undef PB_ASSOC_CLASS_C_DEC
128
 
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>
136
    {
137
 
138
    public:
139
 
140
      typedef compound_data_type< Cntnr> given_data_type;
141
 
142
    };
143
 
144
#define PB_ASSOC_CLASS_T_DEC \
145
        template<typename Key, typename Data>
146
 
147
#define PB_ASSOC_CLASS_C_DEC \
148
        exception_throw_types_traits< \
149
                Key, \
150
                Data>
151
 
152
    template<typename Key, typename Data>
153
    struct exception_throw_types_traits
154
    {
155
 
156
    public:
157
 
158
      typedef int_to_type<false> no_throw_copies_false_indicator;
159
 
160
      typedef int_to_type<true> no_throw_copies_true_indicator;
161
 
162
    private:
163
      enum
164
        {
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
169
        };
170
 
171
      typedef int_to_type<no_throw_copies> no_throw_copies_t;
172
 
173
    public:
174
      static no_throw_copies_t s_no_throw_copies_indicator;
175
    };
176
 
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;
180
 
181
#undef PB_ASSOC_CLASS_T_DEC
182
 
183
#undef PB_ASSOC_CLASS_C_DEC
184
 
185
    template<typename Key, typename Data, class Allocator>
186
    struct value_types_traits
187
    {
188
 
189
    public:
190
 
191
      typedef
192
      typename Allocator::template rebind<
193
        std::pair<const Key, Data> >::other
194
      value_type_allocator;
195
 
196
      typedef typename value_type_allocator::value_type value_type;
197
 
198
      typedef typename value_type_allocator::pointer pointer;
199
 
200
      typedef typename value_type_allocator::const_pointer const_pointer;
201
 
202
      typedef typename value_type_allocator::reference reference;
203
 
204
      typedef typename value_type_allocator::const_reference const_reference;
205
 
206
    };
207
 
208
    template<typename Key, class Allocator>
209
    struct value_types_traits<
210
      Key,
211
      null_data_type,
212
      Allocator>
213
    {
214
 
215
    public:
216
 
217
      typedef
218
      typename Allocator::template rebind<
219
        Key>::other
220
      value_type_allocator;
221
 
222
      typedef typename value_type_allocator::value_type value_type;
223
 
224
      typedef typename value_type_allocator::const_pointer pointer;
225
 
226
      typedef typename value_type_allocator::const_pointer const_pointer;
227
 
228
      typedef typename value_type_allocator::const_reference reference;
229
 
230
      typedef typename value_type_allocator::const_reference const_reference;
231
 
232
    };
233
 
234
    template<typename Key, class Cntnr, class Allocator>
235
    struct value_types_traits<
236
      Key,
237
      compound_data_type<
238
      Cntnr>,
239
      Allocator>
240
    {
241
    private:
242
 
243
      typedef
244
      typename Allocator::template rebind<
245
        std::pair<const Key, Cntnr> >::other
246
      value_type_allocator;
247
 
248
    public:
249
 
250
      typedef typename value_type_allocator::value_type value_type;
251
 
252
      typedef typename value_type_allocator::pointer pointer;
253
 
254
      typedef typename value_type_allocator::const_pointer const_pointer;
255
 
256
      typedef typename value_type_allocator::reference reference;
257
 
258
      typedef typename value_type_allocator::const_reference const_reference;
259
 
260
    };
261
 
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>
273
    {
274
 
275
    public:
276
 
277
      typedef typename Allocator::template rebind<Key>::other key_allocator;
278
 
279
      typedef typename key_allocator::value_type key_type;
280
 
281
      typedef typename key_allocator::pointer key_pointer;
282
 
283
      typedef typename key_allocator::const_pointer const_key_pointer;
284
 
285
      typedef typename key_allocator::reference key_reference;
286
 
287
      typedef typename key_allocator::const_reference const_key_reference;
288
 
289
    };
290
 
291
  } // namespace detail
292
 
293
} // namespace pb_assoc
294
 
295
#endif // #ifndef TYPES_TRAITS_HPP

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.