I have a C ++ value type that is wrapped with a boost. Python in which there is a concept of zero value. Relevant sections of the wrapper code appear as follows:
class_ < TCurrency & gt; Currency ("TCurrency") .def (init & lt; tall & gt; ()) .def (init & lt; const std: string & gt; ())
Currently, any
to __init __ ()
to go through the method trying to create a tap example in Python C ++ ctor is called const string reference ( & amp; = NULL
) to call with an invalid reference. Is it possible to trap this matter where < Code> any is not being passed to a constructor and to satisfy it or
Boost 1.36 and Python 2.6.2 to throw at least a meaningful exception
If there is not used init & lt; Void * & gt;
Overload passes, but I'm not sure how this can affect other CTOs in corner cases. I do not even find that any string bracket & amp; The conversion you mentioned, if I type init> Void * & gt;
come out using Boost.Python 1.37 and Python 2.6.2.
Example:
#include & lt; Iostream & gt; #include & lt; String & gt; #include & lt; Boost / python.hpp & gt; Structure A {# Defined body {std :: cout & lt; & Lt; __PRETTY_FUNCTION__ & lt; & Lt; '\ N'; } A () body A (long) body A (std :: string const & body) A (zero * P) body #undef body}; BOOST_PYTHON_MODULE (E) {namespace boost :: python; Class_ & lt; A & gt; ("A") .def (init & lt; tall & gt; ()) .def (init & lt; std :: string const & gt; ()) .def (init & lt; void * & Gt; ()); }
>>> import pre >>> East. A (A): 0x839bf7c on >> one () and east A object >> >> AA (42) A: A (long int) and LT; East. A Object 0x839 BFCC >>> East A ("ABC") A :: A (Const Stroot :: String End) and LT. X Object 0x839bf7c> >>>
if init> lt; Void * & gt;
Excluded:
>>> ex.A (none) Traceback (most recent call final): File "& lt; stdin>", in line 1, & lt ; Module> Boost.Python.ArgumentError: Python Logic Type in A. __INIT___ (A, any type) does not match the C ++ signature: __int____ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
No comments:
Post a Comment