[C++-sig] Re: Re: Re: Re: custom iterator object
Mike Rovner
mike at bindkey.com
Tue Nov 12 04:25:52 CET 2002
"David Abrahams" <dave at boost-consulting.com> wrote in message
news:un0ofy3i8.fsf at boost-consulting.com...
> > How can I pass 'this' from wrapping class?
>
>
> Didn't I write this?
>
> > > Remember that the iterator's own __iter__ method can be
> > > implemented by wrapping this C++ function:
> > >
> > > object identity(object x) { return x; }
>
> Did I leave something out? You can use:
>
> .def("__iter__", identity)
>
> inside your iterator wrapper class. Does that make it clear? Or are
I'm really sorry not making myself clear.
I have no problem wrapping my itereator class.
> you really asking something else?
I have problem _creating that iterator_ from another object.
For creating an iterator I have to call member function.
For calling it I have to have a C++ object reference, i.e.
Scheme& s;
MyIter s.*pm();
Now I'm trying to wrap that class (that shall return an iterator):
class_<Scheme>("Scheme")
.def("__iter__", mem_fun_ref(&Scheme::GetIter))
where Scheme has a memeber returning MyIter:
class Scheme{
...
MyIter GetIter();
};
Now .def get confused and complains:
/export/home/mike/boost_1_29_0/boost/python/make_function.hpp: In function
`boost::python::api::object boost::python::make_function(F, const
Policies&,
const Keywords&) [with F = std::const_mem_fun_ref_t<MyIter>, Scheme>,
Policies =
boost::python::default_call_policies, Keywords =
boost::python::detail::keywords<0>]':
/export/home/mike/boost_1_29_0/boost/python/class.hpp:319: instantiated
from `void boost
::python::class_<T, X1, X2, X3>::def_impl(const char*, Fn, const Keywords&,
const Policies
&, const char*, ...) [with Fn = std::const_mem_fun_ref_t<MyIter,Scheme>,
Policies = boost::python::default_call_policies, Keywords =
boost::python::detail::keywords<0>, T = Scheme, X1 =
boost::python::detail::not_specified, X2 =
boost::python::detail::not_specified, X3 = boost::python::detail::not_sp
ecified]'
/export/home/mike/boost_1_29_0/boost/python/class.hpp:207: instantiated
from `boost::pyt
hon::class_<T, X1, X2, X3>& boost::python::class_<T, X1, X2, X3>::def(const
char*, F) [wit
h F = std::const_mem_fun_ref_t<MyIterScheme>,
T = Scheme, X1 = boost::python::detail::not_specified, X2 = boost::python:
:detail::not_specified, X3 = boost::python::detail::not_specified]'
PyTcn.cpp:141: instantiated from here
/export/home/mike/boost_1_29_0/boost/python/make_function.hpp:39: incomplete
type `
boost::python::detail::arg_tuple_size<std::const_mem_fun_ref_t<MyIter,Scheme
> >' does not have member `value'
/export/home/mike/boost_1_29_0/boost/python/make_function.hpp:39: enumerator
value for `n_arguments' not integer constant
because I'm trying to feed a function object (returning MyIter from
operator()) to .def.
More information about the Cplusplus-sig
mailing list