[C++-sig] Re: MEMBER_FUNCTION_OVERLOADS doesn't honor virtualness

David Abrahams dave at boost-consulting.com
Mon Nov 1 15:10:15 CET 2004


Jonathan Brandmeyer <jbrandmeyer at earthlink.net> writes:

> On Sun, 2004-10-31 at 23:10 -0500, David Abrahams wrote:
>> Jonathan Brandmeyer <jbrandmeyer at earthlink.net> writes:
>> 
>> > The subject says it all.  Attached is a test case.
>> >
>
>> > BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( print_me, base::print_me, 0, 1)
>> This won't compile without an ampersand-------------^
>
> Are you sure?  For me (GCC 3.3.4), it doesn't compile with the
> address-of operator.  Tests in libs/python/test/keywords.cpp and
> libs/python/test/args.cpp do not use the ampersand.
>
>> What result are you expecting from this?  Can you rewrite the example
>> so that it asserts when you don't get the expected result.
>
> Sure.  I have attached a replacement for the Python file.  

That test doesn't work; you can't expect C++ stream I/O to be seen by
Python.  Try the enclosed.

> The problem
> is that derived.print_me() prints "base: " some_number, when I expect to
> get "derived: " some_number.

Just drop the base:: qualification from
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS and you'll be fine.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: theTest.cpp
Type: text/x-cplusplus
Size: 628 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20041101/f8825dcd/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: theTest.py
Type: application/octet-stream
Size: 447 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20041101/f8825dcd/attachment.obj>
-------------- next part --------------

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com


More information about the Cplusplus-sig mailing list