[C++-sig] re: implicitly_convertible
aashish
aashish at vrac.iastate.edu
Mon Jan 19 01:49:26 CET 2004
Hi,
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.
Thanks,
Aashish
#include <boost/any.hpp>
#include <boost/python.hpp>
#include <boost/python/extract.hpp>
#include <boost/python/dict.hpp>
#include <boost/any.hpp>
#include <boost/python/implicit.hpp>
#include <boost/python/module.hpp>
#include <cstdio>
#include<iostream>
//#include <PlotVariableTable.h>
using namespace boost::python;
namespace bp = boost::python;
class PlotVariableTable
{
public:
/**
* Default Constructor
*
* @param cols number of columns in the table
*/
PlotVariableTable(double rows, double cols):v(rows), v1(cols){}
double v, v1;
};
PlotVariableTable make_x(double n, double n1)
{
PlotVariableTable a = PlotVariableTable( n , n1);
return a;
}
BOOST_PYTHON_MODULE(hello)
{
def("make_x",make_x);
class_<PlotVariableTable>("PlotVariableTable",init<double, double>());
implicitly_convertible<double,PlotVariableTable>();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040118/0a986084/attachment.htm>
More information about the Cplusplus-sig
mailing list