[C++-sig] Iterators for heterogeneous container

2009-11-05 Thread Thomas Daniel
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(); };

Re: [C++-sig] Iterators for heterogeneous container

2009-11-06 Thread Thomas Daniel
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

Re: [C++-sig] Iterators for heterogeneous container

2009-11-07 Thread Thomas Daniel
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

[C++-sig] unfriendly python error message (no line number)

2009-11-08 Thread Thomas Daniel
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

[C++-sig] Problem with overloading between int and double

2010-05-19 Thread Thomas Daniel
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