我有一个C++值类型Boost.Python它有一个空值的概念。包装器代码的相关部分如下所示:
class_<TCurrency> currency( "TCurrency" )
.def( init<long>() )
.def( init<const std::string&>() )
<...>;
目前,尝试通过将{{CD1>}创建到一个空实例,到^ {CD2>}方法,使C++ cor接受一个const字符串引用,并用一个无效引用调用它。(&arg == NULL
)
有没有可能在None
被传递给构造函数的情况下进行陷阱处理,或者至少在程序崩溃之前抛出一个有意义的异常?在
使用boost1.36和python2.6.2。在
添加一个
init<void*>
重载,如果没有使用的话,将传递NULL,但是我不确定这将如何影响角落情况下的其他ctors。如果不使用init<void*>
,我也不会得到您提到的那种None-to-string const&const;转换。使用Boost.Python1.37和Python 2.6.2。在示例:
^{pr2}$如果
init<void*>
被省略:相关问题 更多 >
编程相关推荐