[C++-sig] Wrapping virtual method returning void
Holger Joukl
Holger.Joukl at LBBW.de
Mon Feb 23 08:52:49 CET 2015
Hi,
not boost.python- but C/C++ syntax-related.
You never reach the Base class call in your wrapper class:
> struct SongWrapper : Song, bp::wrapper<Song>
> {
> void chorus()
> {
> if (bp::override chorus = this->get_override("chorus"))
> chorus();
> return; <------------ Called unconditionally
> Song::chorus();
> return;
> }
>
> void default_chorus() { this->Song::chorus(); }
> };
I suggest using proper {} brackets and indentation with if-else constructs
for readability.
Your int-returning member function doesn't suffer from this problem:
>
> struct AnotherSongWrapper : AnotherSong, bp::wrapper<AnotherSong>
> {
> int chorus()
> {
> if (bp::override chorus = this->get_override("chorus"))
> return chorus();
> return AnotherSong::chorus();
> }
>
> int default_chorus() { return this->AnotherSong::chorus(); }
> };
Holger
Landesbank Baden-Wuerttemberg
Anstalt des oeffentlichen Rechts
Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz
HRA 12704
Amtsgericht Stuttgart
More information about the Cplusplus-sig
mailing list