Dead
[official-gcc.git] / gomp-20050608-branch / libstdc++-v3 / include / ext / pb_assoc / detail / value_type_adapter / it_value_type_traits.hpp
blob4be113d8ecd6e02682bc8685ff01e433dd839203
1 // -*- C++ -*-
3 // Copyright (C) 2005, 2006 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 struct value_type_holder
99 typename std::tr1::aligned_storage<sizeof(key_ref_pair),
100 std::tr1::alignment_of<key_ref_pair>::value>::type m_a_key_buf;
102 typename std::tr1::aligned_storage<sizeof(value_type),
103 std::tr1::alignment_of<value_type>::value>::type m_a_value_buf;
106 typedef
107 typename Allocator_::template rebind<
108 value_type_holder>::other::reference
109 value_type_hoder_valerence;
111 inline static pointer
112 recast(value_type_hoder_valerence r_holder)
114 return reinterpret_cast<pointer>(&r_holder.m_a_value_buf);
117 inline static void
118 make_valid(value_type_hoder_valerence r_holder, Base_Key_ r_bk, Value_ r_val)
120 typedef
121 typename Allocator_::template rebind<
122 void* >::other::value_type
123 void_pointer;
125 void_pointer p_target = &r_holder.m_a_key_buf;
127 new (p_target) key_ref_pair(r_bk, r_val.first);
129 typedef
130 typename Allocator_::template rebind<
131 key_ref_pair>::other::pointer
132 key_ref_pair_pointer;
134 key_ref_pair_pointer p_key =
135 reinterpret_cast<key_ref_pair_pointer>(&r_holder.m_a_key_buf);
137 p_target = &r_holder.m_a_value_buf;
139 new (p_target) value_type(*p_key, r_val.second);
143 template<typename Base_Key_,
144 typename Key_,
145 typename Value_,
146 class Allocator_>
147 struct it_value_type_traits_<
148 Base_Key_,
149 Key_,
150 null_data_type,
151 Value_,
152 Allocator_>
154 typedef ref_pair< Base_Key_, Key_> key_ref_pair;
156 typedef
157 typename Allocator_::template rebind<
158 key_ref_pair>::other::const_reference
159 key_ref_pair_val;
161 typedef key_ref_pair_val key_type;
163 typedef key_ref_pair value_type;
165 typedef
166 typename Allocator_::template rebind<
167 value_type>::other::const_reference
168 reference;
170 typedef
171 typename Allocator_::template rebind<
172 value_type>::other::const_reference
173 const_reference;
175 typedef
176 typename Allocator_::template rebind<
177 value_type>::other::const_pointer
178 pointer;
180 typedef
181 typename Allocator_::template rebind<
182 value_type>::other::const_pointer
183 const_pointer;
185 struct value_type_holder
187 typename std::tr1::aligned_storage<sizeof(key_ref_pair),
188 std::tr1::alignment_of<key_ref_pair>::value>::type m_a_key_buf;
190 typename std::tr1::aligned_storage<sizeof(value_type),
191 std::tr1::alignment_of<value_type>::value>::type m_a_value_buf;
194 typedef
195 typename Allocator_::template rebind<
196 value_type_holder>::other::reference
197 value_type_hoder_valerence;
199 inline static pointer
200 recast(value_type_hoder_valerence r_holder)
202 return reinterpret_cast<pointer>(&r_holder.m_a_value_buf);
205 inline static void
206 make_valid(value_type_hoder_valerence r_holder, Base_Key_ r_bk, Value_ r_val)
208 typedef
209 typename Allocator_::template rebind<
210 void* >::other::value_type
211 void_pointer;
213 void_pointer p_target = &r_holder.m_a_value_buf;
215 new (p_target) key_ref_pair(r_bk, r_val.first);