[C++-sig] VC 2005 error when wrapping constructor with const argument

Albert Strasheim 13640887 at sun.ac.za
Wed Sep 7 05:27:05 CEST 2005


Hello all

I recently came across a problem when wrapping classes with constructors 
that take const arguments with Visual C++ 2005 Express Edition Beta 2.

I am using Boost 1.33.0 with Python 2.4.1.

The test case (breaks on VC EE 2005, compiles on VC .NET 2003):

#include <boost/python.hpp>
class Foo {
public:
  Foo(){}
  Foo(const double){}
};
void Export_Foo()
{
  boost::python::class_<Foo>("Foo", boost::python::init<>())
    .def(boost::python::init<const double>())
    ;
}

>From the error I can see that the ArgList in the instantiation of 
make_keyword_range_constructor<...,ArgList,...>(...) still contains the 
const double. make_keyword_range_constructor then uses make_holder to 
convert the ArgList to a function pointer for make_keyword_range_function. 
However, I can see that F in make_keyword_range_function<F, Policies>(...) 
is missing the const qualifier.

It looks like whatever preprocessor magic is happening inside make_holder is 
dropping the const qualifier.

You can find the build log at:

http://albert.bagasie.com/make_holder_bug/make_holder_bug_BuildLog.htm

The complete preprocessed output is at:

http://albert.bagasie.com/make_holder_bug/make_holder_bug.i.gz

Cheers

Albert





More information about the Cplusplus-sig mailing list