diff --git a/test/test_deque_ext.cpp b/test/test_deque_ext.cpp index 395f4719..cb23e901 100755 --- a/test/test_deque_ext.cpp +++ b/test/test_deque_ext.cpp @@ -1,4 +1,3 @@ -// -*- mode:c++ -*- // // Module test_deque_ext.cpp // @@ -29,8 +28,20 @@ bool int_wrapper::our_trace_flag = true; unsigned int_wrapper::our_object_counter = 0; +struct deque_generator { + // Generates deque type for any element type. This matches the + // performance characteristics of the real container and the pointer + // index container in a container_proxy, e.g. for insert/erase at + // the beginning. + template struct apply { + typedef std::deque type; + }; +}; + BOOST_PYTHON_MODULE(test_deque_ext) { + namespace indexing = boost::python::indexing; + boost::python::implicitly_convertible (); boost::python::def ("setTrace", &int_wrapper::setTrace); @@ -44,7 +55,7 @@ BOOST_PYTHON_MODULE(test_deque_ext) typedef std::deque Container1; boost::python::class_("Deque") - .def (boost::python::indexing::container_suite()) + .def (indexing::container_suite()) ; typedef std::deque Container2; @@ -53,13 +64,13 @@ BOOST_PYTHON_MODULE(test_deque_ext) // dangerous - the references can be invalidated by inserts or // deletes! boost::python::class_("Deque_ref") - .def (boost::python::indexing::container_suite + .def (indexing::container_suite ::with_policies (boost::python::return_internal_reference<>())); - typedef boost::python::indexing::container_proxy< std::deque > - Container3; + typedef indexing::container_proxy< + Container2, indexing::identity, deque_generator> Container3; boost::python::class_("Deque_proxy") - .def (boost::python::indexing::container_suite()) + .def (indexing::container_suite()) ; }