我正在使用 boost::python::extract<> 将 boost::python::list 中的项目转换为浮点数。我的问题是 python 中的 int -extract<float>
似乎将 int->float 视为有效转换,但我只想要真正的浮点对象。有没有办法强制 extract<> 更加保守?
extract<float> value(o);
if (value.check()) {
// This is true both for floats and ints
a = value();
}