[C++-sig] Re: is_polymorphic and unions

David Abrahams dave at boost-consulting.com
Tue Jul 22 18:59:11 CEST 2003


spex66 at gmx.net writes:

> Hi Nicodemus
> Hi Dave

Hi!

> I've read all your threads belonging to pyste / boost / union 
>
> actually I've a project with a lot of such unions as you described.
>
> The project is from www.sedris.org for a standardised api for
> geometric & georeferenced data... and I want to port them as quick
> as possible to python :)
>
> so I'm using pyste--AllFromHeader('xxx.h') approach
>
> 36 hours from starting yesterday... I'm stuck with a sort of problems
>
> (1) error C1204:Compiler limit:internal structure overflow (as described in
> boost/faq)
> (2) error C2664: problem with call_policy (?)
> (3) error C2504: in ..../type_traits/is_polymorphic.hpp (79) ---> problem of
> a union
>
> solution to (1) is obviously splitting... sigh -> any chance to got this as
> a feature from pyste, Nicodemus?

The current CVS includes support for "--multiple":
http://tinyurl.com/hp3j

> solution to (2) is pending... detailled description is following (also for
> (3)):
>
> :::::::::::::::::::::::::::::::::::
> PYSTE::>> sedris.cpp 
>     def("SRM_ChangeCoordinateSRF", &SRM_ChangeCoordinateSRF);
>
> :::::::::::::::::::::::::::::::::::
> ERROR::>>
> boost/python/make_function.hpp(77) : error C2664: 
> 'struct boost::mpl::list4<short,
> 						  struct SRM_SRFParamsPair *,
> 						  struct SRM_Coordinate const *,
> 						  struct SRM_Coordinate *
> 						  > __cdecl boost::python::detail::get_signature(
> short(__cdecl *)(struct SRM_SRFParamsPair *       ,const SRM_Coordinate
> *,SRM_Coordinate *))' : 
>
> can not convert parameter 1 from'
> short (__cdecl *)(struct SRM_SRFParamsPair *const ,const SRM_Coordinate
> *,SRM_Coordinate *)' 
> 	in 
> short (__cdecl *)(struct SRM_SRFParamsPair *      ,const SRM_Coordinate
> *,SRM_Coordinate *)' 
>
> This conversion requires a reinterpret_cast, a C-style cast or
> function-style cast

This is an msvc bug which preserves top-level constness of arguments
in function (pointer) types.  If you can redeclare the offending
function as:

  short SRM_ChangeCoordinateSRF(SRM_SRF_Parameters_Pair, const SRM_Coordinate *,SRM_Coordinate *);

you can still make the first parameter const in the function
*definition* without upsetting the compiler.  If you can't change the
declaration of 'whatever' you'll have to resort to forcibly casting
the offending function pointer.

I suppose Pyste could be patched to do this for you...

> :::::::::::::::::::::::::::::::::::
> ERROR::>>
> error C2504: in ..../type_traits/is_polymorphic.hpp (79) ---> problem of a
> union

What's the complete error message for that line?
>
> TRY&ERROR::>>
> I've tried to adopt Dave's tip from 
> http://mail.python.org/pipermail/c++-sig/2003-March/003607.html
>
>> If so, then we have a bug in is_polymorphic.  If not, we should
>> change all uses of is_polymorphic<T> in 
>> 
>>        boost/python/class.hpp
>>        boost/python/object/class_converters.hpp
>>        boost/python/object/inheritance.hpp
>> 
>> to:
>>          mpl::and_<is_class<T>, is_polymorphic<T> >
>
> putting #include for mpl::_and 
> but boost wan't compile (if you need the error-trace, I will post it on
> demand)

#include <boost/mpl/and.hpp>

works for me.

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





More information about the Cplusplus-sig mailing list