3 // Copyright (C) 2005 Free Software Foundation, Inc.
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)
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,
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.
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
;
52 struct base_it_key_type
<
56 typedef typename
Base::const_key_reference type
;
59 template<typename Base_Key_
,
64 struct it_value_type_traits_
66 typedef ref_pair
< Base_Key_
, Key_
> key_ref_pair
;
69 typename
Allocator_::template rebind
<
70 key_ref_pair
>::other::const_reference
73 typedef key_ref_pair_val key_type
;
75 typedef ref_pair
< key_ref_pair_val
, Data_
> value_type
;
78 typename
Allocator_::template rebind
<
79 value_type
>::other::reference
83 typename
Allocator_::template rebind
<
84 value_type
>::other::const_reference
88 typename
Allocator_::template rebind
<
89 value_type
>::other::pointer
93 typename
Allocator_::template rebind
<
94 value_type
>::other::const_pointer
98 typename
Allocator_::template rebind
<
99 int* >::other::value_type
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];
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
);
121 make_valid(value_type_hoder_valerence r_holder
, Base_Key_ r_bk
, Value_ r_val
)
124 typename
Allocator_::template rebind
<
125 void* >::other::value_type
128 void_pointer p_target
= r_holder
.m_a_key_buf
;
130 new (p_target
) key_ref_pair(r_bk
, r_val
.first
);
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_
,
150 struct it_value_type_traits_
<
157 typedef ref_pair
< Base_Key_
, Key_
> key_ref_pair
;
160 typename
Allocator_::template rebind
<
161 key_ref_pair
>::other::const_reference
164 typedef key_ref_pair_val key_type
;
166 typedef key_ref_pair value_type
;
169 typename
Allocator_::template rebind
<
170 value_type
>::other::const_reference
174 typename
Allocator_::template rebind
<
175 value_type
>::other::const_reference
179 typename
Allocator_::template rebind
<
180 value_type
>::other::const_pointer
184 typename
Allocator_::template rebind
<
185 value_type
>::other::const_pointer
189 typename
Allocator_::template rebind
<
190 int* >::other::value_type
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];
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
);
212 make_valid(value_type_hoder_valerence r_holder
, Base_Key_ r_bk
, Value_ r_val
)
215 typename
Allocator_::template rebind
<
216 void* >::other::value_type
219 void_pointer p_target
= r_holder
.m_a_value_buf
;
221 new (p_target
) key_ref_pair(r_bk
, r_val
.first
);