2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 18:12:43 +00:00

MSVC6 and 7 compatibility fixes

[SVN r20779]
This commit is contained in:
Raoul Gough
2003-11-10 18:06:41 +00:00
parent 997467c29f
commit 91db6f2d50
34 changed files with 773 additions and 284 deletions

View File

@@ -33,6 +33,8 @@ unsigned int_wrapper::our_object_counter = 0;
BOOST_PYTHON_MODULE(test_vector_ext)
{
namespace indexing = boost::python::indexing;
boost::python::implicitly_convertible <int, int_wrapper>();
boost::python::def ("setTrace", &int_wrapper::setTrace);
@@ -44,40 +46,33 @@ BOOST_PYTHON_MODULE(test_vector_ext)
;
typedef std::vector<int> Container1;
typedef std::vector<int_wrapper> Container2;
typedef indexing::container_proxy< std::vector<int_wrapper> > Container3;
#if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
typedef indexing::container_suite<Container1> Suite1;
typedef indexing::container_suite<Container2> Suite2;
typedef indexing::container_suite<Container3> Suite3;
#else
typedef indexing::vector_suite<Container1> Suite1;
typedef indexing::vector_suite<Container2> Suite2;
typedef indexing::container_proxy_suite<Container3> Suite3;
#endif
boost::python::class_<Container1>("Vector")
.def (boost::python::indexing::container_suite<Container1>())
.def (Suite1())
.def ("reserve", &Container1::reserve)
;
typedef std::vector<int_wrapper> Container2;
// Returning internal references to elements of a vector is
// dangerous - the references can be invalidated by inserts or
// deletes!
boost::python::class_<Container2>("Vector_ref")
.def (boost::python::indexing::container_suite<Container2>
.def (Suite2
::with_policies (boost::python::return_internal_reference<>()));
typedef boost::python::indexing::container_proxy< std::vector<int_wrapper> >
Container3;
boost::python::class_<Container3>("Vector_proxy")
.def (boost::python::indexing::container_suite<Container3>())
.def (Suite3())
.def ("reserve", &Container3::reserve)
;
/* The no-partial-specialization version for vector<int>
using namespace boost::python;
using namespace indexing;
class_<std::vector<int> > ("vector_int")
.def (visitor <
default_algorithms <
default_sequence_traits <
std::vector <int> > >,
return_value_policy <return_by_value>
>());
*/
}