[C++-sig] range with virtual functions
Piotr Jaroszynski
p.jaroszynski at gmail.com
Thu Mar 29 01:36:28 CEST 2007
On Wednesday 28 of March 2007 22:50:44 Roman Yakovenko wrote:
> I am not sure whether range takes references to [pure]virtual functions,
> but you
> can use same trick as in your previous question: define 2 static functions,
> which take reference to your class instance and return relevant iterator.
> Than expose
> these functions. This should work.
I basically get the idea, but I don't know how to implement these static
functions to return the relevant iterator.
When just wrapping non-pure virtuals I do:
struct FooWrapper
(...)
iterator begin_foo()
{
if (override begin_foo = this->get_override("begin_foo"))
return begin_foo();
return Foo::begin_foo();
}
iterator default_begin_foo() { return this->Foo::begin_foo(); }
and then .def("begin_foo", &Foo::begin_foo, &FooWrapper::defualt_begin_foo).
So I suppose I need to somehow emulate what's def doing here in the static
functions, but how?
P.S. I always wondered why .def is not taking the &FooWrapper::begin_foo, but
the default_begin_foo and the "original" begin_foo from Foo.
--
Best Regards,
Piotr Jaroszynski
More information about the Cplusplus-sig
mailing list