[C++-sig] [Py++] First imressions

David Abrahams dave at boost-consulting.com
Tue Sep 12 03:29:58 CEST 2006


Kirill Lapshin <kir at lapshin.net> writes:

> 1. The way overrides are generated does not compile on MSVC8 (2005). 
> Looks like the problem is in conversion of return type if return type is 
> bool or enum. For example
>
>
> virtual bool is_representative( ) const {
> bp::override func_is_representative = this->get_override(
> "is_representative" );
> return func_is_representative( ); // errors out
> }
>
> error C2440: 'return' : cannot convert from
> 'boost::python::detail::method_result' to 'bool'
> No user-defined-conversion operator available that can perform this
> conversion, or the operator cannot be called

This is a compiler bug, which is worked around by the enclosed patch
to boost/python/override.hpp:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: override.patch
Type: text/x-patch
Size: 638 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060911/98705b3f/attachment.bin>
-------------- next part --------------

Note that your workaround would be more idiomatic if you wrote:

     return func_is_representative().as<bool>();

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com


More information about the Cplusplus-sig mailing list