I am having trouble wrapping a container that can hold multiple object
types and therefore has multiple iterator types.
My C++ library has these classes:
class Tomato;
class Potato;
class Garden {
Iter get_tomatoes();
Iter get_potatoes();
};
template
class Iter {
T get_next();
};
ange(&Garden::potatoes_begin,
&Garden::potatoes_end));
At this point, in Python, you should be able to write:
for potato in garden.potatoes:
and do here whatever you want ...
It's the best I can suggest
2009/11/6 Thomas Daniel :
I am having trouble wrapping a contai
troy d. straszheim wrote:
Thomas Daniel wrote:
BOOST_PYTHON_MODULE(vegetables)
{
class_("Garden")
.def("get_potatoes", &Garden::get_potatoes)
.def("get_tomatoes", &Garden::get_tomatoes)
;
class_("TomatoIter")
.def
No, it is not about template-related error messages :-)...
I am wrapping a class:
#include
struct X {
X() : _x(0) {}
int get() const { return _x; }
int _x;
};
BOOST_PYTHON_MODULE(Test) {
class_("X")
.def("get", &X::get)
;
}
and testing it with python:
x = X();
print x.ge
I have a class with "create" methods for different types of arguments:
#include
class Test {
public:
Test() {}
Test(int x) : _type(x) {}
static Test create(int) { return Test(0); }
static Test create(double) { return Test(1); }
static Test create(const char*) { re