Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / include / ext / pb_assoc / detail / value_type_adapter / it_value_type_traits.hpp
blobc8b09d351548090e5e603568539267f79423ca2a
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 it_value_type_traits.hpp
42 * Contains an adapter of mapping levels.
45 template<class Base, bool Lowest>
46 struct base_it_key_type
48 typedef typename Base::it_key_type type;
51 template<class Base>
52 struct base_it_key_type<
53 Base,
54 true>
56 typedef typename Base::const_key_reference type;
59 template<typename Base_Key_,
60 typename Key_,
61 typename Data_,
62 typename Value_,
63 class Allocator_ >
64 struct it_value_type_traits_
66 typedef ref_pair< Base_Key_, Key_> key_ref_pair;
68 typedef
69 typename Allocator_::template rebind<
70 key_ref_pair>::other::const_reference
71 key_ref_pair_val;
73 typedef key_ref_pair_val key_type;
75 typedef ref_pair< key_ref_pair_val, Data_> value_type;
77 typedef
78 typename Allocator_::template rebind<
79 value_type>::other::reference
80 reference;
82 typedef
83 typename Allocator_::template rebind<
84 value_type>::other::const_reference
85 const_reference;
87 typedef
88 typename Allocator_::template rebind<
89 value_type>::other::pointer
90 pointer;
92 typedef
93 typename Allocator_::template rebind<
94 value_type>::other::const_pointer
95 const_pointer;
97 typedef
98 typename Allocator_::template rebind<
99 int* >::other::value_type
100 buf_t;
102 struct value_type_holder
104 buf_t m_a_key_buf[sizeof(key_ref_pair) / sizeof(buf_t) + 1];
106 buf_t m_a_value_buf[sizeof(value_type) / sizeof(buf_t) + 1];
109 typedef
110 typename Allocator_::template rebind<
111 value_type_holder>::other::reference
112 value_type_hoder_valerence;
114 inline static pointer
115 recast(value_type_hoder_valerence r_holder)
117 return reinterpret_cast<pointer>(r_holder.m_a_value_buf);
120 inline static void
121 make_valid(value_type_hoder_valerence r_holder, Base_Key_ r_bk, Value_ r_val)
123 typedef
124 typename Allocator_::template rebind<
125 void* >::other::value_type
126 void_pointer;
128 void_pointer p_target = r_holder.m_a_key_buf;
130 new (p_target) key_ref_pair(r_bk, r_val.first);
132 typedef
133 typename Allocator_::template rebind<
134 key_ref_pair>::other::pointer
135 key_ref_pair_pointer;
137 key_ref_pair_pointer p_key =
138 reinterpret_cast<key_ref_pair_pointer>(r_holder.m_a_key_buf);
140 p_target = r_holder.m_a_value_buf;
142 new (p_target) value_type(*p_key, r_val.second);
146 template<typename Base_Key_,
147 typename Key_,
148 typename Value_,
149 class Allocator_>
150 struct it_value_type_traits_<
151 Base_Key_,
152 Key_,
153 null_data_type,
154 Value_,
155 Allocator_>
157 typedef ref_pair< Base_Key_, Key_> key_ref_pair;
159 typedef
160 typename Allocator_::template rebind<
161 key_ref_pair>::other::const_reference
162 key_ref_pair_val;
164 typedef key_ref_pair_val key_type;
166 typedef key_ref_pair value_type;
168 typedef
169 typename Allocator_::template rebind<
170 value_type>::other::const_reference
171 reference;
173 typedef
174 typename Allocator_::template rebind<
175 value_type>::other::const_reference
176 const_reference;
178 typedef
179 typename Allocator_::template rebind<
180 value_type>::other::const_pointer
181 pointer;
183 typedef
184 typename Allocator_::template rebind<
185 value_type>::other::const_pointer
186 const_pointer;
188 typedef
189 typename Allocator_::template rebind<
190 int* >::other::value_type
191 buf_t;
193 struct value_type_holder
195 buf_t m_a_key_buf[sizeof(key_ref_pair) / sizeof(buf_t) + 1];
197 buf_t m_a_value_buf[sizeof(value_type) / sizeof(buf_t) + 1];
200 typedef
201 typename Allocator_::template rebind<
202 value_type_holder>::other::reference
203 value_type_hoder_valerence;
205 inline static pointer
206 recast(value_type_hoder_valerence r_holder)
208 return reinterpret_cast<pointer>(r_holder.m_a_value_buf);
211 inline static void
212 make_valid(value_type_hoder_valerence r_holder, Base_Key_ r_bk, Value_ r_val)
214 typedef
215 typename Allocator_::template rebind<
216 void* >::other::value_type
217 void_pointer;
219 void_pointer p_target = r_holder.m_a_value_buf;
221 new (p_target) key_ref_pair(r_bk, r_val.first);