[C++-sig] question about implicit type conversion of vector to a custom type
grant.tang at gmail.com
Tue Aug 16 21:43:10 CEST 2011
This is a question about using implicitly_convertible to convert vector to
another custom class type.
I already have boost python type conversion code to convert Python
list/tuple to c++ vector, which works fine. There is another custom class
EMObject, which is a thin wrapper to many builit-in type. It takes a
built-in type like int, float, string, and vector as a single constructor
argument and return type. So those built-in type can convert to and from
EMObject implicitly. The functions in c++ which takes this EMObject as an
argument are expose to Python. Now I need call these functions in Python
with argument from Python list or tuple. Since I already convert python
list/tuple to c++ vector, I just need declare implicit type conversion from
vector to EMObject like following:
This seems a perfect solution to my question. But unfortunately I find out
only the first one working, regardless which one is the first. Could anybody
tell me why this happen?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Cplusplus-sig