|
11 | 11 | # include <boost/type_traits/transform_traits.hpp> |
12 | 12 | # include <boost/type_traits/cv_traits.hpp> |
13 | 13 | # include <boost/python/converter/rvalue_from_python_data.hpp> |
| 14 | +# include <boost/mpl/eval_if.hpp> |
14 | 15 | # include <boost/mpl/if.hpp> |
| 16 | +# include <boost/mpl/identity.hpp> |
| 17 | +# include <boost/mpl/and.hpp> |
| 18 | +# include <boost/mpl/or.hpp> |
| 19 | +# include <boost/mpl/not.hpp> |
15 | 20 | # include <boost/python/converter/registry.hpp> |
16 | 21 | # include <boost/python/converter/registered.hpp> |
17 | 22 | # include <boost/python/converter/registered_pointee.hpp> |
@@ -141,60 +146,47 @@ struct back_reference_arg_from_python |
141 | 146 |
|
142 | 147 | // ================== |
143 | 148 |
|
| 149 | +template <class C, class T, class F> |
| 150 | +struct if_2 |
| 151 | + : mpl::eval_if<C, mpl::identity<T>, F> |
| 152 | +{}; |
| 153 | + |
144 | 154 | // This metafunction selects the appropriate arg_from_python converter |
145 | 155 | // type for an argument of type T. |
146 | 156 | template <class T> |
147 | 157 | struct select_arg_from_python |
148 | 158 | { |
149 | | - BOOST_STATIC_CONSTANT( |
150 | | - bool, obj_mgr = is_object_manager<T>::value); |
151 | | - |
152 | | - BOOST_STATIC_CONSTANT( |
153 | | - bool, obj_mgr_ref = is_reference_to_object_manager<T>::value); |
154 | | - |
155 | | - BOOST_STATIC_CONSTANT( |
156 | | - bool, ptr = is_pointer<T>::value); |
157 | | - |
158 | | - BOOST_STATIC_CONSTANT( |
159 | | - bool, ptr_cref |
160 | | - = indirect_traits::is_reference_to_pointer<T>::value |
161 | | - && indirect_traits::is_reference_to_const<T>::value |
162 | | - && !indirect_traits::is_reference_to_volatile<T>::value); |
163 | | - |
164 | | - |
165 | | - BOOST_STATIC_CONSTANT( |
166 | | - bool, ref = |
167 | | - indirect_traits::is_reference_to_non_const<T>::value |
168 | | - || indirect_traits::is_reference_to_volatile<T>::value); |
169 | | - |
170 | | - BOOST_STATIC_CONSTANT( |
171 | | - bool, back_ref = |
172 | | - boost::python::is_back_reference<T>::value); |
173 | | - |
174 | | - typedef typename mpl::if_c< |
175 | | - obj_mgr |
176 | | - , object_manager_value_arg_from_python<T> |
177 | | - , typename mpl::if_c< |
178 | | - obj_mgr_ref |
179 | | - , object_manager_ref_arg_from_python<T> |
180 | | - , typename mpl::if_c< |
181 | | - ptr |
182 | | - , pointer_arg_from_python<T> |
183 | | - , typename mpl::if_c< |
184 | | - ptr_cref |
185 | | - , pointer_cref_arg_from_python<T> |
186 | | - , typename mpl::if_c< |
187 | | - ref |
| 159 | + typedef typename if_2< |
| 160 | + is_object_manager<T> |
| 161 | + , object_manager_value_arg_from_python<T> |
| 162 | + , if_2< |
| 163 | + is_reference_to_object_manager<T> |
| 164 | + , object_manager_ref_arg_from_python<T> |
| 165 | + , if_2< |
| 166 | + is_pointer<T> |
| 167 | + , pointer_arg_from_python<T> |
| 168 | + , if_2< |
| 169 | + mpl::and_< |
| 170 | + indirect_traits::is_reference_to_pointer<T> |
| 171 | + , indirect_traits::is_reference_to_const<T> |
| 172 | + , mpl::not_<indirect_traits::is_reference_to_volatile<T> > |
| 173 | + > |
| 174 | + , pointer_cref_arg_from_python<T> |
| 175 | + , if_2< |
| 176 | + mpl::or_< |
| 177 | + indirect_traits::is_reference_to_non_const<T> |
| 178 | + , indirect_traits::is_reference_to_volatile<T> |
| 179 | + > |
188 | 180 | , reference_arg_from_python<T> |
189 | | - , typename mpl::if_c< |
190 | | - back_ref |
| 181 | + , mpl::if_< |
| 182 | + boost::python::is_back_reference<T> |
191 | 183 | , back_reference_arg_from_python<T> |
192 | 184 | , arg_rvalue_from_python<T> |
193 | | - >::type |
194 | | - >::type |
195 | | - >::type |
196 | | - >::type |
197 | | - >::type |
| 185 | + > |
| 186 | + > |
| 187 | + > |
| 188 | + > |
| 189 | + > |
198 | 190 | >::type type; |
199 | 191 | }; |
200 | 192 |
|
|
0 commit comments