[C++-sig] Re: implicitly_convertible and char*
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Fri Jul 9 17:37:01 CEST 2004
--- David Abrahams <dave at boost-consulting.com> wrote:
> > I write saying that implicitly_convertible<X, char*> doesn't work.
> > Dave responds saying that char* is not a valid C++ string, that char
> > const * should work.
> > I amend my example to show that char const * does not work.
> > Thread gets a little sidetracked with "const char*" vs "char const *"
> > ...Limbo
> Sorry, I just don't think I have time to look into the problem right
> now :(
In that case I'd work around the problem in one of these ways:
- create "thin wrapper" functions. I.e. make standalone function with X const&
or X& as the first parameter, and .def() them as member function. You can find
several examples of thin wrappers in this short piece of code:
- if that is impractical due to the large number of functions that you might
have to wrap, write your own "custom from python converter" which you could use
to convert any Python object to X. Here is an example:
Look for "slice_from_python". It is probably not easy to grasp although it is
not much code, but understanding this approach will give you access to a very
^H^H^H^Hextremely powerful tool.
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
More information about the Cplusplus-sig