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

David Abrahams dave at boost-consulting.com
Mon Sep 12 00:22:22 CEST 2005


"Albert Strasheim" <13640887 at sun.ac.za> 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




More information about the Cplusplus-sig mailing list