[C++-sig] Re: implicitly_convertible
David Abrahams
dave at boost-consulting.com
Mon Jan 19 18:16:42 CET 2004
"aashish" <aashish at vrac.iastate.edu> writes:
> I have this porgram where I need to convert a python float in to C++ class
> object and for that I am using implicitly_convertible
>
>
>
> In the porgram below (a very simple one) the constructor takd two arguments
> and when I compile with that I got this error ..
>
>
>
> c:\users\aashish\boost-1.30.2\boost\python\converter\implicit.hpp(34): error
> C2664: 'PlotVariableTable::PlotVariableTable(const PlotVariableTable &)' :
> cannot convert parameter 1 from 'const double' to 'const PlotVariableTable
> &'
>
>
>
> Now when I compiled and tested with the constructor taking only a single
> value (and hence changed some lines accordingly) program just worked fine.
>
>
>
> Please let know is someone can help me as soon as possible.
A single-argument constructor that is not marked "explicit" makes the
argument type convertible to the class type. Without that, a double
is not implicitly convertible to a PlotVariableTable.
implicitly_convertible requires that its first argument is
convertible to its second argument.
These are just C++ rules; and have nothing to do with Boost.Python.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list