6 #ifndef INDEXING_SUITE_JDG20036_HPP 7 # define INDEXING_SUITE_JDG20036_HPP 9 # include <boost/python/class.hpp> 10 # include <boost/python/def_visitor.hpp> 11 # include <boost/python/register_ptr_to_python.hpp> 13 # include <boost/python/return_internal_reference.hpp> 14 # include <boost/python/iterator.hpp> 15 # include <boost/mpl/or.hpp> 16 # include <boost/mpl/not.hpp> 18 namespace boost {
namespace python {
99 ,
class DerivedPolicies
100 ,
bool NoProxy = false
101 ,
bool NoSlice = false
102 ,
class Data =
typename Container::value_type
103 ,
class Index =
typename Container::size_type
104 ,
class Key =
typename Container::value_type
107 :
public def_visitor<
122 , mpl::not_<is_class<Data> > >
128 #if BOOST_WORKAROUND(BOOST_MSVC, == 1200) 134 typedef typename mpl::if_<
140 typedef typename mpl::if_<
154 typedef typename mpl::if_<
172 template <
class Class>
176 proxy_handler::register_container_element();
187 DerivedPolicies::extension_def(cl);
190 template <
class Class>
203 if (PySlice_Check(i))
204 return slice_handler::base_get_slice(
205 container.get(),
reinterpret_cast<PySliceObject*
>(i));
207 return proxy_handler::base_get_item_(container, i);
213 if (PySlice_Check(i))
215 slice_handler::base_set_slice(container,
216 reinterpret_cast<PySliceObject*>(i), v);
220 extract<Data&> elem(v);
227 convert_index(container, i), elem());
232 extract<Data> elem(v);
238 convert_index(container, i), elem());
242 PyErr_SetString(PyExc_TypeError,
"Invalid assignment");
243 throw_error_already_set();
252 if (PySlice_Check(i))
254 slice_handler::base_delete_slice(
255 container, reinterpret_cast<PySliceObject*>(i));
259 Index index = DerivedPolicies::convert_index(container, i);
260 proxy_handler::base_erase_index(container, index, mpl::bool_<NoSlice>());
261 DerivedPolicies::delete_item(container, index);
273 extract<Key const&>
x(key);
277 return DerivedPolicies::contains(container,
x());
284 return DerivedPolicies::contains(container,
x());
293 #endif // INDEXING_SUITE_JDG20036_HPP
static object base_get_item(back_reference< Container & > container, PyObject *i)
static void extension_def(Class &cl)
static size_t base_size(Container &container)
static void base_set_item(Container &container, PyObject *i, PyObject *v)
return_internal_reference return_policy
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
void visit(Class &cl) const
detail::container_element< Container, Index, DerivedPolicies > container_element_t
static void base_delete_item(Container &container, PyObject *i)
mpl::if_< no_proxy, iterator< Container >, iterator< Container, return_policy > >::type def_iterator
mpl::if_< no_proxy, detail::no_proxy_helper< Container, DerivedPolicies, container_element_t, Index >, detail::proxy_helper< Container, DerivedPolicies, container_element_t, Index > >::type proxy_handler
static bool base_contains(Container &container, PyObject *key)
mpl::or_< mpl::bool_< NoProxy >, mpl::not_< is_class< Data > > > no_proxy
mpl::if_< mpl::bool_< NoSlice >, detail::no_slice_helper< Container, DerivedPolicies, proxy_handler, Data, Index >, detail::slice_helper< Container, DerivedPolicies, proxy_handler, Data, Index > >::type slice_handler