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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Albert Strasheim-4
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


_______________________________________________
C++-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/c++-sig
Reply | Threaded
Open this post in threaded view
|

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

David Abrahams
"Albert Strasheim" <[hidden email]> writes:

> 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>())
>     ;
> }

Function parameters declared const are ignored by C++, except for the
purposes of function definitions.  Just remove the const; it doesn't
belong there.

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

_______________________________________________
C++-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/c++-sig