[C++-sig] pure virtuals and properties
Roman Yakovenko
roman.yakovenko at gmail.com
Fri Apr 27 20:36:50 CEST 2007
On 4/26/07, Luca Sbardella <luca.sbardella at gmail.com> wrote:
> Hi, just a quick question on the use o "wrapper.hpp".
> I have the following class and its correspondent wrapper class
>
> class blah
> {
> public:
> virtual double ciao() const = 0;
> };
>
> class blah_wrapper : public blah, public boost::python::wrapper<blah>
> {
> public:
> double ciao() const { return
> boost::python::call<double>(this->get_override("ciao").ptr());
> }
> };
>
> I would like to expose the "ciao" method as a property
>
> class_<blah_wrapper, boost::noncopyable>("blah")
> .add_property("ciao", pure_virtual(&blah::ciao))
> ;
>
> but it doesn't compile... lots of template errors (by the way is there a way
> to use "textfilt" http://textfilt.sourceforge.net/ in
> visual studio?)
> This, on the other hand, does compile as expected
>
> class_<blah_wrapper, boost::noncopyable>("blah")
> .def("ciao", pure_virtual(&blah::ciao))
> ;
>
> I guess we cannot expose e pure virtual function as property, or is there
> something I'm missing?
I could be wrong, but it looks to me like a mistake to make pure
virtual function to behave like a property. May be you can do
something with "make_function", but this will surprise the users.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
More information about the Cplusplus-sig
mailing list