1717# include < boost/type_traits/is_same.hpp>
1818
1919namespace boost { namespace python {
20-
20+
2121 // indexing_suite class. This class is the facade class for
2222 // the management of C++ containers intended to be integrated
2323 // to Python. The objective is make a C++ container look and
2424 // feel and behave exactly as we'd expect a Python container.
2525 // By default indexed elements are returned by proxy. This can be
2626 // disabled by supplying *true* in the NoProxy template parameter.
27- //
27+ //
2828 // Derived classes provide the hooks needed by the indexing_suite
2929 // to do its job:
3030 //
31- // static data_type&
31+ // static data_type&
3232 // get_item(Container& container, index_type i);
3333 //
34- // static object
34+ // static object
3535 // get_slice(Container& container, index_type from, index_type to);
3636 //
37- // static void
37+ // static void
3838 // set_item(Container& container, index_type i, data_type const& v);
3939 //
40- // static void
40+ // static void
4141 // set_slice(
42- // Container& container, index_type from,
42+ // Container& container, index_type from,
4343 // index_type to, data_type const& v
4444 // );
4545 //
4646 // template <class Iter>
47- // static void
48- // set_slice(Container& container, index_type from,
47+ // static void
48+ // set_slice(Container& container, index_type from,
4949 // index_type to, Iter first, Iter last
5050 // );
5151 //
52- // static void
52+ // static void
5353 // delete_item(Container& container, index_type i);
54- //
55- // static void
54+ //
55+ // static void
5656 // delete_slice(Container& container, index_type from, index_type to);
57- //
57+ //
5858 // static size_t
5959 // size(Container& container);
6060 //
6161 // template <class T>
6262 // static bool
6363 // contains(Container& container, T const& val);
64- //
64+ //
6565 // static index_type
6666 // convert_index(Container& container, PyObject* i);
67- //
67+ //
6868 // static index_type
69- // adjust_index(index_type current, index_type from,
69+ // adjust_index(index_type current, index_type from,
7070 // index_type to, size_type len
7171 // );
7272 //
73- // Most of these policies are self explanatory. convert_index and
74- // adjust_index, however, deserves some explanation.
73+ // Most of these policies are self explanatory. convert_index and
74+ // adjust_index, however, deserves some explanation.
7575 //
76- // convert_index converts an Python index into a C++ index that the
77- // container can handle. For instance, negative indexes in Python, by
78- // convention, indexes from the right (e.g. C[-1] indexes the rightmost
79- // element in C). convert_index should handle the necessary conversion
76+ // convert_index converts an Python index into a C++ index that the
77+ // container can handle. For instance, negative indexes in Python, by
78+ // convention, indexes from the right (e.g. C[-1] indexes the rightmost
79+ // element in C). convert_index should handle the necessary conversion
8080 // for the C++ container (e.g. convert -1 to C.size()-1). convert_index
8181 // should also be able to convert the type of the index (A dynamic Python
8282 // type) to the actual type that the C++ container expects.
8383 //
8484 // When a container expands or contracts, held indexes to its elements
8585 // must be adjusted to follow the movement of data. For instance, if
86- // we erase 3 elements, starting from index 0 from a 5 element vector,
86+ // we erase 3 elements, starting from index 0 from a 5 element vector,
8787 // what used to be at index 4 will now be at index 1:
8888 //
8989 // [a][b][c][d][e] ---> [d][e]
@@ -104,7 +104,7 @@ namespace boost { namespace python {
104104 , class Index = typename Container::size_type
105105 , class Key = typename Container::value_type
106106 >
107- class indexing_suite
107+ class indexing_suite
108108 : public def_visitor<
109109 indexing_suite<
110110 Container
@@ -117,7 +117,7 @@ namespace boost { namespace python {
117117 > >
118118 {
119119 private:
120-
120+
121121 typedef mpl::or_<
122122 mpl::bool_<NoProxy>
123123 , mpl::not_<is_class<Data> >
@@ -127,10 +127,10 @@ namespace boost { namespace python {
127127 , is_same<Data, std::complex <double > >
128128 , is_same<Data, std::complex <long double > > >::type>
129129 no_proxy;
130-
130+
131131 typedef detail::container_element<Container, Index, DerivedPolicies>
132132 container_element_t ;
133-
133+
134134#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
135135 struct return_policy : return_internal_reference<> {};
136136#else
@@ -142,7 +142,7 @@ namespace boost { namespace python {
142142 , iterator<Container>
143143 , iterator<Container, return_policy> >::type
144144 def_iterator;
145-
145+
146146 typedef typename mpl::if_<
147147 no_proxy
148148 , detail::no_proxy_helper<
@@ -172,15 +172,15 @@ namespace boost { namespace python {
172172 , Data
173173 , Index> >::type
174174 slice_handler;
175-
175+
176176 public:
177-
177+
178178 template <class Class >
179179 void visit (Class& cl) const
180180 {
181181 // Hook into the class_ generic visitation .def function
182182 proxy_handler::register_container_element ();
183-
183+
184184 cl
185185 .def (" __len__" , base_size)
186186 .def (" __setitem__" , &base_set_item)
@@ -189,37 +189,37 @@ namespace boost { namespace python {
189189 .def (" __contains__" , &base_contains)
190190 .def (" __iter__" , def_iterator ())
191191 ;
192-
192+
193193 DerivedPolicies::extension_def (cl);
194- }
195-
194+ }
195+
196196 template <class Class >
197- static void
197+ static void
198198 extension_def (Class& cl)
199199 {
200200 // default.
201201 // no more extensions
202202 }
203203
204204 private:
205-
205+
206206 static object
207207 base_get_item (back_reference<Container&> container, PyObject* i)
208- {
208+ {
209209 if (PySlice_Check (i))
210210 return slice_handler::base_get_slice (
211- container.get (), reinterpret_cast <PySliceObject*>(i ));
212-
211+ container.get (), static_cast <PySliceObject*>(static_cast < void *>(i) ));
212+
213213 return proxy_handler::base_get_item_ (container, i);
214214 }
215-
216- static void
215+
216+ static void
217217 base_set_item (Container& container, PyObject* i, PyObject* v)
218218 {
219219 if (PySlice_Check (i))
220220 {
221- slice_handler::base_set_slice (container,
222- reinterpret_cast <PySliceObject*>(i ), v);
221+ slice_handler::base_set_slice (container,
222+ static_cast <PySliceObject*>(static_cast < void *>(i) ), v);
223223 }
224224 else
225225 {
@@ -228,7 +228,7 @@ namespace boost { namespace python {
228228 if (elem.check ())
229229 {
230230 DerivedPolicies::
231- set_item (container,
231+ set_item (container,
232232 DerivedPolicies::
233233 convert_index (container, i), elem ());
234234 }
@@ -239,7 +239,7 @@ namespace boost { namespace python {
239239 if (elem.check ())
240240 {
241241 DerivedPolicies::
242- set_item (container,
242+ set_item (container,
243243 DerivedPolicies::
244244 convert_index (container, i), elem ());
245245 }
@@ -252,20 +252,20 @@ namespace boost { namespace python {
252252 }
253253 }
254254
255- static void
255+ static void
256256 base_delete_item (Container& container, PyObject* i)
257257 {
258258 if (PySlice_Check (i))
259259 {
260260 slice_handler::base_delete_slice (
261- container, reinterpret_cast <PySliceObject*>(i ));
261+ container, static_cast <PySliceObject*>(static_cast < void *>(i) ));
262262 return ;
263263 }
264-
264+
265265 Index index = DerivedPolicies::convert_index (container, i);
266266 proxy_handler::base_erase_index (container, index, mpl::bool_<NoSlice>());
267267 DerivedPolicies::delete_item (container, index);
268- }
268+ }
269269
270270 static size_t
271271 base_size (Container& container)
@@ -290,10 +290,10 @@ namespace boost { namespace python {
290290 return DerivedPolicies::contains (container, x ());
291291 else
292292 return false ;
293- }
293+ }
294294 }
295295 };
296-
297- }} // namespace boost::python
296+
297+ }} // namespace boost::python
298298
299299#endif // INDEXING_SUITE_JDG20036_HPP
0 commit comments