Boost logo

Boost :

From: Anton Gluck (gluc_at_[hidden])
Date: 2000-10-29 22:56:45


> ifstream as a parameter. If you don't want to intrude on your class'
> interface, you can do something like this:
>
> struct TextRecordIteratorWrapper : TextRecordIterator
> {
> TextRecordIteratorWrapper(std::ifstream* s) :
> TextRecordIterator(*s) {}
> };
>
> ...
> py::ClassWrapper<TextRecordIteratorWrapper>
> text_record_class(ClusterForPython, "TextRecordIterator");
> text_record_class.def(py::Constructor<std::ifstream*>());
> text_record_class.def(&TextRecordIteratorWrapper::function1, "function1");
> ...

Most of this works, except for the last line (exposing a
TextRecordIterator function, properly renamed of course). This being an
iterator, I tried exposing its HasMore and Next functions. I got this
error:

d:\py_cpp/caller.h(32) : error C2665: 'from_python' : none of the 134
overloads can convert parameter 2 from type 'struct py::Type<class
TextRecordIterator &>'
        d:\py_cpp/functions.h(54) : see reference to function template
instantiation 'struct _object *__cdecl py::Caller<int>::call(int
(__thiscall TextRecordIterator::*)(void),struct _object *,struct _object
*)' being compiled

I suppose the move from TextRecordIteratorWrapper to the underlying
TextRecordIterator causes the problem. Another bug?

Thanks for your help,

Toni


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk